RDK-B
bridge_util_hal.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2015 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 * @file bridge_util_hal.h
22 * @brief For Bridge Util Component: Bridge Utils OEM Layer
23 *
24 */
25 
26 /**
27  * @defgroup BRIDGE_UTIL_OEM BRIDGE UTIL OEM
28  *
29  * BRIDGE UTIL OEM is used for the RDK-B Bridge Util OEM abstraction layer.
30  *
31  * @defgroup BRIDGE_UTIL_OEM_DATA_TYPES BRIDGE UTIL OEM Data Types
32  * @ingroup BRIDGE_UTIL_OEM
33  *
34  * @defgroup BRIDGE_UTIL_OEM_APIS BRIDGE UTIL OEM APIs
35  * @ingroup BRIDGE_UTIL_OEM
36  *
37  **/
38 
39 #ifndef _BRIDGE_UTIL_OEM_H
40 #define _BRIDGE_UTIL_OEM_H
41 
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45 #include <unistd.h>
46 #include <stdbool.h>
47 #include <time.h>
48 #include <pthread.h>
49 
50 #include "OvsAgentApi.h"
51 
52 /**
53  * @addtogroup BRIDGE_UTIL_OEM_DATA_TYPES
54  * @{
55  */
56 
57 #define BRIDGE_UTIL_LOG_FNAME "/rdklogs/logs/bridgeUtils.log"
58 
59 #define GRE_HANDLER_SCRIPT "/etc/utopia/service.d/service_multinet/handle_gre.sh"
60 
61 #define TOTAL_IFLIST_SIZE 1024
62 #define BRIDGE_NAME_SIZE 64
63 #define IFACE_NAME_SIZE 64
64 
65 #define IFLIST_SIZE 256
66 #define MAX_LOG_BUFF_SIZE 1024
67 #define TIMESTAMP 64
68 
69 #define INTERFACE_EXIST 0
70 #define INTERFACE_NOT_EXIST -1
71 
72 extern int DeviceMode; // router = 0, bridge = 2
73 
74 extern int MocaIsolation_Val;
75 
76 extern int need_wifi_gw_refresh;
77 extern int need_switch_gw_refresh;
78 extern int syncMembers;
79 extern int BridgeOprInPropgress;
80 extern FILE *logFp;
81 extern char log_buff[MAX_LOG_BUFF_SIZE];
83 extern char primaryBridgeName[64];
84 extern int PORT2ENABLE;
85 extern int ethWanEnabled;
86 extern char ethWanIfaceName[64];
87 
88 extern struct tm *timeinfo;
89 extern time_t utc_time;
90 
91 #define bridge_util_log(fmt ...) {\
92  snprintf(log_buff, MAX_LOG_BUFF_SIZE-1,fmt);\
93  if(logFp != NULL){ \
94  snprintf(log_buff, MAX_LOG_BUFF_SIZE-1,fmt);\
95  utc_time = time(NULL);\
96  timeinfo = gmtime(&utc_time);\
97  snprintf(log_msg_wtime, MAX_LOG_BUFF_SIZE+TIMESTAMP-1,"%04d-%02d-%02d %02d:%02d:%02d ::: %s",timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec,log_buff);\
98  fprintf(logFp,"%s", log_msg_wtime);\
99  fflush(logFp);}\
100  }
101 
102 /**
103  * @enum Config
104  *
105  * @brief List of Configurations for BridgeUtils API's.
106  */
107 enum Config {
118  MESH = 12,
121 };
122 
123 /**
124  * @enum INTERFACE_TYPE
125  *
126  * @brief List of Interface types for BridgeUtils API's.
127  */
136 };
137 
138 /**
139  * @enum BridgeOpr
140  *
141  * @brief BridgeUtils Operations for BridgeUtils API's.
142  */
143 enum BridgeOpr {
146 };
147 
148 typedef struct bridgeDetails {
152  int vlanID;
158 
159 /** @} */ //END OF GROUP BRIDGE_UTIL_OEM_DATA_TYPES
160 
161 /**
162  * @addtogroup BRIDGE_UTIL_OEM_APIS
163  * @{
164  */
165 
166 /* updateBridgeInfo() function */
167 /**
168 * @brief Provides generic changes which needs to be configured after creating/updating/deleting bridge.
169 * @param bridgeDetails *bridgeInfo - Pointer to Bridge information structure.
170 * @param char* ifNameToBeUpdated - Interface to be deleted and updated, applicable only during sync.
171 * @param int Opr - Information about operations whether the request creating/updating/deleting bridge.
172 * @param int type - Interface type, in case of sync delete value is set to unknown/other.
173 * @return The status of the operation.
174 * @retval 0 on success or a negative error code.
175 *
176 */
177 extern int updateBridgeInfo(bridgeDetails *bridgeInfo, char* ifNameToBeUpdated, int Opr , int type);
178 
179 /* checkIfExists() function */
180 /**
181 * @brief Check if interface is created.
182 * @param char* iface_name - Interface name.
183 * @return The status of the operation.
184 * @retval 0 on success or a negative error code.
185 *
186 */
187 extern int checkIfExists(char* iface_name);
188 
189 /* removeIfaceFromList() function */
190 /**
191 * @brief Remove interface from the list of interfaces.
192 * @param char *str - Interface which needs to be removed from list.
193 * @param const char *sub - List of interfaces name.
194 * @return The status of the operation.
195 * @retval void
196 *
197 */
198 extern void removeIfaceFromList(char *str, const char *sub);
199 
200 /* checkIfExistsInBridge() function */
201 /**
202 * @brief Check if interface is attached to bridge.
203 * @param char* iface_name - Interface name.
204 * @param char *bridge_name - Bridge name.
205 * @return The status of the operation.
206 * @retval 0 on success or a negative error code.
207 *
208 */
209 extern int checkIfExistsInBridge(char* iface_name, char *bridge_name);
210 
211 /* HandlePreConfigVendor() function */
212 /**
213 * @brief Provides OEM/SOC specific changes which needs to be configured before creating/updating/deleting bridge.
214 * @param bridgeDetails *bridgeInfo - Pointer to Bridge info structure.
215 * @param int InstanceNumber - Instance number for configuration.
216 * @return The status of the operation.
217 * @retval 0 on success or a negative error code.
218 *
219 */
220 int HandlePreConfigVendor(bridgeDetails *bridgeInfo,int Config);
221 
222 /* HandlePostConfigVendor() function */
223 /**
224 * @brief Provides OEM/SOC specific changes which needs to be configured after creating/updating/deleting bridge.
225 * @param bridgeDetails *bridgeInfo - Pointer to Bridge info structure.
226 * @param int InstanceNumber - Instance number for configuration.
227 * @return The status of the operation.
228 * @retval 0 on success or a negative error code.
229 *
230 */
231 int HandlePostConfigVendor(bridgeDetails *bridgeInfo,int Config);
232 
233 /* getVendorIfaces() function */
234 /**
235 * @brief Provides vendor interface information for creating/updating/deleting bridge.
236 * @param <None>
237 * @return The status of the operation.
238 * @retval vendor interface or NULL.
239 *
240 */
241 char *getVendorIfaces();
242 
243 /** @} */ //END OF BRIDGE_UTIL_OEM_APIS
244 #endif
checkIfExists
int checkIfExists(char *iface_name)
Check if interface is created.
BRIDGE_NAME_SIZE
#define BRIDGE_NAME_SIZE
Definition: bridge_util_hal.h:62
MESH_WIFI_BACKHAUL_5G
@ MESH_WIFI_BACKHAUL_5G
Definition: bridge_util_hal.h:120
CREATE_BRIDGE
@ CREATE_BRIDGE
Definition: bridge_util_hal.h:145
bridgeDetails::MoCAIfList
char MoCAIfList[256]
Definition: bridge_util_hal.h:154
need_switch_gw_refresh
int need_switch_gw_refresh
ethWanEnabled
int ethWanEnabled
HOTSPOT_5G
@ HOTSPOT_5G
Definition: bridge_util_hal.h:111
logFp
FILE * logFp
IF_VLAN_BRIDGEUTIL
@ IF_VLAN_BRIDGEUTIL
Definition: bridge_util_hal.h:130
LOST_N_FOUND
@ LOST_N_FOUND
Definition: bridge_util_hal.h:112
bridgeDetails
Definition: bridge_util_hal.h:148
utc_time
time_t utc_time
bridgeDetails::GreIfList
char GreIfList[256]
Definition: bridge_util_hal.h:155
DELETE_BRIDGE
@ DELETE_BRIDGE
Definition: bridge_util_hal.h:144
BridgeOpr
BridgeOpr
BridgeUtils Operations for BridgeUtils API's.
Definition: bridge_util_hal.h:143
MOCA_ISOLATION
@ MOCA_ISOLATION
Definition: bridge_util_hal.h:115
IF_BRIDGE_BRIDGEUTIL
@ IF_BRIDGE_BRIDGEUTIL
Definition: bridge_util_hal.h:129
HOTSPOT_2G
@ HOTSPOT_2G
Definition: bridge_util_hal.h:110
getVendorIfaces
char * getVendorIfaces()
Provides vendor interface information for creating/updating/deleting bridge.
log_buff
char log_buff[1024]
IF_MOCA_BRIDGEUTIL
@ IF_MOCA_BRIDGEUTIL
Definition: bridge_util_hal.h:132
PRIVATE_LAN
@ PRIVATE_LAN
Definition: bridge_util_hal.h:108
need_wifi_gw_refresh
int need_wifi_gw_refresh
HandlePostConfigVendor
int HandlePostConfigVendor(bridgeDetails *bridgeInfo, int Config)
Provides OEM/SOC specific changes which needs to be configured after creating/updating/deleting bridg...
bridgeDetails
struct bridgeDetails bridgeDetails
ethWanIfaceName
char ethWanIfaceName[64]
PORT2ENABLE
int PORT2ENABLE
bridgeDetails::bridgeName
char bridgeName[64]
Definition: bridge_util_hal.h:149
HOME_SECURITY
@ HOME_SECURITY
Definition: bridge_util_hal.h:109
bridgeDetails::ethIfList
char ethIfList[256]
Definition: bridge_util_hal.h:153
MESH_BACKHAUL
@ MESH_BACKHAUL
Definition: bridge_util_hal.h:116
IF_GRE_BRIDGEUTIL
@ IF_GRE_BRIDGEUTIL
Definition: bridge_util_hal.h:131
Config
Config
List of Configurations for BridgeUtils API's.
Definition: bridge_util_hal.h:107
MESH_WIFI_BACKHAUL_2G
@ MESH_WIFI_BACKHAUL_2G
Definition: bridge_util_hal.h:119
bridgeDetails::VirtualParentIfname
char VirtualParentIfname[64]
Definition: bridge_util_hal.h:151
IFLIST_SIZE
#define IFLIST_SIZE
Definition: bridge_util_hal.h:65
IF_OTHER_BRIDGEUTIL
@ IF_OTHER_BRIDGEUTIL
Definition: bridge_util_hal.h:135
IF_ETH_BRIDGEUTIL
@ IF_ETH_BRIDGEUTIL
Definition: bridge_util_hal.h:134
MESH
@ MESH
Definition: bridge_util_hal.h:118
checkIfExistsInBridge
int checkIfExistsInBridge(char *iface_name, char *bridge_name)
Check if interface is attached to bridge.
HOTSPOT_SECURE_5G
@ HOTSPOT_SECURE_5G
Definition: bridge_util_hal.h:114
updateBridgeInfo
int updateBridgeInfo(bridgeDetails *bridgeInfo, char *ifNameToBeUpdated, int Opr, int type)
Provides generic changes which needs to be configured after creating/updating/deleting bridge.
bridgeDetails::WiFiIfList
char WiFiIfList[256]
Definition: bridge_util_hal.h:156
log_msg_wtime
char log_msg_wtime[1024+64]
ETH_BACKHAUL
@ ETH_BACKHAUL
Definition: bridge_util_hal.h:117
HandlePreConfigVendor
int HandlePreConfigVendor(bridgeDetails *bridgeInfo, int Config)
Provides OEM/SOC specific changes which needs to be configured before creating/updating/deleting brid...
removeIfaceFromList
void removeIfaceFromList(char *str, const char *sub)
Remove interface from the list of interfaces.
primaryBridgeName
char primaryBridgeName[64]
MocaIsolation_Val
int MocaIsolation_Val
IF_WIFI_BRIDGEUTIL
@ IF_WIFI_BRIDGEUTIL
Definition: bridge_util_hal.h:133
INTERFACE_TYPE
INTERFACE_TYPE
List of Interface types for BridgeUtils API's.
Definition: bridge_util_hal.h:128
MAX_LOG_BUFF_SIZE
#define MAX_LOG_BUFF_SIZE
Definition: bridge_util_hal.h:66
syncMembers
int syncMembers
bridgeDetails::vlan_name
char vlan_name[64]
Definition: bridge_util_hal.h:150
timeinfo
struct tm * timeinfo
TIMESTAMP
#define TIMESTAMP
Definition: bridge_util_hal.h:67
HOTSPOT_SECURE_2G
@ HOTSPOT_SECURE_2G
Definition: bridge_util_hal.h:113
BridgeOprInPropgress
int BridgeOprInPropgress
DeviceMode
int DeviceMode
bridgeDetails::vlanID
int vlanID
Definition: bridge_util_hal.h:152