12#define EBPF_HELPER(return_type, name, args) typedef return_type(*const name##_t) args
129#pragma warning(disable : 4201)
167#define SOCK_ADDR_EXT_HELPER_FN_BASE 0xFFFF
189#define bpf_sock_addr_set_redirect_context \
190 ((bpf_sock_addr_set_redirect_context_t)BPF_FUNC_sock_addr_set_redirect_context)
206#define BPF_SOCK_ADDR_NETWORK_CONTEXT_VERSION 1
233#define BPF_SOCK_ADDR_TEST_CONTEXT_VERSION 1
235#define BPF_SOCK_ADDR_TEST_CONTEXT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(bpf_sock_addr_test_context_t, network_context)
236#define BPF_SOCK_ADDR_TEST_CONTEXT_VERSION_TOTAL_SIZE sizeof(bpf_sock_addr_test_context_t)
237#define BPF_SOCK_ADDR_TEST_CONTEXT_HEADER_VERSION \
238 {BPF_SOCK_ADDR_TEST_CONTEXT_VERSION, \
239 BPF_SOCK_ADDR_TEST_CONTEXT_VERSION_SIZE, \
240 BPF_SOCK_ADDR_TEST_CONTEXT_VERSION_TOTAL_SIZE}
254#define bpf_sock_addr_get_network_context ((bpf_sock_addr_get_network_context_t)BPF_FUNC_sock_addr_get_network_context)
334#define SOCK_OPS_EXT_HELPER_FN_BASE 0xFFFF
350#define bpf_sock_ops_get_flow_id ((bpf_sock_ops_get_flow_id_t)BPF_FUNC_sock_ops_get_flow_id)
enum _bind_operation bind_operation_t
Operations reported by the legacy bind hook.
#define SOCK_ADDR_EXT_HELPER_FN_BASE
Definition ebpf_nethooks.h:167
ebpf_sock_ops_helper_id_t
Definition ebpf_nethooks.h:337
@ BPF_FUNC_sock_ops_get_flow_id
Definition ebpf_nethooks.h:338
ebpf_sock_addr_verdict_t sock_addr_hook_t(bpf_sock_addr_t *context)
Handle socket operation. Currently supports ingress/egress connection initialization.
Definition ebpf_nethooks.h:280
enum _ebpf_sock_addr_verdict ebpf_sock_addr_verdict_t
uint64_t bpf_sock_ops_get_flow_id(bpf_sock_ops_t *ctx)
Get the WFP flow ID associated with the current sock_ops context.
ebpf_sock_addr_helper_id_t
Definition ebpf_nethooks.h:170
@ BPF_FUNC_sock_addr_set_redirect_context
Definition ebpf_nethooks.h:172
@ BPF_FUNC_sock_addr_get_current_pid_tgid
Definition ebpf_nethooks.h:171
@ BPF_FUNC_sock_addr_get_network_context
Definition ebpf_nethooks.h:173
enum _bpf_sock_op_type bpf_sock_op_type_t
ebpf_extension_header_t bpf_sock_addr_test_context_header_t
Header of an eBPF sock_addr test context structure.
Definition ebpf_nethooks.h:218
int sock_ops_hook_t(bpf_sock_ops_t *context)
Handle socket event notification. Currently notifies ingress/egress connection establishment and tear...
Definition ebpf_nethooks.h:332
int bpf_sock_addr_set_redirect_context(bpf_sock_addr_t *ctx, void *data, uint32_t data_size)
Set a context for consumption by a user-mode application (sock_addr specific only)....
_bind_operation
Operations reported by the legacy bind hook.
Definition ebpf_nethooks.h:23
@ BIND_OPERATION_BIND
Entry to bind.
Definition ebpf_nethooks.h:24
@ BIND_OPERATION_UNBIND
Release port.
Definition ebpf_nethooks.h:26
@ BIND_OPERATION_POST_BIND
After port allocation.
Definition ebpf_nethooks.h:25
_bind_action
Actions that can be returned by a bind hook program.
Definition ebpf_nethooks.h:51
@ BIND_REDIRECT
Change the bind endpoint.
Definition ebpf_nethooks.h:74
@ BIND_PERMIT_SOFT
Permit the bind operation (soft permit).
Definition ebpf_nethooks.h:58
@ BIND_PERMIT
Backward compatibility alias for BIND_PERMIT_SOFT.
Definition ebpf_nethooks.h:88
@ BIND_PERMIT_HARD
Permit the bind operation (hard permit).
Definition ebpf_nethooks.h:82
@ BIND_DENY
Deny the bind operation.
Definition ebpf_nethooks.h:65
_bpf_sock_op_type
Definition ebpf_nethooks.h:283
@ BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB
Indicates when a passive (inbound) connection is established.
Definition ebpf_nethooks.h:287
@ BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB
Indicates when an active (outbound) connection is established.
Definition ebpf_nethooks.h:285
@ BPF_SOCK_OPS_CONNECTION_DELETED_CB
Indicates when a connection is deleted.
Definition ebpf_nethooks.h:289
bind_action_t bind_hook_t(bind_md_t *context)
Handle IPv4 and IPv6 socket bind operations.
Definition ebpf_nethooks.h:114
struct bpf_sock_addr bpf_sock_addr_t
Data structure used as context for BPF_PROG_TYPE_CGROUP_SOCK_ADDR program type.
#define SOCK_OPS_EXT_HELPER_FN_BASE
Definition ebpf_nethooks.h:334
int bpf_sock_addr_get_network_context(bpf_sock_addr_t *ctx, void *context_ptr, uint32_t context_size)
Get the network context for the connection (CONNECT_AUTHORIZATION, RECV_ACCEPT, BIND,...
_ebpf_sock_addr_verdict
Definition ebpf_nethooks.h:121
@ BPF_SOCK_ADDR_VERDICT_REJECT
Definition ebpf_nethooks.h:122
@ BPF_SOCK_ADDR_VERDICT_PROCEED_SOFT
Definition ebpf_nethooks.h:123
@ BPF_SOCK_ADDR_VERDICT_PROCEED_HARD
Definition ebpf_nethooks.h:124
enum _bind_action bind_action_t
Actions that can be returned by a bind hook program.
struct _bind_md bind_md_t
Context structure for the legacy bind hook.
struct _bpf_sock_ops bpf_sock_ops_t
struct _bpf_sock_addr_network_context bpf_sock_addr_network_context_t
Network context information for the connection. Available for CONNECT_AUTHORIZATION,...
struct _bpf_sock_addr_test_context bpf_sock_addr_test_context_t
Extended test context for for BPF_PROG_TYPE_CGROUP_SOCK_ADDR program type. This context can be used f...
Context structure for the legacy bind hook.
Definition ebpf_nethooks.h:35
uint8_t protocol
Protocol number (e.g., IPPROTO_TCP).
Definition ebpf_nethooks.h:42
bind_operation_t operation
Operation to do.
Definition ebpf_nethooks.h:41
uint8_t * app_id_end
Pointer to end of App ID.
Definition ebpf_nethooks.h:37
uint8_t socket_address[16]
Socket address to bind to.
Definition ebpf_nethooks.h:39
uint64_t process_id
Process ID.
Definition ebpf_nethooks.h:38
uint8_t * app_id_start
Pointer to start of App ID.
Definition ebpf_nethooks.h:36
uint8_t socket_address_length
Length in bytes of the socket address.
Definition ebpf_nethooks.h:40
Network context information for the connection. Available for CONNECT_AUTHORIZATION,...
Definition ebpf_nethooks.h:198
uint32_t sub_interface_index
Sub-interface index, or 0 if not available; unspecified at BIND.
Definition ebpf_nethooks.h:203
uint32_t interface_type
IANA interface type, or UINT32_MAX if not available.
Definition ebpf_nethooks.h:200
uint32_t version
Struct version (currently 1).
Definition ebpf_nethooks.h:199
uint32_t tunnel_type
IANA tunnel type; 0 if not a tunnel, or UINT32_MAX if not available.
Definition ebpf_nethooks.h:201
uint64_t next_hop_interface_luid
Next-hop interface LUID, or 0 if not available; unspecified at BIND.
Definition ebpf_nethooks.h:202
Extended test context for for BPF_PROG_TYPE_CGROUP_SOCK_ADDR program type. This context can be used f...
Definition ebpf_nethooks.h:227
bpf_sock_addr_network_context_t network_context
Network context.
Definition ebpf_nethooks.h:230
bpf_sock_addr_t context
Socket address context.
Definition ebpf_nethooks.h:229
bpf_sock_addr_test_context_header_t header
Standard versioning header.
Definition ebpf_nethooks.h:228
Definition ebpf_nethooks.h:293
uint32_t local_ip4
Definition ebpf_nethooks.h:300
uint32_t family
IP address family.
Definition ebpf_nethooks.h:295
uint32_t remote_ip4
Definition ebpf_nethooks.h:309
uint32_t compartment_id
Network compartment Id.
Definition ebpf_nethooks.h:315
uint8_t protocol
IP protocol.
Definition ebpf_nethooks.h:314
uint32_t remote_port
Definition ebpf_nethooks.h:312
uint64_t interface_luid
Interface LUID.
Definition ebpf_nethooks.h:316
uint32_t local_ip6[4]
Definition ebpf_nethooks.h:301
bpf_sock_op_type_t op
Definition ebpf_nethooks.h:294
uint32_t remote_ip6[4]
Definition ebpf_nethooks.h:310
uint32_t local_port
Definition ebpf_nethooks.h:303
Data structure used as context for BPF_PROG_TYPE_CGROUP_SOCK_ADDR program type.
Definition ebpf_nethooks.h:135
uint32_t protocol
IP protocol.
Definition ebpf_nethooks.h:162
uint16_t user_port
Destination port in network byte order.
Definition ebpf_nethooks.h:160
uint16_t msg_src_port
Source port in network byte order.
Definition ebpf_nethooks.h:148
uint32_t user_ip4
Definition ebpf_nethooks.h:157
uint32_t user_ip6[4]
Definition ebpf_nethooks.h:158
uint32_t compartment_id
Network compartment Id.
Definition ebpf_nethooks.h:163
uint32_t msg_src_ip6[4]
Definition ebpf_nethooks.h:146
uint64_t interface_luid
Interface LUID.
Definition ebpf_nethooks.h:164
uint32_t msg_src_ip4
Definition ebpf_nethooks.h:145
uint32_t family
IP address family.
Definition ebpf_nethooks.h:136