]> git.proxmox.com Git - mirror_frr.git/blob - tools/cocci.h
Merge pull request #7830 from volta-networks/misc_fixes_2021
[mirror_frr.git] / tools / cocci.h
1 /* some of this stuff doesn't seem to parse properly in coccinelle
2 */
3
4 #define DEFUN(funcname, cmdname, str, help) \
5 static int funcname(const struct cmd_element *self, struct vty *vty, \
6 int argc, struct cmd_token *argv[])
7 #define DEFUN_HIDDEN(funcname, cmdname, str, help) \
8 static int funcname(const struct cmd_element *self, struct vty *vty, \
9 int argc, struct cmd_token *argv[])
10 #define DEFUN_NOSH(funcname, cmdname, str, help) \
11 static int funcname(const struct cmd_element *self, struct vty *vty, \
12 int argc, struct cmd_token *argv[])
13 #define DEFPY(funcname, cmdname, str, help) \
14 static int funcname(const struct cmd_element *self, struct vty *vty, \
15 int argc, struct cmd_token *argv[])
16 #define DEFPY_HIDDEN(funcname, cmdname, str, help) \
17 static int funcname(const struct cmd_element *self, struct vty *vty, \
18 int argc, struct cmd_token *argv[])
19 #define DEFPY_NOSH(funcname, cmdname, str, help) \
20 static int funcname(const struct cmd_element *self, struct vty *vty, \
21 int argc, struct cmd_token *argv[])
22
23 #define ENABLE_BGP_VNC 1
24 #define ALL_LIST_ELEMENTS_RO(list, node, data) \
25 (node) = listhead(list), ((data) = NULL); \
26 (node) != NULL && ((data) = listgetdata(node)); \
27 (node) = listnextnode(node), ((data) = NULL)
28 #define ALL_LIST_ELEMENTS(list, node, nextnode, data) \
29 (node) = listhead(list), ((data) = NULL); \
30 (node) != NULL \
31 && ((data) = listgetdata(node), (nextnode) = node->next); \
32 (node) = (nextnode), ((data) = NULL)
33 #define LIST_HEAD(name, type) \
34 struct name { \
35 struct type *lh_first; /* first element */ \
36 }
37 #define LIST_ENTRY(type) \
38 struct { \
39 struct type *le_next; /* next element */ \
40 struct type **le_prev; /* address of previous next element */ \
41 }
42
43 #define STREAM_GETC(S, P) \
44 do { \
45 uint8_t _pval; \
46 if (!stream_getc2((S), &_pval)) \
47 goto stream_failure; \
48 (P) = _pval; \
49 } while (0)
50
51 #define STREAM_GETW(S, P) \
52 do { \
53 uint16_t _pval; \
54 if (!stream_getw2((S), &_pval)) \
55 goto stream_failure; \
56 (P) = _pval; \
57 } while (0)
58
59 #define STREAM_GETL(S, P) \
60 do { \
61 uint32_t _pval; \
62 if (!stream_getl2((S), &_pval)) \
63 goto stream_failure; \
64 (P) = _pval; \
65 } while (0)
66
67 #define STREAM_GETF(S, P) \
68 do { \
69 union { \
70 float r; \
71 uint32_t d; \
72 } _pval; \
73 if (stream_getl2((S), &_pval.d)) \
74 goto stream_failure; \
75 (P) = _pval.r; \
76 } while (0)
77
78 #define STREAM_GETQ(S, P) \
79 do { \
80 uint64_t _pval; \
81 if (!stream_getq2((S), &_pval)) \
82 goto stream_failure; \
83 (P) = _pval; \
84 } while (0)
85
86 #define STREAM_GET(P, STR, SIZE) \
87 do { \
88 if (!stream_get2((P), (STR), (SIZE))) \
89 goto stream_failure; \
90 } while (0)
91
92 #define AF_FOREACH(af) for ((af) = BGP_AF_START; (af) < BGP_AF_MAX; (af)++)
93
94 #define FOREACH_AFI_SAFI(afi, safi) \
95 \
96 for (afi = AFI_IP; afi < AFI_MAX; afi++) \
97 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
98
99 #define FOREACH_SAFI(safi) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
100
101 #define frr_with_privs(p) \
102 for (int x = 1; x; x--)
103 #define frr_with_mutex(m) \
104 for (int x = 1; x; x--)
105
106 #define ALL_LSDB_TYPED_ADVRTR(lsdb, type, adv_router, lsa) \
107 const struct route_node *iterend = \
108 ospf6_lsdb_head(lsdb, 2, type, adv_router, &lsa); \
109 lsa; \
110 lsa = ospf6_lsdb_next(iterend, lsa)
111
112 #define ALL_LSDB_TYPED(lsdb, type, lsa) \
113 const struct route_node *iterend = \
114 ospf6_lsdb_head(lsdb, 1, type, 0, &lsa); \
115 lsa; \
116 lsa = ospf6_lsdb_next(iterend, lsa)
117
118 #define ALL_LSDB(lsdb, lsa) \
119 const struct route_node *iterend = \
120 ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); \
121 lsa; \
122 lsa = ospf6_lsdb_next(iterend, lsa)
123
124 #define QOBJ_FIELDS struct qobj_node qobj_node;