2021-06-10 22:02:00 +03:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
// SPDX-License-Identifier: MIT
|
2021-04-23 23:26:54 +03:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ebpf_object.h"
|
|
|
|
#include "ebpf_platform.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef uint64_t ebpf_handle_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialize the global handle table.
|
|
|
|
*
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
2021-04-23 23:26:54 +03:00
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-23 23:26:54 +03:00
|
|
|
ebpf_handle_table_initiate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Terminate the global handle table.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ebpf_handle_table_terminate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Create a handle that holds a reference on the object.
|
|
|
|
*
|
|
|
|
* @param[out] handle Pointer to memory that contains the handle on success.
|
|
|
|
* @param[in] object Object to be referenced by this handle.
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_NO_MEMORY Unable to allocate resources for this
|
2021-04-23 23:26:54 +03:00
|
|
|
* operation.
|
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-23 23:26:54 +03:00
|
|
|
ebpf_handle_create(ebpf_handle_t* handle, ebpf_object_t* object);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Remove an existing handle from the handle table and release its
|
|
|
|
* reference on the object.
|
|
|
|
*
|
|
|
|
* @param[in] handle Handle to be released.
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
2021-04-23 23:26:54 +03:00
|
|
|
* @retval EBPF_ERROR_INVALID_HANDLE The provided handle is not valid.
|
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-23 23:26:54 +03:00
|
|
|
ebpf_handle_close(ebpf_handle_t handle);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Find the handle in the handle table, verify the type matches,
|
|
|
|
* acquire a reference to the object and return it.
|
|
|
|
*
|
|
|
|
* @param[in] handle Handle to find in table.
|
|
|
|
* @param[in] object_type Object type to match.
|
|
|
|
* @param[out] object Pointer to memory that contains object success.
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
2021-04-23 23:26:54 +03:00
|
|
|
* @retval EBPF_ERROR_INVALID_HANDLE The provided handle is not valid.
|
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-23 23:26:54 +03:00
|
|
|
ebpf_reference_object_by_handle(ebpf_handle_t handle, ebpf_object_type_t object_type, ebpf_object_t** object);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|