Source code for xdp_sock.h

/*  =========================================================================
    xdp_sock - The xdp_sock class!

    MIT License

    Copyright (c) [2023] XDP Interface

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
    =========================================================================
*/

#ifndef XDP_SOCK_H_INCLUDED
#define XDP_SOCK_H_INCLUDED
#ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/xdp_sock.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds.
[docs]/** * Default xsks map name */ #define XDP_SOCK_XSKS_MAP_DEFAULT "xsks_map"
[docs]/** * Prefer busy poll sockopt */ #define XDP_SOCK_SO_PREFER_BUSY_POLL 69
[docs]/** * Busy poll sockopt */ #define XDP_SOCK_SO_BUSY_POLL 36
[docs]/** * Busy poll budget sockopt */ #define XDP_SOCK_SO_BUSY_POLL_BUDGET 70
// Create a new xdp socket
XDPIFACE_EXPORT xdp_sock_t *
xdp_sock_new (xdp_iface_t *xdp_interface); // Destroy the xdp_sock.
XDPIFACE_EXPORT void xdp_sock_destroy (xdp_sock_t **self_p);
// Create a new xdp socket
XDPIFACE_EXPORT int xdp_sock_lookup_bpf_map (xdp_sock_t *self, xdp_iface_t *xdp_interface, const char *map_name, uint32_t key_size, uint32_t value_size);
// Set socket option
XDPIFACE_EXPORT int xdp_sock_set_sockopt (xdp_sock_t *self, int opt_type, int opt_value);
// Get socket file descriptor
XDPIFACE_EXPORT int xdp_sock_get_fd (xdp_sock_t *self);
// Get batch
XDPIFACE_EXPORT int xdp_sock_rx_batch_get_size (xdp_sock_t *self, uint32_t *frames_recvd, uint32_t nb);
// Release batch
XDPIFACE_EXPORT int xdp_sock_rx_batch_release (xdp_sock_t *self, uint32_t frames_recvd);
// Receive a packet from the batch
XDPIFACE_EXPORT int xdp_sock_recv (xdp_sock_t *self, char *buffer, size_t *buffer_size);
// Set batch size
XDPIFACE_EXPORT int xdp_sock_tx_batch_set_size (xdp_sock_t *self, uint32_t nb);
// Release batch
XDPIFACE_EXPORT int xdp_sock_tx_batch_release (xdp_sock_t *self, uint32_t frames_send);
// Place a frame in the tx ring
XDPIFACE_EXPORT int xdp_sock_send (xdp_sock_t *self, char *buffer, size_t buffer_size);
// Self test of this class.
XDPIFACE_EXPORT void xdp_sock_test (bool verbose);
// @end #ifdef __cplusplus } #endif #endif