#include <sys/socket.h>
#include <linux/netlink.h>
#include <libnfnetlink/linux_nfnetlink.h>
#include <byteswap.h>
Data Structures | |
struct | nfnlhdr |
struct | nfnl_callback |
Macros | |
#define | aligned_u64 unsigned long long __attribute__((aligned(8))) |
#define | NETLINK_NETFILTER 12 |
#define | SOL_NETLINK 270 |
#define | NETLINK_BROADCAST_SEND_ERROR 4 |
#define | NETLINK_NO_ENOBUFS 5 |
#define | NLMSG_TAIL(nlh) (((void *) (nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)) |
#define | NFNL_HEADER_LEN |
#define | NFNL_BUFFSIZE 8192 |
#define | nfnl_attr_present(tb, attr) (tb[attr-1]) |
#define | nfnl_get_data(tb, attr, type) |
#define | nfnl_get_pointer_to_data(tb, attr, type) |
#define | NLA_F_NESTED (1 << 15) |
#define | nfnl_parse_nested(tb, max, nfa) nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa))) |
#define | nfnl_nest(nlh, bufsize, type) |
#define | nfnl_nest_end(nlh, tail) ({ (tail)->nfa_len = (void *) NLMSG_TAIL(nlh) - (void *) tail; }) |
#define | IFNAMSIZ 16 |
#define | __be64_to_cpu(x) (x) |
Enumerations | |
enum | { NFNL_CB_FAILURE = -1, NFNL_CB_STOP = 0, NFNL_CB_CONTINUE = 1 } |
Functions | |
int | nfnl_fd (struct nfnl_handle *h) |
nfnl_fd - returns the descriptor that identifies the socket : nfnetlink handler More... | |
unsigned int | nfnl_portid (const struct nfnl_handle *h) |
nfnl_portid - returns the Netlink port ID of this socket : nfnetlink handler More... | |
struct nfnl_handle * | nfnl_open (void) |
nfnl_open - open a nfnetlink handler More... | |
int | nfnl_close (struct nfnl_handle *) |
nfnl_close - close a nfnetlink handler : nfnetlink handler More... | |
struct nfnl_subsys_handle * | nfnl_subsys_open (struct nfnl_handle *, u_int8_t, u_int8_t, unsigned int) |
void | nfnl_subsys_close (struct nfnl_subsys_handle *) |
nfnl_subsys_close - close a nfnetlink subsys handler : nfnetlink subsystem handler More... | |
void | nfnl_set_sequence_tracking (struct nfnl_handle *h) |
nfnl_set_sequence_tracking - set netlink sequence tracking : nfnetlink handler More... | |
void | nfnl_unset_sequence_tracking (struct nfnl_handle *h) |
nfnl_unset_sequence_tracking - set netlink sequence tracking : nfnetlink handler More... | |
void | nfnl_set_rcv_buffer_size (struct nfnl_handle *h, unsigned int size) |
nfnl_set_rcv_buffer_size - set the size of the receive buffer : libnfnetlink handler : buffer size More... | |
int | nfnl_send (struct nfnl_handle *, struct nlmsghdr *) |
nfnl_send - send a nfnetlink message through netlink socket : nfnetlink handler : netlink message More... | |
int | nfnl_sendmsg (const struct nfnl_handle *, const struct msghdr *msg, unsigned int flags) |
int | nfnl_sendiov (const struct nfnl_handle *nfnlh, const struct iovec *iov, unsigned int num, unsigned int flags) |
void | nfnl_fill_hdr (struct nfnl_subsys_handle *, struct nlmsghdr *, unsigned int, u_int8_t, u_int16_t, u_int16_t, u_int16_t) |
nfnl_fill_hdr - fill in netlink and nfnetlink header : nfnetlink handle : netlink message to be filled in : length of payload bytes (not including nfgenmsg) : AF_INET / ... More... | |
__attribute__ ((deprecated)) int nfnl_talk(struct nfnl_handle * | |
struct nlmsghdr struct nlmsghdr int void int void *ssize_t | nfnl_recv (const struct nfnl_handle *h, unsigned char *buf, size_t len) |
nfnl_recv - receive data from a nfnetlink subsystem : nfnetlink handler : buffer where the data will be stored : size of the buffer More... | |
int | nfnl_callback_register (struct nfnl_subsys_handle *, u_int8_t type, struct nfnl_callback *cb) |
nfnl_callback_register - register a callback for a certain message type : nfnetlink subsys handler : subsys call : nfnetlink callback to be registered More... | |
int | nfnl_callback_unregister (struct nfnl_subsys_handle *, u_int8_t type) |
nfnl_callback_unregister - unregister a certain callback : nfnetlink subsys handler : subsys call More... | |
int | nfnl_handle_packet (struct nfnl_handle *, char *buf, int len) |
struct nfattr * | nfnl_parse_hdr (const struct nfnl_handle *nfnlh, const struct nlmsghdr *nlh, struct nfgenmsg **genmsg) |
int | nfnl_check_attributes (const struct nfnl_handle *nfnlh, const struct nlmsghdr *nlh, struct nfattr *tb[]) |
struct nlmsghdr * | nfnl_get_msg_first (struct nfnl_handle *h, const unsigned char *buf, size_t len) |
nfnl_get_msg_first - get the first message of a multipart netlink message : nfnetlink handle : data received that we want to process : size of the data received More... | |
struct nlmsghdr * | nfnl_get_msg_next (struct nfnl_handle *h, const unsigned char *buf, size_t len) |
int | nfnl_join (const struct nfnl_handle *nfnlh, unsigned int group) |
nfnl_join - join a nfnetlink multicast group : nfnetlink handler : group we want to join More... | |
int | nfnl_process (struct nfnl_handle *h, const unsigned char *buf, size_t len) |
nfnl_process - process data coming from a nfnetlink system : nfnetlink handler : buffer that contains the netlink message : size of the data contained in the buffer (not the buffer size) More... | |
struct nfnl_iterator * | nfnl_iterator_create (const struct nfnl_handle *h, const char *buf, size_t len) |
nfnl_iterator_create: create an nfnetlink iterator : nfnetlink handler : buffer that contains data received from a nfnetlink system : size of the data contained in the buffer (not the buffer size) More... | |
void | nfnl_iterator_destroy (struct nfnl_iterator *it) |
nfnl_iterator_destroy - destroy a nfnetlink iterator : nfnetlink iterator More... | |
int | nfnl_iterator_process (struct nfnl_handle *h, struct nfnl_iterator *it) |
nfnl_iterator_process - process a nfnetlink message : nfnetlink handler : nfnetlink iterator that contains the current message to be proccesed More... | |
int | nfnl_iterator_next (const struct nfnl_handle *h, struct nfnl_iterator *it) |
nfnl_iterator_next - get the next message hold by the iterator : nfnetlink handler : nfnetlink iterator that contains the current message processed More... | |
int | nfnl_catch (struct nfnl_handle *h) |
nfnl_catch - get responses from the nfnetlink system and process them : nfnetlink handler More... | |
int | nfnl_query (struct nfnl_handle *h, struct nlmsghdr *nlh) |
nfnl_query - request/response communication challenge : nfnetlink handler : nfnetlink message to be sent More... | |
int | nfnl_addattr_l (struct nlmsghdr *, int, int, const void *, int) |
nfnl_addattr_l - Add variable length attribute to nlmsghdr : netlink message header to which attribute is to be added : maximum length of netlink message header : type of new attribute : content of new attribute : attribute length More... | |
int | nfnl_addattr8 (struct nlmsghdr *, int, int, u_int8_t) |
nfnl_addattr8 - Add u_int8_t attribute to nlmsghdr More... | |
int | nfnl_addattr16 (struct nlmsghdr *, int, int, u_int16_t) |
nfnl_addattr16 - Add u_int16_t attribute to nlmsghdr More... | |
int | nfnl_addattr32 (struct nlmsghdr *, int, int, u_int32_t) |
nfnl_addattr32 - Add u_int32_t attribute to nlmsghdr More... | |
int | nfnl_nfa_addattr_l (struct nfattr *, int, int, const void *, int) |
nfnl_nfa_addattr_l - Add variable length attribute to struct nfattr More... | |
int | nfnl_nfa_addattr16 (struct nfattr *, int, int, u_int16_t) |
nfnl_nfa_addattr16 - Add u_int16_t attribute to struct nfattr More... | |
int | nfnl_nfa_addattr32 (struct nfattr *, int, int, u_int32_t) |
nfnl_nfa_addattr32 - Add u_int32_t attribute to struct nfattr More... | |
int | nfnl_parse_attr (struct nfattr **, int, struct nfattr *, int) |
void | nfnl_build_nfa_iovec (struct iovec *iov, struct nfattr *nfa, u_int16_t type, u_int32_t len, unsigned char *val) |
nfnl_build_nfa_iovec - Build two iovec's from tag, length and value More... | |
unsigned int | nfnl_rcvbufsiz (const struct nfnl_handle *h, unsigned int size) |
nfnl_rcvbufsiz - set the socket buffer size : nfnetlink handler : size of the buffer we want to set More... | |
void | nfnl_dump_packet (struct nlmsghdr *, int, char *) |
struct nlif_handle * | nlif_open (void) |
Initialize interface table. More... | |
void | nlif_close (struct nlif_handle *orig) |
Destructor of interface table. More... | |
int | nlif_fd (struct nlif_handle *nlif_handle) |
Returns socket descriptor for the netlink socket. More... | |
int | nlif_query (struct nlif_handle *nlif_handle) |
nlif_query - request a dump of interfaces available in the system : pointer to a valid nlif_handler More... | |
int | nlif_catch (struct nlif_handle *nlif_handle) |
Receive message from netlink and update interface table. More... | |
int | nlif_index2name (struct nlif_handle *nlif_handle, unsigned int if_index, char *name) |
Get the name for an ifindex. More... | |
int | nlif_get_ifflags (const struct nlif_handle *h, unsigned int index, unsigned int *flags) |
Get the flags for an ifindex. More... | |
Variables | |
struct nlmsghdr | pid_t |
struct nlmsghdr | unsigned |
struct nlmsghdr struct nlmsghdr int | struct |
#define __be64_to_cpu | ( | x | ) | (x) |
Referenced by nflog_get_timestamp(), and nfq_get_timestamp().
#define aligned_u64 unsigned long long __attribute__((aligned(8))) |
#define IFNAMSIZ 16 |
#define NETLINK_BROADCAST_SEND_ERROR 4 |
Referenced by main(), and nl_init_event_handler().
#define NETLINK_NETFILTER 12 |
#define NETLINK_NO_ENOBUFS 5 |
Referenced by nflog_get_gid(), nflog_get_seq(), nflog_get_seq_global(), nflog_get_uid(), nfq_get_gid(), and nfq_get_uid().
#define NFNL_BUFFSIZE 8192 |
Referenced by nfnl_listen(), nfnl_open(), and nfnl_talk().
Referenced by nflog_get_gid(), nflog_get_hwtype(), nflog_get_indev(), nflog_get_msg_packet_hwhdrlen(), nflog_get_nfmark(), nflog_get_outdev(), nflog_get_physindev(), nflog_get_physoutdev(), nflog_get_seq(), nflog_get_seq_global(), nflog_get_uid(), nfq_get_gid(), nfq_get_indev(), nfq_get_nfmark(), nfq_get_outdev(), nfq_get_physindev(), nfq_get_physoutdev(), and nfq_get_uid().
Referenced by nflog_get_msg_packet_hdr(), nflog_get_msg_packet_hwhdr(), nflog_get_packet_hw(), nflog_get_payload(), nflog_get_prefix(), nflog_get_timestamp(), nfq_get_msg_packet_hdr(), nfq_get_packet_hw(), nfq_get_payload(), and nfq_get_timestamp().
#define NFNL_HEADER_LEN |
Referenced by nflog_set_flags(), nflog_set_mode(), nflog_set_nlbufsiz(), nflog_set_qthresh(), nflog_set_timeout(), nfq_set_mode(), nfq_set_queue_flags(), and nfq_set_queue_maxlen().
Referenced by __build_expect(), and __build_tuple().
#define nfnl_nest_end | ( | nlh, | |
tail | |||
) | ({ (tail)->nfa_len = (void *) NLMSG_TAIL(nlh) - (void *) tail; }) |
Referenced by __build_expect(), and __build_tuple().
#define nfnl_parse_nested | ( | tb, | |
max, | |||
nfa | |||
) | nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa))) |
Referenced by __parse_expect(), and __parse_tuple().
#define NLA_F_NESTED (1 << 15) |
#define NLMSG_TAIL | ( | nlh | ) | (((void *) (nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)) |
Referenced by nfnl_addattr_l().
#define SOL_NETLINK 270 |
__attribute__ | ( | (deprecated) | ) |
nfnl_addattr16 - Add u_int16_t attribute to nlmsghdr
: netlink message header to which attribute is to be added : maximum length of netlink message header : type of new attribute : content of new attribute
References nfnl_addattr_l().
Referenced by nflog_set_flags().
nfnl_addattr32 - Add u_int32_t attribute to nlmsghdr
: netlink message header to which attribute is to be added : maximum length of netlink message header : type of new attribute : content of new attribute
References nfnl_addattr_l().
Referenced by __build_expect(), __build_filter_dump(), nflog_set_nlbufsiz(), nflog_set_qthresh(), nflog_set_timeout(), and nfq_set_queue_flags().
nfnl_addattr8 - Add u_int8_t attribute to nlmsghdr
: netlink message header to which attribute is to be added : maximum length of netlink message header : type of new attribute : content of new attribute
References nfnl_addattr_l().
nfnl_addattr_l - Add variable length attribute to nlmsghdr
: netlink message header to which attribute is to be added : maximum length of netlink message header : type of new attribute : content of new attribute : attribute length
References len, NFA_ALIGN, NFA_DATA, nfattr::nfa_len, NFA_LENGTH, nfattr::nfa_type, NLMSG_ALIGN, nlmsghdr::nlmsg_len, NLMSG_TAIL, and type.
Referenced by nflog_set_mode(), nfnl_addattr16(), nfnl_addattr32(), nfnl_addattr8(), nfq_set_mode(), and nfq_set_queue_maxlen().
void nfnl_build_nfa_iovec | ( | struct iovec * | iov, |
struct nfattr * | nfa, | ||
u_int16_t | type, | ||
u_int32_t | len, | ||
unsigned char * | val | ||
) |
nfnl_build_nfa_iovec - Build two iovec's from tag, length and value
: pointer to array of two 'struct iovec' (caller-allocated) : pointer to 'struct nfattr' (caller-allocated) : type (tag) of attribute : length of value : pointer to buffer containing 'value'
References NFA_ALIGN, nfattr::nfa_len, nfattr::nfa_type, and type.
int nfnl_callback_register | ( | struct nfnl_subsys_handle * | ssh, |
u_int8_t | type, | ||
struct nfnl_callback * | cb | ||
) |
nfnl_callback_register - register a callback for a certain message type : nfnetlink subsys handler : subsys call : nfnetlink callback to be registered
On success, 0 is returned. On error, -1 is returned and errno is set appropiately.
References nfnl_subsys_handle::cb, and nfnl_subsys_handle::cb_count.
Referenced by nfct_callback_register(), nfct_callback_register2(), nfexp_callback_register(), nfexp_callback_register2(), nflog_open_nfnl(), and nfq_open_nfnl().
int nfnl_callback_unregister | ( | struct nfnl_subsys_handle * | ssh, |
u_int8_t | type | ||
) |
nfnl_callback_unregister - unregister a certain callback : nfnetlink subsys handler : subsys call
On sucess, 0 is returned. On error, -1 is returned and errno is set appropiately.
References nfnl_callback::call, nfnl_subsys_handle::cb, nfnl_subsys_handle::cb_count, NULL, and type.
Referenced by nfct_callback_unregister(), nfct_callback_unregister2(), nfexp_callback_unregister(), and nfexp_callback_unregister2().
int nfnl_catch | ( | struct nfnl_handle * | h | ) |
nfnl_catch - get responses from the nfnetlink system and process them : nfnetlink handler
This function handles the data received from the nfnetlink system. For example, events generated by one of the subsystems. The message is passed to the callback registered via callback_register(). Note that this a replacement of nfnl_listen and its use is recommended.
On success, 0 is returned. On error, a -1 is returned. If you do not want to listen to events anymore, then your callback must return NFNL_CB_STOP.
Note that ENOBUFS is returned in case that nfnetlink is exhausted. In that case is possible that the information requested is incomplete.
References __attribute__, buf, NFNL_CB_STOP, nfnl_process(), nfnl_recv(), and nfnl_handle::rcv_buffer_size.
Referenced by nfct_catch(), nfexp_catch(), and nfnl_query().
int nfnl_close | ( | struct nfnl_handle * | nfnlh | ) |
nfnl_close - close a nfnetlink handler : nfnetlink handler
This function closes the nfnetlink handler. On success, 0 is returned. On error, -1 is returned and errno is set appropiately.
References nfnl_handle::fd, NFNL_MAX_SUBSYS, nfnl_subsys_close(), and nfnl_handle::subsys.
Referenced by main(), nfct_close(), nfct_open(), nflog_close(), nflog_open(), nflog_open_nfnl(), nfq_close(), and nfq_open().
References len, nfattr::nfa_len, NFA_NEXT, NFA_OK, NFA_TYPE, NFM_NFA, NFM_PAYLOAD, nlmsg_data(), NLMSG_DATA, nlmsghdr::nlmsg_flags, nlmsghdr::nlmsg_len, nlmsghdr::nlmsg_seq, and nlmsghdr::nlmsg_type.
int nfnl_fd | ( | struct nfnl_handle * | h | ) |
nfnl_fd - returns the descriptor that identifies the socket : nfnetlink handler
Use this function if you need to interact with the socket. Common scenarios are the use of poll()/select() to achieve multiplexation.
References nfnl_handle::fd.
Referenced by nfct_fd(), nflog_fd(), and nfq_fd().
void nfnl_fill_hdr | ( | struct nfnl_subsys_handle * | ssh, |
struct nlmsghdr * | nlh, | ||
unsigned int | len, | ||
u_int8_t | family, | ||
u_int16_t | res_id, | ||
u_int16_t | msg_type, | ||
u_int16_t | msg_flags | ||
) |
nfnl_fill_hdr - fill in netlink and nfnetlink header : nfnetlink handle : netlink message to be filled in : length of payload bytes (not including nfgenmsg) : AF_INET / ...
: resource id : nfnetlink message type (without subsystem) : netlink message flags
This function sets up appropiately the nfnetlink header. See that the pointer to the netlink message passed must point to a memory region of at least the size of struct nlmsghdr + struct nfgenmsg.
References nfnl_handle::flags, nfgenmsg::nfgen_family, NFNETLINK_V0, NFNL_F_SEQTRACK_ENABLED, nfnl_subsys_handle::nfnlh, nlmsghdr::nlmsg_flags, nlmsghdr::nlmsg_len, NLMSG_LENGTH, nlmsghdr::nlmsg_pid, nlmsghdr::nlmsg_seq, nlmsghdr::nlmsg_type, NULL, nfgenmsg::res_id, nfnl_handle::seq, nfnl_subsys_handle::subsys_id, and nfgenmsg::version.
Referenced by __build_conntrack(), __build_expect(), nflog_set_flags(), nflog_set_mode(), nflog_set_nlbufsiz(), nflog_set_qthresh(), nflog_set_timeout(), nfq_set_mode(), nfq_set_queue_flags(), and nfq_set_queue_maxlen().
struct nlmsghdr* nfnl_get_msg_first | ( | struct nfnl_handle * | h, |
const unsigned char * | buf, | ||
size_t | len | ||
) |
nfnl_get_msg_first - get the first message of a multipart netlink message : nfnetlink handle : data received that we want to process : size of the data received
This function returns a pointer to the first netlink message contained in the chunk of data received from certain nfnetlink subsystem.
On success, a valid address that points to the netlink message is returned. On error, NULL is returned.
References nfnl_handle::last_nlhdr, nlh, NLMSG_OK, and NULL.
Referenced by ipulog_get_packet().
struct nlmsghdr* nfnl_get_msg_next | ( | struct nfnl_handle * | h, |
const unsigned char * | buf, | ||
size_t | len | ||
) |
References nfnl_handle::last_nlhdr, nlh, NLM_F_MULTI, NLMSG_DONE, nlmsghdr::nlmsg_flags, NLMSG_NEXT, NLMSG_OK, nlmsghdr::nlmsg_type, and NULL.
Referenced by ipulog_get_packet().
int nfnl_handle_packet | ( | struct nfnl_handle * | , |
char * | buf, | ||
int | len | ||
) |
References len, NLMSG_ALIGN, nlmsghdr::nlmsg_len, and NLMSG_SPACE.
Referenced by nflog_handle_packet(), and nfq_handle_packet().
struct nfnl_iterator* nfnl_iterator_create | ( | const struct nfnl_handle * | h, |
const char * | buf, | ||
size_t | len | ||
) |
nfnl_iterator_create: create an nfnetlink iterator : nfnetlink handler : buffer that contains data received from a nfnetlink system : size of the data contained in the buffer (not the buffer size)
This function creates an iterator that can be used to parse nfnetlink message one by one. The iterator gives more control to the programmer in the messages processing.
On success, a valid address is returned. On error, NULL is returned and errno is set to the appropiate value.
References len, nfnl_iterator::len, nlh, nfnl_iterator::nlh, NLMSG_OK, NLMSG_SPACE, and NULL.
void nfnl_iterator_destroy | ( | struct nfnl_iterator * | it | ) |
nfnl_iterator_destroy - destroy a nfnetlink iterator : nfnetlink iterator
This function destroys a certain iterator. Nothing is returned.
int nfnl_iterator_next | ( | const struct nfnl_handle * | h, |
struct nfnl_iterator * | it | ||
) |
nfnl_iterator_next - get the next message hold by the iterator : nfnetlink handler : nfnetlink iterator that contains the current message processed
This function update the current message to be processed pointer. It returns NFNL_CB_CONTINUE if there is still more messages to be processed, otherwise NFNL_CB_STOP is returned.
References nfnl_iterator::len, nfnl_iterator::nlh, and NLMSG_NEXT.
int nfnl_iterator_process | ( | struct nfnl_handle * | h, |
struct nfnl_iterator * | it | ||
) |
nfnl_iterator_process - process a nfnetlink message : nfnetlink handler : nfnetlink iterator that contains the current message to be proccesed
This function process just the current message selected by the iterator. On success, a value greater or equal to zero is returned. On error, -1 is returned and errno is appropiately set.
References nfnl_iterator::len, nfnl_iterator::nlh, NLMSG_OK, nlmsghdr::nlmsg_seq, NLMSG_SPACE, and nfnl_handle::seq.
int nfnl_join | ( | const struct nfnl_handle * | nfnlh, |
unsigned int | group | ||
) |
nfnl_join - join a nfnetlink multicast group : nfnetlink handler : group we want to join
This function is used to join a certain multicast group. It must be called once the nfnetlink handler has been created. If any doubt, just use it if you have to listen to nfnetlink events.
On success, 0 is returned. On error, -1 is returned and errno is set approapiately.
References nfnl_handle::fd, NETLINK_ADD_MEMBERSHIP, and SOL_NETLINK.
nfnl_nfa_addattr16 - Add u_int16_t attribute to struct nfattr
: struct nfattr : maximal length of nfattr buffer : type for new attribute : content of new attribute
References nfnl_nfa_addattr_l().
nfnl_nfa_addattr32 - Add u_int32_t attribute to struct nfattr
: struct nfattr : maximal length of nfattr buffer : type for new attribute : content of new attribute
References nfnl_nfa_addattr_l().
nfnl_nfa_addattr_l - Add variable length attribute to struct nfattr
: struct nfattr : maximal length of nfattr buffer : type for new attribute : content of new attribute : length of new attribute
References len, NFA_ALIGN, NFA_DATA, nfattr::nfa_len, NFA_LENGTH, nfattr::nfa_type, and type.
Referenced by nfnl_nfa_addattr16(), and nfnl_nfa_addattr32().
struct nfnl_handle* nfnl_open | ( | void | ) |
nfnl_open - open a nfnetlink handler
This function creates a nfnetlink handler, this is required to establish a communication between the userspace and the nfnetlink system.
On success, a valid address that points to a nfnl_handle structure is returned. On error, NULL is returned and errno is set approapiately.
References nfnl_handle::fd, nfnl_handle::flags, nfnl_handle::local, NETLINK_NETFILTER, NFNL_BUFFSIZE, NFNL_F_SEQTRACK_ENABLED, sockaddr_nl::nl_family, NULL, nfnl_handle::peer, nfnl_handle::rcv_buffer_size, and nfnl_handle::seq.
Referenced by main(), nfct_open(), nflog_open(), and nfq_open().
Referenced by ipulog_get_packet(), nfct_parse_conntrack(), and nfexp_parse_expect().
struct nfattr* nfnl_parse_hdr | ( | const struct nfnl_handle * | nfnlh, |
const struct nlmsghdr * | nlh, | ||
struct nfgenmsg ** | genmsg | ||
) |
References nlmsghdr::nlmsg_len, NLMSG_LENGTH, and NULL.
unsigned int nfnl_portid | ( | const struct nfnl_handle * | h | ) |
nfnl_portid - returns the Netlink port ID of this socket : nfnetlink handler
References nfnl_handle::local, and sockaddr_nl::nl_pid.
Referenced by origin_register(), and origin_unregister().
int nfnl_process | ( | struct nfnl_handle * | h, |
const unsigned char * | buf, | ||
size_t | len | ||
) |
nfnl_process - process data coming from a nfnetlink system : nfnetlink handler : buffer that contains the netlink message : size of the data contained in the buffer (not the buffer size)
This function processes all the nfnetlink messages contained inside a buffer. It performs the appropiate sanity checks and passes the message to a certain handler that is registered via register_callback().
On success, NFNL_CB_STOP is returned if the data processing has finished. If a value NFNL_CB_CONTINUE is returned, then there is more data to process. On error, NFNL_CB_CONTINUE is returned and errno is set to the appropiate value.
In case that the callback returns NFNL_CB_FAILURE, errno may be set by the library client. If your callback decides not to process data anymore for any reason, then it must return NFNL_CB_STOP. Otherwise, if the callback continues the processing NFNL_CB_CONTINUE is returned.
References NFNL_CB_STOP, NLMSG_NEXT, NLMSG_OK, nlmsghdr::nlmsg_seq, NLMSG_SPACE, and nfnl_handle::seq.
Referenced by nfnl_catch().
int nfnl_query | ( | struct nfnl_handle * | h, |
struct nlmsghdr * | nlh | ||
) |
nfnl_query - request/response communication challenge : nfnetlink handler : nfnetlink message to be sent
This function sends a nfnetlink message to a certain subsystem and receives the response messages associated, such messages are passed to the callback registered via register_callback(). Note that this function is a replacement for nfnl_talk, its use is recommended.
On success, 0 is returned. On error, a negative is returned. If your does not want to listen to events anymore, then your callback must return NFNL_CB_STOP.
Note that ENOBUFS is returned in case that nfnetlink is exhausted. In that case is possible that the information requested is incomplete.
References nfnl_catch(), and nfnl_send().
Referenced by nfct_query(), nfexp_query(), nflog_set_flags(), nflog_set_mode(), nflog_set_nlbufsiz(), nflog_set_qthresh(), nflog_set_timeout(), nfq_set_mode(), nfq_set_queue_flags(), and nfq_set_queue_maxlen().
unsigned int nfnl_rcvbufsiz | ( | const struct nfnl_handle * | h, |
unsigned int | size | ||
) |
nfnl_rcvbufsiz - set the socket buffer size : nfnetlink handler : size of the buffer we want to set
This function sets the new size of the socket buffer. Use this setting to increase the socket buffer size if your system is reporting ENOBUFS errors.
This function returns the new size of the socket buffer.
References nfnl_handle::fd, size, and SO_RCVBUFFORCE.
Referenced by main(), nflog_set_nlbufsiz(), nl_init_event_handler(), and nl_resize_socket_buffer().
struct nlmsghdr struct nlmsghdr int void int void* ssize_t nfnl_recv | ( | const struct nfnl_handle * | h, |
unsigned char * | buf, | ||
size_t | len | ||
) |
nfnl_recv - receive data from a nfnetlink subsystem : nfnetlink handler : buffer where the data will be stored : size of the buffer
This function doesn't perform any sanity checking. So do no expect that the data is well-formed. Such checkings are done by the parsing functions.
On success, 0 is returned. On error, -1 is returned and errno is set appropiately.
Note that ENOBUFS is returned in case that nfnetlink is exhausted. In that case is possible that the information requested is incomplete.
References nfnl_handle::fd, sockaddr_nl::nl_pid, and nfnl_handle::peer.
Referenced by ipulog_read(), and nfnl_catch().
int nfnl_send | ( | struct nfnl_handle * | nfnlh, |
struct nlmsghdr * | n | ||
) |
nfnl_send - send a nfnetlink message through netlink socket : nfnetlink handler
: netlink message
On success, the number of bytes is returned. On error, -1 is returned and errno is set appropiately.
References nfnl_handle::fd, nfnl_debug_dump_packet, nlmsghdr::nlmsg_len, and nfnl_handle::peer.
Referenced by nfct_send(), nfexp_send(), and nfnl_query().
int nfnl_sendiov | ( | const struct nfnl_handle * | nfnlh, |
const struct iovec * | iov, | ||
unsigned int | num, | ||
unsigned int | flags | ||
) |
int nfnl_sendmsg | ( | const struct nfnl_handle * | , |
const struct msghdr * | msg, | ||
unsigned int | flags | ||
) |
References nfnl_handle::fd.
Referenced by nfnl_sendiov().
void nfnl_set_rcv_buffer_size | ( | struct nfnl_handle * | h, |
unsigned int | size | ||
) |
nfnl_set_rcv_buffer_size - set the size of the receive buffer : libnfnetlink handler : buffer size
This function sets the size of the receive buffer size, i.e. the size of the buffer used by nfnl_recv. Default value is 4096 bytes.
References nfnl_handle::rcv_buffer_size, and size.
void nfnl_set_sequence_tracking | ( | struct nfnl_handle * | h | ) |
nfnl_set_sequence_tracking - set netlink sequence tracking : nfnetlink handler
References nfnl_handle::flags, and NFNL_F_SEQTRACK_ENABLED.
void nfnl_subsys_close | ( | struct nfnl_subsys_handle * | ssh | ) |
nfnl_subsys_close - close a nfnetlink subsys handler : nfnetlink subsystem handler
Release all the callbacks registered in a subsystem handler.
References nfnl_subsys_handle::cb, nfnl_subsys_handle::cb_count, NULL, and nfnl_subsys_handle::subscriptions.
Referenced by main(), nfct_close(), nfct_open_nfnl(), nfnl_close(), and nfq_open_nfnl().
struct nfnl_subsys_handle* nfnl_subsys_open | ( | struct nfnl_handle * | , |
u_int8_t | , | ||
u_int8_t | , | ||
unsigned | int | ||
) |
Referenced by main(), nfct_open_nfnl(), nflog_open_nfnl(), and nfq_open_nfnl().
void nfnl_unset_sequence_tracking | ( | struct nfnl_handle * | h | ) |
nfnl_unset_sequence_tracking - set netlink sequence tracking : nfnetlink handler
References nfnl_handle::flags, and NFNL_F_SEQTRACK_ENABLED.
Referenced by nflog_open(), and nfq_open().
int nlif_catch | ( | struct nlif_handle * | h | ) |
Receive message from netlink and update interface table.
nlif_handle | A pointer to a nlif_handle created |
References NULL, nlif_handle::rtnl_handle, and rtnl_receive().
void nlif_close | ( | struct nlif_handle * | h | ) |
Destructor of interface table.
nlif_handle | A pointer to a nlif_handle created via nlif_open() |
References ifindex_node::head, nlif_handle::ifadd_handler, nlif_handle::ifdel_handler, nlif_handle::ifindex_hash, list_for_each_entry_safe, NULL, rtnl_close(), nlif_handle::rtnl_handle, and rtnl_handler_unregister().
Referenced by main().
int nlif_fd | ( | struct nlif_handle * | h | ) |
Returns socket descriptor for the netlink socket.
nlif_handle | A pointer to a nlif_handle created |
References NULL, rtnl_handle::rtnl_fd, and nlif_handle::rtnl_handle.
Referenced by nl_init_interface_handler().
int nlif_get_ifflags | ( | const struct nlif_handle * | h, |
unsigned int | index, | ||
unsigned int * | flags | ||
) |
Get the flags for an ifindex.
nlif_handle | A pointer to a nlif_handle created |
index | ifindex to be resolved |
flags | pointer to variable used to store the interface flags |
References flags, ifindex_node::head, nlif_handle::ifindex_hash, list_for_each_entry, and NULL.
Referenced by main().
int nlif_index2name | ( | struct nlif_handle * | h, |
unsigned int | index, | ||
char * | name | ||
) |
Get the name for an ifindex.
nlif_handle | A pointer to a nlif_handle created |
index | ifindex to be resolved |
name | interface name, pass a buffer of IFNAMSIZ size |
References ifindex_node::head, nlif_handle::ifindex_hash, list_for_each_entry, and NULL.
Referenced by main(), nfq_get_indev_name(), nfq_get_outdev_name(), nfq_get_physindev_name(), and nfq_get_physoutdev_name().
struct nlif_handle* nlif_open | ( | void | ) |
Initialize interface table.
Initialize rtnl interface and interface table Call this before any nlif_* function
References rtnl_handler::arg, rtnl_handler::handlefn, nlif_handle::ifadd_handler, nlif_handle::ifdel_handler, nlif_handle::ifindex_hash, INIT_LIST_HEAD, rtnl_handler::nlmsg_type, NULL, RTM_DELLINK, RTM_NEWLINK, rtnl_close(), nlif_handle::rtnl_handle, rtnl_handler_register(), rtnl_handler_unregister(), and rtnl_open().
Referenced by main(), and nl_init_interface_handler().
int nlif_query | ( | struct nlif_handle * | nlif_handle | ) |
nlif_query - request a dump of interfaces available in the system : pointer to a valid nlif_handler
References NULL, RTM_GETLINK, rtnl_dump_type(), and nlif_handle::rtnl_handle.
Referenced by main(), and nl_init_interface_handler().
Referenced by fini_nssocket(), init_nssocket(), and main().