]> git.proxmox.com Git - mirror_ovs.git/blame - lib/ovs-lldp.h
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / lib / ovs-lldp.h
CommitLineData
be53a5c4 1/*
72c642e5 2 * Copyright (c) 2015 Nicira, Inc.
be53a5c4
DF
3 * Copyright (c) 2014 Wind River Systems, Inc.
4 * Copyright (c) 2015 Avaya, Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef OVS_LLDP_H
20#define OVS_LLDP_H
21
22#include <stdint.h>
0477baa9 23#include "dp-packet.h"
ee89ea7b 24#include "openvswitch/hmap.h"
b19bab5b 25#include "openvswitch/list.h"
be53a5c4 26#include "lldp/lldpd.h"
5617ae6a 27#include "ovs-atomic.h"
be53a5c4
DF
28#include "packets.h"
29#include "timer.h"
30
31/* Transmit every LLDPD_TX_INTERVAL seconds. */
ac211bdd 32#define LLDP_DEFAULT_TRANSMIT_INTERVAL_MS (LLDPD_TX_INTERVAL * 1000)
be53a5c4 33
be53a5c4
DF
34struct flow;
35struct netdev;
36struct smap;
37
be53a5c4
DF
38/* Structure per LLDP instance (at the moment per port when enabled).
39 */
40struct lldp {
41 struct hmap_node hmap_node; /* Node in all_lldps list. */
42 struct lldpd *lldpd;
43 char *name; /* Name of the port. */
44 struct timer tx_timer; /* Send LLDP when expired. */
45 struct hmap mappings_by_isid; /* "struct" indexed by ISID */
46 struct hmap mappings_by_aux; /* "struct" indexed by aux */
47 struct ovs_list active_mapping_queue;
48 struct ovs_refcount ref_cnt;
19aef6ef 49 bool enabled; /* LLDP enabled on port */
be53a5c4
DF
50};
51
52/* Configuration specific to Auto Attach.
53 */
54struct aa_settings {
55 char *system_description;
56 char *system_name;
57};
58
59/* Configuration of Auto Attach mappings.
60 */
61struct aa_mapping_settings {
72c642e5
BP
62 uint32_t isid;
63 uint16_t vlan;
be53a5c4
DF
64};
65
66enum bridge_aa_vlan_oper {
67 BRIDGE_AA_VLAN_OPER_UNDEF,
68 BRIDGE_AA_VLAN_OPER_ADD,
69 BRIDGE_AA_VLAN_OPER_REMOVE
70};
71
72/* Bridge Auto Attach operations. Mostly for adding/removing VLAN on
73 * the trunk port connected to the Auto Attach server.
74 */
75struct bridge_aa_vlan {
76 struct ovs_list list_node;
77 char *port_name;
72c642e5 78 uint16_t vlan;
be53a5c4
DF
79 enum bridge_aa_vlan_oper oper;
80};
81
82void lldp_init(void);
83long long int lldp_wait(struct lldp *lldp);
84long long int lldp_wake_time(const struct lldp *lldp);
85void lldp_run(struct lldpd *cfg);
86bool lldp_should_send_packet(struct lldp *cfg);
19aef6ef
DF
87bool lldp_should_process_flow(struct lldp *lldp, const struct flow *flow);
88bool lldp_configure(struct lldp *lldp, const struct smap *cfg);
0477baa9
DF
89void lldp_process_packet(struct lldp *cfg, const struct dp_packet *);
90void lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
74ff3298 91 const struct eth_addr eth_src);
be53a5c4
DF
92void lldpd_assign_cfg_to_protocols(struct lldpd *cfg);
93struct lldp * lldp_create(const struct netdev *netdev, const uint32_t mtu,
94 const struct smap *cfg);
95struct lldp * lldp_ref(const struct lldp *lldp_);
96void lldp_unref(struct lldp *lldp);
97
98int aa_get_vlan_queued(struct ovs_list *list);
99unsigned int aa_get_vlan_queue_size(void);
100int aa_configure(const struct aa_settings *s);
101int aa_mapping_register(void *aux, const struct aa_mapping_settings *s);
102int aa_mapping_unregister(void *aux);
103
104/* Used by unit tests */
105struct lldp * lldp_create_dummy(void);
9547cc66 106void lldp_destroy_dummy(struct lldp *);
be53a5c4
DF
107
108#endif /* OVS_LLDP_H */