Skip to content

Commit 10e21c8

Browse files
committed
Add stub for service bridge
Added the stub for a new service, that will have the functionalities of a L2 Bridge. Features: - VLAN support - Per-VLAN Spanning Tree Protocol configuration Characteristics of the datamodel: - For VLAN, each port has two containers, to manage Access/Trunk mode. - For STP, there are two lists: one at root level and one at Ports level. Each node of the lists manages a particular instance of STP. The configuration of each instance / port will be done using an external library Signed-off-by: Gianluca Scopelliti <gianlu.1033@gmail.com>
1 parent f47bc29 commit 10e21c8

66 files changed

Lines changed: 9940 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
6+
.swagger-codegen-ignore
7+
8+
src/*.cpp
9+
src/*.h
10+
11+
!src/*Interface.h
12+
!src/*JsonObject.h
13+
!src/*JsonObject.cpp
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake_minimum_required (VERSION 3.2)
2+
3+
set (CMAKE_CXX_STANDARD 11)
4+
5+
add_subdirectory(src)
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
module bridge {
2+
yang-version 1.1;
3+
namespace "http://polycube.network/bridge";
4+
prefix "bridge";
5+
6+
import polycube-base { prefix "polycube-base"; }
7+
import polycube-standard-base { prefix "polycube-standard-base"; }
8+
9+
import ietf-yang-types { prefix "yang"; }
10+
11+
organization "Polycube open source project";
12+
description "YANG data model for the Polycube L2 bridge";
13+
14+
polycube-base:service-description "L2 Bridge Service";
15+
polycube-base:service-version "1.0.0";
16+
polycube-base:service-name "bridge";
17+
polycube-base:service-min-kernel-version "4.11.0";
18+
19+
uses "polycube-standard-base:standard-base-yang-module" {
20+
augment ports {
21+
leaf mac {
22+
type yang:mac-address;
23+
description "MAC address of the port";
24+
config true;
25+
polycube-base:init-only-config;
26+
polycube-base:cli-example "C5:13:2D:36:27:9B";
27+
}
28+
29+
leaf mode {
30+
type enumeration {
31+
enum access;
32+
enum trunk;
33+
}
34+
default access;
35+
description "Type of bridge interface: access/trunk";
36+
polycube-base:cli-example "access";
37+
}
38+
39+
container access {
40+
description "vlan associated to a port in access mode";
41+
leaf vlanid {
42+
type uint16;
43+
default 1;
44+
description "VLAN associated with this interface";
45+
polycube-base:cli-example "1";
46+
}
47+
}
48+
49+
container trunk {
50+
list allowed {
51+
description "Allowed vlans";
52+
key "vlanid";
53+
leaf vlanid {
54+
type uint16;
55+
description "Allowed vlan";
56+
polycube-base:cli-example "1";
57+
}
58+
}
59+
60+
leaf native-vlan-enabled {
61+
type boolean;
62+
default true;
63+
description "Enable/Disable the native vlan feature in this trunk port";
64+
polycube-base:cli-example "true";
65+
}
66+
67+
leaf native-vlan {
68+
type uint16;
69+
default 1;
70+
description "VLAN that is not tagged in this trunk port";
71+
polycube-base:cli-example "1";
72+
}
73+
}
74+
75+
list stp {
76+
key "vlan";
77+
description "Per-vlan Spanning Tree Protocol Port Configuration";
78+
leaf vlan {
79+
type uint16;
80+
mandatory true;
81+
description "VLAN identifier for this entry";
82+
polycube-base:cli-example "1";
83+
}
84+
85+
leaf state {
86+
type enumeration {
87+
enum disabled;
88+
enum blocking;
89+
enum listening;
90+
enum learning;
91+
enum forwarding;
92+
}
93+
description "STP port state";
94+
config false;
95+
}
96+
97+
leaf path-cost {
98+
type uint32;
99+
default 4;
100+
description "STP cost associated with this interface";
101+
polycube-base:cli-example "19";
102+
}
103+
104+
leaf port-priority {
105+
type uint8;
106+
default 128;
107+
description "Port priority of this interface";
108+
polycube-base:cli-example "128";
109+
}
110+
}
111+
112+
}
113+
}
114+
115+
container fdb {
116+
leaf aging-time {
117+
type uint32;
118+
units seconds;
119+
default 300;
120+
description "Aging time of the filtering database (in seconds)";
121+
polycube-base:cli-example "300";
122+
}
123+
124+
list entry {
125+
key "vlan mac";
126+
description "Entry associated with the filtering database";
127+
128+
leaf vlan {
129+
type uint16;
130+
mandatory true;
131+
description "VLAN identifier";
132+
polycube-base:cli-example "1";
133+
}
134+
135+
leaf mac {
136+
type yang:mac-address;
137+
mandatory true;
138+
description "MAC address of the filtering database entry";
139+
polycube-base:cli-example "C5:13:2D:36:27:9B";
140+
}
141+
142+
leaf type {
143+
type enumeration {
144+
enum static;
145+
enum dynamic;
146+
}
147+
default static;
148+
description "Type of filtering entry";
149+
config false;
150+
polycube-base:cli-example "static | dynamic";
151+
}
152+
153+
leaf port {
154+
type string;
155+
mandatory true;
156+
description "Output port name";
157+
polycube-base:cli-example "port2";
158+
}
159+
160+
leaf age {
161+
type uint32;
162+
units seconds;
163+
description "Age of the current filtering database entry";
164+
config false;
165+
}
166+
}
167+
168+
action flush {
169+
description "Flushes the filtering database of the bridge";
170+
}
171+
}
172+
173+
leaf stp-enabled {
174+
type boolean;
175+
default false;
176+
description "Enable/Disable the STP protocol of the bridge";
177+
polycube-base:cli-example "false";
178+
}
179+
180+
leaf mac {
181+
type yang:mac-address;
182+
description "Main MAC address of the bridge used by the STP";
183+
polycube-base:cli-example "C5:13:2D:36:27:9B";
184+
}
185+
186+
list stp {
187+
key "vlan";
188+
description "Per-vlan Spanning Tree Protocol Configuration";
189+
leaf vlan {
190+
type uint16;
191+
mandatory true;
192+
description "VLAN identifier for this entry";
193+
polycube-base:cli-example "1";
194+
}
195+
196+
leaf priority {
197+
type uint16;
198+
default 32768;
199+
description "Bridge priority for STP";
200+
polycube-base:cli-example "32768";
201+
}
202+
203+
leaf forward-delay {
204+
type uint32;
205+
units seconds;
206+
default 10;
207+
description "Delay used by STP bridges for port state transition";
208+
polycube-base:cli-example "10";
209+
}
210+
211+
leaf hello-time {
212+
type uint32;
213+
units seconds;
214+
default 2;
215+
description "Interval between transmissions of BPDU messages";
216+
polycube-base:cli-example "2";
217+
}
218+
219+
leaf max-message-age {
220+
type uint32;
221+
units seconds;
222+
default 20;
223+
description "Maximum age of a BPDU";
224+
polycube-base:cli-example "20";
225+
}
226+
}
227+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* bridge API generated from bridge.yang
3+
*
4+
* NOTE: This file is auto generated by polycube-codegen
5+
* https://github.com/polycube-network/polycube-codegen
6+
*/
7+
8+
9+
/* Do not edit this file manually */
10+
11+
#include "api/BridgeApiImpl.h"
12+
#include "../datamodel/bridge.h" // generated from datamodel
13+
14+
#define SERVICE_PYANG_GIT ""
15+
#define SERVICE_SWAGGER_CODEGEN_GIT "GIT_REPO_ID"
16+
17+
#include <polycube/services/shared_library.h>
18+
19+
extern "C" const char *data_model() {
20+
return bridge_datamodel.c_str();
21+
}

0 commit comments

Comments
 (0)