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 #define NL_AUTO_PID 0
00033
00034
00035
00036
00037
00038
00039
00040
00041 #define NL_AUTO_SEQ 0
00042
00043 struct nl_msg;
00044 struct nl_tree;
00045 struct ucred;
00046
00047
00048 extern int nlmsg_msg_size(int);
00049 extern int nlmsg_total_size(int);
00050 extern int nlmsg_padlen(int);
00051
00052
00053 extern void * nlmsg_data(const struct nlmsghdr *);
00054 extern int nlmsg_len(const struct nlmsghdr *);
00055 extern void * nlmsg_tail(const struct nlmsghdr *);
00056
00057
00058 extern struct nlattr * nlmsg_attrdata(const struct nlmsghdr *, int);
00059 extern int nlmsg_attrlen(const struct nlmsghdr *, int);
00060
00061
00062 extern int nlmsg_valid_hdr(const struct nlmsghdr *, int);
00063 extern int nlmsg_ok(const struct nlmsghdr *, int);
00064 extern struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *);
00065 extern int nlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
00066 int, struct nla_policy *);
00067 extern struct nlattr * nlmsg_find_attr(struct nlmsghdr *, int, int);
00068 extern int nlmsg_validate(struct nlmsghdr *, int, int,
00069 struct nla_policy *);
00070
00071
00072 #define nlmsg_new() nlmsg_alloc()
00073 #define nlmsg_build_simple(a, b) nlmsg_alloc_simple(a, b)
00074 #define nlmsg_build(ptr) nlmsg_inherit(ptr)
00075
00076 extern struct nl_msg * nlmsg_alloc(void);
00077 extern struct nl_msg * nlmsg_alloc_size(size_t);
00078 extern struct nl_msg * nlmsg_alloc_simple(int, int);
00079 extern void nlmsg_set_default_size(size_t);
00080 extern struct nl_msg * nlmsg_inherit(struct nlmsghdr *);
00081 extern struct nl_msg * nlmsg_convert(struct nlmsghdr *);
00082 extern void * nlmsg_reserve(struct nl_msg *, size_t, int);
00083 extern int nlmsg_append(struct nl_msg *, void *, size_t, int);
00084 extern int nlmsg_expand(struct nl_msg *, size_t);
00085
00086 extern struct nlmsghdr * nlmsg_put(struct nl_msg *, uint32_t, uint32_t,
00087 int, int, int);
00088 extern struct nlmsghdr * nlmsg_hdr(struct nl_msg *);
00089 extern void nlmsg_free(struct nl_msg *);
00090
00091
00092 extern void nlmsg_set_proto(struct nl_msg *, int);
00093 extern int nlmsg_get_proto(struct nl_msg *);
00094 extern size_t nlmsg_get_max_size(struct nl_msg *);
00095 extern void nlmsg_set_src(struct nl_msg *, struct sockaddr_nl *);
00096 extern struct sockaddr_nl *nlmsg_get_src(struct nl_msg *);
00097 extern void nlmsg_set_dst(struct nl_msg *, struct sockaddr_nl *);
00098 extern struct sockaddr_nl *nlmsg_get_dst(struct nl_msg *);
00099 extern void nlmsg_set_creds(struct nl_msg *, struct ucred *);
00100 extern struct ucred * nlmsg_get_creds(struct nl_msg *);
00101
00102 extern char * nl_nlmsgtype2str(int, char *, size_t);
00103 extern int nl_str2nlmsgtype(const char *);
00104
00105 extern char * nl_nlmsg_flags2str(int, char *, size_t);
00106
00107 extern int nl_msg_parse(struct nl_msg *,
00108 void (*cb)(struct nl_object *, void *),
00109 void *);
00110
00111 extern void nl_msg_dump(struct nl_msg *, FILE *);
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 #define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \
00127 nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
00128 nlmsg_attrlen(nlh, hdrlen), rem)
00129
00130
00131
00132
00133
00134
00135
00136
00137 #define nlmsg_for_each_msg(pos, head, len, rem) \
00138 for (pos = head, rem = len; \
00139 nlmsg_ok(pos, rem); \
00140 pos = nlmsg_next(pos, &(rem)))
00141
00142
00143
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147
00148 #endif