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 struct nl_msg;
00020 struct nl_tree;
00021 struct ucred;
00022
00023
00024 extern int nlmsg_msg_size(int);
00025 extern int nlmsg_total_size(int);
00026 extern int nlmsg_padlen(int);
00027
00028
00029 extern void * nlmsg_data(const struct nlmsghdr *);
00030 extern int nlmsg_len(const struct nlmsghdr *);
00031 extern void * nlmsg_tail(const struct nlmsghdr *);
00032
00033
00034 extern struct nlattr * nlmsg_attrdata(const struct nlmsghdr *, int);
00035 extern int nlmsg_attrlen(const struct nlmsghdr *, int);
00036
00037
00038 extern int nlmsg_ok(const struct nlmsghdr *, int);
00039 extern struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *);
00040 extern int nlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
00041 int, struct nla_policy *);
00042 extern struct nlattr * nlmsg_find_attr(struct nlmsghdr *, int, int);
00043 extern int nlmsg_validate(struct nlmsghdr *, int, int,
00044 struct nla_policy *);
00045
00046 extern struct nl_msg * nlmsg_new(void);
00047 extern struct nl_msg * nlmsg_build(struct nlmsghdr *);
00048 extern struct nl_msg * nlmsg_build_simple(int, int);
00049 extern struct nl_msg * nlmsg_build_no_hdr(void);
00050 extern struct nl_msg * nlmsg_convert(struct nlmsghdr *);
00051 extern int nlmsg_append(struct nl_msg *, void *, size_t, int);
00052
00053 extern struct nlmsghdr * nlmsg_hdr(struct nl_msg *);
00054 extern void nlmsg_free(struct nl_msg *);
00055
00056
00057 extern void nlmsg_set_proto(struct nl_msg *, int);
00058 extern int nlmsg_get_proto(struct nl_msg *);
00059 extern void nlmsg_set_src(struct nl_msg *, struct sockaddr_nl *);
00060 extern struct sockaddr_nl *nlmsg_get_src(struct nl_msg *);
00061 extern void nlmsg_set_dst(struct nl_msg *, struct sockaddr_nl *);
00062 extern struct sockaddr_nl *nlmsg_get_dst(struct nl_msg *);
00063 extern void nlmsg_set_creds(struct nl_msg *, struct ucred *);
00064 extern struct ucred * nlmsg_get_creds(struct nl_msg *);
00065
00066 extern char * nl_nlmsgtype2str(int, char *, size_t);
00067 extern int nl_str2nlmsgtype(const char *);
00068
00069 extern char * nl_nlmsg_flags2str(int, char *, size_t);
00070
00071 extern int nl_msg_parse(struct nl_msg *,
00072 void (*cb)(struct nl_object *, void *),
00073 void *);
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 #define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \
00089 nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
00090 nlmsg_attrlen(nlh, hdrlen), rem)
00091
00092
00093
00094
00095
00096
00097
00098
00099 #define nlmsg_for_each_msg(pos, head, len, rem) \
00100 for (pos = head, rem = len; \
00101 nlmsg_ok(pos, rem); \
00102 pos = nlmsg_next(pos, &(rem)))
00103
00104
00105
00106 #endif