]>
Commit | Line | Data |
---|---|---|
1fdc9eae | 1 | /* Declarations and definitions for kernel interaction over netlink |
2 | * Copyright (C) 2016 Cumulus Networks, Inc. | |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
896014f4 DL |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
1fdc9eae | 19 | */ |
20 | ||
21 | #ifndef _ZEBRA_KERNEL_NETLINK_H | |
22 | #define _ZEBRA_KERNEL_NETLINK_H | |
23 | ||
51e94aa7 EDP |
24 | #ifdef __cplusplus |
25 | extern "C" { | |
26 | #endif | |
27 | ||
1fdc9eae | 28 | #ifdef HAVE_NETLINK |
29 | ||
9ed7517b | 30 | #define NL_RCV_PKT_BUF_SIZE 32768 |
1fdc9eae | 31 | #define NL_PKT_BUF_SIZE 8192 |
32 | ||
d62a17ae | 33 | extern void netlink_parse_rtattr(struct rtattr **tb, int max, |
34 | struct rtattr *rta, int len); | |
87da6a60 SW |
35 | extern void netlink_parse_rtattr_nested(struct rtattr **tb, int max, |
36 | struct rtattr *rta); | |
d62a17ae | 37 | extern int addattr_l(struct nlmsghdr *n, unsigned int maxlen, int type, |
86391e56 | 38 | const void *data, unsigned int alen); |
d62a17ae | 39 | extern int rta_addattr_l(struct rtattr *rta, unsigned int maxlen, int type, |
86391e56 | 40 | const void *data, unsigned int alen); |
d62a17ae | 41 | extern int addattr16(struct nlmsghdr *n, unsigned int maxlen, int type, |
d7c0a89a | 42 | uint16_t data); |
d62a17ae | 43 | extern int addattr32(struct nlmsghdr *n, unsigned int maxlen, int type, |
44 | int data); | |
1fdc9eae | 45 | extern struct rtattr *addattr_nest(struct nlmsghdr *n, int maxlen, int type); |
46 | extern int addattr_nest_end(struct nlmsghdr *n, struct rtattr *nest); | |
d62a17ae | 47 | extern struct rtattr *rta_nest(struct rtattr *rta, int maxlen, int type); |
1fdc9eae | 48 | extern int rta_nest_end(struct rtattr *rta, struct rtattr *nest); |
d62a17ae | 49 | extern const char *nl_msg_type_to_str(uint16_t msg_type); |
d7c0a89a QY |
50 | extern const char *nl_rtproto_to_str(uint8_t rtproto); |
51 | extern const char *nl_family_to_str(uint8_t family); | |
52 | extern const char *nl_rttype_to_str(uint8_t rttype); | |
1fdc9eae | 53 | |
acfa8927 SW |
54 | #if defined(HANDLE_NETLINK_FUZZING) |
55 | extern bool netlink_read; | |
81a2f870 | 56 | extern void netlink_read_init(const char *fname); |
acfa8927 | 57 | #endif /* HANDLE_NETLINK_FUZZING */ |
2414abd3 | 58 | extern int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int), |
7cdb1a84 | 59 | const struct nlsock *nl, |
8b962e77 | 60 | const struct zebra_dplane_info *dp_info, |
d62a17ae | 61 | int count, int startup); |
2414abd3 DS |
62 | extern int netlink_talk_filter(struct nlmsghdr *h, ns_id_t ns, int startup); |
63 | extern int netlink_talk(int (*filter)(struct nlmsghdr *, ns_id_t, int startup), | |
d62a17ae | 64 | struct nlmsghdr *n, struct nlsock *nl, |
65 | struct zebra_ns *zns, int startup); | |
7cdb1a84 MS |
66 | /* Version with 'info' struct only */ |
67 | int netlink_talk_info(int (*filter)(struct nlmsghdr *, ns_id_t, int startup), | |
68 | struct nlmsghdr *n, | |
8b962e77 | 69 | const struct zebra_dplane_info *dp_info, int startup); |
7cdb1a84 | 70 | |
d62a17ae | 71 | extern int netlink_request(struct nlsock *nl, struct nlmsghdr *n); |
1fdc9eae | 72 | |
73 | #endif /* HAVE_NETLINK */ | |
74 | ||
51e94aa7 EDP |
75 | #ifdef __cplusplus |
76 | } | |
77 | #endif | |
78 | ||
1fdc9eae | 79 | #endif /* _ZEBRA_KERNEL_NETLINK_H */ |