|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
21 #include <sys/types.h>
23 #include <sys/ioctl.h>
24 #include <sys/socket.h>
28 #include <sys/prctl.h>
34 #include <linux/icmp.h>
35 #include <arpa/inet.h>
37 #include <netinet/if_ether.h>
38 #include <net/if_arp.h>
39 #include <asm/byteorder.h>
42 #include <sys/epoll.h>
50 #define APP_NAME "ICMP_Responder"
51 #define IF_NAME "memif_connection"
55 #define DBG(...) do { \
56 printf (APP_NAME":%s:%d: ", __func__, __LINE__); \
57 printf (__VA_ARGS__); \
64 #define INFO(...) do { \
65 printf ("INFO: "__VA_ARGS__); \
70 #define MAX_MEMIF_BUFS 256
100 printf (
"MEMIF DETAILS\n");
101 printf (
"==============================\n");
105 memset (&md, 0,
sizeof (md));
106 ssize_t buflen = 2048;
108 memset (
buf, 0, buflen);
122 printf (
"\tinterface name: %s\n", (
char *) md.
if_name);
123 printf (
"\tapp name: %s\n", (
char *) md.
inst_name);
124 printf (
"\tremote interface name: %s\n", (
char *) md.
remote_if_name);
126 printf (
"\tid: %u\n", md.
id);
127 printf (
"\tsecret: %s\n", (
char *) md.
secret);
137 printf (
"ethernet\n");
143 printf (
"punt/inject\n");
146 printf (
"unknown\n");
151 printf (
"\trx queues:\n");
158 printf (
"\ttx queues:\n");
179 INFO (
"memif connected!");
188 INFO (
"memif disconnected!");
206 printf (
"LIBMEMIF EXAMPLE APP: %s",
APP_NAME);
211 printf (
"==============================\n");
218 printf (
"\tuse CTRL+C to exit\n");
236 DBG (
"allocated %d/%ld buffers, %u free buffers",
r, n,
252 DBG (
"tx: %d/%u",
r,
c->tx_buf_num);
297 DBG (
"received %d buffers. %u/%u alloc/free buffers",
302 INFO (
"buffer_alloc error");
306 for (
i = 0;
i < rx;
i++)
309 (
c->rx_bufs +
i)->len,
310 (
void *) (
c->tx_bufs +
i)->data,
311 &(
c->tx_bufs +
i)->len,
c->ip_addr);
322 DBG (
"freed %d buffers. %u/%u alloc/free buffers",
334 DBG (
"freed %d buffers. %u/%u alloc/free buffers",
344 memset (&args, 0,
sizeof (args));
381 c->tx_qid = strtol (argv[1], &
end, 10);
383 INFO (
"tx qid: %u",
c->tx_qid);
414 DBG (
"poll_event error!");
int on_connect(memif_conn_handle_t conn, void *private_ctx)
memif_interface_mode_t mode
int icmpr_memif_create(int is_master)
int memif_create(memif_conn_handle_t *c, memif_conn_args_t *args, memif_connection_update_t *on_connect, memif_connection_update_t *on_disconnect, memif_interrupt_t *on_interrupt, void *private_ctx)
Memory interface create function.
Memif connection arguments.
int memif_get_details(memif_conn_handle_t conn, memif_details_t *md, char *buf, ssize_t buflen)
Memif get details.
memif_queue_details_t * tx_queues
vnet_hw_if_output_node_runtime_t * r
int on_disconnect(memif_conn_handle_t conn, void *private_ctx)
int icmpr_tx_burst(uint16_t qid)
int on_interrupt(memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
int memif_init(memif_control_fd_update_t *on_control_fd_update, char *app_name, memif_alloc_t *memif_alloc, memif_realloc_t *memif_realloc, memif_free_t *memif_free)
Memif initialization.
static void print_memif_details()
uint16_t memif_get_version()
Memif get version.
struct memif_connection memif_connection_t
f64 end
end of the time range
uint8_t * remote_inst_name
int memif_buffer_alloc(memif_conn_handle_t conn, uint16_t qid, memif_buffer_t *bufs, uint16_t count, uint16_t *count_out, uint16_t size)
Memif buffer alloc.
#define LIBMEMIF_VERSION
Libmemif version.
sll srl srl sll sra u16x4 i
int memif_cleanup()
Memif cleanup.
void * memif_conn_handle_t
Memif connection handle pointer of type void, pointing to internal structure.
uint8_t * socket_filename
int main(int argc, char *argv[])
int memif_tx_burst(memif_conn_handle_t conn, uint16_t qid, memif_buffer_t *bufs, uint16_t count, uint16_t *tx)
Memif transmit buffer burst.
uint8_t interface_name[32]
int memif_delete(memif_conn_handle_t *conn)
Memif delete.
int resolve_packet(void *in_pck, ssize_t in_size, void *out_pck, uint32_t *out_size, uint8_t ip_addr[4])
char * memif_strerror(int err_code)
Memif strerror.
void * malloc(size_t size)
memif_queue_details_t * rx_queues
int memif_poll_event(int timeout)
Memif poll event.
memif_connection_t memif_connection
int memif_refill_queue(memif_conn_handle_t conn, uint16_t qid, uint16_t count, uint16_t headroom)
Memif refill queue.
int memif_rx_burst(memif_conn_handle_t conn, uint16_t qid, memif_buffer_t *bufs, uint16_t count, uint16_t *rx)
Memif receive buffer burst.
int icmpr_buffer_alloc(long n, uint16_t qid)