1 /* -*- mode: c; c-file-style: "openbsd" -*- */
3 * Copyright (c) 2015 Nicira, Inc.
4 * Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #include <netinet/if_ether.h>
24 #include <netinet/in.h>
29 #include <sys/types.h>
31 #include "dp-packet.h"
33 #include "lldpd-structs.h"
36 #include "openvswitch/vlog.h"
39 #define LLDPD_CTL_SOCKET ""
40 #define LLDPCLI_PATH ""
41 #define PRIVSEP_USER ""
42 #define PRIVSEP_GROUP ""
43 #define PRIVSEP_CHROOT ""
45 #define ETHERTYPE_LLDP 0x88cc
50 #define LLDPD_TX_INTERVAL 5
51 #define LLDPD_TX_HOLD 4
52 #define LLDPD_TTL LLDPD_TX_INTERVAL * LLDPD_TX_HOLD
53 #define LLDPD_TX_MSGDELAY 1
54 #define LLDPD_MAX_NEIGHBORS 4
55 #define LLDPD_FAST_TX_INTERVAL 1
56 #define LLDPD_FAST_INIT 4
58 #define USING_AGENTX_SUBAGENT_MODULE 1
60 #define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware *,struct dp_packet *
61 #define PROTO_DECODE_SIG struct lldpd *, char *, int, struct lldpd_hardware *,\
62 struct lldpd_chassis **, struct lldpd_port **
63 #define PROTO_GUESS_SIG char *, int
66 int mode; /* > 0 mode identifier (unique per protocol) */
67 int enabled; /* Is this protocol enabled? */
68 char *name; /* Name of protocol */
69 char arg; /* Argument to enable this protocol */
70 int(*send)(PROTO_SEND_SIG); /* How to send a frame */
71 int(*decode)(PROTO_DECODE_SIG); /* How to decode a frame */
72 int(*guess)(PROTO_GUESS_SIG); /* Can be NULL, use MAC address in this
75 u_int8_t mac[ETH_ADDR_LEN]; /* Destination MAC address used by this
80 #define SMART_HIDDEN(port) (port->p_hidden_in)
83 struct lldpd_config g_config;
84 struct protocol *g_protocols;
87 struct ovs_list g_chassis; /* Contains "struct lldp_chassis". */
88 struct lldpd_hardware g_hardware;
92 struct lldpd_hardware *lldpd_get_hardware(struct lldpd *,
93 char *, int, struct lldpd_ops *);
94 struct lldpd_hardware *lldpd_alloc_hardware(struct lldpd *, char *, int);
95 void lldpd_hardware_cleanup(struct lldpd*, struct lldpd_hardware *);
96 struct lldpd_mgmt *lldpd_alloc_mgmt(int family, void *addr, size_t addrsize,
98 void lldpd_recv(struct lldpd *, struct lldpd_hardware *, char *, size_t);
99 uint32_t lldpd_send(struct lldpd_hardware *, struct dp_packet *);
100 void lldpd_loop(struct lldpd *);
102 int lldpd_main(int, char **);
103 void lldpd_update_localports(struct lldpd *);
104 void lldpd_cleanup(struct lldpd *);
106 void lldpd_assign_cfg_to_protocols(struct lldpd *);
109 int lldp_send(PROTO_SEND_SIG);
110 int lldp_decode(PROTO_DECODE_SIG);
112 #endif /* _LLDPD_H */