Skip to content

Commit

Permalink
Fix netevent header structure (#174)
Browse files Browse the repository at this point in the history
* added netevent header

* fix netevent_sim

* use netevent_ext_function_addresses_t

---------

Co-authored-by: Laksh Kotian <[email protected]>
  • Loading branch information
LakshK98 and Laksh Kotian authored Dec 9, 2024
1 parent e205003 commit 0700450
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
20 changes: 17 additions & 3 deletions ebpf_extensions/neteventebpfext/netevent_ebpf_ext_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,26 @@ _netevent_ebpf_extension_detach_provider(_In_ HANDLE nmr_binding_handle);
// Structures for attaching to NetEvent (as an NMR client)
//

typedef struct netevent_ext_header
{
uint16_t version; ///< Version of the extension data structure.
size_t size; ///< Size of the netevent function addresses structure.
} netevent_ext_header_t;

// This is the type definition for the netevent helper function addresses.
// This type should be matched by the Netevent NMI provider.
typedef struct netevent_ext_function_addresses
{
netevent_ext_header_t header;
uint32_t helper_function_count;
uint64_t* helper_function_address;
} netevent_ext_function_addresses_t;

// Dispatch table for the client module's helper functions
static const void* _ebpf_netevent_ext_helper_functions[] = {(void*)&_ebpf_netevent_push_event};
const ebpf_helper_function_addresses_t _netevent_client_dispatch = {
const netevent_ext_function_addresses_t _netevent_client_dispatch = {
.header =
{.version = EBPF_HELPER_FUNCTION_ADDRESSES_CURRENT_VERSION,
.size = EBPF_HELPER_FUNCTION_ADDRESSES_CURRENT_VERSION_SIZE},
{.version = EBPF_HELPER_FUNCTION_ADDRESSES_CURRENT_VERSION, .size = sizeof(netevent_ext_function_addresses_t)},
.helper_function_count = EBPF_COUNT_OF(_ebpf_netevent_ext_helper_functions),
.helper_function_address = (uint64_t*)_ebpf_netevent_ext_helper_functions};

Expand Down
19 changes: 12 additions & 7 deletions tests/neteventebpfext/netevent_sim/netevent_npi_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ typedef struct
} netevent_event_info_t;
typedef void (*netevent_push_event)(netevent_event_info_t*);

// This is the type definition for the eBPF helper function addresses
// when version is EBPF_HELPER_FUNCTION_ADDRESSES_CURRENT_VERSION.
typedef struct _ebpf_helper_function_addresses
typedef struct netevent_ext_header
{
ebpf_extension_header_t header;
UINT32 helper_function_count;
UINT64* helper_function_address;
} ebpf_helper_function_addresses_t;
uint16_t version; ///< Version of the extension data structure.
size_t size; ///< Size of the netevent function addresses structure.
} netevent_ext_header_t;

// This is the type definition for the netevent helper function addresses.
typedef struct netevent_ext_function_addresses
{
netevent_ext_header_t header;
uint32_t helper_function_count;
uint64_t* helper_function_address;
} netevent_ext_function_addresses_t;
8 changes: 4 additions & 4 deletions tests/neteventebpfext/netevent_sim/netevent_npi_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ typedef struct PROVIDER_REGISTRATION_CONTEXT_
// Define the context structure for the provider module's binding to a client module
typedef struct PROVIDER_BINDING_CONTEXT_
{
HANDLE client_binding_handle; // Handle of the attached client
const ebpf_helper_function_addresses_t* client_dispatch; // Dispatch routines addresses of the attached client
PNPI_REGISTRATION_INSTANCE client_registration_instance; // Registration instance of the attached client
void* client_binding_context; // Binding context of the attached client
HANDLE client_binding_handle; // Handle of the attached client
const netevent_ext_function_addresses_t* client_dispatch; // Dispatch routines addresses of the attached client
PNPI_REGISTRATION_INSTANCE client_registration_instance; // Registration instance of the attached client
void* client_binding_context; // Binding context of the attached client
} PROVIDER_BINDING_CONTEXT;

0 comments on commit 0700450

Please sign in to comment.