]>
Commit | Line | Data |
---|---|---|
43c02e7b VB |
1 | /* |
2 | * Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx> | |
3 | * | |
51434125 | 4 | * Permission to use, copy, modify, and/or distribute this software for any |
43c02e7b VB |
5 | * purpose with or without fee is hereby granted, provided that the above |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | #ifndef _LLDPD_H | |
18 | #define _LLDPD_H | |
19 | ||
20 | #if HAVE_CONFIG_H | |
d38eae28 | 21 | # include <config.h> |
43c02e7b VB |
22 | #endif |
23 | ||
24 | #define _GNU_SOURCE 1 | |
25 | #include <stdlib.h> | |
26 | #include <string.h> | |
27 | #include <sys/queue.h> | |
d38eae28 VB |
28 | #ifdef HAVE_SYS_TYPES_H |
29 | # include <sys/types.h> | |
30 | #endif | |
43c02e7b | 31 | #ifndef INCLUDE_LINUX_IF_H |
d38eae28 | 32 | # include <net/if.h> |
43c02e7b | 33 | #else |
d38eae28 VB |
34 | # include <arpa/inet.h> |
35 | # include <linux/if.h> | |
43c02e7b | 36 | #endif |
b7997528 | 37 | #if HAVE_GETIFADDRS |
d38eae28 | 38 | # include <ifaddrs.h> |
43c02e7b VB |
39 | #endif |
40 | #include <net/ethernet.h> | |
41 | #include <netinet/in.h> | |
4afe659e | 42 | #include <linux/ethtool.h> |
2acc1418 | 43 | #include <sys/un.h> |
43c02e7b VB |
44 | |
45 | #include "compat.h" | |
46 | #include "lldp.h" | |
4bad1937 | 47 | #if defined (ENABLE_CDP) || defined (ENABLE_FDP) |
d38eae28 | 48 | # include "cdp.h" |
4bad1937 VB |
49 | #endif |
50 | #ifdef ENABLE_SONMP | |
d38eae28 | 51 | # include "sonmp.h" |
4bad1937 VB |
52 | #endif |
53 | #ifdef ENABLE_EDP | |
d38eae28 | 54 | # include "edp.h" |
4bad1937 | 55 | #endif |
db323555 | 56 | #include "marshal.h" |
43c02e7b | 57 | |
89840df0 VB |
58 | #define SYSFS_CLASS_NET "/sys/class/net/" |
59 | #define SYSFS_CLASS_DMI "/sys/class/dmi/id/" | |
43c02e7b VB |
60 | #define LLDPD_TTL 120 |
61 | #define LLDPD_TX_DELAY 30 | |
62 | #define LLDPD_TX_MSGDELAY 1 | |
63 | #define LLDPD_CTL_SOCKET "/var/run/lldpd.socket" | |
64 | #define LLDPD_PID_FILE "/var/run/lldpd.pid" | |
65 | ||
66 | #define UNIX_PATH_MAX 108 | |
67 | ||
68 | #define USING_AGENTX_SUBAGENT_MODULE 1 | |
69 | ||
a1347cd8 | 70 | #ifdef ENABLE_DOT1 |
48acfcaf VB |
71 | #define LLDPD_PPVID_CAP_SUPPORTED (1 << 1) |
72 | #define LLDPD_PPVID_CAP_ENABLED (1 << 2) | |
9757bfbc SK |
73 | |
74 | struct lldpd_ppvid { | |
75 | TAILQ_ENTRY(lldpd_ppvid) p_entries; | |
76 | u_int8_t p_cap_status; | |
77 | u_int16_t p_ppvid; | |
78 | }; | |
79 | #define STRUCT_LLDPD_PPVID "(Lbw)" | |
80 | ||
43c02e7b VB |
81 | struct lldpd_vlan { |
82 | TAILQ_ENTRY(lldpd_vlan) v_entries; | |
83 | char *v_name; | |
84 | u_int16_t v_vid; | |
85 | }; | |
0c8f36f3 | 86 | #define STRUCT_LLDPD_VLAN "(Lsw)" |
9757bfbc SK |
87 | |
88 | struct lldpd_pi { | |
89 | TAILQ_ENTRY(lldpd_pi) p_entries; | |
90 | char *p_pi; | |
48acfcaf | 91 | int p_pi_len; |
9757bfbc | 92 | }; |
48acfcaf | 93 | #define STRUCT_LLDPD_PI "(LC)" |
a1347cd8 | 94 | #endif |
43c02e7b | 95 | |
e3a44efb | 96 | #ifdef ENABLE_LLDPMED |
0c8f36f3 | 97 | #define STRUCT_LLDPD_MED_POLICY "(bbbwbb)" |
e3a44efb VB |
98 | struct lldpd_med_policy { |
99 | u_int8_t type; | |
100 | u_int8_t unknown; | |
101 | u_int8_t tagged; | |
102 | u_int16_t vid; | |
103 | u_int8_t priority; | |
104 | u_int8_t dscp; | |
e3a44efb VB |
105 | }; |
106 | ||
0c8f36f3 | 107 | #define STRUCT_LLDPD_MED_LOC "(bC)" |
e3a44efb VB |
108 | struct lldpd_med_loc { |
109 | u_int8_t format; | |
110 | char *data; | |
111 | int data_len; | |
e3a44efb | 112 | }; |
6d08df0e VB |
113 | |
114 | #define STRUCT_LLDPD_MED_POWER "(bbbw)" | |
115 | struct lldpd_med_power { | |
116 | u_int8_t devicetype; /* PD or PSE */ | |
117 | u_int8_t source; | |
118 | u_int8_t priority; | |
119 | u_int16_t val; | |
120 | }; | |
e3a44efb VB |
121 | #endif |
122 | ||
3fd015c0 VB |
123 | #ifdef ENABLE_DOT3 |
124 | #define STRUCT_LLDPD_DOT3_MACPHY "(bbww)" | |
125 | struct lldpd_dot3_macphy { | |
126 | u_int8_t autoneg_support; | |
127 | u_int8_t autoneg_enabled; | |
128 | u_int16_t autoneg_advertised; | |
129 | u_int16_t mau_type; | |
130 | }; | |
befbdf89 | 131 | |
608cb51c | 132 | #define STRUCT_LLDPD_DOT3_POWER "(bbbbbbbbbww)" |
befbdf89 VB |
133 | struct lldpd_dot3_power { |
134 | u_int8_t devicetype; | |
135 | u_int8_t supported; | |
136 | u_int8_t enabled; | |
137 | u_int8_t paircontrol; | |
138 | u_int8_t pairs; | |
139 | u_int8_t class; | |
608cb51c VB |
140 | u_int8_t powertype; /* If set to LLDP_DOT3_POWER_8023AT_OFF, |
141 | following fields have no meaning */ | |
142 | u_int8_t source; | |
143 | u_int8_t priority; | |
144 | u_int16_t requested; | |
145 | u_int16_t allocated; | |
befbdf89 | 146 | }; |
3fd015c0 VB |
147 | #endif |
148 | ||
43c02e7b | 149 | struct lldpd_chassis { |
75068724 VB |
150 | TAILQ_ENTRY(lldpd_chassis) c_entries; |
151 | u_int16_t c_refcount; /* Reference count by ports */ | |
152 | u_int16_t c_index; /* Monotonic index */ | |
153 | u_int8_t c_protocol; /* Protocol used to get this chassis */ | |
43c02e7b VB |
154 | u_int8_t c_id_subtype; |
155 | char *c_id; | |
156 | int c_id_len; | |
157 | char *c_name; | |
158 | char *c_descr; | |
159 | ||
160 | u_int16_t c_cap_available; | |
161 | u_int16_t c_cap_enabled; | |
162 | ||
163 | u_int16_t c_ttl; | |
164 | ||
165 | struct in_addr c_mgmt; | |
166 | u_int32_t c_mgmt_if; | |
89840df0 VB |
167 | |
168 | #ifdef ENABLE_LLDPMED | |
34602f3b | 169 | #define STRUCT_LLDPD_CHASSIS_MED "wbsssssss" |
40ecae87 | 170 | u_int16_t c_med_cap_available; |
89840df0 VB |
171 | u_int8_t c_med_type; |
172 | char *c_med_hw; | |
173 | char *c_med_fw; | |
174 | char *c_med_sw; | |
175 | char *c_med_sn; | |
176 | char *c_med_manuf; | |
177 | char *c_med_model; | |
178 | char *c_med_asset; | |
89840df0 | 179 | #else |
a1347cd8 | 180 | #define STRUCT_LLDPD_CHASSIS_MED "" |
89840df0 | 181 | #endif |
1531f7f3 VB |
182 | |
183 | }; | |
75068724 | 184 | #define STRUCT_LLDPD_CHASSIS "(LwwbbCsswwwll" STRUCT_LLDPD_CHASSIS_MED ")" |
43c02e7b VB |
185 | |
186 | struct lldpd_port { | |
75068724 VB |
187 | TAILQ_ENTRY(lldpd_port) p_entries; |
188 | struct lldpd_chassis *p_chassis; /* Attached chassis */ | |
189 | time_t p_lastchange; /* Time of last change of values */ | |
190 | time_t p_lastupdate; /* Time of last update received */ | |
191 | struct lldpd_frame *p_lastframe; /* Frame received during last update */ | |
192 | u_int8_t p_protocol; /* Protocol used to get this port */ | |
43c02e7b VB |
193 | u_int8_t p_id_subtype; |
194 | char *p_id; | |
195 | int p_id_len; | |
196 | char *p_descr; | |
548109b2 | 197 | u_int16_t p_mfs; |
8482abe9 VB |
198 | u_int8_t p_hidden_in:1; /* Considered as hidden for reception */ |
199 | u_int8_t p_hidden_out:2; /* Considered as hidden for emission */ | |
43c02e7b | 200 | |
a1347cd8 | 201 | #ifdef ENABLE_DOT3 |
befbdf89 | 202 | #define STRUCT_LLDPD_PORT_DOT3 "l" STRUCT_LLDPD_DOT3_MACPHY STRUCT_LLDPD_DOT3_POWER |
43c02e7b VB |
203 | /* Dot3 stuff */ |
204 | u_int32_t p_aggregid; | |
3fd015c0 | 205 | struct lldpd_dot3_macphy p_macphy; |
befbdf89 | 206 | struct lldpd_dot3_power p_power; |
a1347cd8 VB |
207 | #else |
208 | #define STRUCT_LLDPD_PORT_DOT3 "" | |
209 | #endif | |
1531f7f3 | 210 | |
740593ff VB |
211 | #ifdef ENABLE_LLDPMED |
212 | #define STRUCT_LLDPD_PORT_MED "w" \ | |
213 | STRUCT_LLDPD_MED_POLICY \ | |
214 | STRUCT_LLDPD_MED_POLICY \ | |
215 | STRUCT_LLDPD_MED_POLICY \ | |
216 | STRUCT_LLDPD_MED_POLICY \ | |
217 | STRUCT_LLDPD_MED_POLICY \ | |
218 | STRUCT_LLDPD_MED_POLICY \ | |
219 | STRUCT_LLDPD_MED_POLICY \ | |
220 | STRUCT_LLDPD_MED_POLICY \ | |
221 | STRUCT_LLDPD_MED_LOC \ | |
222 | STRUCT_LLDPD_MED_LOC \ | |
223 | STRUCT_LLDPD_MED_LOC \ | |
6d08df0e | 224 | STRUCT_LLDPD_MED_POWER |
740593ff VB |
225 | u_int16_t p_med_cap_enabled; |
226 | struct lldpd_med_policy p_med_policy[LLDPMED_APPTYPE_LAST]; | |
227 | struct lldpd_med_loc p_med_location[LLDPMED_LOCFORMAT_LAST]; | |
6d08df0e | 228 | struct lldpd_med_power p_med_power; |
740593ff VB |
229 | #else |
230 | #define STRUCT_LLDPD_PORT_MED "" | |
231 | #endif | |
232 | ||
a1347cd8 | 233 | #ifdef ENABLE_DOT1 |
48acfcaf | 234 | #define STRUCT_LLDPD_PORT_DOT1 "wPPPPPP" |
75b3469d | 235 | u_int16_t p_pvid; |
1531f7f3 | 236 | TAILQ_HEAD(, lldpd_vlan) p_vlans; |
9757bfbc SK |
237 | TAILQ_HEAD(, lldpd_ppvid) p_ppvids; |
238 | TAILQ_HEAD(, lldpd_pi) p_pids; | |
a1347cd8 VB |
239 | #else |
240 | #define STRUCT_LLDPD_PORT_DOT1 "" | |
241 | #endif | |
1531f7f3 VB |
242 | }; |
243 | ||
42b39485 | 244 | #define STRUCT_LLDPD_PORT "(LPttPbbCswb" \ |
740593ff VB |
245 | STRUCT_LLDPD_PORT_DOT3 \ |
246 | STRUCT_LLDPD_PORT_MED \ | |
247 | STRUCT_LLDPD_PORT_DOT1 ")" | |
43c02e7b VB |
248 | |
249 | struct lldpd_frame { | |
250 | int size; | |
b5c7ce8d | 251 | unsigned char frame[1]; |
43c02e7b VB |
252 | }; |
253 | ||
6e75df87 VB |
254 | struct lldpd_hardware; |
255 | struct lldpd; | |
256 | struct lldpd_ops { | |
257 | int(*send)(struct lldpd *, | |
258 | struct lldpd_hardware*, | |
259 | char *, size_t); /* Function to send a frame */ | |
260 | int(*recv)(struct lldpd *, | |
261 | struct lldpd_hardware*, | |
262 | int, char *, size_t); /* Function to receive a frame */ | |
263 | int(*cleanup)(struct lldpd *, struct lldpd_hardware *); /* Cleanup function. */ | |
264 | }; | |
265 | ||
44002d66 VB |
266 | /* An interface is uniquely identified by h_ifindex, h_ifname and h_ops. This |
267 | * means if an interface becomes enslaved, it will be considered as a new | |
268 | * interface. The same applies for renaming and we include the index in case of | |
269 | * renaming to an existing interface. */ | |
43c02e7b VB |
270 | struct lldpd_hardware { |
271 | TAILQ_ENTRY(lldpd_hardware) h_entries; | |
272 | ||
6e75df87 VB |
273 | fd_set h_recvfds; /* FD for reception */ |
274 | int h_sendfd; /* FD for sending, only used by h_ops */ | |
275 | struct lldpd_ops *h_ops; /* Hardware-dependent functions */ | |
276 | void *h_data; /* Hardware-dependent data */ | |
43c02e7b | 277 | |
43c02e7b | 278 | int h_mtu; |
6e75df87 VB |
279 | int h_flags; /* Packets will be sent only |
280 | if IFF_RUNNING. Will be | |
281 | removed if this is left | |
282 | to 0. */ | |
283 | int h_ifindex; /* Interface index, used by SNMP */ | |
284 | char h_ifname[IFNAMSIZ]; /* Should be unique */ | |
43c02e7b VB |
285 | u_int8_t h_lladdr[ETHER_ADDR_LEN]; |
286 | ||
287 | u_int64_t h_tx_cnt; | |
288 | u_int64_t h_rx_cnt; | |
289 | u_int64_t h_rx_discarded_cnt; | |
290 | u_int64_t h_rx_ageout_cnt; | |
37387046 | 291 | u_int64_t h_rx_unrecognized_cnt; |
43c02e7b | 292 | |
75068724 VB |
293 | struct lldpd_port h_lport; /* Port attached to this hardware port */ |
294 | TAILQ_HEAD(, lldpd_port) h_rports; /* Remote ports */ | |
43c02e7b VB |
295 | }; |
296 | ||
297 | struct lldpd_interface { | |
298 | TAILQ_ENTRY(lldpd_interface) next; | |
299 | char *name; | |
300 | }; | |
0c8f36f3 | 301 | #define STRUCT_LLDPD_INTERFACE "(Ls)" |
43c02e7b | 302 | |
77507b69 | 303 | #define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware * |
43c02e7b VB |
304 | #define PROTO_DECODE_SIG struct lldpd *, char *, int, struct lldpd_hardware *, struct lldpd_chassis **, struct lldpd_port ** |
305 | #define PROTO_GUESS_SIG char *, int | |
306 | ||
43c02e7b | 307 | struct protocol { |
f2dcb180 VB |
308 | #define LLDPD_MODE_LLDP 1 |
309 | #define LLDPD_MODE_CDPV1 2 | |
310 | #define LLDPD_MODE_CDPV2 3 | |
311 | #define LLDPD_MODE_SONMP 4 | |
312 | #define LLDPD_MODE_EDP 5 | |
313 | #define LLDPD_MODE_FDP 6 | |
42b39485 | 314 | #define LLDPD_MODE_MAX LLDPD_MODE_FDP |
43c02e7b VB |
315 | int mode; /* > 0 mode identifier (unique per protocol) */ |
316 | int enabled; /* Is this protocol enabled? */ | |
317 | char *name; /* Name of protocol */ | |
318 | char arg; /* Argument to enable this protocol */ | |
319 | int(*send)(PROTO_SEND_SIG); /* How to send a frame */ | |
320 | int(*decode)(PROTO_DECODE_SIG); /* How to decode a frame */ | |
321 | int(*guess)(PROTO_GUESS_SIG); /* Can be NULL, use MAC address in this case */ | |
322 | u_int8_t mac[ETH_ALEN]; /* Destination MAC address used by this protocol */ | |
43c02e7b VB |
323 | }; |
324 | ||
42b39485 | 325 | /* Smart mode / Hide mode */ |
8482abe9 VB |
326 | #define SMART_INCOMING_FILTER (1<<0) /* Incoming filtering enabled */ |
327 | #define SMART_INCOMING_ONE_PROTO (1<<1) /* On reception, keep only one proto */ | |
328 | #define SMART_INCOMING_ONE_NEIGH (1<<2) /* On reception, keep only one neighbor */ | |
329 | #define SMART_OUTGOING_FILTER (1<<3) /* Outgoing filtering enabled */ | |
330 | #define SMART_OUTGOING_ONE_PROTO (1<<4) /* On emission, keep only one proto */ | |
331 | #define SMART_OUTGOING_ONE_NEIGH (1<<5) /* On emission, consider only one neighbor */ | |
332 | #define SMART_INCOMING (SMART_INCOMING_FILTER | \ | |
333 | SMART_INCOMING_ONE_PROTO | \ | |
334 | SMART_INCOMING_ONE_NEIGH) | |
335 | #define SMART_OUTGOING (SMART_OUTGOING_FILTER | \ | |
336 | SMART_OUTGOING_ONE_PROTO | \ | |
337 | SMART_OUTGOING_ONE_NEIGH) | |
4d1a5b39 | 338 | #define SMART_HIDDEN(port) (port->p_hidden_in) |
42b39485 VB |
339 | |
340 | ||
77d7090e VB |
341 | #define CALLBACK_SIG struct lldpd*, struct lldpd_callback* |
342 | struct lldpd_callback { | |
343 | TAILQ_ENTRY(lldpd_callback) next; | |
344 | int fd; /* FD that will trigger this callback */ | |
345 | void(*function)(CALLBACK_SIG); /* Function called */ | |
346 | void *data; /* Optional data for this callback*/ | |
347 | }; | |
348 | ||
43c02e7b VB |
349 | struct lldpd { |
350 | int g_sock; | |
351 | int g_delay; | |
352 | ||
353 | struct protocol *g_protocols; | |
43c02e7b VB |
354 | time_t g_lastsent; |
355 | int g_lastrid; | |
42b39485 | 356 | int g_smart; |
537a8043 | 357 | int g_receiveonly; |
43c02e7b VB |
358 | #ifdef USE_SNMP |
359 | int g_snmp; | |
360 | #endif /* USE_SNMP */ | |
361 | ||
362 | /* Unix socket handling */ | |
363 | int g_ctl; | |
77d7090e VB |
364 | |
365 | TAILQ_HEAD(, lldpd_callback) g_callbacks; | |
43c02e7b VB |
366 | |
367 | char *g_mgmt_pattern; | |
ba85f9f4 | 368 | char *g_interfaces; |
43c02e7b | 369 | |
40ce835b | 370 | char *g_descr_override; |
c036b15d | 371 | char *g_lsb_release; |
abcbb820 VB |
372 | int g_advertise_version; |
373 | #ifdef ENABLE_LLDPMED | |
374 | int g_noinventory; | |
375 | #endif | |
40ce835b | 376 | |
77507b69 | 377 | #define LOCAL_CHASSIS(cfg) ((struct lldpd_chassis *)(TAILQ_FIRST(&cfg->g_chassis))) |
75068724 | 378 | TAILQ_HEAD(, lldpd_chassis) g_chassis; |
43c02e7b VB |
379 | TAILQ_HEAD(, lldpd_hardware) g_hardware; |
380 | }; | |
381 | ||
6e75df87 VB |
382 | typedef void(*lldpd_ifhandlers)(struct lldpd *, struct ifaddrs *); |
383 | ||
43c02e7b VB |
384 | enum hmsg_type { |
385 | HMSG_NONE, | |
386 | HMSG_GET_INTERFACES, | |
84853b92 | 387 | HMSG_GET_NB_PORTS, |
43c02e7b | 388 | HMSG_GET_PORT, |
84853b92 | 389 | HMSG_GET_CHASSIS, |
43c02e7b | 390 | HMSG_GET_VLANS, |
9757bfbc SK |
391 | HMSG_GET_PPVIDS, |
392 | HMSG_GET_PIDS, | |
740593ff | 393 | HMSG_SET_LOCATION, |
86f24df3 | 394 | HMSG_SET_POLICY, |
009ddd23 | 395 | HMSG_SET_POWER, |
42ee7382 | 396 | HMSG_SET_DOT3_POWER, |
43c02e7b VB |
397 | HMSG_SHUTDOWN |
398 | }; | |
399 | ||
400 | struct hmsg_hdr { | |
401 | enum hmsg_type type; | |
402 | int16_t len; | |
403 | pid_t pid; | |
a8818344 | 404 | }; |
43c02e7b VB |
405 | |
406 | struct hmsg { | |
407 | struct hmsg_hdr hdr; | |
a8818344 VB |
408 | char data[]; |
409 | }; | |
43c02e7b VB |
410 | |
411 | #define HMSG_HEADER_SIZE sizeof(struct hmsg_hdr) | |
412 | #define MAX_HMSGSIZE 8192 | |
413 | ||
414 | /* lldpd.c */ | |
44002d66 VB |
415 | struct lldpd_hardware *lldpd_get_hardware(struct lldpd *, |
416 | char *, int, struct lldpd_ops *); | |
6e75df87 VB |
417 | struct lldpd_hardware *lldpd_alloc_hardware(struct lldpd *, char *); |
418 | void lldpd_hardware_cleanup(struct lldpd*, struct lldpd_hardware *); | |
a1347cd8 | 419 | #ifdef ENABLE_DOT1 |
9757bfbc | 420 | void lldpd_ppvid_cleanup(struct lldpd_port *); |
43c02e7b | 421 | void lldpd_vlan_cleanup(struct lldpd_port *); |
9757bfbc | 422 | void lldpd_pi_cleanup(struct lldpd_port *); |
a1347cd8 | 423 | #endif |
43c02e7b | 424 | void lldpd_remote_cleanup(struct lldpd *, struct lldpd_hardware *, int); |
9898ac07 | 425 | void lldpd_port_cleanup(struct lldpd*, struct lldpd_port *, int); |
77507b69 | 426 | void lldpd_chassis_cleanup(struct lldpd_chassis *, int); |
77d7090e VB |
427 | int lldpd_callback_add(struct lldpd *, int, void(*fn)(CALLBACK_SIG), void *); |
428 | void lldpd_callback_del(struct lldpd *, int, void(*fn)(CALLBACK_SIG)); | |
2acc1418 | 429 | int lldpd_main(int, char **); |
43c02e7b VB |
430 | |
431 | /* lldp.c */ | |
432 | int lldp_send(PROTO_SEND_SIG); | |
433 | int lldp_decode(PROTO_DECODE_SIG); | |
434 | ||
435 | /* cdp.c */ | |
4bad1937 | 436 | #ifdef ENABLE_CDP |
43c02e7b VB |
437 | int cdpv1_send(PROTO_SEND_SIG); |
438 | int cdpv2_send(PROTO_SEND_SIG); | |
43c02e7b VB |
439 | int cdpv1_guess(PROTO_GUESS_SIG); |
440 | int cdpv2_guess(PROTO_GUESS_SIG); | |
4bad1937 VB |
441 | #endif |
442 | #if defined (ENABLE_CDP) || defined (ENABLE_FDP) | |
443 | int cdp_decode(PROTO_DECODE_SIG); | |
444 | #endif | |
445 | #ifdef ENABLE_FDP | |
446 | int fdp_send(PROTO_SEND_SIG); | |
447 | #endif | |
43c02e7b | 448 | |
4bad1937 | 449 | #ifdef ENABLE_SONMP |
43c02e7b VB |
450 | /* sonmp.c */ |
451 | int sonmp_send(PROTO_SEND_SIG); | |
452 | int sonmp_decode(PROTO_DECODE_SIG); | |
4bad1937 | 453 | #endif |
43c02e7b | 454 | |
4bad1937 | 455 | #ifdef ENABLE_EDP |
43c02e7b VB |
456 | /* edp.c */ |
457 | int edp_send(PROTO_SEND_SIG); | |
458 | int edp_decode(PROTO_DECODE_SIG); | |
4bad1937 | 459 | #endif |
43c02e7b VB |
460 | |
461 | /* ctl.c */ | |
b5562b23 | 462 | int ctl_create(char *); |
43c02e7b | 463 | int ctl_connect(char *); |
b5562b23 | 464 | void ctl_cleanup(char *); |
77d7090e | 465 | void ctl_accept(struct lldpd *, struct lldpd_callback *); |
43c02e7b VB |
466 | void ctl_msg_init(struct hmsg *, enum hmsg_type); |
467 | int ctl_msg_send(int, struct hmsg *); | |
468 | int ctl_msg_recv(int, struct hmsg *); | |
469 | int ctl_msg_pack_list(char *, void *, unsigned int, struct hmsg *, void **); | |
470 | int ctl_msg_unpack_list(char *, void *, unsigned int, struct hmsg *, void **); | |
471 | int ctl_msg_pack_structure(char *, void *, unsigned int, struct hmsg *, void **); | |
472 | int ctl_msg_unpack_structure(char *, void *, unsigned int, struct hmsg *, void **); | |
473 | ||
6e75df87 | 474 | /* interfaces.c */ |
ba85f9f4 | 475 | void lldpd_ifh_whitelist(struct lldpd *, struct ifaddrs *); |
849954d7 | 476 | void lldpd_ifh_bond(struct lldpd *, struct ifaddrs *); |
6e75df87 | 477 | void lldpd_ifh_eth(struct lldpd *, struct ifaddrs *); |
5994b27d | 478 | #ifdef ENABLE_DOT1 |
6e75df87 | 479 | void lldpd_ifh_vlan(struct lldpd *, struct ifaddrs *); |
5994b27d | 480 | #endif |
6e75df87 VB |
481 | void lldpd_ifh_mgmt(struct lldpd *, struct ifaddrs *); |
482 | ||
483 | /* dmi.c */ | |
89840df0 | 484 | #ifdef ENABLE_LLDPMED |
0265b1e5 | 485 | #if __i386__ || __amd64__ |
6f1046d1 VB |
486 | char *dmi_hw(void); |
487 | char *dmi_fw(void); | |
488 | char *dmi_sn(void); | |
489 | char *dmi_manuf(void); | |
490 | char *dmi_model(void); | |
491 | char *dmi_asset(void); | |
89840df0 | 492 | #endif |
0265b1e5 | 493 | #endif |
43c02e7b VB |
494 | |
495 | /* log.c */ | |
6bb9c4e0 | 496 | void log_init(int, const char *); |
e51da5ec | 497 | void log_warn(const char *, ...) __attribute__ ((format (printf, 1, 2))); |
563e2dfc | 498 | #define LLOG_WARN(x,...) log_warn("%s: " x, __FUNCTION__ , ## __VA_ARGS__) |
e51da5ec | 499 | void log_warnx(const char *, ...) __attribute__ ((format (printf, 1, 2))); |
563e2dfc | 500 | #define LLOG_WARNX(x,...) log_warnx("%s: " x, __FUNCTION__ , ## __VA_ARGS__) |
e51da5ec | 501 | void log_info(const char *, ...) __attribute__ ((format (printf, 1, 2))); |
563e2dfc | 502 | #define LLOG_INFO(x,...) log_info("%s: " x, __FUNCTION__ , ## __VA_ARGS__) |
e51da5ec | 503 | void log_debug(const char *, ...) __attribute__ ((format (printf, 1, 2))); |
563e2dfc | 504 | #define LLOG_DEBUG(x,...) log_debug("%s: " x, __FUNCTION__ , ## __VA_ARGS__) |
43c02e7b VB |
505 | void fatal(const char *); |
506 | void fatalx(const char *); | |
507 | ||
508 | /* agent.c */ | |
6f1046d1 | 509 | void agent_shutdown(void); |
bbea66e1 | 510 | void agent_init(struct lldpd *, char *, int); |
43c02e7b | 511 | |
d72a05d4 | 512 | /* agent_priv.c */ |
6f1046d1 | 513 | void agent_priv_register_domain(void); |
43c02e7b | 514 | |
a552a72e VB |
515 | /* client.c */ |
516 | struct client_handle { | |
517 | enum hmsg_type type; | |
518 | void (*handle)(struct lldpd*, struct hmsg*, struct hmsg*); | |
519 | }; | |
520 | ||
77d7090e VB |
521 | void client_handle_client(struct lldpd *, struct lldpd_callback *, |
522 | char *, int); | |
a552a72e VB |
523 | void client_handle_none(struct lldpd *, struct hmsg *, |
524 | struct hmsg *); | |
525 | void client_handle_get_interfaces(struct lldpd *, struct hmsg *, | |
526 | struct hmsg *); | |
740593ff | 527 | void client_handle_port_related(struct lldpd *, struct hmsg *, |
a552a72e VB |
528 | struct hmsg *); |
529 | void client_handle_shutdown(struct lldpd *, struct hmsg *, | |
530 | struct hmsg *); | |
531 | ||
b5562b23 | 532 | /* priv.c */ |
a2993d83 | 533 | void priv_init(char*); |
6f1046d1 VB |
534 | int priv_ctl_create(void); |
535 | void priv_ctl_cleanup(void); | |
536 | char *priv_gethostbyname(void); | |
a7502371 VB |
537 | int priv_open(char*); |
538 | int priv_ethtool(char*, struct ethtool_cmd*); | |
849954d7 | 539 | int priv_iface_init(const char *); |
ef76f920 | 540 | int priv_iface_multicast(const char *, u_int8_t *, int); |
d72a05d4 | 541 | int priv_snmp_socket(struct sockaddr_un *); |
4afe659e VB |
542 | |
543 | /* privsep_fdpass.c */ | |
544 | int receive_fd(int); | |
545 | void send_fd(int, int); | |
b5562b23 | 546 | |
43c02e7b | 547 | #endif /* _LLDPD_H */ |