auto-attach: Add auto-attach support to ofproto layer
[cascardo/ovs.git] / lib / ovs-lldp.h
1 /*
2  * Copyright (c) 2014 Wind River Systems, Inc.
3  * Copyright (c) 2015 Avaya, Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef OVS_LLDP_H
19 #define OVS_LLDP_H
20
21 #include <stdint.h>
22 #include "dp-packet.h"
23 #include "hmap.h"
24 #include "list.h"
25 #include "lldp/lldpd.h"
26 #include "ovsdb-data.h"
27 #include "ovs-thread.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_wildcards;
35 struct flow;
36 struct netdev;
37 struct smap;
38
39 struct lldp_status {
40     /* TODO should reflect lldp stack detail */
41     char *stackdetail; /* Added because MSVC doesn't like empty structs */
42 };
43
44 /* Structure per LLDP instance (at the moment per port when enabled).
45  */
46 struct lldp {
47     struct hmap_node    hmap_node;        /* Node in all_lldps list. */
48     struct lldpd        *lldpd;
49     char                *name;            /* Name of the port. */
50     struct timer        tx_timer;         /* Send LLDP when expired. */
51     struct hmap         mappings_by_isid; /* "struct" indexed by ISID */
52     struct hmap         mappings_by_aux;  /* "struct" indexed by aux */
53     struct ovs_list     active_mapping_queue;
54     struct ovs_refcount ref_cnt;
55 };
56
57 /* Configuration specific to Auto Attach.
58  */
59 struct aa_settings {
60     char *system_description;
61     char *system_name;
62 };
63
64 /* Configuration of Auto Attach mappings.
65  */
66 struct aa_mapping_settings {
67     int64_t isid;
68     int64_t vlan;
69 };
70
71 enum bridge_aa_vlan_oper {
72    BRIDGE_AA_VLAN_OPER_UNDEF,
73    BRIDGE_AA_VLAN_OPER_ADD,
74    BRIDGE_AA_VLAN_OPER_REMOVE
75 };
76
77 /* Bridge Auto Attach operations.  Mostly for adding/removing VLAN on
78  * the trunk port connected to the Auto Attach server.
79  */
80 struct bridge_aa_vlan {
81     struct ovs_list list_node;
82     char *port_name;
83     uint32_t vlan;
84     enum bridge_aa_vlan_oper oper;
85 };
86
87 void lldp_init(void);
88 long long int lldp_wait(struct lldp *lldp);
89 long long int lldp_wake_time(const struct lldp *lldp);
90 void lldp_run(struct lldpd *cfg);
91 bool lldp_should_send_packet(struct lldp *cfg);
92 bool lldp_should_process_flow(const struct flow *flow);
93 bool lldp_configure(struct lldp *lldp);
94 void lldp_process_packet(struct lldp *cfg, const struct dp_packet *);
95 void lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
96                      uint8_t eth_src[ETH_ADDR_LEN]);
97 void lldpd_assign_cfg_to_protocols(struct lldpd *cfg);
98 struct lldp * lldp_create(const struct netdev *netdev, const uint32_t mtu,
99                           const struct smap *cfg);
100 struct lldp * lldp_ref(const struct lldp *lldp_);
101 void lldp_unref(struct lldp *lldp);
102
103 int aa_get_vlan_queued(struct ovs_list *list);
104 unsigned int aa_get_vlan_queue_size(void);
105 int aa_configure(const struct aa_settings *s);
106 int aa_mapping_register(void *aux, const struct aa_mapping_settings *s);
107 int aa_mapping_unregister(void *aux);
108
109 /* Used by unit tests */
110 struct lldp * lldp_create_dummy(void);
111
112 #endif /* OVS_LLDP_H */