]>
Commit | Line | Data |
---|---|---|
be53a5c4 DF |
1 | /* -*- mode: c; c-file-style: "openbsd" -*- */ |
2 | /* | |
3 | * Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx> | |
4 | * | |
5 | * Permission to use, copy, modify, and/or distribute this software for any | |
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 | ||
18 | #ifndef _LLDPD_H | |
19 | #define _LLDPD_H | |
20 | ||
21 | #ifndef _WIN32 | |
22 | #include <netinet/if_ether.h> | |
23 | #include <netinet/in.h> | |
24 | #endif | |
25 | #include <stdlib.h> | |
26 | #include <stddef.h> | |
27 | #include <string.h> | |
28 | #include <sys/types.h> | |
29 | #include <sys/un.h> | |
30 | #include "list.h" | |
31 | #include "lldpd-structs.h" | |
32 | #include "lldp-tlv.h" | |
33 | #include "packets.h" | |
34 | #include "openvswitch/vlog.h" | |
35 | #include "ofpbuf.h" | |
36 | ||
37 | #define SYSCONFDIR "" | |
38 | #define LLDPD_CTL_SOCKET "" | |
39 | #define LLDPCLI_PATH "" | |
40 | #define PRIVSEP_USER "" | |
41 | #define PRIVSEP_GROUP "" | |
42 | #define PRIVSEP_CHROOT "" | |
43 | ||
44 | #define ETHERTYPE_LLDP 0x88cc | |
45 | ||
46 | struct event; | |
47 | struct event_base; | |
48 | ||
49 | #define LLDPD_TX_INTERVAL 5 | |
50 | #define LLDPD_TX_HOLD 4 | |
51 | #define LLDPD_TTL LLDPD_TX_INTERVAL * LLDPD_TX_HOLD | |
52 | #define LLDPD_TX_MSGDELAY 1 | |
53 | #define LLDPD_MAX_NEIGHBORS 4 | |
54 | #define LLDPD_FAST_TX_INTERVAL 1 | |
55 | #define LLDPD_FAST_INIT 4 | |
56 | ||
57 | #define USING_AGENTX_SUBAGENT_MODULE 1 | |
58 | ||
59 | #define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware *,struct ofpbuf * | |
60 | #define PROTO_DECODE_SIG struct lldpd *, char *, int, struct lldpd_hardware *,\ | |
61 | struct lldpd_chassis **, struct lldpd_port ** | |
62 | #define PROTO_GUESS_SIG char *, int | |
63 | ||
64 | #define ALIGNED_CAST(TYPE, ATTR) ((TYPE) (void *) (ATTR)) | |
65 | ||
66 | struct protocol { | |
67 | int mode; /* > 0 mode identifier (unique per protocol) */ | |
68 | int enabled; /* Is this protocol enabled? */ | |
69 | char *name; /* Name of protocol */ | |
70 | char arg; /* Argument to enable this protocol */ | |
71 | int(*send)(PROTO_SEND_SIG); /* How to send a frame */ | |
72 | int(*decode)(PROTO_DECODE_SIG); /* How to decode a frame */ | |
73 | int(*guess)(PROTO_GUESS_SIG); /* Can be NULL, use MAC address in this | |
74 | * case | |
75 | */ | |
76 | u_int8_t mac[ETH_ADDR_LEN]; /* Destination MAC address used by this | |
77 | * protocol | |
78 | */ | |
79 | }; | |
80 | ||
81 | #define SMART_HIDDEN(port) (port->p_hidden_in) | |
82 | ||
83 | struct lldpd { | |
84 | int g_sock; | |
85 | struct lldpd_config g_config; | |
86 | struct protocol *g_protocols; | |
87 | int g_lastrid; | |
88 | ||
89 | /* Unix socket handling */ | |
90 | const char *g_ctlname; | |
91 | int g_ctl; | |
92 | ||
93 | char *g_lsb_release; | |
94 | ||
95 | struct lldpd_chassis g_chassis; | |
96 | struct lldpd_hardware g_hardware; | |
97 | }; | |
98 | ||
99 | /* lldpd.c */ | |
100 | struct lldpd_hardware *lldpd_get_hardware(struct lldpd *, | |
101 | char *, int, struct lldpd_ops *); | |
102 | struct lldpd_hardware *lldpd_alloc_hardware(struct lldpd *, char *, int); | |
103 | void lldpd_hardware_cleanup(struct lldpd*, struct lldpd_hardware *); | |
104 | struct lldpd_mgmt *lldpd_alloc_mgmt(int family, void *addr, size_t addrsize, | |
105 | u_int32_t iface); | |
106 | void lldpd_recv(struct lldpd *, struct lldpd_hardware *, char *, size_t); | |
107 | uint32_t lldpd_send(struct lldpd_hardware *, struct ofpbuf *); | |
108 | void lldpd_loop(struct lldpd *); | |
109 | ||
110 | int lldpd_main(int, char **); | |
111 | void lldpd_update_localports(struct lldpd *); | |
112 | void lldpd_cleanup(struct lldpd *); | |
113 | ||
114 | void lldpd_assign_cfg_to_protocols(struct lldpd *); | |
115 | ||
116 | /* lldp.c */ | |
117 | int lldp_send(PROTO_SEND_SIG); | |
118 | int lldp_decode(PROTO_DECODE_SIG); | |
119 | ||
120 | #endif /* _LLDPD_H */ |