le_net_common.h

Go to the documentation of this file.
1 
2 /*
3  * ====================== WARNING ======================
4  *
5  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
6  * DO NOT MODIFY IN ANY WAY.
7  *
8  * ====================== WARNING ======================
9  */
10 /**
11  * @file le_net_common.h
12  *
13  * Type definitions for le_net.
14  *
15  */
16 #ifndef LE_NET_COMMON_H_INCLUDE_GUARD
17 #define LE_NET_COMMON_H_INCLUDE_GUARD
18 
19 
20 #include "legato.h"
21 
22 // Interface specific includes
23 #include "le_dcs_common.h"
24 
25 #define IFGEN_LE_NET_PROTOCOL_ID "7a4ebf3dc960d25d7838429b8a0cc94f"
26 #define IFGEN_LE_NET_MSG_SIZE 152
27 /** @addtogroup le_net
28  * @{ **/
29 
30 
31 //--------------------------------------------------------------------------------------------------
32 /**
33  * Interface name string length.
34  */
35 //--------------------------------------------------------------------------------------------------
36 #define LE_NET_INTERFACE_NAME_MAX_LEN 100
37 
38 //--------------------------------------------------------------------------------------------------
39 /**
40  * IPv4 addr string's max length
41  */
42 //--------------------------------------------------------------------------------------------------
43 #define LE_NET_IPV4ADDR_MAX_LEN 16
44 
45 //--------------------------------------------------------------------------------------------------
46 /**
47  * IPv6 addr string's max length
48  */
49 //--------------------------------------------------------------------------------------------------
50 #define LE_NET_IPV6ADDR_MAX_LEN 46
51 
52 //--------------------------------------------------------------------------------------------------
53 /**
54  * IP addr string's max length
55  */
56 //--------------------------------------------------------------------------------------------------
57 #define LE_NET_IPADDR_MAX_LEN 46
58 
59 //--------------------------------------------------------------------------------------------------
60 /**
61  * Structure used to communitcate a channel's DNS Server address
62  */
63 //--------------------------------------------------------------------------------------------------
64 typedef struct
65 {
66  char ipv4Addr1[16 + 1];
67  char ipv4Addr2[16 + 1];
68  char ipv6Addr1[46 + 1];
69  char ipv6Addr2[46 + 1];
70 }
72 
73 
74 //--------------------------------------------------------------------------------------------------
75 /**
76  * Structure used to communitcate a channel's Default Gateway
77  */
78 //--------------------------------------------------------------------------------------------------
79 typedef struct
80 {
81  char ipv4Addr[16 + 1];
82  char ipv6Addr[46 + 1];
83 }
85 
86 
87 
88 //--------------------------------------------------------------------------------------------------
89 /**
90  * Get if this client bound locally.
91  */
92 //--------------------------------------------------------------------------------------------------
93 LE_SHARED bool ifgen_le_net_HasLocalBinding
94 (
95  void
96 );
97 
98 
99 //--------------------------------------------------------------------------------------------------
100 /**
101  * Init data that is common across all threads
102  */
103 //--------------------------------------------------------------------------------------------------
104 LE_SHARED void ifgen_le_net_InitCommonData
105 (
106  void
107 );
108 
109 
110 //--------------------------------------------------------------------------------------------------
111 /**
112  * Perform common initialization and open a session
113  */
114 //--------------------------------------------------------------------------------------------------
115 LE_SHARED le_result_t ifgen_le_net_OpenSession
116 (
117  le_msg_SessionRef_t _ifgen_sessionRef,
118  bool isBlocking
119 );
120 
121 //--------------------------------------------------------------------------------------------------
122 /**
123  * Add or remove a route on the given channel according to the input flag in the last argument for
124  * the given destination address its given subnet's mask prefix length.
125  *
126  * The channel reference in the first input argument identifies the network interface which a route
127  * is to be added onto or removed from. Whether the operation is an add or a remove depends on the
128  * isAdd boolean value of the last API input argument.
129  *
130  * The IP address and subnet input arguments specify the destination address and subnet for the
131  * route. If it is a network route, the formats used for them are the same as used in the Linux
132  * command "route add -net <ipAddr>/<prefixLength> dev <netInterface>". If the route is a
133  * host route, the prefixLength input argument should be given as "" (i.e. a null string).
134  *
135  * @note The prefixLength parameter used to take a subnet mask (255.255.255.0) for IPv4 and prefix
136  * length for IPv6. Now it only takes prefix length, although compatibility code is present
137  * to make it compatible with previous API declaration. Providing a subnet mask is however
138  * deprecated and the compatibility code will be removed in a latter version.
139  *
140  * @return
141  * - LE_OK upon success, otherwise another le_result_t failure code
142  */
143 //--------------------------------------------------------------------------------------------------
144 LE_SHARED le_result_t ifgen_le_net_ChangeRoute
145 (
146  le_msg_SessionRef_t _ifgen_sessionRef,
147  le_dcs_ChannelRef_t channelRef,
148  ///< [IN] the channel onto which the route change is made
149  const char* LE_NONNULL destAddr,
150  ///< [IN] Destination IP address for the route
151  const char* LE_NONNULL prefixLength,
152  ///< [IN] Destination's subnet prefix length
153  bool isAdd
154  ///< [IN] the change is to add (true) or delete (false)
155 );
156 
157 //--------------------------------------------------------------------------------------------------
158 /**
159  * Set the default GW addr for the given data channel retrieved from its technology
160  *
161  * @return
162  * - LE_OK upon success, otherwise LE_FAULT
163  */
164 //--------------------------------------------------------------------------------------------------
165 LE_SHARED le_result_t ifgen_le_net_SetDefaultGW
166 (
167  le_msg_SessionRef_t _ifgen_sessionRef,
168  le_dcs_ChannelRef_t channelRef
169  ///< [IN] the channel on which interface its default GW
170  ///< addr is to be set
171 );
172 
173 //--------------------------------------------------------------------------------------------------
174 /**
175  * Get the default GW address for the given data channel.
176  *
177  * @note
178  * Accomodates dual-stack IPv4/IPv6 addresses. If the default GW address only is only IPv4 or
179  * IPv6, but not both, the unused field of "addr" will be nulled.
180  *
181  * @return
182  * - LE_OK upon success, otherwise LE_FAULT
183  */
184 //--------------------------------------------------------------------------------------------------
185 LE_SHARED le_result_t ifgen_le_net_GetDefaultGW
186 (
187  le_msg_SessionRef_t _ifgen_sessionRef,
188  le_dcs_ChannelRef_t channelRef,
189  ///< [IN] Channel to retrieve GW addresses
191  ///< [OUT] Channel's Default GW addresses
192 );
193 
194 //--------------------------------------------------------------------------------------------------
195 /**
196  * Backup the current default GW configs of the system, including both IPv4 and IPv6 as applicable.
197  * For each client application using this API to back up this system setting, only one backup copy
198  * is kept. When a client application makes a second call to this API, its first backup copy will
199  * be overwritten by the newer.
200  * Thus, le_net keeps one single backup copy per client application, and, thus, multiple backup
201  * copies altogether. They are kept in their LIFO (last-in-first-out) chronological order that
202  * the sequence for client applications to call le_net_RestoreDefaltGW() should be in the exact
203  * reverse order of their calling le_net_BackupDefaultGW() such that config backups and restorations
204  * happen in the correct LIFO manner.
205  */
206 //--------------------------------------------------------------------------------------------------
207 LE_SHARED void ifgen_le_net_BackupDefaultGW
208 (
209  le_msg_SessionRef_t _ifgen_sessionRef
210 );
211 
212 //--------------------------------------------------------------------------------------------------
213 /**
214  * Restore the default GW configs of the system to the last backed up ones, including IPv4 and/or
215  * IPv6 depending on whether this same client application has called le_net_SetDefaultGW() to
216  * change the system's IPv4 and/or IPv6 configs or not. The le_net interface remembers it and
217  * perform config restoration only as necessary when le_net_RestoreDefaultGW() is called. When
218  * le_net_BackupDefaultGW() is called, both IPv4 and IPv6 default GW configs are archived when
219  * present.
220  * As le_net keeps one single backup copy per client application, and, thus, multiple backup
221  * copies altogether, they are kept in their LIFO (last-in-first-out) chronological order that
222  * the sequence for client applications to call le_net_RestoreDefaltGW() should be in the exact
223  * reverse order of their calling le_net_BackupDefaultGW() such that config backups and restorations
224  * happen in the correct LIFO manner.
225  * If these applications do not follow this order, the le_net interface will first generate a
226  * warning in the system log and then still go ahead to restore the configs as directed. These
227  * applications hold the responsibility for the resulting routing configs on the device.
228  */
229 //--------------------------------------------------------------------------------------------------
230 LE_SHARED le_result_t ifgen_le_net_RestoreDefaultGW
231 (
232  le_msg_SessionRef_t _ifgen_sessionRef
233 );
234 
235 //--------------------------------------------------------------------------------------------------
236 /**
237  * Set the DNS addresses for the given data channel retrieved from its technology
238  *
239  * @return
240  * - LE_OK upon success, otherwise LE_FAULT
241  */
242 //--------------------------------------------------------------------------------------------------
243 LE_SHARED le_result_t ifgen_le_net_SetDNS
244 (
245  le_msg_SessionRef_t _ifgen_sessionRef,
246  le_dcs_ChannelRef_t channelRef
247  ///< [IN] the channel from which the DNS addresses retrieved
248  ///< will be set into the system config
249 );
250 
251 //--------------------------------------------------------------------------------------------------
252 /**
253  * Get the DNS server addresses for the given data channel retrieved from its technology
254  *
255  * @note
256  * Can accomodate up to two dual-stack DNS server addresses. In the case that there are more
257  * than two server addresses, the first two addresses of each IP version will be returned. If
258  * there are fewer than two dual-stack addresses, or contain only one type of IPv4 or IPv6
259  * addresses, the unused portions of the passed structure will be nulled and returned.
260  *
261  * @return
262  * - LE_OK upon success, otherwise LE_FAULT
263  */
264 //--------------------------------------------------------------------------------------------------
265 LE_SHARED le_result_t ifgen_le_net_GetDNS
266 (
267  le_msg_SessionRef_t _ifgen_sessionRef,
268  le_dcs_ChannelRef_t channelRef,
269  ///< [IN] Channel to retrieve DNS server addresses
271  ///< [OUT] DNS server addresses
272 );
273 
274 //--------------------------------------------------------------------------------------------------
275 /**
276  * Remove the last added DNS addresses via the le_dcs_SetDNS API
277  */
278 //--------------------------------------------------------------------------------------------------
279 LE_SHARED void ifgen_le_net_RestoreDNS
280 (
281  le_msg_SessionRef_t _ifgen_sessionRef
282 );
283 /** @} **/
284 #endif // LE_NET_COMMON_H_INCLUDE_GUARD
#define LE_SHARED
Definition: le_basics.h:300
le_result_t
Definition: le_basics.h:46
Definition: le_net_common.h:64
struct le_dcs_Channel * le_dcs_ChannelRef_t
Definition: le_dcs_common.h:79
struct le_msg_Session * le_msg_SessionRef_t
Definition: le_messaging.h:860
Definition: le_net_common.h:79