2024-05-04 22:55:56 +03:00
|
|
|
// Copyright (c) eBPF for Windows contributors
|
2021-06-10 22:02:00 +03:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-04-23 18:42:55 +03:00
|
|
|
|
|
|
|
#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
|
|
|
*
|
2023-04-21 21:06:48 +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
|
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.
|
|
|
|
*/
|
2022-11-14 20:40:21 +03:00
|
|
|
_Must_inspect_result_ ebpf_result_t
|
2023-04-21 21:06:48 +03:00
|
|
|
ebpf_link_create(
|
2022-12-12 20:56:51 +03:00
|
|
|
ebpf_attach_type_t attach_type,
|
|
|
|
_In_reads_(context_data_length) const uint8_t* context_data,
|
2023-04-21 21:06:48 +03:00
|
|
|
size_t context_data_length,
|
|
|
|
_Outptr_ ebpf_link_t** link);
|
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
|
|
|
*
|
2022-12-16 02:58:33 +03:00
|
|
|
* @param[in, out] link The link object to attach the program to.
|
|
|
|
* @param[in, out] 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.
|
|
|
|
*/
|
2022-11-14 20:40:21 +03:00
|
|
|
_Must_inspect_result_ ebpf_result_t
|
2022-12-12 20:56:51 +03:00
|
|
|
ebpf_link_attach_program(_Inout_ ebpf_link_t* link, _Inout_ 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-09-15 21:11:13 +03:00
|
|
|
ebpf_link_detach_program(_Inout_ ebpf_link_t* link);
|
2021-04-23 18:42:55 +03:00
|
|
|
|
2021-09-11 07:54:07 +03:00
|
|
|
/**
|
|
|
|
* @brief Get bpf_link_info about a link.
|
|
|
|
*
|
|
|
|
* @param[in] link The link object to get info about.
|
|
|
|
* @param[out] buffer Buffer to write bpf_link_info into.
|
2022-12-16 02:58:33 +03:00
|
|
|
* @param[in, out] info_size On input, the size in bytes of the buffer.
|
2021-09-11 07:54:07 +03:00
|
|
|
* On output, the number of bytes actually written.
|
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_INSUFFICIENT_BUFFER The buffer was too small to hold bpf_link_info.
|
|
|
|
*/
|
2022-11-14 20:40:21 +03:00
|
|
|
_Must_inspect_result_ ebpf_result_t
|
2021-09-11 07:54:07 +03:00
|
|
|
ebpf_link_get_info(
|
|
|
|
_In_ const ebpf_link_t* link,
|
|
|
|
_Out_writes_to_(*info_size, *info_size) uint8_t* buffer,
|
|
|
|
_Inout_ uint16_t* info_size);
|
|
|
|
|
2021-04-23 18:42:55 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|