diff options
Diffstat (limited to 'lib/lldp/lldpd.h')
-rw-r--r-- | lib/lldp/lldpd.h | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/lib/lldp/lldpd.h b/lib/lldp/lldpd.h new file mode 100644 index 000000000..f142180bb --- /dev/null +++ b/lib/lldp/lldpd.h @@ -0,0 +1,120 @@ +/* -*- mode: c; c-file-style: "openbsd" -*- */ +/* + * Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LLDPD_H +#define _LLDPD_H + +#ifndef _WIN32 +#include <netinet/if_ether.h> +#include <netinet/in.h> +#endif +#include <stdlib.h> +#include <stddef.h> +#include <string.h> +#include <sys/types.h> +#include <sys/un.h> +#include "list.h" +#include "lldpd-structs.h" +#include "lldp-tlv.h" +#include "packets.h" +#include "openvswitch/vlog.h" +#include "ofpbuf.h" + +#define SYSCONFDIR "" +#define LLDPD_CTL_SOCKET "" +#define LLDPCLI_PATH "" +#define PRIVSEP_USER "" +#define PRIVSEP_GROUP "" +#define PRIVSEP_CHROOT "" + +#define ETHERTYPE_LLDP 0x88cc + +struct event; +struct event_base; + +#define LLDPD_TX_INTERVAL 5 +#define LLDPD_TX_HOLD 4 +#define LLDPD_TTL LLDPD_TX_INTERVAL * LLDPD_TX_HOLD +#define LLDPD_TX_MSGDELAY 1 +#define LLDPD_MAX_NEIGHBORS 4 +#define LLDPD_FAST_TX_INTERVAL 1 +#define LLDPD_FAST_INIT 4 + +#define USING_AGENTX_SUBAGENT_MODULE 1 + +#define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware *,struct ofpbuf * +#define PROTO_DECODE_SIG struct lldpd *, char *, int, struct lldpd_hardware *,\ + struct lldpd_chassis **, struct lldpd_port ** +#define PROTO_GUESS_SIG char *, int + +#define ALIGNED_CAST(TYPE, ATTR) ((TYPE) (void *) (ATTR)) + +struct protocol { + int mode; /* > 0 mode identifier (unique per protocol) */ + int enabled; /* Is this protocol enabled? */ + char *name; /* Name of protocol */ + char arg; /* Argument to enable this protocol */ + int(*send)(PROTO_SEND_SIG); /* How to send a frame */ + int(*decode)(PROTO_DECODE_SIG); /* How to decode a frame */ + int(*guess)(PROTO_GUESS_SIG); /* Can be NULL, use MAC address in this + * case + */ + u_int8_t mac[ETH_ADDR_LEN]; /* Destination MAC address used by this + * protocol + */ +}; + +#define SMART_HIDDEN(port) (port->p_hidden_in) + +struct lldpd { + int g_sock; + struct lldpd_config g_config; + struct protocol *g_protocols; + int g_lastrid; + + /* Unix socket handling */ + const char *g_ctlname; + int g_ctl; + + char *g_lsb_release; + + struct lldpd_chassis g_chassis; + struct lldpd_hardware g_hardware; +}; + +/* lldpd.c */ +struct lldpd_hardware *lldpd_get_hardware(struct lldpd *, + char *, int, struct lldpd_ops *); +struct lldpd_hardware *lldpd_alloc_hardware(struct lldpd *, char *, int); +void lldpd_hardware_cleanup(struct lldpd*, struct lldpd_hardware *); +struct lldpd_mgmt *lldpd_alloc_mgmt(int family, void *addr, size_t addrsize, + u_int32_t iface); +void lldpd_recv(struct lldpd *, struct lldpd_hardware *, char *, size_t); +uint32_t lldpd_send(struct lldpd_hardware *, struct ofpbuf *); +void lldpd_loop(struct lldpd *); + +int lldpd_main(int, char **); +void lldpd_update_localports(struct lldpd *); +void lldpd_cleanup(struct lldpd *); + +void lldpd_assign_cfg_to_protocols(struct lldpd *); + +/* lldp.c */ +int lldp_send(PROTO_SEND_SIG); +int lldp_decode(PROTO_DECODE_SIG); + +#endif /* _LLDPD_H */ |