diff options
author | Chirag Shah <chirag@nvidia.com> | 2022-05-13 07:29:37 +0200 |
---|---|---|
committer | Chirag Shah <chirag@nvidia.com> | 2022-05-16 19:45:14 +0200 |
commit | f8f3e484d4afe0ec9eea55f85ebd187b3b20a1f7 (patch) | |
tree | e8e8e7ea384ab9827ce7b158c6e0984e92835783 /zebra/kernel_netlink.h | |
parent | zebra: add protocol name to nexthop dump (diff) | |
download | frr-f8f3e484d4afe0ec9eea55f85ebd187b3b20a1f7.tar.xz frr-f8f3e484d4afe0ec9eea55f85ebd187b3b20a1f7.zip |
zebra: new netlink parse utility for rta
Signed-off-by: Chirag Shah <chirag@nvidia.com>
Diffstat (limited to 'zebra/kernel_netlink.h')
-rw-r--r-- | zebra/kernel_netlink.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/zebra/kernel_netlink.h b/zebra/kernel_netlink.h index 9421ea1c6..08cd706a9 100644 --- a/zebra/kernel_netlink.h +++ b/zebra/kernel_netlink.h @@ -90,6 +90,43 @@ extern void netlink_parse_rtattr_flags(struct rtattr **tb, int max, unsigned short flags); extern void netlink_parse_rtattr_nested(struct rtattr **tb, int max, struct rtattr *rta); +/* + * nl_addraw_l copies raw form the netlink message buffer into netlink + * message header pointer. It ensures the aligned data buffer does not + * override past max length. + * return value is 0 if its successful + */ +extern bool nl_addraw_l(struct nlmsghdr *n, unsigned int maxlen, + const void *data, unsigned int len); +/* + * nl_rta_put - add an additional optional attribute(rtattr) to the + * Netlink message buffer. + * + * Returns true if the attribute could be added to the message (fits into the + * buffer), otherwise false is returned. + */ +extern bool nl_rta_put(struct rtattr *rta, unsigned int maxlen, int type, + const void *data, int alen); +extern bool nl_rta_put16(struct rtattr *rta, unsigned int maxlen, int type, + uint16_t data); +extern bool nl_rta_put64(struct rtattr *rta, unsigned int maxlen, int type, + uint64_t data); +/* + * nl_rta_nest - start an additional optional attribute (rtattr) nest. + * + * Returns a valid pointer to the beginning of the nest if the attribute + * describing the nest could be added to the message (fits into the buffer), + * otherwise NULL is returned. + */ +extern struct rtattr *nl_rta_nest(struct rtattr *rta, unsigned int maxlen, + int type); +/* + * nl_rta_nest_end - finalize nesting of an aditionl optionl attributes. + * + * Updates the length field of the attribute header to include the appeneded + * attributes. Returns a total length of the Netlink message. + */ +extern int nl_rta_nest_end(struct rtattr *rta, struct rtattr *nest); extern const char *nl_msg_type_to_str(uint16_t msg_type); extern const char *nl_rtproto_to_str(uint8_t rtproto); extern const char *nl_family_to_str(uint8_t family); |