RDK Documentation (Open Sourced RDK Components)
Device_InterfaceStack.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 2016 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 Device_InterfaceStack.h
22  * @brief The header file provides TR069 device interface stack information APIs.
23  */
24 
25 /**
26  * @defgroup TR69_HOSTIF_INTERFACESTACK_INTERFACE TR-069 Object (Device.InterfaceStack.{i})
27  * The Device.InterfaceStack table contains information about the relationships between
28  * the multiple layers of interface objects. In particular, it contains information on
29  * which interfaces run on top of which other interfaces.
30  *
31  * This table is auto-generated by the CPE based on the LowerLayers parameters on
32  * individual interface objects.
33  *
34  * Each table row represents a "link" between two interface objects, a higher-layer
35  * interface object (referenced by HigherLayer) and a lower-layer interface object
36  * (referenced by LowerLayer). Consequently, if a referenced interface object is
37  * deleted, the CPE MUST delete the corresponding InterfaceStack row(s) that had
38  * referenced it.
39  *
40  * @note At most one entry in this table can exist with the same values for
41  * HigherLayer and LowerLayer.
42  *
43  * @ingroup TR69_HOSTIF_PROFILE
44  *
45  * @defgroup TR69_HOSTIF_INTERFACESTACK_INTERFACE_API TR-069 Object (Device.InterfaceStack.{i}) Public APIs
46  * Describe the details about TR-069 Device interface stack APIs specifications.
47  * @ingroup TR69_HOSTIF_INTERFACESTACK_INTERFACE
48  *
49  * @defgroup TR69_HOSTIF_INTERFACESTACK_INTERFACE_CLASSES TR-069 Object (Device.InterfaceStack.{i}) Public Classes
50  * Describe the details about classes used in TR069 Device interface stack.
51  * @ingroup TR69_HOSTIF_INTERFACESTACK_INTERFACE
52  *
53  * @defgroup TR69_HOSTIF_INTERFACESTACK_INTERFACE_DSSTRUCT TR-069 Object (Device.InterfaceStack.{i}) Public DataStructure
54  * Describe the details about structure used in TR069 Device interface stack.
55  * @ingroup TR69_HOSTIF_INTERFACESTACK_INTERFACE
56  *
57  */
58 
59 /**
60 * @defgroup tr69hostif
61 * @{
62 * @defgroup hostif
63 * @{
64 **/
65 
66 
67 #ifndef DEVICE_INTERFACESTACK_H_
68 #define DEVICE_INTERFACESTACK_H_
69 
70 /*****************************************************************************
71  * TR069-SPECIFIC INCLUDE FILES
72  *****************************************************************************/
73 #ifdef USE_INTFSTACK_PROFILE
74 /*****************************************************************************
75  * TR069-SPECIFIC INCLUDE FILES
76  *****************************************************************************/
77 #include <string>
78 #include <map>
79 #include <list>
80 
81 #include "hostIf_main.h"
82 #include "hostIf_tr69ReqHandler.h"
83 #include "hostIf_utils.h"
84 
85 /**
86  * The Device.InterfaceStack table contains information about the relationships between
87  * the multiple layers of interface objects. In particular, it contains information on
88  * which interfaces run on top of which other interfaces.
89  *
90  * This table is auto-generated by the CPE based on the LowerLayers parameters on
91  * individual interface objects.
92  *
93  * Each table row represents a "link" between two interface objects, a higher-layer
94  * interface object (referenced by HigherLayer) and a lower-layer interface object
95  * (referenced by LowerLayer). Consequently, if a referenced interface object is
96  * deleted, the CPE MUST delete the corresponding InterfaceStack row(s) that had
97  * referenced it.
98  *
99  * @note At most one entry in this table can exist with the same values for
100  * HigherLayer and LowerLayer.
101  *
102  */
103 
104 #define MAX_HIGHERLAYER_LEN 256
105 #define MAX_LOWERLAYER_LEN 256
106 
107 /**
108  * @addtogroup TR69_HOSTIF_INTERFACESTACK_INTERFACE_DSSTRUCT
109  * @{
110  */
111 /**
112  * @enum EInterfaceStackMembers
113  * @brief These values are the members of the EInterfaceStackMembers.
114  */
115 typedef enum EDeviceInterfaceStackMembers
116 {
117  eHigherLayer,
118  eLowerLayer
119 }EInterfaceStackMembers;
120 
121 /**
122  * @brief It contains the members variables of the LayerInfo_t structure.
123  */
124 typedef struct
125 {
126  std::string higherLayer;
127  std::string lowerLayer;
128 } LayerInfo_t;
129 /** @} */ //End of the Doxygen tag TR69_HOSTIF_INTERFACESTACK_INTERFACE_DSSTRUCT
130 
131 typedef std::multimap<std::string, LayerInfo_t> InterfaceStackMap_t;
132 typedef std::map<std::string, int> IPInterfacesMap_t;
133 
134 /**
135  * @brief This class provides the interface for getting Device interface stack information.
136  * @ingroup TR69_HOSTIF_INTERFACESTACK_INTERFACE_CLASSES
137  */
138 class hostif_InterfaceStack {
139  int dev_id;
140 
141  /*
142  * Holds interface stack class instances
143  */
144  static GHashTable *stIshash;
145 
146  /*
147  * Holds Notification Hash table
148  */
149  static GHashTable *m_notifyHash;
150 
151  /*
152  * Contains the details about the bridges and its related bridge interfaces in CPE
153  *
154  * Key is the bridge name
155  * Value is the comma separated bride interfaces
156  */
157  static GHashTable *stBridgeTableHash;
158 
159  static GMutex *stMutex;
160 
161  char higherLayer[MAX_HIGHERLAYER_LEN];
162  char lowerLayer[MAX_LOWERLAYER_LEN];
163 
164  bool bCalledHigherLayer;
165  bool bCalledLowerLayer;
166 
167  char backupHigherLayer[MAX_HIGHERLAYER_LEN];
168  char backupLowerLayer[MAX_LOWERLAYER_LEN];
169 
170  hostif_InterfaceStack(int dev_id, char *higherLayer, char *lowerLayer);
171  ~hostif_InterfaceStack();
172  static int createInstance(int dev_id, char *higherLayer, char *lowerLayer);
173  static int populateBridgeTable();
174  static void deleteBridgeTable();
175  static int insertRowIntoBridgeTable(char *bridge, char *bridgeInterfaces);
176  static void bridgeInteface_key_data_free(gpointer key);
177  static void bridgeInteface_value_data_free(gpointer value);
178 
179  template<typename T> static int getLowerInterfaceNumberOfEntries();
180  template<typename T> static std::string getInterfaceName(T* pIface);
181  template<typename T> static std::string getLowerLayerName(int index);
182  template<typename T> static int buildLowerLayerInfo(InterfaceStackMap_t &layerInfo);
183  static int buildBridgeTableLayerInfo(InterfaceStackMap_t &layerInfo);
184 
185  static std::list<std::string> getBridgeElements(char* elementsCSV);
186  static std::string getDMForBridgePort(int bridgeNum, int portNum);
187  static void addBridgeNameLayerInfo(InterfaceStackMap_t &layerInfo, std::string ifname, std::string bridgeLowerLayer);
188  static int addBridgeChildLayerInfo(InterfaceStackMap_t &layerInfo, std::string ifname, std::string bridgeHigherLayer);
189  static void addBridgeUnmanagedLayerInfo(InterfaceStackMap_t &layerInfo, std::string ifname, std::string bridgeHigherLayer, std::string bridgeLowerLayer);
190  static int getIPInterfaces(IPInterfacesMap_t& interfaceList);
191  static std::string getDMForIPLayer(int portNum);
192  static void fillHigherLayersWithIP(InterfaceStackMap_t &layerInfo, IPInterfacesMap_t& ipInterfaceMap);
193  static void print_map(InterfaceStackMap_t &layerInfo);
194 
195  public:
196  static hostif_InterfaceStack* getInstance(int dev_id);
197  static GList* getAllInstances();
198  static void closeInstance(hostif_InterfaceStack *pDev);
199  static void closeAllInstances();
200  static int get_Device_InterfaceStackNumberOfEntries(HOSTIF_MsgData_t *stMsgData);
201  int get_Device_InterfaceStack_HigherLayer(HOSTIF_MsgData_t *stMsgData,bool *pChanged = NULL);
202  int get_Device_InterfaceStack_LowerLayer(HOSTIF_MsgData_t *stMsgData,bool* pChanged = NULL);
203  static void getLock();
204  static void releaseLock();
205  static GHashTable* getNotifyHash();
206 
207 };
208 /* End of TR_069_DEVICE_INTERFACESTACK_GETTER_API doxygen group */
209 /**
210  * @}
211  */
212 
213 #endif /* USE_INTFSTACK_PROFILE */
214 
215 #endif /* DEVICE_INTERFACESTACK_H_ */
216 
217 
218 /** @} */
219 /** @} */
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_main.h
hostIf_main API.