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