firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
msg.c File Reference
#include <netlink-local.h>
#include <netlink/netlink.h>
#include <netlink/utils.h>
#include <netlink/cache.h>
#include <netlink/attr.h>
#include <linux/socket.h>
Include dependency graph for msg.c:


#define PRINT_FLAG(f)


Size Calculations
int nlmsg_msg_size (int payload)
 length of netlink message not including padding More...
int nlmsg_total_size (int payload)
 length of netlink message including padding More...
int nlmsg_padlen (int payload)
 length of padding at the message's tail More...
Payload Access
void * nlmsg_data (const struct nlmsghdr *nlh)
 head of message payload More...
void * nlmsg_tail (const struct nlmsghdr *nlh)
int nlmsg_len (const struct nlmsghdr *nlh)
 length of message payload More...
Attribute Access
struct nlattrnlmsg_attrdata (const struct nlmsghdr *nlh, int hdrlen)
 head of attributes data More...
int nlmsg_attrlen (const struct nlmsghdr *nlh, int hdrlen)
 length of attributes data More...
Message Parsing
int nlmsg_valid_hdr (const struct nlmsghdr *nlh, int hdrlen)
int nlmsg_ok (const struct nlmsghdr *nlh, int remaining)
 check if the netlink message fits into the remaining bytes More...
struct nlmsghdrnlmsg_next (struct nlmsghdr *nlh, int *remaining)
 next netlink message in message stream More...
int nlmsg_parse (struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, struct nla_policy *policy)
 parse attributes of a netlink message More...
struct nlattrnlmsg_find_attr (struct nlmsghdr *nlh, int hdrlen, int attrtype)
 nlmsg_find_attr - find a specific attribute in a netlink message More...
int nlmsg_validate (struct nlmsghdr *nlh, int hdrlen, int maxtype, struct nla_policy *policy)
 nlmsg_validate - validate a netlink message including attributes More...
Message Building/Access
struct nl_msgnlmsg_alloc (void)
 Allocate a new netlink message with the default maximum payload size. More...
struct nl_msgnlmsg_alloc_size (size_t max)
 Allocate a new netlink message with maximum payload size specified. More...
struct nl_msgnlmsg_inherit (struct nlmsghdr *hdr)
 Allocate a new netlink message and inherit netlink message header. More...
struct nl_msgnlmsg_alloc_simple (int nlmsgtype, int flags)
 Allocate a new netlink message. More...
void nlmsg_set_default_size (size_t max)
 Set the default maximum message payload size for allocated messages. More...
struct nl_msgnlmsg_convert (struct nlmsghdr *hdr)
 Convert a netlink message received from a netlink socket to a nl_msg. More...
void * nlmsg_reserve (struct nl_msg *n, size_t len, int pad)
 Reserve room for additional data in a netlink message. More...
int nlmsg_append (struct nl_msg *n, void *data, size_t len, int pad)
 Append data to tail of a netlink message. More...
int nlmsg_expand (struct nl_msg *n, size_t newlen)
 Expand maximum payload size of a netlink message. More...
struct nlmsghdrnlmsg_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. More...
struct nlmsghdrnlmsg_hdr (struct nl_msg *n)
 Return actual netlink message. More...
void nlmsg_get (struct nl_msg *msg)
 Acquire a reference on a netlink message. More...
void nlmsg_free (struct nl_msg *msg)
 Release a reference from an netlink message. More...
void nlmsg_set_proto (struct nl_msg *msg, int protocol)
int nlmsg_get_proto (struct nl_msg *msg)
size_t nlmsg_get_max_size (struct nl_msg *msg)
void nlmsg_set_src (struct nl_msg *msg, struct sockaddr_nl *addr)
struct sockaddr_nlnlmsg_get_src (struct nl_msg *msg)
void nlmsg_set_dst (struct nl_msg *msg, struct sockaddr_nl *addr)
struct sockaddr_nlnlmsg_get_dst (struct nl_msg *msg)
void nlmsg_set_creds (struct nl_msg *msg, struct ucred *creds)
struct ucred * nlmsg_get_creds (struct nl_msg *msg)
Netlink Message Flags Translations
char * nl_nlmsg_flags2str (int flags, char *buf, size_t len)
Direct Parsing
int nl_msg_parse (struct nl_msg *msg, void(*cb)(struct nl_object *, void *), void *arg)
void nl_msg_dump (struct nl_msg *msg, FILE *ofd)
 Dump message in human readable format to file descriptor. More...

Netlink Message Type Translations

char * nl_nlmsgtype2str (int type, char *buf, size_t size)
int nl_str2nlmsgtype (const char *name)

Macro Definition Documentation

#define PRINT_FLAG (   f)
if (flags & NLM_F_##f) { \
flags &= ~NLM_F_##f; \
strncat(buf, #f, len - strlen(buf) - 1); \
if (flags) \
strncat(buf, ",", len - strlen(buf) - 1); \
static int struct nlattr enum ipset_adt adt u32 u32 flags
Definition: ip_set_hash_gen.h:1157
u_int32_t u_int32_t u_int32_t u_int32_t const unsigned char * buf
Definition: libnetfilter_queue.h:86
int len
Definition: utils.c:56

Referenced by nl_nlmsg_flags2str().