2021-04-23 18:42:55 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) Microsoft Corporation
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ebpf_platform.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef GUID ebpf_attach_type_t;
|
2021-04-27 02:17:44 +03:00
|
|
|
typedef struct _ebpf_link ebpf_link_t;
|
2021-04-25 02:03:51 +03:00
|
|
|
typedef struct _ebpf_program ebpf_program_t;
|
2021-04-23 18:42:55 +03:00
|
|
|
|
|
|
|
/**
|
2021-04-27 02:17:44 +03:00
|
|
|
* @brief Create a new link object.
|
2021-04-23 18:42:55 +03:00
|
|
|
*
|
2021-04-27 02:17:44 +03:00
|
|
|
* @param[out] link Pointer to memory that will contain the link object
|
2021-04-23 18:42:55 +03:00
|
|
|
* on success.
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_NO_MEMORY Unable to allocate resources for this
|
2021-04-27 02:17:44 +03:00
|
|
|
* link object.
|
2021-04-23 18:42:55 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-27 02:17:44 +03:00
|
|
|
ebpf_link_create(ebpf_link_t** link);
|
2021-04-23 18:42:55 +03:00
|
|
|
|
|
|
|
/**
|
2021-04-27 02:17:44 +03:00
|
|
|
* @brief Initialize this link object and load the associated hook
|
2021-04-23 18:42:55 +03:00
|
|
|
* provider if needed.
|
|
|
|
*
|
2021-04-27 02:17:44 +03:00
|
|
|
* @param[in] link The link object to initialize.
|
2021-04-23 18:42:55 +03:00
|
|
|
* @param[in] attach_type Attach type to load.
|
|
|
|
* @param[in] context_data Data to be passed to the hook provider.
|
|
|
|
* @param[in] context_data_length Length of the data to be passed to the hook
|
|
|
|
* provider.
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
2021-04-23 18:42:55 +03:00
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-27 02:17:44 +03:00
|
|
|
ebpf_link_initialize(
|
|
|
|
ebpf_link_t* link, ebpf_attach_type_t attach_type, const uint8_t* context_data, size_t context_data_length);
|
2021-04-23 18:42:55 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the properties from the hook provider.
|
|
|
|
*
|
2021-04-27 02:17:44 +03:00
|
|
|
* @param[in] link The link object to get properties from.
|
2021-04-23 18:42:55 +03:00
|
|
|
* @param[out] hook_properties Pointer to buffer that contains the hook
|
|
|
|
* provider properties on success.
|
|
|
|
* @param[out] hook_properties_length Pointer to size that contains the size
|
|
|
|
* of the hook provider properties.
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_INVALID_ARGUMENT Hook instance has not been
|
2021-04-23 18:42:55 +03:00
|
|
|
* initialized.
|
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-27 02:17:44 +03:00
|
|
|
ebpf_link_get_properties(ebpf_link_t* link, uint8_t** hook_properties, size_t* hook_properties_length);
|
2021-04-23 18:42:55 +03:00
|
|
|
|
|
|
|
/**
|
2021-04-27 02:17:44 +03:00
|
|
|
* @brief Attach a program to this link object.
|
2021-04-23 18:42:55 +03:00
|
|
|
*
|
2021-04-27 02:17:44 +03:00
|
|
|
* @param[in] link The link object to attach the program to.
|
|
|
|
* @param[in] program The program to attach to this link object.
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_INVALID_ARGUMENT Hook instance has not been
|
2021-04-23 18:42:55 +03:00
|
|
|
* initialized.
|
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-27 02:17:44 +03:00
|
|
|
ebpf_link_attach_program(ebpf_link_t* link, ebpf_program_t* program);
|
2021-04-23 18:42:55 +03:00
|
|
|
|
|
|
|
/**
|
2021-04-27 02:17:44 +03:00
|
|
|
* @brief Detach a program from this link object.
|
2021-04-23 18:42:55 +03:00
|
|
|
*
|
2021-04-27 02:17:44 +03:00
|
|
|
* @param[in] link The link object to detach.
|
2021-04-23 18:42:55 +03:00
|
|
|
*/
|
|
|
|
void
|
2021-04-27 02:17:44 +03:00
|
|
|
ebpf_link_detach_program(ebpf_link_t* link);
|
2021-04-23 18:42:55 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|