SimpleLink CC3100/CC3200 Host Driver  Version 1.0.1.6
Simplifies the implementation of Internet connectivity
netapp.h
1 /*
2  * netapp.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
5  *
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution.
18  *
19  * Neither the name of Texas Instruments Incorporated nor the names of
20  * its contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35 */
36 
37 /*****************************************************************************/
38 /* Include files */
39 /*****************************************************************************/
40 
41 #include "simplelink.h"
42 
43 #ifndef __NETAPP_H__
44 #define __NETAPP_H__
45 
46 
47 
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
60 /*****************************************************************************/
61 /* Macro declarations */
62 /*****************************************************************************/
63 
64 /*ERROR code*/
65 #define SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR (-230)
66 
67 /* Http Server interface */
68 #define MAX_INPUT_STRING (64) /* because of WPA */
69 
70 #define MAX_AUTH_NAME_LEN (20)
71 #define MAX_AUTH_PASSWORD_LEN (20)
72 #define MAX_AUTH_REALM_LEN (20)
73 
74 #define MAX_DEVICE_URN_LEN (15+1)
75 #define MAX_DOMAIN_NAME_LEN (24+1)
76 
77 #define MAX_ACTION_LEN (30)
78 /* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly! */
79 #define MAX_TOKEN_NAME_LEN (20)
80 #define MAX_TOKEN_VALUE_LEN MAX_INPUT_STRING
81 
82 #define NETAPP_MAX_SERVICE_TEXT_SIZE (256)
83 #define NETAPP_MAX_SERVICE_NAME_SIZE (60)
84 #define NETAPP_MAX_SERVICE_HOST_NAME_SIZE (64)
85 
86 
87 /* Server Responses */
88 #define SL_NETAPP_RESPONSE_NONE (0)
89 #define SL_NETAPP_HTTPSETTOKENVALUE (1)
90 
91 #define SL_NETAPP_FAMILY_MASK (0x80)
92 
93 /* mDNS types */
94 #define SL_NET_APP_MASK_IPP_TYPE_OF_SERVICE (0x00000001)
95 #define SL_NET_APP_MASK_DEVICE_INFO_TYPE_OF_SERVICE (0x00000002)
96 #define SL_NET_APP_MASK_HTTP_TYPE_OF_SERVICE (0x00000004)
97 #define SL_NET_APP_MASK_HTTPS_TYPE_OF_SERVICE (0x00000008)
98 #define SL_NET_APP_MASK_WORKSATION_TYPE_OF_SERVICE (0x00000010)
99 #define SL_NET_APP_MASK_GUID_TYPE_OF_SERVICE (0x00000020)
100 #define SL_NET_APP_MASK_H323_TYPE_OF_SERVICE (0x00000040)
101 #define SL_NET_APP_MASK_NTP_TYPE_OF_SERVICE (0x00000080)
102 #define SL_NET_APP_MASK_OBJECITVE_TYPE_OF_SERVICE (0x00000100)
103 #define SL_NET_APP_MASK_RDP_TYPE_OF_SERVICE (0x00000200)
104 #define SL_NET_APP_MASK_REMOTE_TYPE_OF_SERVICE (0x00000400)
105 #define SL_NET_APP_MASK_RTSP_TYPE_OF_SERVICE (0x00000800)
106 #define SL_NET_APP_MASK_SIP_TYPE_OF_SERVICE (0x00001000)
107 #define SL_NET_APP_MASK_SMB_TYPE_OF_SERVICE (0x00002000)
108 #define SL_NET_APP_MASK_SOAP_TYPE_OF_SERVICE (0x00004000)
109 #define SL_NET_APP_MASK_SSH_TYPE_OF_SERVICE (0x00008000)
110 #define SL_NET_APP_MASK_TELNET_TYPE_OF_SERVICE (0x00010000)
111 #define SL_NET_APP_MASK_TFTP_TYPE_OF_SERVICE (0x00020000)
112 #define SL_NET_APP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE (0x00040000)
113 #define SL_NET_APP_MASK_RAOP_TYPE_OF_SERVICE (0x00080000)
114 #define SL_NET_APP_MASK_ALL_TYPE_OF_SERVICE (0xFFFFFFFF)
115 
116 /********************************************************************************************************/
117 /* sl_NetAppDnsGetHostByName error codes */
118 
119 #define SL_NET_APP_DNS_QUERY_NO_RESPONSE (-159) /* DNS query failed, no response */
120 #define SL_NET_APP_DNS_NO_SERVER (-161) /* No DNS server was specified */
121 #define SL_NET_APP_DNS_PARAM_ERROR (-162) /* mDNS parameters error */
122 #define SL_NET_APP_DNS_QUERY_FAILED (-163) /* DNS query failed; no DNS server sent an 'answer' */
123 #define SL_NET_APP_DNS_INTERNAL_1 (-164)
124 #define SL_NET_APP_DNS_INTERNAL_2 (-165)
125 #define SL_NET_APP_DNS_MALFORMED_PACKET (-166) /* Improperly formed or corrupted DNS packet received */
126 #define SL_NET_APP_DNS_INTERNAL_3 (-167)
127 #define SL_NET_APP_DNS_INTERNAL_4 (-168)
128 #define SL_NET_APP_DNS_INTERNAL_5 (-169)
129 #define SL_NET_APP_DNS_INTERNAL_6 (-170)
130 #define SL_NET_APP_DNS_INTERNAL_7 (-171)
131 #define SL_NET_APP_DNS_INTERNAL_8 (-172)
132 #define SL_NET_APP_DNS_INTERNAL_9 (-173)
133 #define SL_NET_APP_DNS_MISMATCHED_RESPONSE (-174) /* Server response type does not match the query request*/
134 #define SL_NET_APP_DNS_INTERNAL_10 (-175)
135 #define SL_NET_APP_DNS_INTERNAL_11 (-176)
136 #define SL_NET_APP_DNS_NO_ANSWER (-177) /* No response for one-shot query */
137 #define SL_NET_APP_DNS_NO_KNOWN_ANSWER (-178) /* No known answer for query */
138 #define SL_NET_APP_DNS_NAME_MISMATCH (-179) /* Illegal service name according to the RFC */
139 #define SL_NET_APP_DNS_NOT_STARTED (-180) /* mDNS is not running */
140 #define SL_NET_APP_DNS_HOST_NAME_ERROR (-181) /* Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763 */
141 #define SL_NET_APP_DNS_NO_MORE_ENTRIES (-182) /* No more entries be found. */
142 
143 #define SL_NET_APP_DNS_MAX_SERVICES_ERROR (-200) /* Maximum advertise services are already configured */
144 #define SL_NET_APP_DNS_IDENTICAL_SERVICES_ERROR (-201) /* Trying to register a service that is already exists */
145 #define SL_NET_APP_DNS_NOT_EXISTED_SERVICE_ERROR (-203) /* Trying to delete service that does not existed */
146 #define SL_NET_APP_DNS_ERROR_SERVICE_NAME_ERROR (-204) /* Illegal service name according to the RFC */
147 #define SL_NET_APP_DNS_RX_PACKET_ALLOCATION_ERROR (-205) /* Retry request */
148 #define SL_NET_APP_DNS_BUFFER_SIZE_ERROR (-206) /* List size buffer is bigger than internally allowed in the NWP */
149 #define SL_NET_APP_DNS_NET_APP_SET_ERROR (-207) /* Illegal length of one of the mDNS Set functions */
150 #define SL_NET_APP_DNS_GET_SERVICE_LIST_FLAG_ERROR (-208)
151 #define SL_NET_APP_DNS_NO_CONFIGURATION_ERROR (-209)
152 
153 /* Set Dev name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN) */
154 #define SL_ERROR_DEVICE_NAME_LEN_ERR (-117)
155 #define SL_ERROR_DEVICE_NAME_INVALID (-118)
156 /* Set domain name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME) */
157 #define SL_ERROR_DOMAIN_NAME_LEN_ERR (-119)
158 #define SL_ERROR_DOMAIN_NAME_INVALID (-120)
159 
160 /********************************************************************************************************/
161 
162 /* NetApp application IDs */
163 #define SL_NET_APP_HTTP_SERVER_ID (1)
164 #define SL_NET_APP_DHCP_SERVER_ID (2)
165 #define SL_NET_APP_MDNS_ID (4)
166 #define SL_NET_APP_DNS_SERVER_ID (8)
167 #define SL_NET_APP_DEVICE_CONFIG_ID (16)
168 /* NetApp application set/get options */
169 #define NETAPP_SET_DHCP_SRV_BASIC_OPT (0)
170 /* HTTP server set/get options */
171 #define NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER (0)
172 #define NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK (1)
173 #define NETAPP_SET_GET_HTTP_OPT_AUTH_NAME (2)
174 #define NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD (3)
175 #define NETAPP_SET_GET_HTTP_OPT_AUTH_REALM (4)
176 #define NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS (5)
177 
178 #define NETAPP_SET_GET_MDNS_CONT_QUERY_OPT (1)
179 #define NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT (2)
180 #define NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT (3)
181 
182 /* DNS server set/get options */
183 #define NETAPP_SET_GET_DNS_OPT_DOMAIN_NAME (0)
184 
185 /* Device Config set/get options */
186 #define NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN (0)
187 #define NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME (1)
188 
189 
190 /*****************************************************************************/
191 /* Structure/Enum declarations */
192 /*****************************************************************************/
193 
194 typedef struct
195 {
196  _u32 PacketsSent;
197  _u32 PacketsReceived;
198  _u16 MinRoundTime;
199  _u16 MaxRoundTime;
200  _u16 AvgRoundTime;
201  _u32 TestTime;
203 
204 typedef struct
205 {
206  _u32 PingIntervalTime; /* delay between pings, in milliseconds */
207  _u16 PingSize; /* ping packet size in bytes */
208  _u16 PingRequestTimeout; /* timeout time for every ping in milliseconds */
209  _u32 TotalNumberOfAttempts; /* max number of ping requests. 0 - forever */
210  _u32 Flags; /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping. */
211  _u32 Ip; /* IPv4 address or IPv6 first 4 bytes */
212  _u32 Ip1OrPaadding;
213  _u32 Ip2OrPaadding;
214  _u32 Ip3OrPaadding;
216 
217 typedef struct _slHttpServerString_t
218 {
219  _u8 len;
220  _u8 *data;
222 
223 typedef struct _slHttpServerData_t
224 {
225  _u8 value_len;
226  _u8 name_len;
227  _u8 *token_value;
228  _u8 *token_name;
230 
232 {
233  slHttpServerString_t action;
234  slHttpServerString_t token_name;
235  slHttpServerString_t token_value;
237 
238 typedef union
239 {
240  slHttpServerString_t httpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */
241  slHttpServerPostData_t httpPostData; /* SL_NETAPP_HTTPPOSTTOKENVALUE */
243 
244 typedef union
245 {
246  slHttpServerString_t token_value;
248 
249 typedef struct
250 {
251  _u32 Event;
252  SlHttpServerEventData_u EventData;
254 
255 typedef struct
256 {
257  _u32 Response;
258  SlHttpServerResponsedata_u ResponseData;
260 
261 
262 typedef struct
263 {
264  _u32 lease_time;
265  _u32 ipv4_addr_start;
266  _u32 ipv4_addr_last;
268 
269 /*mDNS parameters*/
270 typedef enum
271 {
272  SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
273  SL_NET_APP_FULL_SERVICE_IPV4_TYPE,
274  SL_NET_APP_SHORT_SERVICE_IPV4_TYPE
275 
276 } SlNetAppGetServiceListType_e;
277 
278 typedef struct
279 {
280  _u32 service_ipv4;
281  _u16 service_port;
282  _u16 Reserved;
284 
285 typedef struct
286 {
287  _u32 service_ipv4;
288  _u16 service_port;
289  _u16 Reserved;
290  _u8 service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
291  _u8 service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
293 
294 typedef struct
295 {
296  _u32 service_ipv4;
297  _u16 service_port;
298  _u16 Reserved;
299  _u8 service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
300  _u8 service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
301  _u8 service_text[NETAPP_MAX_SERVICE_TEXT_SIZE];
303 
304 typedef struct
305 {
306  /*The below parameters are used to configure the advertise times and interval
307  For example:
308  If:
309  Period is set to T
310  Repetitions are set to P
311  Telescopic factor is K=2
312  The transmission shall be:
313  advertise P times
314  wait T
315  advertise P times
316  wait 4 * T
317  advertise P time
318  wait 16 * T ... (till max time reached / configuration changed / query issued)
319  */
320  _u32 t; /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */
321  _u32 p; /* Number of repetitions. Default value is 1 */
322  _u32 k; /* Telescopic factor. Default value is 2. */
323  _u32 RetransInterval;/* Announcing retransmission interval */
324  _u32 Maxinterval; /* Announcing max period interval */
325  _u32 max_time; /* Announcing max time */
327 
328 /*****************************************************************************/
329 /* Types declarations */
330 /*****************************************************************************/
331 typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*);
332 
333 /*****************************************************************************/
334 /* Function prototypes */
335 /*****************************************************************************/
336 
337 
360 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
361 _i16 sl_NetAppStart(const _u32 AppBitMap);
362 #endif
363 
386 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
387 _i16 sl_NetAppStop(const _u32 AppBitMap);
388 #endif
389 
436 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
437 _i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ip_addr,const _u8 family );
438 #endif
439 
495 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
496 _i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */
497  const _u8 ServiceLen,
498  const _u8 Family, /* 4-IPv4 , 16-IPv6 */
499  _u32 pAddr[],
500  _u32 *pPort,
501  _u16 *pTextLen, /* in: max len , out: actual len */
502  _i8 *pText
503  );
504 
505 #endif
506 
555 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
556 _i16 sl_NetAppGetServiceList(const _u8 IndexOffest,
557  const _u8 MaxServiceCount,
558  const _u8 Flags,
559  _i8 *pBuffer,
560  const _u32 RxBufferLength
561  );
562 
563 #endif
564 
588 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
589 _i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName,const _u8 ServiceNameLen);
590 #endif
591 
656 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
657 _i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName,
658  const _u8 ServiceNameLen,
659  const _i8* pText,
660  const _u8 TextLen,
661  const _u16 Port,
662  const _u32 TTL,
663  _u32 Options);
664 #endif
665 
726 #if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
727 _i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family,SlPingReport_t *pReport,const P_SL_DEV_PING_CALLBACK pPingCallback);
728 #endif
729 
793 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
794 _i32 sl_NetAppSet(const _u8 AppId ,const _u8 Option,const _u8 OptionLen,const _u8 *pOptionValue);
795 #endif
796 
865 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
866 _i32 sl_NetAppGet(const _u8 AppId,const _u8 Option,_u8 *pOptionLen, _u8 *pOptionValue);
867 #endif
868 
869 
870 
879 #ifdef __cplusplus
880 }
881 #endif /* __cplusplus */
882 
883 #endif /* __NETAPP_H__ */
884 
_i16 sl_NetAppStop(const _u32 AppBitMap)
Stops a network application.
_i16 sl_NetAppDnsGetHostByName(_i8 *hostname, const _u16 usNameLen, _u32 *out_ip_addr, const _u8 family)
Get host IP by name.
_i16 sl_NetAppMDNSRegisterService(const _i8 *pServiceName, const _u8 ServiceNameLen, const _i8 *pText, const _u8 TextLen, const _u16 Port, const _u32 TTL, _u32 Options)
Register a new mDNS service.
_i32 sl_NetAppSet(const _u8 AppId, const _u8 Option, const _u8 OptionLen, const _u8 *pOptionValue)
Internal function for setting network application configurations.
_i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, const _u8 ServiceLen, const _u8 Family, _u32 pAddr[], _u32 *pPort, _u16 *pTextLen, _i8 *pText)
Return service attributes like IP address, port and text according to service name.
_i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName, const _u8 ServiceNameLen)
Unregister mDNS service This function deletes the mDNS service from the mDNS package and the database...
_i16 sl_NetAppStart(const _u32 AppBitMap)
Starts a network application.
_i16 sl_NetAppGetServiceList(const _u8 IndexOffest, const _u8 MaxServiceCount, const _u8 Flags, _i8 *pBuffer, const _u32 RxBufferLength)
Get service List Insert into out pBuffer a list of peer's services that are the NWP. The list is in a form of service struct. The user should chose the type of the service struct like:
_i32 sl_NetAppGet(const _u8 AppId, const _u8 Option, _u8 *pOptionLen, _u8 *pOptionValue)
Internal function for getting network applications configurations.
_i16 sl_NetAppPingStart(const SlPingStartCommand_t *pPingParams, const _u8 family, SlPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback)
send ICMP ECHO_REQUEST to network hosts
Definition: netapp.h:231