Modules | |
Conntrack | |
Log | |
Queue | |
Socket Creating | |
| |
int | nfnl_connect (struct nl_sock *sk) |
Create and connect netfilter netlink socket. | |
Sending | |
| |
int | nfnl_send_simple (struct nl_sock *sk, uint8_t subsys_id, uint8_t type, int flags, uint8_t family, uint16_t res_id) |
Send trivial netfilter netlink message. | |
Message Parsing | |
| |
uint8_t | nfnlmsg_subsys (struct nlmsghdr *nlh) |
Get netfilter subsystem id from message. | |
uint8_t | nfnlmsg_subtype (struct nlmsghdr *nlh) |
Get netfilter message type from message. | |
uint8_t | nfnlmsg_family (struct nlmsghdr *nlh) |
Get netfilter family from message. | |
uint16_t | nfnlmsg_res_id (struct nlmsghdr *nlh) |
Get netfilter resource id from message. | |
Message Building | |
| |
struct nl_msg * | nfnlmsg_alloc_simple (uint8_t subsys_id, uint8_t type, int flags, uint8_t family, uint16_t res_id) |
Allocate a new netfilter netlink message. | |
int | nfnlmsg_put (struct nl_msg *msg, uint32_t pid, uint32_t seq, uint8_t subsys_id, uint8_t type, int flags, uint8_t family, uint16_t res_id) |
Add netlink and netfilter netlink headers to netlink message. |
<------- NLMSG_ALIGN(hlen) ------> <---- NLMSG_ALIGN(len) --->
+----------------------------+- - -+- - - - - - - - - - -+- - -+
| Header | Pad | Payload | Pad |
| struct nlmsghdr | | | |
+----------------------------+- - -+- - - - - - - - - - -+- - -+
<-------- NFNL_HDRLEN --------->
+--------------------------+- - -+------------+
| Netfilter Netlink Header | Pad | Attributes |
| struct nfgenmsg | | |
+--------------------------+- - -+------------+
nfnlmsg_attrdata(nfg, hdrlen)-----^
struct nl_msg *msg; // Create a new empty netlink message msg = nlmsg_alloc(); // Append the netlink and netfilter netlink message header hdr = nfnlmsg_put(msg, PID, SEQ, SUBSYS, TYPE, NLM_F_ECHO, FAMILY, RES_ID); // Append the attributes. nla_put_u32(msg, 1, 0x10); // Message is ready to be sent. nl_send_auto_complete(sk, msg); // All done? Free the message. nlmsg_free(msg);
// For trivial messages not requiring any subsys specific header or // attributes, nfnl_send_simple() may be used to send messages directly. nfnl_send_simple(sk, SUBSYS, TYPE, 0, FAMILY, RES_ID);
int nfnl_connect | ( | struct nl_sock * | sk | ) |
Create and connect netfilter netlink socket.
sk | Netlink socket. |
Creates a NETLINK_NETFILTER netlink socket, binds the socket and issues a connection attempt.
Definition at line 84 of file nfnl.c.
References nl_connect().
int nfnl_send_simple | ( | struct nl_sock * | sk, | |
uint8_t | subsys_id, | |||
uint8_t | type, | |||
int | flags, | |||
uint8_t | family, | |||
uint16_t | res_id | |||
) |
Send trivial netfilter netlink message.
sk | Netlink socket. | |
subsys_id | nfnetlink subsystem | |
type | nfnetlink message type | |
flags | message flags | |
family | nfnetlink address family | |
res_id | nfnetlink resource id |
Definition at line 107 of file nfnl.c.
References nl_send_simple().
uint8_t nfnlmsg_subsys | ( | struct nlmsghdr * | nlh | ) |
uint8_t nfnlmsg_subtype | ( | struct nlmsghdr * | nlh | ) |
uint8_t nfnlmsg_family | ( | struct nlmsghdr * | nlh | ) |
Get netfilter family from message.
nlh | netlink messsage header |
Definition at line 149 of file nfnl.c.
References nlmsg_data().
uint16_t nfnlmsg_res_id | ( | struct nlmsghdr * | nlh | ) |
Get netfilter resource id from message.
nlh | netlink messsage header |
Definition at line 160 of file nfnl.c.
References nlmsg_data().
struct nl_msg* nfnlmsg_alloc_simple | ( | uint8_t | subsys_id, | |
uint8_t | type, | |||
int | flags, | |||
uint8_t | family, | |||
uint16_t | res_id | |||
) | [read] |
Allocate a new netfilter netlink message.
subsys_id | nfnetlink subsystem | |
type | nfnetlink message type | |
flags | message flags | |
family | nfnetlink address family | |
res_id | nfnetlink resource id |
Definition at line 200 of file nfnl.c.
References nlmsg_alloc_simple(), and nlmsg_free().
int nfnlmsg_put | ( | struct nl_msg * | msg, | |
uint32_t | pid, | |||
uint32_t | seq, | |||
uint8_t | subsys_id, | |||
uint8_t | type, | |||
int | flags, | |||
uint8_t | family, | |||
uint16_t | res_id | |||
) |
Add netlink and netfilter netlink headers to netlink message.
msg | netlink message | |
pid | netlink process id | |
seq | sequence number of message | |
subsys_id | nfnetlink subsystem | |
type | nfnetlink message type | |
flags | message flags | |
family | nfnetlink address family | |
res_id | nfnetlink resource id |
Definition at line 230 of file nfnl.c.
References nlmsg_put().