00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef NETLINK_MSG_H_
00013 #define NETLINK_MSG_H_
00014
00015 #include <netlink/netlink.h>
00016 #include <netlink/object.h>
00017 #include <netlink/attr.h>
00018
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022
00023 #define NL_DONTPAD 0
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #define NL_AUTO_PORT 0
00034 #define NL_AUTO_PID NL_AUTO_PORT
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #define NL_AUTO_SEQ 0
00045
00046 struct nl_msg;
00047 struct nl_tree;
00048 struct ucred;
00049
00050 extern int nlmsg_size(int);
00051 extern int nlmsg_total_size(int);
00052 extern int nlmsg_padlen(int);
00053
00054 extern void * nlmsg_data(const struct nlmsghdr *);
00055 extern int nlmsg_datalen(const struct nlmsghdr *);
00056 extern void * nlmsg_tail(const struct nlmsghdr *);
00057
00058
00059 extern struct nlattr * nlmsg_attrdata(const struct nlmsghdr *, int);
00060 extern int nlmsg_attrlen(const struct nlmsghdr *, int);
00061
00062
00063 extern int nlmsg_valid_hdr(const struct nlmsghdr *, int);
00064 extern int nlmsg_ok(const struct nlmsghdr *, int);
00065 extern struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *);
00066 extern int nlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
00067 int, struct nla_policy *);
00068 extern struct nlattr * nlmsg_find_attr(struct nlmsghdr *, int, int);
00069 extern int nlmsg_validate(struct nlmsghdr *, int, int,
00070 struct nla_policy *);
00071
00072 extern struct nl_msg * nlmsg_alloc(void);
00073 extern struct nl_msg * nlmsg_alloc_size(size_t);
00074 extern struct nl_msg * nlmsg_alloc_simple(int, int);
00075 extern void nlmsg_set_default_size(size_t);
00076 extern struct nl_msg * nlmsg_inherit(struct nlmsghdr *);
00077 extern struct nl_msg * nlmsg_convert(struct nlmsghdr *);
00078 extern void * nlmsg_reserve(struct nl_msg *, size_t, int);
00079 extern int nlmsg_append(struct nl_msg *, void *, size_t, int);
00080 extern int nlmsg_expand(struct nl_msg *, size_t);
00081
00082 extern struct nlmsghdr * nlmsg_put(struct nl_msg *, uint32_t, uint32_t,
00083 int, int, int);
00084 extern struct nlmsghdr * nlmsg_hdr(struct nl_msg *);
00085 extern void nlmsg_get(struct nl_msg *);
00086 extern void nlmsg_free(struct nl_msg *);
00087
00088
00089 extern void nlmsg_set_proto(struct nl_msg *, int);
00090 extern int nlmsg_get_proto(struct nl_msg *);
00091 extern size_t nlmsg_get_max_size(struct nl_msg *);
00092 extern void nlmsg_set_src(struct nl_msg *, struct sockaddr_nl *);
00093 extern struct sockaddr_nl *nlmsg_get_src(struct nl_msg *);
00094 extern void nlmsg_set_dst(struct nl_msg *, struct sockaddr_nl *);
00095 extern struct sockaddr_nl *nlmsg_get_dst(struct nl_msg *);
00096 extern void nlmsg_set_creds(struct nl_msg *, struct ucred *);
00097 extern struct ucred * nlmsg_get_creds(struct nl_msg *);
00098
00099 extern char * nl_nlmsgtype2str(int, char *, size_t);
00100 extern int nl_str2nlmsgtype(const char *);
00101
00102 extern char * nl_nlmsg_flags2str(int, char *, size_t);
00103
00104 extern int nl_msg_parse(struct nl_msg *,
00105 void (*cb)(struct nl_object *, void *),
00106 void *);
00107
00108 extern void nl_msg_dump(struct nl_msg *, FILE *);
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 #define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \
00124 nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
00125 nlmsg_attrlen(nlh, hdrlen), rem)
00126
00127
00128
00129
00130
00131
00132
00133 #define nlmsg_for_each(pos, head, len) \
00134 for (int rem = len, pos = head; \
00135 nlmsg_ok(pos, rem); \
00136 pos = nlmsg_next(pos, &rem))
00137
00138 #define nlmsg_for_each_msg(pos, head, len, rem) \
00139 nlmsg_for_each(pos, head, len)
00140
00141
00142
00143 #ifdef __cplusplus
00144 }
00145 #endif
00146
00147 #endif