]> git.proxmox.com Git - ovs.git/blame - lib/lldp/lldpd.h
sparse: Add guards to prevent FreeBSD-incompatible #include order.
[ovs.git] / lib / lldp / lldpd.h
CommitLineData
be53a5c4
DF
1/* -*- mode: c; c-file-style: "openbsd" -*- */
2/*
809fd54d 3 * Copyright (c) 2015 Nicira, Inc.
be53a5c4
DF
4 * Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx>
5 *
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.
9 *
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.
17 */
18
19#ifndef _LLDPD_H
20#define _LLDPD_H
21
b2befd5b 22#include <sys/types.h>
be53a5c4 23#include <netinet/in.h>
be53a5c4
DF
24#include <stdlib.h>
25#include <stddef.h>
26#include <string.h>
0477baa9 27#include "dp-packet.h"
b19bab5b 28#include "openvswitch/list.h"
be53a5c4
DF
29#include "lldpd-structs.h"
30#include "lldp-tlv.h"
31#include "packets.h"
32#include "openvswitch/vlog.h"
be53a5c4 33
be53a5c4
DF
34#define ETHERTYPE_LLDP 0x88cc
35
be53a5c4
DF
36#define LLDPD_TX_INTERVAL 5
37#define LLDPD_TX_HOLD 4
ac211bdd 38#define LLDPD_TTL (LLDPD_TX_INTERVAL * LLDPD_TX_HOLD)
be53a5c4 39
0477baa9 40#define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware *,struct dp_packet *
be53a5c4
DF
41#define PROTO_DECODE_SIG struct lldpd *, char *, int, struct lldpd_hardware *,\
42 struct lldpd_chassis **, struct lldpd_port **
43#define PROTO_GUESS_SIG char *, int
44
be53a5c4
DF
45struct protocol {
46 int mode; /* > 0 mode identifier (unique per protocol) */
47 int enabled; /* Is this protocol enabled? */
48 char *name; /* Name of protocol */
49 char arg; /* Argument to enable this protocol */
50 int(*send)(PROTO_SEND_SIG); /* How to send a frame */
51 int(*decode)(PROTO_DECODE_SIG); /* How to decode a frame */
52 int(*guess)(PROTO_GUESS_SIG); /* Can be NULL, use MAC address in this
53 * case
54 */
74ff3298 55 struct eth_addr mac; /* Destination MAC address used by this protocol */
be53a5c4
DF
56};
57
58#define SMART_HIDDEN(port) (port->p_hidden_in)
59
60struct lldpd {
be53a5c4
DF
61 struct lldpd_config g_config;
62 struct protocol *g_protocols;
63 int g_lastrid;
64
e87a8e67 65 struct ovs_list g_chassis; /* Contains "struct lldp_chassis". */
2cbb2d90 66 struct ovs_list g_hardware; /* Contains "struct lldpd_hardware". */
be53a5c4
DF
67};
68
2cbb2d90
BP
69static inline struct lldpd_hardware *
70lldpd_first_hardware(struct lldpd *lldpd)
71{
417e7e66 72 return CONTAINER_OF(ovs_list_front(&lldpd->g_hardware),
2cbb2d90
BP
73 struct lldpd_hardware, h_entries);
74}
75
be53a5c4
DF
76/* lldpd.c */
77struct lldpd_hardware *lldpd_get_hardware(struct lldpd *,
78 char *, int, struct lldpd_ops *);
79struct lldpd_hardware *lldpd_alloc_hardware(struct lldpd *, char *, int);
80void lldpd_hardware_cleanup(struct lldpd*, struct lldpd_hardware *);
81struct lldpd_mgmt *lldpd_alloc_mgmt(int family, void *addr, size_t addrsize,
82 u_int32_t iface);
83void lldpd_recv(struct lldpd *, struct lldpd_hardware *, char *, size_t);
0477baa9 84uint32_t lldpd_send(struct lldpd_hardware *, struct dp_packet *);
be53a5c4
DF
85void lldpd_loop(struct lldpd *);
86
87int lldpd_main(int, char **);
88void lldpd_update_localports(struct lldpd *);
89void lldpd_cleanup(struct lldpd *);
90
91void lldpd_assign_cfg_to_protocols(struct lldpd *);
92
93/* lldp.c */
94int lldp_send(PROTO_SEND_SIG);
95int lldp_decode(PROTO_DECODE_SIG);
96
97#endif /* _LLDPD_H */