| libnfnetlink.h | | libnfnetlink.h | |
| | | | |
| skipping to change at line 46 | | skipping to change at line 46 | |
| struct nlmsghdr nlh; | | struct nlmsghdr nlh; | |
| struct nfgenmsg nfmsg; | | struct nfgenmsg nfmsg; | |
| }; | | }; | |
| | | | |
| struct nfnl_callback { | | struct nfnl_callback { | |
| int (*call)(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data); | | int (*call)(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data); | |
| void *data; | | void *data; | |
| u_int16_t attr_count; | | u_int16_t attr_count; | |
| }; | | }; | |
| | | | |
|
| struct nfnl_handle { | | struct nfnl_handle; | |
| int fd; | | struct nfnl_subsys_handle; | |
| struct sockaddr_nl local; | | | |
| struct sockaddr_nl peer; | | | |
| u_int8_t subsys_id; | | | |
| u_int32_t seq; | | | |
| u_int32_t dump; | | | |
| struct nlmsghdr *last_nlhdr; | | | |
| | | | |
| u_int8_t cb_count; | | | |
| struct nfnl_callback *cb; /* array of callbacks */ | | | |
| }; | | | |
| | | | |
| extern int nfnl_fd(struct nfnl_handle *h); | | extern int nfnl_fd(struct nfnl_handle *h); | |
| | | | |
| /* get a new library handle */ | | /* get a new library handle */ | |
|
| extern int nfnl_open(struct nfnl_handle *, u_int8_t, u_int8_t, unsigned int
); | | extern struct nfnl_handle *nfnl_open(void); | |
| extern int nfnl_close(struct nfnl_handle *); | | extern int nfnl_close(struct nfnl_handle *); | |
| | | | |
|
| | | extern struct nfnl_subsys_handle *nfnl_subsys_open(struct nfnl_handle *, | |
| | | u_int8_t, u_int8_t, | |
| | | unsigned int); | |
| | | extern void nfnl_subsys_close(struct nfnl_subsys_handle *); | |
| | | | |
| /* sending of data */ | | /* sending of data */ | |
| extern int nfnl_send(struct nfnl_handle *, struct nlmsghdr *); | | extern int nfnl_send(struct nfnl_handle *, struct nlmsghdr *); | |
| extern int nfnl_sendmsg(const struct nfnl_handle *, const struct msghdr *ms
g, | | extern int nfnl_sendmsg(const struct nfnl_handle *, const struct msghdr *ms
g, | |
| unsigned int flags); | | unsigned int flags); | |
| extern int nfnl_sendiov(const struct nfnl_handle *nfnlh, | | extern int nfnl_sendiov(const struct nfnl_handle *nfnlh, | |
| const struct iovec *iov, unsigned int num, | | const struct iovec *iov, unsigned int num, | |
| unsigned int flags); | | unsigned int flags); | |
|
| extern void nfnl_fill_hdr(struct nfnl_handle *, struct nlmsghdr *, | | extern void nfnl_fill_hdr(struct nfnl_subsys_handle *, struct nlmsghdr *, | |
| unsigned int, u_int8_t, u_int16_t, u_int16_t, | | unsigned int, u_int8_t, u_int16_t, u_int16_t, | |
| u_int16_t); | | u_int16_t); | |
| extern int nfnl_talk(struct nfnl_handle *, struct nlmsghdr *, pid_t, | | extern int nfnl_talk(struct nfnl_handle *, struct nlmsghdr *, pid_t, | |
| unsigned, struct nlmsghdr *, | | unsigned, struct nlmsghdr *, | |
| int (*)(struct sockaddr_nl *, struct nlmsghdr *, void
*), | | int (*)(struct sockaddr_nl *, struct nlmsghdr *, void
*), | |
| void *); | | void *); | |
| | | | |
| /* simple challenge/response */ | | /* simple challenge/response */ | |
| extern int nfnl_listen(struct nfnl_handle *, | | extern int nfnl_listen(struct nfnl_handle *, | |
| int (*)(struct sockaddr_nl *, struct nlmsghdr *, void
*), | | int (*)(struct sockaddr_nl *, struct nlmsghdr *, void
*), | |
| void *); | | void *); | |
| | | | |
| /* receiving */ | | /* receiving */ | |
| extern ssize_t nfnl_recv(const struct nfnl_handle *h, unsigned char *buf, s
ize_t len); | | extern ssize_t nfnl_recv(const struct nfnl_handle *h, unsigned char *buf, s
ize_t len); | |
|
| extern int nfnl_callback_register(struct nfnl_handle *, | | extern int nfnl_callback_register(struct nfnl_subsys_handle *, | |
| u_int8_t type, struct nfnl_callback *cb); | | u_int8_t type, struct nfnl_callback *cb); | |
|
| extern int nfnl_callback_unregister(struct nfnl_handle *, u_int8_t type); | | extern int nfnl_callback_unregister(struct nfnl_subsys_handle *, u_int8_t t
ype); | |
| extern int nfnl_handle_packet(struct nfnl_handle *, char *buf, int len); | | extern int nfnl_handle_packet(struct nfnl_handle *, char *buf, int len); | |
| | | | |
| /* parsing */ | | /* parsing */ | |
| extern struct nfattr *nfnl_parse_hdr(const struct nfnl_handle *nfnlh, | | extern struct nfattr *nfnl_parse_hdr(const struct nfnl_handle *nfnlh, | |
| const struct nlmsghdr *nlh, | | const struct nlmsghdr *nlh, | |
| struct nfgenmsg **genmsg); | | struct nfgenmsg **genmsg); | |
| extern int nfnl_check_attributes(const struct nfnl_handle *nfnlh, | | extern int nfnl_check_attributes(const struct nfnl_handle *nfnlh, | |
| const struct nlmsghdr *nlh, | | const struct nlmsghdr *nlh, | |
| struct nfattr *tb[]); | | struct nfattr *tb[]); | |
| extern struct nlmsghdr *nfnl_get_msg_first(struct nfnl_handle *h, | | extern struct nlmsghdr *nfnl_get_msg_first(struct nfnl_handle *h, | |
| const unsigned char *buf, | | const unsigned char *buf, | |
| size_t len); | | size_t len); | |
| extern struct nlmsghdr *nfnl_get_msg_next(struct nfnl_handle *h, | | extern struct nlmsghdr *nfnl_get_msg_next(struct nfnl_handle *h, | |
| const unsigned char *buf, | | const unsigned char *buf, | |
| size_t len); | | size_t len); | |
| | | | |
|
| | | /* callback verdict */ | |
| | | enum { | |
| | | NFNL_CB_FAILURE = -1, /* failure */ | |
| | | NFNL_CB_STOP = 0, /* stop the query */ | |
| | | NFNL_CB_CONTINUE = 1, /* keep iterating */ | |
| | | }; | |
| | | | |
| | | /* join a certain netlink multicast group */ | |
| | | extern int nfnl_join(const struct nfnl_handle *nfnlh, unsigned int group); | |
| | | | |
| | | /* process a netlink message */ | |
| | | extern int nfnl_process(struct nfnl_handle *h, | |
| | | const unsigned char *buf, | |
| | | size_t len); | |
| | | | |
| | | /* iterator API */ | |
| | | | |
| | | extern struct nfnl_iterator * | |
| | | nfnl_iterator_create(const struct nfnl_handle *h, | |
| | | const char *buf, | |
| | | size_t len); | |
| | | | |
| | | extern void nfnl_iterator_destroy(struct nfnl_iterator *it); | |
| | | | |
| | | extern int nfnl_iterator_process(struct nfnl_handle *h, | |
| | | struct nfnl_iterator *it); | |
| | | | |
| | | extern int nfnl_iterator_next(const struct nfnl_handle *h, | |
| | | struct nfnl_iterator *it); | |
| | | | |
| | | /* replacement for nfnl_listen */ | |
| | | extern int nfnl_catch(struct nfnl_handle *h); | |
| | | | |
| | | /* replacement for nfnl_talk */ | |
| | | extern int nfnl_query(struct nfnl_handle *h, struct nlmsghdr *nlh); | |
| | | | |
| #define nfnl_attr_present(tb, attr) \ | | #define nfnl_attr_present(tb, attr) \ | |
| (tb[attr-1]) | | (tb[attr-1]) | |
| | | | |
| #define nfnl_get_data(tb, attr, type) \ | | #define nfnl_get_data(tb, attr, type) \ | |
| ({ type __ret = 0; \ | | ({ type __ret = 0; \ | |
| if (tb[attr-1]) \ | | if (tb[attr-1]) \ | |
| __ret = *(type *)NFA_DATA(tb[attr-1]); \ | | __ret = *(type *)NFA_DATA(tb[attr-1]); \ | |
| __ret; \ | | __ret; \ | |
| }) | | }) | |
| | | | |
| #define nfnl_get_pointer_to_data(tb, attr, type) \ | | #define nfnl_get_pointer_to_data(tb, attr, type) \ | |
| ({ type *__ret = NULL; \ | | ({ type *__ret = NULL; \ | |
| if (tb[attr-1]) \ | | if (tb[attr-1]) \ | |
| __ret = NFA_DATA(tb[attr-1]); \ | | __ret = NFA_DATA(tb[attr-1]); \ | |
| __ret; \ | | __ret; \ | |
| }) | | }) | |
| | | | |
| /* nfnl attribute handling functions */ | | /* nfnl attribute handling functions */ | |
|
| extern int nfnl_addattr_l(struct nlmsghdr *, int, int, void *, int); | | extern int nfnl_addattr_l(struct nlmsghdr *, int, int, const void *, int); | |
| | | extern int nfnl_addattr16(struct nlmsghdr *, int, int, u_int16_t); | |
| extern int nfnl_addattr32(struct nlmsghdr *, int, int, u_int32_t); | | extern int nfnl_addattr32(struct nlmsghdr *, int, int, u_int32_t); | |
|
| extern int nfnl_nfa_addattr_l(struct nfattr *, int, int, void *, int); | | extern int nfnl_nfa_addattr_l(struct nfattr *, int, int, const void *, int) | |
| | | ; | |
| | | extern int nfnl_nfa_addattr16(struct nfattr *, int, int, u_int16_t); | |
| extern int nfnl_nfa_addattr32(struct nfattr *, int, int, u_int32_t); | | extern int nfnl_nfa_addattr32(struct nfattr *, int, int, u_int32_t); | |
| extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int); | | extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int); | |
| #define nfnl_parse_nested(tb, max, nfa) \ | | #define nfnl_parse_nested(tb, max, nfa) \ | |
| nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa))) | | nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa))) | |
| #define nfnl_nest(nlh, bufsize, type) \ | | #define nfnl_nest(nlh, bufsize, type) \ | |
| ({ struct nfattr *__start = NLMSG_TAIL(nlh); \ | | ({ struct nfattr *__start = NLMSG_TAIL(nlh); \ | |
| nfnl_addattr_l(nlh, bufsize, (NFNL_NFA_NEST | type), NULL, 0); \ | | nfnl_addattr_l(nlh, bufsize, (NFNL_NFA_NEST | type), NULL, 0); \ | |
| __start; }) | | __start; }) | |
| #define nfnl_nest_end(nlh, tail) \ | | #define nfnl_nest_end(nlh, tail) \ | |
| ({ (tail)->nfa_len = (void *) NLMSG_TAIL(nlh) - (void *) tail; }) | | ({ (tail)->nfa_len = (void *) NLMSG_TAIL(nlh) - (void *) tail; }) | |
| | | | |
End of changes. 9 change blocks. |
| 18 lines changed or deleted | | 52 lines changed or added | |
|