ovn-nbctl: Print empty string for non-existent external-id.
[cascardo/ovs.git] / lib / ovs-lldp.h
1 /*
2  * Copyright (c) 2015 Nicira, Inc.
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>
23 #include "dp-packet.h"
24 #include "hmap.h"
25 #include "list.h"
26 #include "lldp/lldpd.h"
27 #include "ovs-atomic.h"
28 #include "packets.h"
29 #include "timer.h"
30
31 /* Transmit every LLDPD_TX_INTERVAL seconds. */
32 #define LLDP_DEFAULT_TRANSMIT_INTERVAL_MS (LLDPD_TX_INTERVAL * 1000)
33
34 struct flow;
35 struct netdev;
36 struct smap;
37
38 /* Structure per LLDP instance (at the moment per port when enabled).
39  */
40 struct 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;
49 };
50
51 /* Configuration specific to Auto Attach.
52  */
53 struct aa_settings {
54     char *system_description;
55     char *system_name;
56 };
57
58 /* Configuration of Auto Attach mappings.
59  */
60 struct aa_mapping_settings {
61     uint32_t isid;
62     uint16_t vlan;
63 };
64
65 enum bridge_aa_vlan_oper {
66    BRIDGE_AA_VLAN_OPER_UNDEF,
67    BRIDGE_AA_VLAN_OPER_ADD,
68    BRIDGE_AA_VLAN_OPER_REMOVE
69 };
70
71 /* Bridge Auto Attach operations.  Mostly for adding/removing VLAN on
72  * the trunk port connected to the Auto Attach server.
73  */
74 struct bridge_aa_vlan {
75     struct ovs_list list_node;
76     char *port_name;
77     uint16_t vlan;
78     enum bridge_aa_vlan_oper oper;
79 };
80
81 void lldp_init(void);
82 long long int lldp_wait(struct lldp *lldp);
83 long long int lldp_wake_time(const struct lldp *lldp);
84 void lldp_run(struct lldpd *cfg);
85 bool lldp_should_send_packet(struct lldp *cfg);
86 bool lldp_should_process_flow(const struct flow *flow);
87 bool lldp_configure(struct lldp *lldp);
88 void lldp_process_packet(struct lldp *cfg, const struct dp_packet *);
89 void lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
90                      uint8_t eth_src[ETH_ADDR_LEN]);
91 void lldpd_assign_cfg_to_protocols(struct lldpd *cfg);
92 struct lldp * lldp_create(const struct netdev *netdev, const uint32_t mtu,
93                           const struct smap *cfg);
94 struct lldp * lldp_ref(const struct lldp *lldp_);
95 void lldp_unref(struct lldp *lldp);
96
97 int aa_get_vlan_queued(struct ovs_list *list);
98 unsigned int aa_get_vlan_queue_size(void);
99 int aa_configure(const struct aa_settings *s);
100 int aa_mapping_register(void *aux, const struct aa_mapping_settings *s);
101 int aa_mapping_unregister(void *aux);
102
103 /* Used by unit tests */
104 struct lldp * lldp_create_dummy(void);
105
106 #endif /* OVS_LLDP_H */