|
| int | nfnl_connect (struct nl_handle *handle) |
| | Create and connect netfilter netlink socket. More...
|
| |
|
| int | nfnl_send_simple (struct nl_handle *handle, uint8_t subsys_id, uint8_t type, int flags, uint8_t family, uint16_t res_id) |
| | Send trivial netfilter netlink message. More...
|
| |
|
| 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. More...
|
| |
| 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. More...
|
| |
- Message Format
<------- NLMSG_ALIGN(hlen) ------> <---- NLMSG_ALIGN(len) --->
+----------------------------+- - -+- - - - - - - - - - -+- - -+
| Header | Pad | Payload | Pad |
+----------------------------+- - -+- - - - - - - - - - -+- - -+
<-------- NFNL_HDRLEN --------->
+--------------------------+- - -+------------+
| Netfilter Netlink Header | Pad | Attributes |
| struct nfgenmsg | | |
+--------------------------+- - -+------------+
nfnlmsg_attrdata(nfg, hdrlen)-----^
- 1) Creating a new netfilter netlink message
struct nl_msg *msg;
FAMILY, RES_ID);
- 2) Sending of trivial messages
-
◆ nfnl_connect()
| int nfnl_connect |
( |
struct nl_handle * |
handle | ) |
|
- Parameters
-
Creates a NETLINK_NETFILTER netlink socket, binds the socket and issues a connection attempt.
- See also
- nl_connect()
- Returns
- 0 on success or a negative error code.
Definition at line 85 of file nfnl.c.
References nl_connect().
◆ nfnl_send_simple()
| int nfnl_send_simple |
( |
struct nl_handle * |
handle, |
|
|
uint8_t |
subsys_id, |
|
|
uint8_t |
type, |
|
|
int |
flags, |
|
|
uint8_t |
family, |
|
|
uint16_t |
res_id |
|
) |
| |
- Parameters
-
| handle | Netlink handle. |
| subsys_id | nfnetlink subsystem |
| type | nfnetlink message type |
| flags | message flags |
| family | nfnetlink address family |
| res_id | nfnetlink resource id |
- Returns
- Newly allocated netlink message or NULL.
Definition at line 108 of file nfnl.c.
111 struct nfgenmsg hdr = {
112 .nfgen_family = family,
113 .version = NFNETLINK_V0,
114 .res_id = htons(res_id),
117 return nl_send_simple(handle, NFNLMSG_TYPE(subsys_id, type), flags,
References nl_send_simple().
◆ nfnlmsg_subsys()
| uint8_t nfnlmsg_subsys |
( |
struct nlmsghdr * |
nlh | ) |
|
◆ nfnlmsg_subtype()
| uint8_t nfnlmsg_subtype |
( |
struct nlmsghdr * |
nlh | ) |
|
◆ nfnlmsg_family()
| uint8_t nfnlmsg_family |
( |
struct nlmsghdr * |
nlh | ) |
|
- Parameters
-
| nlh | netlink messsage header |
Definition at line 150 of file nfnl.c.
154 return nfg->nfgen_family;
References nlmsg_data().
◆ nfnlmsg_res_id()
| uint16_t nfnlmsg_res_id |
( |
struct nlmsghdr * |
nlh | ) |
|
- Parameters
-
| nlh | netlink messsage header |
Definition at line 161 of file nfnl.c.
165 return ntohs(nfg->res_id);
References nlmsg_data().
◆ nfnlmsg_alloc_simple()
| struct nl_msg* nfnlmsg_alloc_simple |
( |
uint8_t |
subsys_id, |
|
|
uint8_t |
type, |
|
|
int |
flags, |
|
|
uint8_t |
family, |
|
|
uint16_t |
res_id |
|
) |
| |
- Parameters
-
| subsys_id | nfnetlink subsystem |
| type | nfnetlink message type |
| flags | message flags |
| family | nfnetlink address family |
| res_id | nfnetlink resource id |
- Returns
- Newly allocated netlink message or NULL.
Definition at line 201 of file nfnl.c.
210 if (nfnlmsg_append(msg, family, res_id) < 0)
211 goto nla_put_failure;
References nlmsg_alloc_simple().
◆ nfnlmsg_put()
| 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 |
|
) |
| |
- Parameters
-
| 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 231 of file nfnl.c.
237 nlh =
nlmsg_put(msg, pid, seq, NFNLMSG_TYPE(subsys_id, type), 0, flags);
239 return nl_get_errno();
241 return nfnlmsg_append(msg, family, res_id);
References nlmsg_put().
void * nlmsg_data(const struct nlmsghdr *nlh)
head of message payload
uint16_t nlmsg_type
Message type (content type)
int nl_send_simple(struct nl_handle *handle, int type, int flags, void *buf, size_t size)
Send simple netlink message using nl_send_auto_complete()
void nlmsg_free(struct nl_msg *n)
Free a netlink message.
struct nl_msg * nlmsg_alloc(void)
Allocate a new netlink message with the default maximum payload size.
int nla_put_u32(struct nl_msg *n, int attrtype, uint32_t value)
Add a u32 netlink attribute to a netlink message.
int nl_send_auto_complete(struct nl_handle *handle, struct nl_msg *msg)
Send netlink message and check & extend header values as needed.
int nl_connect(struct nl_handle *handle, int protocol)
Create and connect netlink socket.
struct nl_msg * nlmsg_alloc_simple(int nlmsgtype, int flags)
Allocate a new netlink message.
struct nlmsghdr * nlmsg_put(struct nl_msg *n, uint32_t pid, uint32_t seq, int type, int payload, int flags)
Add a netlink message header to a 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.
#define NLM_F_ECHO
Echo this request.
int nfnl_send_simple(struct nl_handle *handle, uint8_t subsys_id, uint8_t type, int flags, uint8_t family, uint16_t res_id)
Send trivial netfilter netlink message.