knet_handle_enable_filter3
Install a filter to route packets
Usage
#include <libknet.h>
int knet_handle_enable_filter(
knet_handle_t knet_h,
void *dst_host_filter_fn_private_data,
int(*)(void *private_data, const unsigned char *outdata, ssize_t outdata_len, uint8_t tx_rx, knet_node_id_t this_host_id, knet_node_id_t src_host_id, int8_t *channel, knet_node_id_t *dst_host_ids, size_t *dst_host_ids_entries) dst_host_filter_fn
);
Overview
knet_handle_enable_filter
knet_h - pointer to knet_handle_t
dst_host_filter_fn_private_data void pointer to data that can be used to identify the callback.
dst_host_filter_fn - is a callback function that is invoked every time a packet hits datafd (see knet_handle_new(3)). the function allows users to tell libknet where the packet has to be delivered.
const unsigned char *outdata - is a pointer to the current packet ssize_t outdata_len - length of the above data uint8_t tx_rx - filter is called on tx or rx (KNET_NOTIFY_TX, KNET_NOTIFY_RX) knet_node_id_t this_host_id - host_id processing the packet knet_node_id_t src_host_id - host_id that generated the packet knet_node_id_t *dst_host_ids - array of KNET_MAX_HOST knet_node_id_t where to store the destinations (uninitialized by caller, callee should never read it) size_t *dst_host_ids_entries - number of hosts to send the message
dst_host_filter_fn should return -1 on error, packet is discarded. 0 packet is unicast and should be sent to dst_host_ids and there are dst_host_ids_entries in the buffer. 1 packet is broadcast/multicast and is sent all hosts. contents of dst_host_ids and dst_host_ids_entries are ignored.
Return value
knet_handle_enable_filter returns 0 on success -1 on error and errno is set.
Releases
4 releases since Debian 10 (Buster); the text changed 3 times.