2 * Copyright (c) 2015 Nicira, Inc.
3 * Copyright (c) 2014 Wind River Systems, Inc.
4 * Copyright (c) 2015 Avaya, Inc.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include "dp-packet.h"
24 #include "openvswitch/hmap.h"
25 #include "openvswitch/list.h"
26 #include "lldp/lldpd.h"
27 #include "ovs-atomic.h"
31 /* Transmit every LLDPD_TX_INTERVAL seconds. */
32 #define LLDP_DEFAULT_TRANSMIT_INTERVAL_MS (LLDPD_TX_INTERVAL * 1000)
38 /* Structure per LLDP instance (at the moment per port when enabled).
41 struct hmap_node hmap_node
; /* Node in all_lldps list. */
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
;
49 bool enabled
; /* LLDP enabled on port */
52 /* Configuration specific to Auto Attach.
55 char *system_description
;
59 /* Configuration of Auto Attach mappings.
61 struct aa_mapping_settings
{
66 enum bridge_aa_vlan_oper
{
67 BRIDGE_AA_VLAN_OPER_UNDEF
,
68 BRIDGE_AA_VLAN_OPER_ADD
,
69 BRIDGE_AA_VLAN_OPER_REMOVE
72 /* Bridge Auto Attach operations. Mostly for adding/removing VLAN on
73 * the trunk port connected to the Auto Attach server.
75 struct bridge_aa_vlan
{
76 struct ovs_list list_node
;
79 enum bridge_aa_vlan_oper oper
;
83 long long int lldp_wait(struct lldp
*lldp
);
84 long long int lldp_wake_time(const struct lldp
*lldp
);
85 void lldp_run(struct lldpd
*cfg
);
86 bool lldp_should_send_packet(struct lldp
*cfg
);
87 bool lldp_should_process_flow(struct lldp
*lldp
, const struct flow
*flow
);
88 bool lldp_configure(struct lldp
*lldp
, const struct smap
*cfg
);
89 void lldp_process_packet(struct lldp
*cfg
, const struct dp_packet
*);
90 void lldp_put_packet(struct lldp
*lldp
, struct dp_packet
*packet
,
91 const struct eth_addr eth_src
);
92 void lldpd_assign_cfg_to_protocols(struct lldpd
*cfg
);
93 struct lldp
* lldp_create(const struct netdev
*netdev
, const uint32_t mtu
,
94 const struct smap
*cfg
);
95 struct lldp
* lldp_ref(const struct lldp
*lldp_
);
96 void lldp_unref(struct lldp
*lldp
);
98 int aa_get_vlan_queued(struct ovs_list
*list
);
99 unsigned int aa_get_vlan_queue_size(void);
100 int aa_configure(const struct aa_settings
*s
);
101 int aa_mapping_register(void *aux
, const struct aa_mapping_settings
*s
);
102 int aa_mapping_unregister(void *aux
);
104 /* Used by unit tests */
105 struct lldp
* lldp_create_dummy(void);
106 void lldp_destroy_dummy(struct lldp
*);
108 #endif /* OVS_LLDP_H */