SimpleLink Host Driver  0.0.5.1
 All Data Structures Functions Variables Groups
netapp.h
1 /*
2  * netapp.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2014 Texas Instruments Incorporated - http://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 #include "simplelink.h"
38 
39 #ifndef __NETAPP_H__
40 #define __NETAPP_H__
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /*************************************************************************************************************/
47 /*ERROR code*/
48 #define NETAPP_RX_BUFFER_LENGTH_ERROR -230
49 /*************************************************************************************************************/
50 
51 typedef struct
52 {
53  unsigned long PacketsSent;
54  unsigned long PacketsReceived;
55  unsigned short MinRoundTime;
56  unsigned short MaxRoundTime;
57  unsigned short AvgRoundTime;
58  unsigned long TestTime;
60 
61 
62 typedef struct
63 {
64  unsigned long PingIntervalTime; /* delay between pings, in miliseconds */
65  unsigned short PingSize; /* ping packet size in bytes */
66  unsigned short PingRequestTimeout; /* timeout time for every ping in miliseconds */
67  unsigned long TotalNumberOfAttempts; /* max number of ping requests. 0 - forever */
68  unsigned long Flags; /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping. */
69  unsigned long Ip; /* IPv4 address or IPv6 first 4 bytes */
70  unsigned long Ip1OrPaadding;
71  unsigned long Ip2OrPaadding;
72  unsigned long Ip3OrPaadding;
74 
75 
76 /* Http Server interface */
77 
78 #define MAX_INPUT_STRING 64 /* because of WPA */
79 
80 #define MAX_AUTH_NAME_LEN 20
81 #define MAX_AUTH_PASSWORD_LEN 20
82 #define MAX_AUTH_REALM_LEN 20
83 
84 #define MAX_DEVICE_URN_LEN (15+1)
85 #define MAX_DOMAIN_NAME_LEN (24+1)
86 
87 #define MAX_ACTION_LEN 30
88 #define MAX_TOKEN_NAME_LEN 20 /* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly!! */
89 #define MAX_TOKEN_VALUE_LEN MAX_INPUT_STRING
90 
91 /* Server Events */
92 #define SL_NETAPP_HTTPGETTOKENVALUE 1
93 #define SL_NETAPP_HTTPPOSTTOKENVALUE 2
94 
95 
96 
97 #define NETAPP_MAX_SERVICE_TEXT_SIZE 256
98 #define NETAPP_MAX_SERVICE_NAME_SIZE 60
99 #define NETAPP_MAX_SERVICE_HOST_NAME_SIZE 64
100 
101 
102 /* Server Responses */
103 #define SL_NETAPP_RESPONSE_NONE 0
104 #define SL_NETAPP_HTTPSETTOKENVALUE 1
105 
106 #define SL_NETAPP_FAMILY_MASK 0x80
107 
108 typedef struct _slHttpServerString_t
109 {
110  unsigned char len;
111  unsigned char *data;
113 
114 typedef struct _slHttpServerData_t
115 {
116  unsigned char value_len;
117  unsigned char name_len;
118  unsigned char *token_value;
119  unsigned char *token_name;
121 
123 {
124  slHttpServerString_t action;
125  slHttpServerString_t token_name;
126  slHttpServerString_t token_value;
128 
129 typedef union
130 {
131  slHttpServerString_t httpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */
132  slHttpServerPostData_t httpPostData; /* SL_NETAPP_HTTPPOSTTOKENVALUE */
134 
135 typedef union
136 {
137  slHttpServerString_t token_value;
139 
140 typedef struct
141 {
142  unsigned long Event;
143  SlHttpServerEventData_u EventData;
145 
146 typedef struct
147 {
148  unsigned long Response;
149  SlHttpServerResponsedata_u ResponseData;
151 
152 
153 typedef struct
154 {
155  unsigned long lease_time;
156  unsigned long ipv4_addr_start;
157  unsigned long ipv4_addr_last;
159 
160 /********************************************************************************************************/
161 /*mDNS parameters*/
162 
163 
164 typedef enum
165 {
166  SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
167  SL_NET_APP_FULL_SERVICE_IPV4_TYPE,
168  SL_NET_APP_SHORT_SERVICE_IPV4_TYPE
169 
170 } SlNetAppGetServiceListType_e;
171 
172 typedef struct
173 {
174  unsigned long service_ipv4;
175  unsigned short service_port;
176  unsigned short Reserved;
178 
179 
180 
181 typedef struct
182 {
183  unsigned long service_ipv4;
184  unsigned short service_port;
185  unsigned short Reserved;
186  unsigned char service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
187  unsigned char service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
189 
190 typedef struct
191 {
192  unsigned long service_ipv4;
193  unsigned short service_port;
194  unsigned short Reserved;
195  unsigned char service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
196  unsigned char service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
197  unsigned char service_text[NETAPP_MAX_SERVICE_TEXT_SIZE];
199 
200 typedef struct
201 {
202  /*The below parameters are used to configure the advertise times and interval
203  For example:
204  If:
205  Period is set to T
206  Repetitions are set to P
207  Telescopic factor is K=2
208  The transmission shall be:
209  advertise P times
210  wait T
211  advertise P times
212  wait 4 * T
213  advertise P time
214  wait 16 * T ... (till max time reached / configuration changed / query issued)
215  */
216  unsigned long t; /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */
217  unsigned long p; /* Number of repetitions. Default value is 1 */
218  unsigned long k; /* Telescopic factor. Default value is 2. */
219  unsigned long RetransInterval;/* Announcing retransmission interval */
220  unsigned long Maxinterval; /* Announcing max period interval */
221  unsigned long max_time; /* Announcing max time */
223 
224 #define SL_NET_APP_MASK_IPP_TYPE_OF_SERVICE 0x00000001
225 #define SL_NET_APP_MASK_DEVICE_INFO_TYPE_OF_SERVICE 0x00000002
226 #define SL_NET_APP_MASK_HTTP_TYPE_OF_SERVICE 0x00000004
227 #define SL_NET_APP_MASK_HTTPS_TYPE_OF_SERVICE 0x00000008
228 #define SL_NET_APP_MASK_WORKSATION_TYPE_OF_SERVICE 0x00000010
229 #define SL_NET_APP_MASK_GUID_TYPE_OF_SERVICE 0x00000020
230 #define SL_NET_APP_MASK_H323_TYPE_OF_SERVICE 0x00000040
231 #define SL_NET_APP_MASK_NTP_TYPE_OF_SERVICE 0x00000080
232 #define SL_NET_APP_MASK_OBJECITVE_TYPE_OF_SERVICE 0x00000100
233 #define SL_NET_APP_MASK_RDP_TYPE_OF_SERVICE 0x00000200
234 #define SL_NET_APP_MASK_REMOTE_TYPE_OF_SERVICE 0x00000400
235 #define SL_NET_APP_MASK_RTSP_TYPE_OF_SERVICE 0x00000800
236 #define SL_NET_APP_MASK_SIP_TYPE_OF_SERVICE 0x00001000
237 #define SL_NET_APP_MASK_SMB_TYPE_OF_SERVICE 0x00002000
238 #define SL_NET_APP_MASK_SOAP_TYPE_OF_SERVICE 0x00004000
239 #define SL_NET_APP_MASK_SSH_TYPE_OF_SERVICE 0x00008000
240 #define SL_NET_APP_MASK_TELNET_TYPE_OF_SERVICE 0x00010000
241 #define SL_NET_APP_MASK_TFTP_TYPE_OF_SERVICE 0x00020000
242 #define SL_NET_APP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE 0x00040000
243 #define SL_NET_APP_MASK_RAOP_TYPE_OF_SERVICE 0x00080000
244 #define SL_NET_APP_MASK_ALL_TYPE_OF_SERVICE 0xFFFFFFFF
245 
246 /********************************************************************************************************/
247 /* sl_NetAppDnsGetHostByName error codes */
248 
249 #define SL_NET_APP_DNS_QUERY_NO_RESPONSE (-159) /* DNS query failed, no response */
250 #define SL_NET_APP_DNS_NO_SERVER (-161) /* No DNS server was specified */
251 #define SL_NET_APP_DNS_QUERY_FAILED (-163) /* DNS query failed; no DNS server sent an 'answer' */
252 #define SL_NET_APP_DNS_MALFORMED_PACKET (-166) /* Improperly formed or corrupted DNS packet received */
253 #define SL_NET_APP_DNS_MISMATCHED_RESPONSE (-174) /* Server response type does not match the query request*/
254 
255 /********************************************************************************************************/
256 
257 
258 /* NetApp application IDs */
259 #define SL_NET_APP_HTTP_SERVER_ID (1)
260 #define SL_NET_APP_DHCP_SERVER_ID (2)
261 #define SL_NET_APP_MDNS_ID (4)
262 #define SL_NET_APP_DNS_SERVER_ID (8)
263 #define SL_NET_APP_DEVICE_CONFIG_ID (16)
264 
265 /* NetApp application set/get options */
266 #define NETAPP_SET_DHCP_SRV_BASIC_OPT (0)
267 
268 /* HTTP server set/get options */
269 #define NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER (0)
270 #define NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK (1)
271 #define NETAPP_SET_GET_HTTP_OPT_AUTH_NAME (2)
272 #define NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD (3)
273 #define NETAPP_SET_GET_HTTP_OPT_AUTH_REALM (4)
274 #define NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS (5)
275 
276 #define NETAPP_SET_GET_MDNS_CONT_QUERY_OPT (1)
277 #define NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT (2)
278 #define NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT (3)
279 
280 /* DNS server set/get options */
281 #define NETAPP_SET_GET_DNS_OPT_DOMAIN_NAME (0)
282 
283 /* Device Config set/get options */
284 #define NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN (0)
285 #define NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME (1)
286 
287 typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*);
288 
289 /*****************************************************************************
290 
291  API Prototypes
292 
293  *****************************************************************************/
294 
323 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
324 int sl_NetAppStart(unsigned long AppBitMap);
325 #endif
326 
349 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
350 int sl_NetAppStop(unsigned long AppBitMap);
351 #endif
352 
353 
398 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
399 int sl_NetAppDnsGetHostByName(char * hostname, unsigned short usNameLen, unsigned long* out_ip_addr,unsigned char family );
400 #endif
401 
402 
461 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
462 long sl_NetAppDnsGetHostByService(char *pServiceName, /* string containing all (or only part): name + subtype + service */
463  unsigned char ServiceLen,
464  unsigned char Family, /* 4-IPv4 , 16-IPv6 */
465  unsigned long pAddr[],
466  unsigned long *pPort,
467  unsigned short *pTextLen, /* in: max len , out: actual len */
468  char *pText
469  );
470 
471 #endif
472 
529 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
530 int sl_NetAppGetServiceList(unsigned char IndexOffest,
531  unsigned char MaxServiceCount,
532  unsigned char Flags,
533  char *pBuffer,
534  unsigned long RxBufferLength
535  );
536 
537 
538 #endif
539 
540 
567 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
568 int sl_NetAppMDNSUnRegisterService( const char *pServiceName,
569  unsigned char ServiceNameLen);
570 
571 
572 #endif
573 
638 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
639 int sl_NetAppMDNSRegisterService( const char* pServiceName,
640  unsigned char ServiceNameLen,
641  const char* pText,
642  unsigned char TextLen,
643  unsigned short Port,
644  unsigned long TTL,
645  unsigned long Options);
646 
647 #endif
648 
649 
710 #if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
711 int sl_NetAppPingStart(SlPingStartCommand_t* pPingParams,unsigned char family,SlPingReport_t *pReport,const P_SL_DEV_PING_CALLBACK pPingCallback);
712 #endif
713 
759 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
760 long sl_NetAppSet(unsigned char AppId ,unsigned char Option,unsigned char OptionLen, unsigned char *pOptionValue);
761 #endif
762 
813 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
814 long sl_NetAppGet(unsigned char AppId, unsigned char Option,unsigned char *pOptionLen, unsigned char *pOptionValue);
815 #endif
816 
817 
818 
827 #ifdef __cplusplus
828 }
829 #endif /* __cplusplus */
830 
831 #endif /* __NETAPP_H__ */
832 
int sl_NetAppDnsGetHostByName(char *hostname, unsigned short usNameLen, unsigned long *out_ip_addr, unsigned char family)
Get host IP by name.
int sl_NetAppGetServiceList(unsigned char IndexOffest, unsigned char MaxServiceCount, unsigned char Flags, char *pBuffer, unsigned long 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:
Definition: netapp.h:153
int sl_NetAppPingStart(SlPingStartCommand_t *pPingParams, unsigned char family, SlPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback)
send ICMP ECHO_REQUEST to network hosts
Definition: netapp.h:51
int sl_NetAppStart(unsigned long AppBitMap)
Starts a network application.
long sl_NetAppSet(unsigned char AppId, unsigned char Option, unsigned char OptionLen, unsigned char *pOptionValue)
Internal function for setting network application configurations.
Definition: netapp.h:114
int sl_NetAppMDNSUnRegisterService(const char *pServiceName, unsigned char ServiceNameLen)
Unregister mDNS service This function deletes the mDNS service from the mDNS package and the database...
int sl_NetAppMDNSRegisterService(const char *pServiceName, unsigned char ServiceNameLen, const char *pText, unsigned char TextLen, unsigned short Port, unsigned long TTL, unsigned long Options)
Register a new mDNS service.
Definition: netapp.h:62
Definition: netapp.h:140
long sl_NetAppDnsGetHostByService(char *pServiceName, unsigned char ServiceLen, unsigned char Family, unsigned long pAddr[], unsigned long *pPort, unsigned short *pTextLen, char *pText)
Return service attributes like IP address, port and text according to service name.
Definition: netapp.h:108
Definition: netapp.h:172
Definition: netapp.h:135
Definition: netapp.h:181
long sl_NetAppGet(unsigned char AppId, unsigned char Option, unsigned char *pOptionLen, unsigned char *pOptionValue)
Internal function for getting network applications configurations.
Definition: netapp.h:129
int sl_NetAppStop(unsigned long AppBitMap)
Stops a network application.
Definition: netapp.h:146
Definition: netapp.h:122