]>
Commit | Line | Data |
---|---|---|
4b292b55 | 1 | /* -*- mode: c; c-file-style: "openbsd" -*- */ |
43c02e7b VB |
2 | /* |
3 | * Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx> | |
4 | * | |
51434125 | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
43c02e7b VB |
6 | * purpose with or without fee is hereby granted, provided that the above |
7 | * copyright notice and this permission notice appear in all copies. | |
8 | * | |
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
16 | */ | |
17 | ||
4b292b55 VB |
18 | #ifndef _LLDPD_STRUCTS_H |
19 | #define _LLDPD_STRUCTS_H | |
43c02e7b VB |
20 | |
21 | #if HAVE_CONFIG_H | |
d38eae28 | 22 | # include <config.h> |
43c02e7b VB |
23 | #endif |
24 | ||
4b292b55 VB |
25 | #include <sys/types.h> |
26 | #include <sys/socket.h> | |
e12c2365 VB |
27 | |
28 | /* This is not very convenient, but we need net/if.h for IFNAMSIZ and others but | |
29 | * we may also need linux/if.h in some modules. And they conflict each others. | |
30 | */ | |
31 | #ifdef HOST_OS_LINUX | |
32 | # include <linux/if.h> | |
43c02e7b | 33 | #else |
e12c2365 | 34 | # include <net/if.h> |
43c02e7b | 35 | #endif |
e12c2365 | 36 | |
43c02e7b | 37 | #include <netinet/in.h> |
21a48c64 | 38 | #include <netinet/if_ether.h> |
4b292b55 | 39 | #include <sys/queue.h> |
43c02e7b | 40 | |
4b292b55 | 41 | #include "compat/compat.h" |
db323555 | 42 | #include "marshal.h" |
4b292b55 | 43 | #include "lldp-const.h" |
43c02e7b | 44 | |
a1347cd8 | 45 | #ifdef ENABLE_DOT1 |
9757bfbc SK |
46 | struct lldpd_ppvid { |
47 | TAILQ_ENTRY(lldpd_ppvid) p_entries; | |
48 | u_int8_t p_cap_status; | |
49 | u_int16_t p_ppvid; | |
50 | }; | |
f6d20631 VB |
51 | MARSHAL_BEGIN(lldpd_ppvid) |
52 | MARSHAL_TQE(lldpd_ppvid, p_entries) | |
985a4cb5 | 53 | MARSHAL_END(lldpd_ppvid); |
9757bfbc | 54 | |
43c02e7b VB |
55 | struct lldpd_vlan { |
56 | TAILQ_ENTRY(lldpd_vlan) v_entries; | |
57 | char *v_name; | |
58 | u_int16_t v_vid; | |
59 | }; | |
f6d20631 VB |
60 | MARSHAL_BEGIN(lldpd_vlan) |
61 | MARSHAL_TQE(lldpd_vlan, v_entries) | |
62 | MARSHAL_STR(lldpd_vlan, v_name) | |
985a4cb5 | 63 | MARSHAL_END(lldpd_vlan); |
9757bfbc SK |
64 | |
65 | struct lldpd_pi { | |
66 | TAILQ_ENTRY(lldpd_pi) p_entries; | |
67 | char *p_pi; | |
48acfcaf | 68 | int p_pi_len; |
9757bfbc | 69 | }; |
f6d20631 VB |
70 | MARSHAL_BEGIN(lldpd_pi) |
71 | MARSHAL_TQE(lldpd_pi, p_entries) | |
72 | MARSHAL_FSTR(lldpd_pi, p_pi, p_pi_len) | |
985a4cb5 | 73 | MARSHAL_END(lldpd_pi); |
a1347cd8 | 74 | #endif |
43c02e7b | 75 | |
e3a44efb | 76 | #ifdef ENABLE_LLDPMED |
e3a44efb | 77 | struct lldpd_med_policy { |
4b292b55 | 78 | u_int8_t index; /* Not used. */ |
e3a44efb VB |
79 | u_int8_t type; |
80 | u_int8_t unknown; | |
81 | u_int8_t tagged; | |
82 | u_int16_t vid; | |
83 | u_int8_t priority; | |
84 | u_int8_t dscp; | |
e3a44efb | 85 | }; |
f6d20631 | 86 | MARSHAL(lldpd_med_policy); |
e3a44efb | 87 | |
e3a44efb | 88 | struct lldpd_med_loc { |
4b292b55 | 89 | u_int8_t index; /* Not used. */ |
e3a44efb VB |
90 | u_int8_t format; |
91 | char *data; | |
92 | int data_len; | |
e3a44efb | 93 | }; |
f6d20631 VB |
94 | MARSHAL_BEGIN(lldpd_med_loc) |
95 | MARSHAL_FSTR(lldpd_med_loc, data, data_len) | |
985a4cb5 | 96 | MARSHAL_END(lldpd_med_loc); |
6d08df0e | 97 | |
6d08df0e VB |
98 | struct lldpd_med_power { |
99 | u_int8_t devicetype; /* PD or PSE */ | |
100 | u_int8_t source; | |
101 | u_int8_t priority; | |
102 | u_int16_t val; | |
103 | }; | |
f6d20631 | 104 | MARSHAL(lldpd_med_power); |
e3a44efb VB |
105 | #endif |
106 | ||
3fd015c0 | 107 | #ifdef ENABLE_DOT3 |
3fd015c0 VB |
108 | struct lldpd_dot3_macphy { |
109 | u_int8_t autoneg_support; | |
110 | u_int8_t autoneg_enabled; | |
111 | u_int16_t autoneg_advertised; | |
112 | u_int16_t mau_type; | |
113 | }; | |
befbdf89 | 114 | |
befbdf89 VB |
115 | struct lldpd_dot3_power { |
116 | u_int8_t devicetype; | |
117 | u_int8_t supported; | |
118 | u_int8_t enabled; | |
119 | u_int8_t paircontrol; | |
120 | u_int8_t pairs; | |
121 | u_int8_t class; | |
608cb51c VB |
122 | u_int8_t powertype; /* If set to LLDP_DOT3_POWER_8023AT_OFF, |
123 | following fields have no meaning */ | |
124 | u_int8_t source; | |
125 | u_int8_t priority; | |
126 | u_int16_t requested; | |
127 | u_int16_t allocated; | |
befbdf89 | 128 | }; |
f6d20631 | 129 | MARSHAL(lldpd_dot3_power); |
3fd015c0 VB |
130 | #endif |
131 | ||
4e7ec823 | 132 | #if defined (ENABLE_CDP) || defined (ENABLE_FDP) |
5334d8c8 GW |
133 | struct cdpv2_power { |
134 | u_int16_t request_id; | |
135 | u_int16_t management_id; | |
136 | }; | |
137 | #endif | |
138 | ||
f15d3950 VB |
139 | enum { |
140 | LLDPD_AF_UNSPEC = 0, | |
141 | LLDPD_AF_IPV4, | |
142 | LLDPD_AF_IPV6, | |
143 | LLDPD_AF_LAST | |
144 | }; | |
145 | ||
e6b36c87 | 146 | #define LLDPD_MGMT_MAXADDRSIZE 16 /* sizeof(struct in6_addr) */ |
b562f01f VB |
147 | union lldpd_address { |
148 | struct in_addr inet; | |
149 | struct in6_addr inet6; | |
150 | u_int8_t octets[LLDPD_MGMT_MAXADDRSIZE]; /* network byte order! */ | |
151 | }; | |
e6b36c87 JV |
152 | struct lldpd_mgmt { |
153 | TAILQ_ENTRY(lldpd_mgmt) m_entries; | |
b562f01f VB |
154 | int m_family; |
155 | union lldpd_address m_addr; | |
e6b36c87 JV |
156 | size_t m_addrsize; |
157 | u_int32_t m_iface; | |
158 | }; | |
159 | MARSHAL_BEGIN(lldpd_mgmt) | |
160 | MARSHAL_TQE(lldpd_mgmt, m_entries) | |
985a4cb5 | 161 | MARSHAL_END(lldpd_mgmt); |
e6b36c87 | 162 | |
43c02e7b | 163 | struct lldpd_chassis { |
75068724 VB |
164 | TAILQ_ENTRY(lldpd_chassis) c_entries; |
165 | u_int16_t c_refcount; /* Reference count by ports */ | |
166 | u_int16_t c_index; /* Monotonic index */ | |
167 | u_int8_t c_protocol; /* Protocol used to get this chassis */ | |
43c02e7b VB |
168 | u_int8_t c_id_subtype; |
169 | char *c_id; | |
170 | int c_id_len; | |
171 | char *c_name; | |
172 | char *c_descr; | |
173 | ||
174 | u_int16_t c_cap_available; | |
175 | u_int16_t c_cap_enabled; | |
176 | ||
e6b36c87 | 177 | TAILQ_HEAD(, lldpd_mgmt) c_mgmt; |
89840df0 VB |
178 | |
179 | #ifdef ENABLE_LLDPMED | |
40ecae87 | 180 | u_int16_t c_med_cap_available; |
89840df0 VB |
181 | u_int8_t c_med_type; |
182 | char *c_med_hw; | |
183 | char *c_med_fw; | |
184 | char *c_med_sw; | |
185 | char *c_med_sn; | |
186 | char *c_med_manuf; | |
187 | char *c_med_model; | |
188 | char *c_med_asset; | |
89840df0 | 189 | #endif |
1531f7f3 VB |
190 | |
191 | }; | |
d938c51f VB |
192 | /* WARNING: any change to this structure should also be reflected into |
193 | `lldpd_copy_chassis()` which is not using marshaling. */ | |
f6d20631 | 194 | MARSHAL_BEGIN(lldpd_chassis) |
74e0080e VB |
195 | MARSHAL_IGNORE(lldpd_chassis, c_entries.tqe_next) |
196 | MARSHAL_IGNORE(lldpd_chassis, c_entries.tqe_prev) | |
f6d20631 VB |
197 | MARSHAL_FSTR(lldpd_chassis, c_id, c_id_len) |
198 | MARSHAL_STR(lldpd_chassis, c_name) | |
199 | MARSHAL_STR(lldpd_chassis, c_descr) | |
e6b36c87 | 200 | MARSHAL_SUBTQ(lldpd_chassis, lldpd_mgmt, c_mgmt) |
f6d20631 VB |
201 | #ifdef ENABLE_LLDPMED |
202 | MARSHAL_STR(lldpd_chassis, c_med_hw) | |
203 | MARSHAL_STR(lldpd_chassis, c_med_fw) | |
204 | MARSHAL_STR(lldpd_chassis, c_med_sw) | |
205 | MARSHAL_STR(lldpd_chassis, c_med_sn) | |
206 | MARSHAL_STR(lldpd_chassis, c_med_manuf) | |
207 | MARSHAL_STR(lldpd_chassis, c_med_model) | |
208 | MARSHAL_STR(lldpd_chassis, c_med_asset) | |
209 | #endif | |
985a4cb5 | 210 | MARSHAL_END(lldpd_chassis); |
f6d20631 | 211 | |
fb1b78bb | 212 | #ifdef ENABLE_CUSTOM |
7c26c8b4 | 213 | |
214 | #define CUSTOM_TLV_ADD 1 | |
215 | #define CUSTOM_TLV_REPLACE 2 | |
216 | #define CUSTOM_TLV_REMOVE 3 | |
217 | ||
cd5de7a2 AA |
218 | /* Custom TLV struct as defined on page 35 of IEEE 802.1AB-2005 */ |
219 | struct lldpd_custom { | |
220 | TAILQ_ENTRY(lldpd_custom) next; /* Pointer to next custom TLV */ | |
221 | ||
222 | /* Organizationally Unique Identifier */ | |
223 | u_int8_t oui[LLDP_TLV_ORG_OUI_LEN]; | |
224 | /* Organizationally Defined Subtype */ | |
225 | u_int8_t subtype; | |
5427983b | 226 | /* Organizationally Defined Information String */ |
8caf4341 | 227 | u_int8_t *oui_info; |
cd5de7a2 AA |
228 | /* Organizationally Defined Information String length */ |
229 | int oui_info_len; | |
230 | }; | |
231 | MARSHAL_BEGIN(lldpd_custom) | |
232 | MARSHAL_TQE(lldpd_custom, next) | |
8caf4341 | 233 | MARSHAL_FSTR(lldpd_custom, oui_info, oui_info_len) |
cd5de7a2 | 234 | MARSHAL_END(lldpd_custom); |
fb1b78bb | 235 | #endif |
43c02e7b VB |
236 | |
237 | struct lldpd_port { | |
75068724 VB |
238 | TAILQ_ENTRY(lldpd_port) p_entries; |
239 | struct lldpd_chassis *p_chassis; /* Attached chassis */ | |
240 | time_t p_lastchange; /* Time of last change of values */ | |
241 | time_t p_lastupdate; /* Time of last update received */ | |
c79467f6 TE |
242 | time_t p_lastremove; /* Time of last removal of a remote port. Used for local ports only |
243 | * Used for deciding lldpStatsRemTablesLastChangeTime */ | |
75068724 VB |
244 | struct lldpd_frame *p_lastframe; /* Frame received during last update */ |
245 | u_int8_t p_protocol; /* Protocol used to get this port */ | |
579bedd5 VB |
246 | u_int8_t p_hidden_in:1; /* Considered as hidden for reception */ |
247 | u_int8_t p_hidden_out:2; /* Considered as hidden for emission */ | |
e7331ce9 VB |
248 | u_int8_t p_disable_rx:3; /* Should RX be disabled for this port? */ |
249 | u_int8_t p_disable_tx:4; /* Should TX be disabled for this port? */ | |
579bedd5 | 250 | /* Important: all fields that should be ignored to check if a port has |
28414fbd | 251 | * been changed should be before this mark. */ |
aafa99bd | 252 | #define LLDPD_PORT_START_MARKER (offsetof(struct lldpd_port, _p_hardware_flags)) |
196757ce | 253 | int _p_hardware_flags; /* This is a copy of hardware flags. Do not use it! */ |
43c02e7b VB |
254 | u_int8_t p_id_subtype; |
255 | char *p_id; | |
256 | int p_id_len; | |
257 | char *p_descr; | |
e1717397 | 258 | int p_descr_force; /* Description has been forced by user */ |
548109b2 | 259 | u_int16_t p_mfs; |
78346c89 | 260 | u_int16_t p_ttl; /* TTL for remote port */ |
43c02e7b | 261 | |
a1347cd8 | 262 | #ifdef ENABLE_DOT3 |
43c02e7b VB |
263 | /* Dot3 stuff */ |
264 | u_int32_t p_aggregid; | |
3fd015c0 | 265 | struct lldpd_dot3_macphy p_macphy; |
befbdf89 | 266 | struct lldpd_dot3_power p_power; |
a1347cd8 | 267 | #endif |
1531f7f3 | 268 | |
740593ff | 269 | #ifdef ENABLE_LLDPMED |
740593ff | 270 | u_int16_t p_med_cap_enabled; |
4b292b55 VB |
271 | struct lldpd_med_policy p_med_policy[LLDP_MED_APPTYPE_LAST]; |
272 | struct lldpd_med_loc p_med_location[LLDP_MED_LOCFORMAT_LAST]; | |
6d08df0e | 273 | struct lldpd_med_power p_med_power; |
740593ff VB |
274 | #endif |
275 | ||
4e7ec823 | 276 | #if defined (ENABLE_CDP) || defined (ENABLE_FDP) |
5334d8c8 GW |
277 | struct cdpv2_power p_cdp_power; |
278 | #endif | |
279 | ||
a1347cd8 | 280 | #ifdef ENABLE_DOT1 |
75b3469d | 281 | u_int16_t p_pvid; |
1531f7f3 | 282 | TAILQ_HEAD(, lldpd_vlan) p_vlans; |
9757bfbc SK |
283 | TAILQ_HEAD(, lldpd_ppvid) p_ppvids; |
284 | TAILQ_HEAD(, lldpd_pi) p_pids; | |
a1347cd8 | 285 | #endif |
fb1b78bb | 286 | #ifdef ENABLE_CUSTOM |
cd5de7a2 | 287 | TAILQ_HEAD(, lldpd_custom) p_custom_list; |
fb1b78bb | 288 | #endif |
1531f7f3 | 289 | }; |
f6d20631 VB |
290 | MARSHAL_BEGIN(lldpd_port) |
291 | MARSHAL_TQE(lldpd_port, p_entries) | |
292 | MARSHAL_POINTER(lldpd_port, lldpd_chassis, p_chassis) | |
293 | MARSHAL_IGNORE(lldpd_port, p_lastframe) | |
294 | MARSHAL_FSTR(lldpd_port, p_id, p_id_len) | |
295 | MARSHAL_STR(lldpd_port, p_descr) | |
296 | #ifdef ENABLE_LLDPMED | |
297 | MARSHAL_SUBSTRUCT(lldpd_port, lldpd_med_loc, p_med_location[0]) | |
298 | MARSHAL_SUBSTRUCT(lldpd_port, lldpd_med_loc, p_med_location[1]) | |
299 | MARSHAL_SUBSTRUCT(lldpd_port, lldpd_med_loc, p_med_location[2]) | |
300 | #endif | |
301 | #ifdef ENABLE_DOT1 | |
302 | MARSHAL_SUBTQ(lldpd_port, lldpd_vlan, p_vlans) | |
303 | MARSHAL_SUBTQ(lldpd_port, lldpd_ppvid, p_ppvids) | |
304 | MARSHAL_SUBTQ(lldpd_port, lldpd_pi, p_pids) | |
305 | #endif | |
fb1b78bb | 306 | #ifdef ENABLE_CUSTOM |
cd5de7a2 | 307 | MARSHAL_SUBTQ(lldpd_port, lldpd_custom, p_custom_list) |
fb1b78bb | 308 | #endif |
985a4cb5 | 309 | MARSHAL_END(lldpd_port); |
1531f7f3 | 310 | |
f6d20631 | 311 | /* Used to modify some port related settings */ |
e7331ce9 VB |
312 | #define LLDPD_RXTX_UNCHANGED 0 |
313 | #define LLDPD_RXTX_TXONLY 1 | |
314 | #define LLDPD_RXTX_RXONLY 2 | |
315 | #define LLDPD_RXTX_DISABLED 3 | |
316 | #define LLDPD_RXTX_BOTH 4 | |
317 | #define LLDPD_RXTX_FROM_PORT(p) (((p)->p_disable_rx && (p)->p_disable_tx)?LLDPD_RXTX_DISABLED: \ | |
318 | ((p)->p_disable_rx && !(p)->p_disable_tx)?LLDPD_RXTX_TXONLY: \ | |
319 | (!(p)->p_disable_rx && (p)->p_disable_tx)?LLDPD_RXTX_RXONLY: \ | |
320 | LLDPD_RXTX_BOTH) | |
321 | #define LLDPD_RXTX_RXENABLED(v) ((v) == LLDPD_RXTX_RXONLY || (v) == LLDPD_RXTX_BOTH) | |
322 | #define LLDPD_RXTX_TXENABLED(v) ((v) == LLDPD_RXTX_TXONLY || (v) == LLDPD_RXTX_BOTH) | |
f6d20631 VB |
323 | struct lldpd_port_set { |
324 | char *ifname; | |
8e46010c | 325 | char *local_id; |
c267d0f2 | 326 | char *local_descr; |
e7331ce9 | 327 | int rxtx; |
f6d20631 VB |
328 | #ifdef ENABLE_LLDPMED |
329 | struct lldpd_med_policy *med_policy; | |
330 | struct lldpd_med_loc *med_location; | |
331 | struct lldpd_med_power *med_power; | |
332 | #endif | |
333 | #ifdef ENABLE_DOT3 | |
334 | struct lldpd_dot3_power *dot3_power; | |
335 | #endif | |
fb1b78bb | 336 | #ifdef ENABLE_CUSTOM |
41cb7781 AA |
337 | struct lldpd_custom *custom; |
338 | int custom_list_clear; | |
7c26c8b4 | 339 | int custom_tlv_op; |
fb1b78bb | 340 | #endif |
f6d20631 VB |
341 | }; |
342 | MARSHAL_BEGIN(lldpd_port_set) | |
343 | MARSHAL_STR(lldpd_port_set, ifname) | |
8e46010c | 344 | MARSHAL_STR(lldpd_port_set, local_id) |
c267d0f2 | 345 | MARSHAL_STR(lldpd_port_set, local_descr) |
f6d20631 VB |
346 | #ifdef ENABLE_LLDPMED |
347 | MARSHAL_POINTER(lldpd_port_set, lldpd_med_policy, med_policy) | |
348 | MARSHAL_POINTER(lldpd_port_set, lldpd_med_loc, med_location) | |
349 | MARSHAL_POINTER(lldpd_port_set, lldpd_med_power, med_power) | |
350 | #endif | |
351 | #ifdef ENABLE_DOT3 | |
352 | MARSHAL_POINTER(lldpd_port_set, lldpd_dot3_power, dot3_power) | |
353 | #endif | |
fb1b78bb | 354 | #ifdef ENABLE_CUSTOM |
41cb7781 | 355 | MARSHAL_POINTER(lldpd_port_set, lldpd_custom, custom) |
fb1b78bb | 356 | #endif |
985a4cb5 | 357 | MARSHAL_END(lldpd_port_set); |
43c02e7b | 358 | |
8ec333bd VB |
359 | /* Smart mode / Hide mode */ |
360 | #define SMART_INCOMING_FILTER (1<<0) /* Incoming filtering enabled */ | |
361 | #define SMART_INCOMING_ONE_PROTO (1<<1) /* On reception, keep only one proto */ | |
362 | #define SMART_INCOMING_ONE_NEIGH (1<<2) /* On reception, keep only one neighbor */ | |
363 | #define SMART_OUTGOING_FILTER (1<<3) /* Outgoing filtering enabled */ | |
364 | #define SMART_OUTGOING_ONE_PROTO (1<<4) /* On emission, keep only one proto */ | |
365 | #define SMART_OUTGOING_ONE_NEIGH (1<<5) /* On emission, consider only one neighbor */ | |
366 | #define SMART_INCOMING (SMART_INCOMING_FILTER | \ | |
367 | SMART_INCOMING_ONE_PROTO | \ | |
368 | SMART_INCOMING_ONE_NEIGH) | |
369 | #define SMART_OUTGOING (SMART_OUTGOING_FILTER | \ | |
370 | SMART_OUTGOING_ONE_PROTO | \ | |
371 | SMART_OUTGOING_ONE_NEIGH) | |
372 | ||
373 | struct lldpd_config { | |
e4ff3ed5 | 374 | int c_paused; /* lldpd is paused */ |
8843f168 | 375 | int c_tx_interval; /* Transmit interval */ |
71b0f981 | 376 | int c_ttl; /* TTL */ |
8ec333bd VB |
377 | int c_smart; /* Bitmask for smart configuration (see SMART_*) */ |
378 | int c_receiveonly; /* Receive only mode */ | |
42589660 | 379 | int c_max_neighbors; /* Maximum number of neighbors (per protocol) */ |
8ec333bd VB |
380 | |
381 | char *c_mgmt_pattern; /* Pattern to match a management address */ | |
382 | char *c_cid_pattern; /* Pattern to match interfaces to use for chassis ID */ | |
5660759b | 383 | char *c_cid_string; /* User defined string for chassis ID */ |
8ec333bd | 384 | char *c_iface_pattern; /* Pattern to match interfaces to use */ |
0a78e14f | 385 | char *c_perm_ifaces; /* Pattern to match interfaces to keep */ |
8ec333bd VB |
386 | |
387 | char *c_platform; /* Override platform description (for CDP) */ | |
388 | char *c_description; /* Override chassis description */ | |
ce347d29 | 389 | char *c_hostname; /* Override system name */ |
8ec333bd | 390 | int c_advertise_version; /* Should the precise version be advertised? */ |
bb37268d | 391 | int c_set_ifdescr; /* Set interface description */ |
f84199dd | 392 | int c_promisc; /* Interfaces should be in promiscuous mode */ |
ca838758 | 393 | int c_cap_advertise; /* Chassis capabilities advertisement */ |
1c2217aa | 394 | int c_mgmt_advertise; /* Management addresses advertisement */ |
8ec333bd VB |
395 | |
396 | #ifdef ENABLE_LLDPMED | |
397 | int c_noinventory; /* Don't send inventory with LLDP-MED */ | |
b9de0ca6 | 398 | int c_enable_fast_start; /* enable fast start */ |
399 | int c_tx_fast_init; /* Num of lldpd lldppdu's for fast start */ | |
400 | int c_tx_fast_interval; /* Time intr between sends during fast start */ | |
be511d00 | 401 | #endif |
c10302a3 | 402 | int c_tx_hold; /* Transmit hold */ |
dfbd7185 RP |
403 | int c_bond_slave_src_mac_type; /* Src mac type in lldp frames over bond |
404 | slaves */ | |
8fbd3195 | 405 | int c_lldp_portid_type; /* The PortID type */ |
1eadc9a1 | 406 | int c_lldp_agent_type; /* The agent type */ |
8ec333bd VB |
407 | }; |
408 | MARSHAL_BEGIN(lldpd_config) | |
409 | MARSHAL_STR(lldpd_config, c_mgmt_pattern) | |
410 | MARSHAL_STR(lldpd_config, c_cid_pattern) | |
5660759b | 411 | MARSHAL_STR(lldpd_config, c_cid_string) |
8ec333bd | 412 | MARSHAL_STR(lldpd_config, c_iface_pattern) |
0a78e14f | 413 | MARSHAL_STR(lldpd_config, c_perm_ifaces) |
ce347d29 | 414 | MARSHAL_STR(lldpd_config, c_hostname) |
8ec333bd VB |
415 | MARSHAL_STR(lldpd_config, c_platform) |
416 | MARSHAL_STR(lldpd_config, c_description) | |
985a4cb5 | 417 | MARSHAL_END(lldpd_config); |
8ec333bd | 418 | |
43c02e7b VB |
419 | struct lldpd_frame { |
420 | int size; | |
b5c7ce8d | 421 | unsigned char frame[1]; |
43c02e7b VB |
422 | }; |
423 | ||
6e75df87 VB |
424 | struct lldpd_hardware; |
425 | struct lldpd; | |
426 | struct lldpd_ops { | |
427 | int(*send)(struct lldpd *, | |
428 | struct lldpd_hardware*, | |
429 | char *, size_t); /* Function to send a frame */ | |
430 | int(*recv)(struct lldpd *, | |
431 | struct lldpd_hardware*, | |
432 | int, char *, size_t); /* Function to receive a frame */ | |
433 | int(*cleanup)(struct lldpd *, struct lldpd_hardware *); /* Cleanup function. */ | |
434 | }; | |
435 | ||
44002d66 VB |
436 | /* An interface is uniquely identified by h_ifindex, h_ifname and h_ops. This |
437 | * means if an interface becomes enslaved, it will be considered as a new | |
438 | * interface. The same applies for renaming and we include the index in case of | |
439 | * renaming to an existing interface. */ | |
43c02e7b VB |
440 | struct lldpd_hardware { |
441 | TAILQ_ENTRY(lldpd_hardware) h_entries; | |
442 | ||
d6e889b6 VB |
443 | struct lldpd *h_cfg; /* Pointer to main configuration */ |
444 | void *h_recv; /* FD for reception */ | |
6e75df87 | 445 | int h_sendfd; /* FD for sending, only used by h_ops */ |
5347914e | 446 | int h_mangle; /* 1 if we have to mangle the MAC address */ |
6e75df87 VB |
447 | struct lldpd_ops *h_ops; /* Hardware-dependent functions */ |
448 | void *h_data; /* Hardware-dependent data */ | |
579bedd5 | 449 | void *h_timer; /* Timer for this port */ |
43c02e7b | 450 | |
43c02e7b | 451 | int h_mtu; |
6e75df87 VB |
452 | int h_flags; /* Packets will be sent only |
453 | if IFF_RUNNING. Will be | |
454 | removed if this is left | |
455 | to 0. */ | |
456 | int h_ifindex; /* Interface index, used by SNMP */ | |
457 | char h_ifname[IFNAMSIZ]; /* Should be unique */ | |
43c02e7b VB |
458 | u_int8_t h_lladdr[ETHER_ADDR_LEN]; |
459 | ||
460 | u_int64_t h_tx_cnt; | |
461 | u_int64_t h_rx_cnt; | |
462 | u_int64_t h_rx_discarded_cnt; | |
37387046 | 463 | u_int64_t h_rx_unrecognized_cnt; |
14052b61 VB |
464 | u_int64_t h_ageout_cnt; |
465 | u_int64_t h_insert_cnt; | |
466 | u_int64_t h_delete_cnt; | |
42589660 | 467 | u_int64_t h_drop_cnt; |
43c02e7b | 468 | |
acb5f65b VB |
469 | /* Previous values of different stuff. */ |
470 | /* Backup of the previous local port. Used to check if there was a | |
471 | * change to send an immediate update. All those are not marshalled to | |
472 | * the client. */ | |
473 | void *h_lport_previous; | |
17d34115 | 474 | ssize_t h_lport_previous_len; |
acb5f65b VB |
475 | /* Backup of the previous chassis ID. Used to check if there was a |
476 | * change and send an LLDP shutdown. */ | |
477 | u_int8_t h_lchassis_previous_id_subtype; | |
478 | char *h_lchassis_previous_id; | |
479 | int h_lchassis_previous_id_len; | |
480 | /* Backup of the previous port ID. Used to check if there was a change | |
481 | * and send an LLDP shutdown. */ | |
482 | u_int8_t h_lport_previous_id_subtype; | |
483 | char *h_lport_previous_id; | |
484 | int h_lport_previous_id_len; | |
485 | ||
75068724 VB |
486 | struct lldpd_port h_lport; /* Port attached to this hardware port */ |
487 | TAILQ_HEAD(, lldpd_port) h_rports; /* Remote ports */ | |
b9de0ca6 | 488 | |
be511d00 | 489 | #ifdef ENABLE_LLDPMED |
b9de0ca6 | 490 | int h_tx_fast; /* current tx fast start count */ |
be511d00 | 491 | #endif |
43c02e7b | 492 | }; |
f6d20631 VB |
493 | MARSHAL_BEGIN(lldpd_hardware) |
494 | MARSHAL_IGNORE(lldpd_hardware, h_entries.tqe_next) | |
495 | MARSHAL_IGNORE(lldpd_hardware, h_entries.tqe_prev) | |
496 | MARSHAL_IGNORE(lldpd_hardware, h_ops) | |
497 | MARSHAL_IGNORE(lldpd_hardware, h_data) | |
d6e889b6 | 498 | MARSHAL_IGNORE(lldpd_hardware, h_cfg) |
b1785ed5 VB |
499 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous) |
500 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous_len) | |
acb5f65b VB |
501 | MARSHAL_IGNORE(lldpd_hardware, h_lchassis_previous_id_subtype) |
502 | MARSHAL_IGNORE(lldpd_hardware, h_lchassis_previous_id) | |
503 | MARSHAL_IGNORE(lldpd_hardware, h_lchassis_previous_id_len) | |
504 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous_id_subtype) | |
505 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous_id) | |
506 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous_id_len) | |
f6d20631 VB |
507 | MARSHAL_SUBSTRUCT(lldpd_hardware, lldpd_port, h_lport) |
508 | MARSHAL_SUBTQ(lldpd_hardware, lldpd_port, h_rports) | |
985a4cb5 | 509 | MARSHAL_END(lldpd_hardware); |
43c02e7b VB |
510 | |
511 | struct lldpd_interface { | |
512 | TAILQ_ENTRY(lldpd_interface) next; | |
513 | char *name; | |
514 | }; | |
f6d20631 VB |
515 | MARSHAL_BEGIN(lldpd_interface) |
516 | MARSHAL_TQE(lldpd_interface, next) | |
517 | MARSHAL_STR(lldpd_interface, name) | |
985a4cb5 | 518 | MARSHAL_END(lldpd_interface); |
f6d20631 VB |
519 | TAILQ_HEAD(lldpd_interface_list, lldpd_interface); |
520 | MARSHAL_TQ(lldpd_interface_list, lldpd_interface); | |
43c02e7b | 521 | |
4e90a9e0 VB |
522 | struct lldpd_neighbor_change { |
523 | char *ifname; | |
524 | #define NEIGHBOR_CHANGE_DELETED -1 | |
525 | #define NEIGHBOR_CHANGE_ADDED 1 | |
526 | #define NEIGHBOR_CHANGE_UPDATED 0 | |
527 | int state; | |
528 | struct lldpd_port *neighbor; | |
529 | }; | |
530 | MARSHAL_BEGIN(lldpd_neighbor_change) | |
531 | MARSHAL_STR(lldpd_neighbor_change, ifname) | |
532 | MARSHAL_POINTER(lldpd_neighbor_change, lldpd_port, neighbor) | |
985a4cb5 | 533 | MARSHAL_END(lldpd_neighbor_change); |
4e90a9e0 | 534 | |
4b292b55 VB |
535 | /* Cleanup functions */ |
536 | void lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *); | |
537 | void lldpd_chassis_cleanup(struct lldpd_chassis *, int); | |
4e90a9e0 | 538 | void lldpd_remote_cleanup(struct lldpd_hardware *, |
ef3707da VB |
539 | void(*expire)(struct lldpd_hardware *, struct lldpd_port *), |
540 | int); | |
4b292b55 | 541 | void lldpd_port_cleanup(struct lldpd_port *, int); |
8ec333bd | 542 | void lldpd_config_cleanup(struct lldpd_config *); |
a1347cd8 | 543 | #ifdef ENABLE_DOT1 |
9757bfbc | 544 | void lldpd_ppvid_cleanup(struct lldpd_port *); |
43c02e7b | 545 | void lldpd_vlan_cleanup(struct lldpd_port *); |
9757bfbc | 546 | void lldpd_pi_cleanup(struct lldpd_port *); |
a1347cd8 | 547 | #endif |
fb1b78bb | 548 | #ifdef ENABLE_CUSTOM |
7c26c8b4 | 549 | void lldpd_custom_tlv_cleanup(struct lldpd_port *, struct lldpd_custom *); |
550 | void lldpd_custom_tlv_add(struct lldpd_port *, struct lldpd_custom *); | |
cd5de7a2 | 551 | void lldpd_custom_list_cleanup(struct lldpd_port *); |
fb1b78bb | 552 | #endif |
6e75df87 | 553 | |
0265b1e5 | 554 | #endif |