RDK-B
vlan_hal_emu.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's LICENSE file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**********************************************************************
21 
22  module: vlan_hal.h
23 
24  For CCSP Component: VLAN_Provisioning_and_management
25 
26  ---------------------------------------------------------------
27 
28  description:
29 
30  This header file gives the function call prototypes and
31  structure definitions used for the RDK-Broadband
32  VLAN abstraction layer
33 
34  ---------------------------------------------------------------
35 
36  environment:
37 
38  This HAL layer is intended to support VLAN drivers
39  through the System Calls.
40 
41  ---------------------------------------------------------------
42 
43  author:
44 
45  zhicheng_qiu@cable.comcast.com
46 
47 **********************************************************************/
48 
49 #ifndef __VLAN_HAL_H__
50 #define __VLAN_HAL_H__
51 
52 #include <stdio.h>
53 #include <stdlib.h>
54 #include <string.h>
55 
56 #ifndef ULONG
57 #define ULONG unsigned long
58 #endif
59 
60 #ifndef BOOL
61 #define BOOL unsigned char
62 #endif
63 
64 #ifndef CHAR
65 #define CHAR char
66 #endif
67 
68 #ifndef UCHAR
69 #define UCHAR unsigned char
70 #endif
71 
72 #ifndef INT
73 #define INT int
74 #endif
75 
76 #ifndef UINT
77 #define UINT unsigned int
78 #endif
79 
80 #ifndef TRUE
81 #define TRUE 1
82 #endif
83 
84 #ifndef FALSE
85 #define FALSE 0
86 #endif
87 
88 #ifndef ENABLE
89 #define ENABLE 1
90 #endif
91 
92 #ifndef RETURN_OK
93 #define RETURN_OK 0
94 #endif
95 
96 #ifndef RETURN_ERR
97 #define RETURN_ERR -1
98 #endif
99 
100 //defines for HAL version 1.0
101 #define VLAN_HAL_MAJOR_VERSION 1 // This is the major verion of this HAL.
102 #define VLAN_HAL_MINOR_VERSION 0 // This is the minor verson of the HAL.
103 #define VLAN_HAL_MAINTENANCE_VERSION 1 // This is the maintenance version of the HAL.
104 
105 //defines for charecter length for VLAN configurartion
106 #define VLAN_HAL_MAX_VLANGROUP_TEXT_LENGTH 32
107 #define VLAN_HAL_MAX_VLANID_TEXT_LENGTH 32
108 #define VLAN_HAL_MAX_INTERFACE_NAME_TEXT_LENGTH 32
109 
110 #define VLAN_HAL_MAX_LINE_BUFFER_LENGTH 120
111 
112 /**********************************************************************
113  ENUMERATION DEFINITIONS
114 **********************************************************************/
115 
116 /**********************************************************************
117  STRUCTURE DEFINITIONS
118 **********************************************************************/
119 
120 // Structure for VLANID Maintainance
121 typedef struct _vlan_vlanidconfiguration
122 {
126 
128 
129 //Structure for InterfaceName Maintainance
130 struct InterfaceDetails //LNT_EMU
131 {
132  char InterfaceName[10];
133 }INF[10];
134 
135 /**********************************************************************
136  *
137  * VLAN HAL function prototypes
138  *
139 ***********************************************************************/
140 
141 //This HAL is used to creat an new vlan group, and assig default vlanID.
142 // If success, return 0
143 // If group is already exist and has expected vlanID, this HAL return 0
144 int vlan_hal_addGroup(const char *groupName,const char *vlanID);
145 //int vlan_hal_addGroup(const char *groupName);
146 
147 //This HAL is used to delete existing vlan group, and delete correspond interface association.
148 // If success, return 0
149 // If group is not exist, return 0,
150 int vlan_hal_delGroup(const char *groupName);
151 
152 //This HAL is used to add interface to existing vlan group, and assign the vlanID.
153 // If success, return 0
154 // If group is not exist, return -1
155 // If interface is already in group, and has expected vlan ID, return 0
156 int vlan_hal_addInterface(const char *groupName, const char *ifName,const char *vlanID);
157 
158 //This HAL is used to deassociate existing interface from group.
159 // If success, return 0
160 // If interface is not exist, return 0,
161 int vlan_hal_delInterface(const char *groupName, const char *ifName,const char *vlanID);
162 
163 //This HAL is used dump the group setting, for debug purpose
164 int vlan_hal_printGroup(const char *groupName);
165 //This HAL is used dump all group setting.
167 
168 //This HAL is used to deassociate all existing interface from group.
169 int vlan_hal_delete_all_Interfaces(const char *groupName);
170 
171 //This HAL utility is used identify given bridge available in linux bridge
172 int _is_this_group_available_in_ovs_bridge(char * br_name);
173 
174 //This HAL utility is used identify given interface available in given bridge
175 int _is_this_interface_available_in_ovs_bridge(const char *groupName,char * if_name);
176 
177 //This HAL utility is used identify given interface available in anyone of linux bridge
178 int _is_this_interface_available_in_given_ovs_bridge(char * if_name, char * br_name);
179 
180 //This HAL utility is used get the buffer from shell output
181 void _get_shell_outputbuffer(char * cmd, char * out, int len);
182 
183 //This HAL utility is used store the VLAN ID, Group Name configuration
184 int insert_VLAN_ConfigEntry(char *groupName, char *vlanID);
185 
186 //This HAL utility is used delete the VLAN ID, Group Name configuration
187 int delete_VLAN_ConfigEntry(char *groupName);
188 
189 //This HAL utility is used delete the VLAN ID, Group Name configuration from link
190 int get_vlanId_for_GroupName(const char *groupName, char *vlanID);
191 
192 //This HAL utility is used get the VLAN ID for corresponding Group Name from link
194 
195 //This HAL utility is used get the Interface Names
196 int GetInterfaceName();//LNT_EMU
197 
198 
199 /*
200 Example usage on Puma6 platfom:
201  Private network group (vlan100)
202  brlan0 eth_1(external swith port 1), eth_2(port 2), eth_3(port 3), MoCA.100 (MoCA vlan100), ath0(2.4G vlan100), ath1 (5G vlan100)
203 
204 vlan_hal_addGroup("brlan0", "100"); //brctl addbr brlan0
205 vlan_hal_addInterface("brlan0", "l2sd0", NULL); //vconfig add l2sd0 100; brctl addif brlan0 l2sd0.100
206 
207 
208  Xfinity Home VLAN (vlan101)
209  brlan1 eth_4(port 4), MoCA.101(MoCA vlan101), ath2(2.4G vlan101), ath3 (5G vlan101)
210 
211 vlan_hal_addGroup("brlan1", "101"); //brctl addbr brlan1
212 vlan_hal_addInterface("brlan1", "l2sd0", NULL); //vconfig add l2sd0 100; brctl addif brlan1 l2sd0.101
213 
214 
215  Xfinity Wifi VLAN 2.4G (vlan102)
216  brlan2 gretap0.102 (GRE vlan102), MoCA.102(MoCA vlan102), ath4(2.4G vlan102)
217 
218 vlan_hal_addGroup("brlan2", "102"); //brctl addbr brlan2
219 vlan_hal_addInterface("brlan2", "l2sd0", NULL); //vconfig add l2sd0 102; brctl addif brlan1 l2sd0.102
220 vlan_hal_addInterface("brlan2", "gretap0", NULL); //vconfig add gretap0 102; brctl addif brlan1 gretap0.102
221 
222 
223  Xfinity Wifi VLAN 5G (vlan103)
224  brlan3 gretap0.103 (GRE vlan103), MoCA.103(MoCA vlan103), ath5(2.4G vlan103)
225 
226 vlan_hal_addGroup("brlan3", "103"); //brctl addbr brlan3
227 vlan_hal_addInterface("brlan3", "l2sd0", NULL); //vconfig add l2sd0 103; brctl addif brlan1 l2sd0.103
228 vlan_hal_addInterface("brlan3", "gretap0", NULL); //vconfig add gretap0 103; brctl addif brlan1 gretap0.103
229 
230 */
231 #endif /*__VLAN_HAL_H__*/
_vlan_vlanidconfiguration::groupName
char groupName[32]
Definition: vlan_hal.h:154
vlan_hal_printAllGroup
int vlan_hal_printAllGroup()
vlan_hal_delInterface
int vlan_hal_delInterface(const char *groupName, const char *ifName, const char *vlanID)
vlan_hal_delGroup
int vlan_hal_delGroup(const char *groupName)
VLAN_HAL_MAX_VLANGROUP_TEXT_LENGTH
#define VLAN_HAL_MAX_VLANGROUP_TEXT_LENGTH
Definition: vlan_hal_emu.h:106
insert_VLAN_ConfigEntry
int insert_VLAN_ConfigEntry(char *groupName, char *vlanID)
_vlan_vlanidconfiguration
Definition: vlan_hal.h:148
delete_VLAN_ConfigEntry
int delete_VLAN_ConfigEntry(char *groupName)
vlan_hal_printGroup
int vlan_hal_printGroup(const char *groupName)
print_all_vlanId_Configuration
int print_all_vlanId_Configuration(void)
vlan_hal_addInterface
int vlan_hal_addInterface(const char *groupName, const char *ifName, const char *vlanID)
_vlan_vlanidconfiguration::nextlink
struct _vlan_vlanidconfiguration * nextlink
Definition: vlan_hal.h:156
_get_shell_outputbuffer
void _get_shell_outputbuffer(char *cmd, char *out, int len)
vlan_vlanidconfiguration_t
struct _vlan_vlanidconfiguration vlan_vlanidconfiguration_t
VLAN_HAL_MAX_VLANID_TEXT_LENGTH
#define VLAN_HAL_MAX_VLANID_TEXT_LENGTH
Definition: vlan_hal_emu.h:107
vlan_hal_addGroup
int vlan_hal_addGroup(const char *groupName, const char *vlanID)
_is_this_group_available_in_ovs_bridge
int _is_this_group_available_in_ovs_bridge(char *br_name)
GetInterfaceName
int GetInterfaceName()
INF
struct InterfaceDetails INF[10]
vlan_hal_delete_all_Interfaces
int vlan_hal_delete_all_Interfaces(const char *groupName)
InterfaceDetails::InterfaceName
char InterfaceName[10]
Definition: vlan_hal_emu.h:132
_vlan_vlanidconfiguration::vlanID
char vlanID[32]
Definition: vlan_hal.h:155
_is_this_interface_available_in_given_ovs_bridge
int _is_this_interface_available_in_given_ovs_bridge(char *if_name, char *br_name)
get_vlanId_for_GroupName
int get_vlanId_for_GroupName(const char *groupName, char *vlanID)
InterfaceDetails
Definition: vlan_hal_emu.h:130
_is_this_interface_available_in_ovs_bridge
int _is_this_interface_available_in_ovs_bridge(const char *groupName, char *if_name)