SimpleLink CC31xx/CC32xx Host Driver  Version 3.0.1.46
Simplifies the implementation of Internet connectivity
netapp.c
1 /*
2  * netapp.c - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2017 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 
38 
39 /*****************************************************************************/
40 /* Include files */
41 /*****************************************************************************/
42 #include <ti/drivers/net/wifi/simplelink.h>
43 #include <ti/drivers/net/wifi/source/protocol.h>
44 #include <ti/drivers/net/wifi/source/driver.h>
45 
46 /*****************************************************************************/
47 /* Macro declarations */
48 /*****************************************************************************/
49 
50 /*****************************************************************************/
51 /* Functions prototypes */
52 /*****************************************************************************/
53 _SlReturnVal_t _SlNetAppHandleAsync_DnsGetHostByName(void *pVoidBuf);
54 
55 _SlReturnVal_t _SlNetAppHandleAsync_DnsGetHostByService(void *pVoidBuf);
56 _SlReturnVal_t _SlNetAppHandleAsync_PingResponse(void *pVoidBuf);
57 static void _SlNetAppCopyPingResultsToReport(SlPingReportResponse_t *pResults,SlNetAppPingReport_t *pReport);
58 
59 _i16 _SlNetAppMDNSRegisterUnregisterService(const _i8* pServiceName,
60  const _u8 ServiceNameLen,
61  const _i8* pText,
62  const _u8 TextLen,
63  const _u16 Port,
64  const _u32 TTL,
65  const _u32 Options);
66 
67 
68 _u16 _SlNetAppSendTokenValue(SlNetAppHttpServerData_t * Token);
69 
70 _u16 _SlNetAppSendResponse( _u16 handle, SlNetAppResponse_t *NetAppResponse);
71 
72 #define SL_NETAPP_SERVICE_SIZE_MASK (0x7)
73 #define SL_NETAPP_PING_GUARD_INTERVAL (20000)
74 
75 static _u16 NetAppServiceSizeLUT[] =
76 {
77  (_u16)sizeof(_BasicResponse_t), /* 0 - Default value */
78  (_u16)sizeof(SlNetAppGetFullServiceWithTextIpv4List_t), /* 1 - SL_NETAPP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE */
79  (_u16)sizeof(SlNetAppGetFullServiceIpv4List_t), /* 2 - SL_NETAPP_FULL_SERVICE_IPV4_TYPE */
80  (_u16)sizeof(SlNetAppGetShortServiceIpv4List_t), /* 3 - SL_NETAPP_SHORT_SERVICE_IPV4_TYPE */
81  (_u16)sizeof(SlNetAppGetFullServiceWithTextIpv6List_t), /* 4 - SL_NETAPP_FULL_SERVICE_WITH_TEXT_IPV6_TYPE */
82  (_u16)sizeof(SlNetAppGetFullServiceIpv6List_t), /* 5 - SL_NETAPP_FULL_SERVICE_IPV6_TYPE */
83  (_u16)sizeof(SlNetAppGetShortServiceIpv6List_t), /* 6 - SL_NETAPP_SHORT_SERVICE_IPV6_TYPE */
84  (_u16)sizeof(_BasicResponse_t), /* 7 - Default value */
85 };
86 
87 typedef union
88 {
91 }_SlNetAppStartStopMsg_u;
92 
93 
94 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
95 
96 static const _SlCmdCtrl_t _SlNetAppStartCtrl =
97 {
98  SL_OPCODE_NETAPP_START_COMMAND,
99  (_SlArgSize_t)sizeof(_NetAppStartStopCommand_t),
100  (_SlArgSize_t)sizeof(_NetAppStartStopResponse_t)
101 };
102 
103 _i16 sl_NetAppStart(const _u32 AppBitMap)
104 {
105  _SlNetAppStartStopMsg_u Msg;
106  Msg.Cmd.AppId = AppBitMap;
107 
108  /* verify that this api is allowed. if not allowed then
109  ignore the API execution and return immediately with an error */
110  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
111  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppStartCtrl, &Msg, NULL));
112 
113  return Msg.Rsp.status;
114 }
115 #endif
116 
117 /*****************************************************************************
118  sl_NetAppStop
119 *****************************************************************************/
120 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
121 
122 static const _SlCmdCtrl_t _SlNetAppStopCtrl =
123 {
124  SL_OPCODE_NETAPP_STOP_COMMAND,
125  (_SlArgSize_t)sizeof(_NetAppStartStopCommand_t),
126  (_SlArgSize_t)sizeof(_NetAppStartStopResponse_t)
127 };
128 
129 _i16 sl_NetAppStop(const _u32 AppBitMap)
130 {
131  _SlNetAppStartStopMsg_u Msg;
132 
133  /* verify that this api is allowed. if not allowed then
134  ignore the API execution and return immediately with an error */
135  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
136  Msg.Cmd.AppId = AppBitMap;
137  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppStopCtrl, &Msg, NULL));
138 
139  return Msg.Rsp.status;
140 }
141 #endif
142 
143 
144 /*****************************************************************************
145  sl_NetAppArpFlush
146 *****************************************************************************/
147 
148 #if _SL_INCLUDE_FUNC(sl_NetAppArpFlush)
149 
150 
152 {
153  /* verify that this api is allowed. if not allowed then
154  ignore the API execution and return immediately with an error */
155  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
156 
157  return _SlDrvBasicCmd(SL_OPCODE_NETAPP_ARPFLUSH);
158 }
159 #endif
160 
161 /*****************************************************************************
162  sl_NetAppNdFlush
163 *****************************************************************************/
164 
165 #if _SL_INCLUDE_FUNC(sl_NetAppNdFlush)
166 
167 
169 {
170  /* verify that this api is allowed. if not allowed then
171  ignore the API execution and return immediately with an error */
172  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
173 
174  return _SlDrvBasicCmd(SL_OPCODE_NETAPP_NDFLUSH_V6);
175 }
176 #endif
177 
178 /******************************************************************************/
179 /* sl_NetAppGetServiceList */
180 /******************************************************************************/
181 typedef struct
182 {
183  _u8 IndexOffest;
184  _u8 MaxServiceCount;
185  _u8 Flags;
186  _i8 Padding;
187 }NetappGetServiceListCMD_t;
188 
189 typedef union
190 {
191  NetappGetServiceListCMD_t Cmd;
192  _BasicResponse_t Rsp;
193 }_SlNetappGetServiceListMsg_u;
194 
195 
196 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
197 
198 static const _SlCmdCtrl_t _SlGetServiceListeCtrl =
199 {
200  SL_OPCODE_NETAPP_NETAPP_MDNS_LOOKUP_SERVICE,
201  (_SlArgSize_t)sizeof(NetappGetServiceListCMD_t),
202  (_SlArgSize_t)sizeof(_BasicResponse_t)
203 };
204 
205 _i16 sl_NetAppGetServiceList(const _u8 IndexOffest,
206  const _u8 MaxServiceCount,
207  const _u8 Flags,
208  _i8 *pBuffer,
209  const _u32 BufferLength
210  )
211 {
212 
213  _i32 retVal= 0;
214  _SlNetappGetServiceListMsg_u Msg;
215  _SlCmdExt_t CmdExt;
216  _u16 ServiceSize = 0;
217  _u16 BufferSize = 0;
218 
219  /* verify that this api is allowed. if not allowed then
220  ignore the API execution and return immediately with an error */
221  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
222 
223  /*
224  Calculate RX pBuffer size
225  WARNING:
226  if this size is BufferSize than 1480 error should be returned because there
227  is no place in the RX packet.
228  */
229  ServiceSize = NetAppServiceSizeLUT[Flags & SL_NETAPP_SERVICE_SIZE_MASK];
230  BufferSize = MaxServiceCount * ServiceSize;
231 
232  /* Check the size of the requested services is smaller than size of the user buffer.
233  If not an error is returned in order to avoid overwriting memory. */
234  if(BufferLength < BufferSize)
235  {
236  return SL_ERROR_NET_APP_RX_BUFFER_LENGTH;
237  }
238 
239  _SlDrvResetCmdExt(&CmdExt);
240  CmdExt.RxPayloadLen = (_i16)BufferSize;
241  CmdExt.pRxPayload = (_u8 *)pBuffer;
242 
243  Msg.Cmd.IndexOffest = IndexOffest;
244  Msg.Cmd.MaxServiceCount = MaxServiceCount;
245  Msg.Cmd.Flags = Flags;
246  Msg.Cmd.Padding = 0;
247 
248  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetServiceListeCtrl, &Msg, &CmdExt));
249  retVal = Msg.Rsp.status;
250 
251  return (_i16)retVal;
252 }
253 
254 #endif
255 
256 /*****************************************************************************/
257 /* sl_mDNSRegisterService */
258 /*****************************************************************************/
259 /*
260  * The below struct depicts the constant parameters of the command/API RegisterService.
261  *
262  1. ServiceLen - The length of the service should be smaller than SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
263  2. TextLen - The length of the text should be smaller than SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
264  3. port - The port on this target host.
265  4. TTL - The TTL of the service
266  5. Options - bitwise parameters:
267  bit 0 - is unique (means if the service needs to be unique)
268  bit 31 - for internal use if the service should be added or deleted (set means ADD).
269  bit 1-30 for future.
270 
271  NOTE:
272 
273  1. There are another variable parameter is this API which is the service name and the text.
274  2. According to now there is no warning and Async event to user on if the service is a unique.
275 *
276  */
277 
278 typedef struct
279 {
280  _u8 ServiceNameLen;
281  _u8 TextLen;
282  _u16 Port;
283  _u32 TTL;
284  _u32 Options;
285 }NetappMdnsSetService_t;
286 
287 typedef union
288 {
289  NetappMdnsSetService_t Cmd;
290  _BasicResponse_t Rsp;
291 }_SlNetappMdnsRegisterServiceMsg_u;
292 
293 #if (_SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService) || _SL_INCLUDE_FUNC(sl_NetAppMDNSUnregisterService))
294 
295 static const _SlCmdCtrl_t _SlRegisterServiceCtrl =
296 {
297  SL_OPCODE_NETAPP_MDNSREGISTERSERVICE,
298  (_SlArgSize_t)sizeof(NetappMdnsSetService_t),
299  (_SlArgSize_t)sizeof(_BasicResponse_t)
300 };
301 
302 /******************************************************************************
303 
304  sl_NetAppMDNSRegisterService
305 
306  CALLER user from its host
307 
308 
309  DESCRIPTION:
310  Add/delete service
311  The function manipulates the command that register the service and call
312  to the NWP in order to add/delete the service to/from the mDNS package and to/from the DB.
313 
314  This register service is a service offered by the application.
315  This unregister service is a service offered by the application before.
316 
317  The service name should be full service name according to RFC
318  of the DNS-SD - means the value in name field in SRV answer.
319 
320  Example for service name:
321  1. PC1._ipp._tcp.local
322  2. PC2_server._ftp._tcp.local
323 
324  If the option is_unique is set, mDNS probes the service name to make sure
325  it is unique before starting to announce the service on the network.
326  Instance is the instance portion of the service name.
327 
328 
329 
330 
331  PARAMETERS:
332 
333  The command is from constant parameters and variables parameters.
334 
335  Constant parameters are:
336 
337  ServiceLen - The length of the service.
338  TextLen - The length of the service should be smaller than 64.
339  port - The port on this target host.
340  TTL - The TTL of the service
341  Options - bitwise parameters:
342  bit 0 - is unique (means if the service needs to be unique)
343  bit 31 - for internal use if the service should be added or deleted (set means ADD).
344  bit 1-30 for future.
345 
346  The variables parameters are:
347 
348  Service name(full service name) - The service name.
349  Example for service name:
350  1. PC1._ipp._tcp.local
351  2. PC2_server._ftp._tcp.local
352 
353  Text - The description of the service.
354  should be as mentioned in the RFC
355  (according to type of the service IPP,FTP...)
356 
357  NOTE - pay attention
358 
359  1. Temporary - there is an allocation on stack of internal buffer.
360  Its size is SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
361  It means that the sum of the text length and service name length cannot be bigger than
362  SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
363  If it is - An error is returned.
364 
365  2. According to now from certain constraints the variables parameters are set in the
366  attribute part (contain constant parameters)
367 
368 
369 
370  RETURNS: Status - the immediate response of the command status.
371  0 means success.
372 
373 ******************************************************************************/
374 _i16 _SlNetAppMDNSRegisterUnregisterService(const _i8* pServiceName,
375  const _u8 ServiceNameLen,
376  const _i8* pText,
377  const _u8 TextLen,
378  const _u16 Port,
379  const _u32 TTL,
380  const _u32 Options)
381 {
382  _SlNetappMdnsRegisterServiceMsg_u Msg;
383  _SlCmdExt_t CmdExt ;
384  _i8 ServiceNameAndTextBuffer[SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH];
385  _i8 *TextPtr;
386 
387  /* verify that this api is allowed. if not allowed then
388  ignore the API execution and return immediately with an error */
389  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
390  /*
391 
392  NOTE - pay attention
393 
394  1. Temporary - there is an allocation on stack of internal buffer.
395  Its size is SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
396  It means that the sum of the text length and service name length cannot be bigger than
397  SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
398  If it is - An error is returned.
399 
400  2. According to now from certain constraints the variables parameters are set in the
401  attribute part (contain constant parameters)
402 
403  */
404 
405  /*build the attribute part of the command.
406  It contains the constant parameters of the command*/
407 
408  Msg.Cmd.ServiceNameLen = ServiceNameLen;
409  Msg.Cmd.Options = Options;
410  Msg.Cmd.Port = Port;
411  Msg.Cmd.TextLen = TextLen;
412  Msg.Cmd.TTL = TTL;
413 
414  /*Build the payload part of the command
415  Copy the service name and text to one buffer.
416  NOTE - pay attention
417  The size of the service length + the text length should be smaller than 255,
418  Until the simplelink drive supports to variable length through SPI command. */
419  if(TextLen + ServiceNameLen > (SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH - 1 )) /*-1 is for giving a place to set null termination at the end of the text*/
420  {
421  return -1;
422  }
423 
424  _SlDrvMemZero(ServiceNameAndTextBuffer, (_u16)SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH);
425 
426  /*Copy the service name*/
427  sl_Memcpy(ServiceNameAndTextBuffer,
428  pServiceName,
429  ServiceNameLen);
430 
431  if(TextLen > 0 )
432  {
433  TextPtr = &ServiceNameAndTextBuffer[ServiceNameLen];
434  /*Copy the text just after the service name*/
435  sl_Memcpy(TextPtr,
436  pText,
437  TextLen);
438  }
439 
440  _SlDrvResetCmdExt(&CmdExt);
441  CmdExt.TxPayload1Len = (TextLen + ServiceNameLen);
442  CmdExt.pTxPayload1 = (_u8 *)ServiceNameAndTextBuffer;
443 
444  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRegisterServiceCtrl, &Msg, &CmdExt));
445 
446  return (_i16)Msg.Rsp.status;
447 }
448 #endif
449 
450 /**********************************************************************************************/
451 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
452 
453 _i16 sl_NetAppMDNSRegisterService(const _i8* pServiceName,
454  const _u8 ServiceNameLen,
455  const _i8* pText,
456  const _u8 TextLen,
457  const _u16 Port,
458  const _u32 TTL,
459  _u32 Options)
460 {
461  /* verify that this api is allowed. if not allowed then
462  ignore the API execution and return immediately with an error */
463  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
464 
465  /*
466 
467  NOTE - pay attention
468 
469  1. Temporary - there is an allocation on stack of internal buffer.
470  Its size is SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
471  It means that the sum of the text length and service name length cannot be bigger than
472  SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
473  If it is - An error is returned.
474 
475  2. According to now from certain constraints the variables parameters are set in the
476  attribute part (contain constant parameters)
477 
478  */
479 
480  /*Set the add service bit in the options parameter.
481  In order not use different opcodes for the register service and unregister service
482  bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added
483  if it is cleared it means that the service should be deleted and there is only meaning to pServiceName
484  and ServiceNameLen values. */
485  Options |= SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT;
486 
487  return _SlNetAppMDNSRegisterUnregisterService(pServiceName,
488  ServiceNameLen,
489  pText,
490  TextLen,
491  Port,
492  TTL,
493  Options);
494 }
495 #endif
496 /**********************************************************************************************/
497 
498 
499 /**********************************************************************************************/
500 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
501 
502 _i16 sl_NetAppMDNSUnRegisterService(const _i8* pServiceName,
503  const _u8 ServiceNameLen,_u32 Options)
504 {
505 
506  /* verify that this api is allowed. if not allowed then
507  ignore the API execution and return immediately with an error */
508  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
509 
510  /*
511 
512  NOTE - pay attention
513 
514  The size of the service length should be smaller than 255,
515  Until the simplelink drive supports to variable length through SPI command.
516 
517 
518  */
519 
520  /*Clear the add service bit in the options parameter.
521  In order not use different opcodes for the register service and unregister service
522  bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added
523  if it is cleared it means that the service should be deleted and there is only meaning to pServiceName
524  and ServiceNameLen values.*/
525 
526  Options &= (~SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT);
527 
528  return _SlNetAppMDNSRegisterUnregisterService( pServiceName,
529  ServiceNameLen,
530  NULL,
531  0,
532  0,
533  0,
534  Options);
535 
536 
537 }
538 #endif
539 /**********************************************************************************************/
540 
541 
542 /*****************************************************************************/
543 /* sl_DnsGetHostByService */
544 /*****************************************************************************/
545 /*
546  * The below struct depicts the constant parameters of the command/API sl_DnsGetHostByService.
547  *
548  1. ServiceLen - The length of the service should be smaller than 255.
549  2. AddrLen - TIPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
550 *
551  */
552 
553 typedef struct
554 {
555  _u8 ServiceLen;
556  _u8 AddrLen;
557  _u16 Padding;
558 }_GetHostByServiceCommand_t;
559 
560 /*
561  * The below structure depict the constant parameters that are returned in the Async event answer
562  * according to command/API sl_DnsGetHostByService for IPv4 and IPv6.
563  *
564  1Status - The status of the response.
565  2.Address - Contains the IP address of the service.
566  3.Port - Contains the port of the service.
567  4.TextLen - Contains the max length of the text that the user wants to get.
568  it means that if the test of service is bigger that its value than
569  the text is cut to inout_TextLen value.
570  Output: Contain the length of the text that is returned. Can be full text or part
571  of the text (see above).
572 *
573 */
574 
575 typedef struct
576 {
577  _u16 Status;
578  _u16 TextLen;
579  _u32 Port;
580  _u32 Address[4];
581 }_GetHostByServiceIPv6AsyncResponse_t;
582 
583 /*
584  * The below struct contains pointers to the output parameters that the user gives
585  *
586  */
587 typedef struct
588 {
589  _i16 Status;
590  _u32 *out_pAddr;
591  _u32 *out_pPort;
592  _u16 *inout_TextLen; /* in: max len , out: actual len */
593  _i8 *out_pText;
594 }_GetHostByServiceAsyncResponse_t;
595 
596 typedef union
597 {
598  _GetHostByServiceCommand_t Cmd;
599  _BasicResponse_t Rsp;
600 }_SlGetHostByServiceMsg_u;
601 
602 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
603 
604 static const _SlCmdCtrl_t _SlGetHostByServiceCtrl =
605 {
606  SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICE,
607  (_SlArgSize_t)sizeof(_GetHostByServiceCommand_t),
608  (_SlArgSize_t)sizeof(_BasicResponse_t)
609 };
610 
611 /******************************************************************************/
612 
613 _i16 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */
614  const _u8 ServiceLen,
615  const _u8 Family, /* 4-IPv4 , 16-IPv6 */
616  _u32 pAddr[],
617  _u32 *pPort,
618  _u16 *pTextLen, /* in: max len , out: actual len */
619  _i8 *pText
620  )
621 {
622  _SlGetHostByServiceMsg_u Msg;
623  _SlCmdExt_t CmdExt ;
624  _GetHostByServiceAsyncResponse_t AsyncRsp;
625  _i16 ObjIdx = MAX_CONCURRENT_ACTIONS;
626 
627  /* verify that this api is allowed. if not allowed then
628  ignore the API execution and return immediately with an error */
629  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
630  _SlDrvMemZero(&AsyncRsp, sizeof(_GetHostByServiceAsyncResponse_t));
631 
632 /*
633  Note:
634  1. The return's attributes are belonged to first service that is found.
635  It can be other services with the same service name will response to
636  the query. The results of these responses are saved in the peer cache of the NWP, and
637  should be read by another API.
638 
639  2. Text length can be 120 bytes only - not more
640  It is because of constraints in the NWP on the buffer that is allocated for the Async event.
641 
642  3.The API waits to Async event by blocking. It means that the API is finished only after an Async event
643  is sent by the NWP.
644 
645  4.No rolling option!!! - only PTR type is sent.
646 
647 */
648  /*build the attribute part of the command.
649  It contains the constant parameters of the command */
650 
651  Msg.Cmd.ServiceLen = ServiceLen;
652  Msg.Cmd.AddrLen = Family;
653 
654  /*Build the payload part of the command
655  Copy the service name and text to one buffer.*/
656 
657  _SlDrvResetCmdExt(&CmdExt);
658  CmdExt.TxPayload1Len = ServiceLen;
659  CmdExt.pTxPayload1 = (_u8 *)pServiceName;
660 
661  /*set pointers to the output parameters (the returned parameters).
662  This pointers are belonged to local struct that is set to global Async response parameter.
663  It is done in order not to run more than one sl_DnsGetHostByService at the same time.
664  The API should be run only if global parameter is pointed to NULL. */
665  AsyncRsp.out_pText = pText;
666  AsyncRsp.inout_TextLen = (_u16* )pTextLen;
667  AsyncRsp.out_pPort = pPort;
668  AsyncRsp.out_pAddr = (_u32 *)&pAddr[0];
669 
670  ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, GETHOSYBYSERVICE_ID, SL_MAX_SOCKETS);
671 
672  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
673  {
674  return SL_POOL_IS_EMPTY;
675  }
676 
677  if (SL_AF_INET6 == Family)
678  {
679  g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK;
680  }
681  /* Send the command */
682  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByServiceCtrl, &Msg, &CmdExt));
683 
684  /* If the immediate reponse is O.K. than wait for aSYNC event response. */
685  if(SL_RET_CODE_OK == Msg.Rsp.status)
686  {
687  VERIFY_RET_OK(_SlDrvWaitForInternalAsyncEvent(ObjIdx,0,0));
688 
689  /* If we are - it means that Async event was sent.
690  The results are copied in the Async handle return functions */
691 
692  Msg.Rsp.status = AsyncRsp.Status;
693  }
694 
695  _SlDrvReleasePoolObj(ObjIdx);
696  return Msg.Rsp.status;
697 }
698 #endif
699 
700 /******************************************************************************/
701 
702 /******************************************************************************
703  _SlNetAppHandleAsync_DnsGetHostByService
704 
705  CALLER NWP - Async event on sl_DnsGetHostByService with IPv4 Family
706 
707 
708  DESCRIPTION:
709 
710  Async event on sl_DnsGetHostByService command with IPv4 Family.
711  Return service attributes like IP address, port and text according to service name.
712  The user sets a service name Full/Part (see example below), and should get the:
713  1. IP of the service
714  2. The port of service.
715  3. The text of service.
716 
717  Hence it can make a connection to the specific service and use it.
718  It is similar to get host by name method.
719 
720  It is done by a single shot query with PTR type on the service name.
721 
722 
723 
724  Note:
725  1. The return's attributes are belonged to first service that is found.
726  It can be other services with the same service name will response to
727  the query. The results of these responses are saved in the peer cache of the NWP, and
728  should be read by another API.
729 
730 
731  PARAMETERS:
732 
733  pVoidBuf - is point to opcode of the event.
734  it contains the outputs that are given to the user
735 
736  outputs description:
737 
738  1.out_pAddr[] - output: Contain the IP address of the service.
739  2.out_pPort - output: Contain the port of the service.
740  3.inout_TextLen - Input: Contain the max length of the text that the user wants to get.
741  it means that if the test of service is bigger that its value than
742  the text is cut to inout_TextLen value.
743  Output: Contain the length of the text that is returned. Can be full text or part
744  of the text (see above).
745 
746  4.out_pText - Contain the text of the service (full or part see above- inout_TextLen description).
747 
748  *
749 
750 
751  RETURNS: success or fail.
752 
753 ******************************************************************************/
754 _SlReturnVal_t _SlNetAppHandleAsync_DnsGetHostByService(void *pVoidBuf)
755 {
756  _u16 TextLen;
757  _u16 UserTextLen;
758  _GetHostByServiceAsyncResponse_t* Res= NULL;
759  _GetHostByServiceIPv6AsyncResponse_t *pMsgArgs = (_GetHostByServiceIPv6AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf);
760 
761  VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs);
762  /*Res pointed to mDNS global object struct */
763  Res = (_GetHostByServiceAsyncResponse_t*)g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs;
764  /*IPv6*/
765  if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK)
766  {
767  Res->out_pAddr[1] = pMsgArgs->Address[1]; /* Copy data from IPv6 address to Host user's pAddr. The array must be at least 4 cells of _u32 */
768  Res->out_pAddr[2] = pMsgArgs->Address[2];
769  Res->out_pAddr[3] = pMsgArgs->Address[3];
770  }
771 
772  TextLen = pMsgArgs->TextLen;
773 
774  /*It is 4 bytes so we avoid from memcpy*/
775  Res->out_pAddr[0] = pMsgArgs->Address[0]; /* Copy first cell data from IPv4/6 address to Host user's pAddr */
776  Res->out_pPort[0] = pMsgArgs->Port;
777  Res->Status = (_i16)pMsgArgs->Status;
778  /*set to TextLen the text length of the user (input fromthe user).*/
779  UserTextLen = Res->inout_TextLen[0];
780 
781  /*Cut the service text if the user requested for smaller text.*/
782  UserTextLen = (TextLen <= UserTextLen) ? TextLen : UserTextLen;
783  Res->inout_TextLen[0] = UserTextLen ;
784 
785  /**************************************************************************************************
786 
787  2. Copy the payload part of the evnt (the text) to the payload part of the response
788  the lenght of the copy is according to the text length in the attribute part. */
789 
790  /*IPv6*/
791  if (g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK)
792  {
793  sl_Memcpy(Res->out_pText,
794  (_i8 *)(& pMsgArgs[1]), /* & pMsgArgs[1] -> 1st byte after the fixed header = 1st byte of variable text.*/
795  UserTextLen);
796  }
797  else
798  {
799  sl_Memcpy(Res->out_pText,
800  (_i8 *)(& pMsgArgs->Address[1]), /* & pMsgArgs[1] -> 1st byte after the fixed header = 1st byte of variable text.*/
801  UserTextLen);
802  }
803 
804  SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
805 
806  return SL_OS_RET_CODE_OK;
807 }
808 
809 /*****************************************************************************/
810 /* _SlNetAppHandleAsync_DnsGetHostByAddr */
811 /*****************************************************************************/
812 _SlReturnVal_t _SlNetAppHandleAsync_DnsGetHostByAddr(void *pVoidBuf)
813 {
814  SL_TRACE0(DBG_MSG, MSG_303, "STUB: _SlNetAppHandleAsync_DnsGetHostByAddr not implemented yet!");
815  return SL_OS_RET_CODE_OK;
816 }
817 
818 /*****************************************************************************/
819 /* sl_DnsGetHostByName */
820 /*****************************************************************************/
821 typedef union
822 {
825 }_GetHostByNameAsyncResponse_u;
826 
827 typedef union
828 {
830  _BasicResponse_t Rsp;
831 }_SlGetHostByNameMsg_u;
832 
833 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
834 static const _SlCmdCtrl_t _SlGetHostByNameCtrl =
835 {
836  SL_OPCODE_NETAPP_DNSGETHOSTBYNAME,
837  (_SlArgSize_t)sizeof(NetAppGetHostByNameCommand_t),
838  (_SlArgSize_t)sizeof(_BasicResponse_t)
839 };
840 
841 _i16 sl_NetAppDnsGetHostByName(_i8 * pHostName,const _u16 NameLen, _u32* OutIpAddr,const _u8 Family )
842 {
843  _SlGetHostByNameMsg_u Msg;
844  _SlCmdExt_t ExtCtrl;
845  _GetHostByNameAsyncResponse_u AsyncRsp;
846  _i16 ObjIdx = MAX_CONCURRENT_ACTIONS;
847 
848  /* verify that this api is allowed. if not allowed then
849  ignore the API execution and return immediately with an error */
850  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
851 
852  _SlDrvResetCmdExt(&ExtCtrl);
853  ExtCtrl.TxPayload1Len = NameLen;
854  ExtCtrl.pTxPayload1 = (_u8 *)pHostName;
855 
856  Msg.Cmd.Len = NameLen;
857  Msg.Cmd.Family = Family;
858 
859  /*Use Obj to issue the command, if not available try later */
860  ObjIdx = _SlDrvWaitForPoolObj(GETHOSYBYNAME_ID,SL_MAX_SOCKETS);
861  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
862  {
863  return SL_POOL_IS_EMPTY;
864  }
865  if (SL_RET_CODE_STOP_IN_PROGRESS == ObjIdx)
866  {
867  return SL_RET_CODE_STOP_IN_PROGRESS;
868  }
869 
870  SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
871 
872  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&AsyncRsp;
873  /*set bit to indicate IPv6 address is expected */
874  if (SL_AF_INET6 == Family)
875  {
876  g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK;
877  }
878 
879  SL_DRV_PROTECTION_OBJ_UNLOCK();
880 
881  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByNameCtrl, &Msg, &ExtCtrl));
882 
883  if(SL_RET_CODE_OK == Msg.Rsp.status)
884  {
885  VERIFY_RET_OK(_SlDrvWaitForInternalAsyncEvent(ObjIdx,0,0));
886 
887  Msg.Rsp.status = (_i16)AsyncRsp.IpV4.Status;
888 
889  if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status)
890  {
891  sl_Memcpy((_i8 *)OutIpAddr,
892  (_i8 *)&AsyncRsp.IpV4.Ip0,
893  (SL_AF_INET == Family) ? SL_IPV4_ADDRESS_SIZE : SL_IPV6_ADDRESS_SIZE);
894  }
895  }
896  _SlDrvReleasePoolObj(ObjIdx);
897  return Msg.Rsp.status;
898 }
899 #endif
900 
901 
902 /******************************************************************************/
903 /* _SlNetAppHandleAsync_DnsGetHostByName */
904 /******************************************************************************/
905 _SlReturnVal_t _SlNetAppHandleAsync_DnsGetHostByName(void *pVoidBuf)
906 {
907  NetAppGetHostByNameIPv4AsyncResponse_t *pMsgArgs = (NetAppGetHostByNameIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf);
908 
909  SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
910 
911  VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs);
912 
913  /*IPv6 */
914  if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK)
915  {
916  sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(NetAppGetHostByNameIPv6AsyncResponse_t));
917  }
918  /*IPv4 */
919  else
920  {
921  sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(NetAppGetHostByNameIPv4AsyncResponse_t));
922  }
923 
924  SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
925  SL_DRV_PROTECTION_OBJ_UNLOCK();
926  return SL_OS_RET_CODE_OK;
927 }
928 
929 static void _SlNetAppCopyPingResultsToReport(SlPingReportResponse_t *pResults,SlNetAppPingReport_t *pReport)
930 {
931  pReport->PacketsSent = pResults->NumSendsPings;
932  pReport->PacketsReceived = pResults->NumSuccsessPings;
933  pReport->MinRoundTime = pResults->RttMin;
934  pReport->MaxRoundTime = pResults->RttMax;
935  pReport->AvgRoundTime = pResults->RttAvg;
936  pReport->TestTime = pResults->TestTime;
937 }
938 
939 /*****************************************************************************/
940 /* _SlNetAppHandleAsync_PingResponse */
941 /*****************************************************************************/
942 _SlReturnVal_t _SlNetAppHandleAsync_PingResponse(void *pVoidBuf)
943 {
944  SlPingReportResponse_t *pMsgArgs = (SlPingReportResponse_t *)_SL_RESP_ARGS_START(pVoidBuf);
945  SlNetAppPingReport_t pingReport;
946 
947  if(pPingCallBackFunc)
948  {
949  _SlNetAppCopyPingResultsToReport(pMsgArgs,&pingReport);
950  pPingCallBackFunc(&pingReport);
951  }
952  else
953  {
954  SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
955 
956  VERIFY_SOCKET_CB(NULL != g_pCB->PingCB.PingAsync.pAsyncRsp);
957 
958  if (NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs)
959  {
960  sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(SlPingReportResponse_t));
961  SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
962  }
963  SL_DRV_PROTECTION_OBJ_UNLOCK();
964  }
965 
966  return SL_OS_RET_CODE_OK;
967 }
968 
969 /*****************************************************************************/
970 /* sl_NetAppPing */
971 /*****************************************************************************/
972 typedef union
973 {
976 }_SlPingStartMsg_u;
977 
978 typedef enum
979 {
980  CMD_PING_TEST_RUNNING = 0,
981  CMD_PING_TEST_STOPPED
982 }_SlPingStatus_e;
983 
984 #if _SL_INCLUDE_FUNC(sl_NetAppPing)
985 _i16 sl_NetAppPing(const SlNetAppPingCommand_t* pPingParams, const _u8 Family, SlNetAppPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback)
986 {
987  _SlCmdCtrl_t CmdCtrl = {0, (_SlArgSize_t)sizeof(SlNetAppPingCommand_t), (_SlArgSize_t)sizeof(_BasicResponse_t)};
988  _SlPingStartMsg_u Msg;
989  SlPingReportResponse_t PingRsp;
990  _i16 ObjIdx = MAX_CONCURRENT_ACTIONS;
991  _u32 PingTimeout = 0;
992 
993  /* verify that this api is allowed. if not allowed then
994  ignore the API execution and return immediately with an error */
995  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
996 
997  if(NULL != pPingParams)
998  {
999  if(SL_AF_INET == Family)
1000  {
1001  CmdCtrl.Opcode = SL_OPCODE_NETAPP_PINGSTART;
1002  sl_Memcpy(&Msg.Cmd.Ip, &pPingParams->Ip, SL_IPV4_ADDRESS_SIZE);
1003  }
1004  else
1005  {
1006  CmdCtrl.Opcode = SL_OPCODE_NETAPP_PINGSTART_V6;
1007  sl_Memcpy(&Msg.Cmd.Ip, &pPingParams->Ip, SL_IPV6_ADDRESS_SIZE);
1008  }
1009 
1010  Msg.Cmd.PingIntervalTime = pPingParams->PingIntervalTime;
1011  Msg.Cmd.PingSize = pPingParams->PingSize;
1012  Msg.Cmd.PingRequestTimeout = pPingParams->PingRequestTimeout;
1013  Msg.Cmd.TotalNumberOfAttempts = pPingParams->TotalNumberOfAttempts;
1014  Msg.Cmd.Flags = pPingParams->Flags;
1015 
1016 
1017  /* calculate the ping timeout according to the parmas + the guard interval */
1018  PingTimeout = SL_NETAPP_PING_GUARD_INTERVAL + (pPingParams->PingIntervalTime * pPingParams->TotalNumberOfAttempts);
1019 
1020  if (Msg.Cmd.Ip != 0)
1021  {
1022  /* If the following conditions are met, return an error
1023  Wrong ping parameters - ping cannot be called with the following parameters:
1024  1. infinite ping packet
1025  2. report only when finished
1026  3. no callback supplied */
1027  if ((pPingCallback == NULL) && (pPingParams->Flags == 0) && (pPingParams->TotalNumberOfAttempts == 0))
1028  {
1029  return SL_RET_CODE_NET_APP_PING_INVALID_PARAMS;
1030  }
1031 
1032  if( pPingCallback )
1033  {
1034  pPingCallBackFunc = pPingCallback;
1035  }
1036  else
1037  {
1038  /* Use Obj to issue the command, if not available try later */
1039  ObjIdx = _SlDrvWaitForPoolObj(PING_ID,SL_MAX_SOCKETS);
1040  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
1041  {
1042  return SL_POOL_IS_EMPTY;
1043  }
1044  if (SL_RET_CODE_STOP_IN_PROGRESS == ObjIdx)
1045  {
1046  return SL_RET_CODE_STOP_IN_PROGRESS;
1047  }
1048  OSI_RET_OK_CHECK(sl_LockObjLock(&g_pCB->ProtectionLockObj, SL_OS_WAIT_FOREVER));
1049  /* async response handler for non callback mode */
1050  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&PingRsp;
1051  pPingCallBackFunc = NULL;
1052  OSI_RET_OK_CHECK(sl_LockObjUnlock(&g_pCB->ProtectionLockObj));
1053  }
1054  }
1055  }
1056  /* Issue Stop Command */
1057  else
1058  {
1059  CmdCtrl.Opcode = SL_OPCODE_NETAPP_PINGSTART;
1060  Msg.Cmd.Ip = 0;
1061  }
1062  /* send the command */
1063  VERIFY_RET_OK(_SlDrvCmdOp(&CmdCtrl, &Msg, NULL));
1064  if (Msg.Cmd.Ip != 0)
1065  {
1066  if(CMD_PING_TEST_RUNNING == (_i16)Msg.Rsp.Status || CMD_PING_TEST_STOPPED == (_i16)Msg.Rsp.Status )
1067  {
1068  /* block waiting for results if no callback function is used */
1069  if( NULL == pPingCallback )
1070  {
1071  VERIFY_RET_OK(_SlDrvWaitForInternalAsyncEvent(ObjIdx, PingTimeout, SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE));
1072 
1073  if( SL_OS_RET_CODE_OK == (_i16)PingRsp.Status )
1074  {
1075  _SlNetAppCopyPingResultsToReport(&PingRsp,pReport);
1076  }
1077  _SlDrvReleasePoolObj(ObjIdx);
1078  }
1079  }
1080  else
1081  { /* ping failure, no async response */
1082  if( NULL == pPingCallback )
1083  {
1084  _SlDrvReleasePoolObj(ObjIdx);
1085  }
1086  }
1087  }
1088  return (_i16)Msg.Rsp.Status;
1089 }
1090 #endif
1091 
1092 /*****************************************************************************/
1093 /* sl_NetAppSet */
1094 /*****************************************************************************/
1095 typedef union
1096 {
1097  SlNetAppSetGet_t Cmd;
1098  _BasicResponse_t Rsp;
1099 }_SlNetAppMsgSet_u;
1100 
1101 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
1102 
1103 static const _SlCmdCtrl_t _SlNetAppSetCmdCtrl =
1104 {
1105  SL_OPCODE_NETAPP_NETAPPSET,
1106  (_SlArgSize_t)sizeof(SlNetAppSetGet_t),
1107  (_SlArgSize_t)sizeof(_BasicResponse_t)
1108 };
1109 
1110 _i16 sl_NetAppSet(const _u8 AppId ,const _u8 Option, const _u8 OptionLen, const _u8 *pOptionValue)
1111 {
1112  _SlNetAppMsgSet_u Msg;
1113  _SlCmdExt_t CmdExt;
1114 
1115  /* verify that this api is allowed. if not allowed then
1116  ignore the API execution and return immediately with an error */
1117  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1118 
1119  _SlDrvResetCmdExt(&CmdExt);
1120  CmdExt.TxPayload1Len = (OptionLen+3) & (~3);
1121  CmdExt.pTxPayload1 = (_u8 *)pOptionValue;
1122 
1123  Msg.Cmd.AppId = AppId;
1124  Msg.Cmd.ConfigLen = OptionLen;
1125  Msg.Cmd.ConfigOpt = Option;
1126 
1127  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSetCmdCtrl, &Msg, &CmdExt));
1128 
1129  return (_i16)Msg.Rsp.status;
1130 }
1131 #endif
1132 
1133 /*****************************************************************************/
1134 /* sl_NetAppSendTokenValue */
1135 /*****************************************************************************/
1136 typedef union
1137 {
1139  _BasicResponse_t Rsp;
1140 }_SlNetAppMsgSendTokenValue_u;
1141 
1142 const _SlCmdCtrl_t _SlNetAppSendTokenValueCmdCtrl =
1143 {
1144  SL_OPCODE_NETAPP_HTTPSENDTOKENVALUE,
1145  (_SlArgSize_t)sizeof(SlNetAppHttpServerSendToken_t),
1146  (_SlArgSize_t)sizeof(_BasicResponse_t)
1147 };
1148 
1149 _u16 _SlNetAppSendTokenValue(SlNetAppHttpServerData_t * Token_value)
1150 {
1151  _SlNetAppMsgSendTokenValue_u Msg;
1152  _SlCmdExt_t CmdExt;
1153 
1154  _SlDrvMemZero(&CmdExt, (_u16)sizeof(_SlCmdExt_t));
1155 
1156  CmdExt.TxPayload1Len = (Token_value->ValueLen+3) & (~3);
1157  CmdExt.pTxPayload1 = (_u8 *) Token_value->pTokenValue;
1158 
1159  Msg.Cmd.TokenValueLen = Token_value->ValueLen;
1160  Msg.Cmd.TokenNameLen = Token_value->NameLen;
1161  sl_Memcpy(&Msg.Cmd.TokenName[0], Token_value->pTokenName, Token_value->NameLen);
1162 
1163  VERIFY_RET_OK(_SlDrvCmdSend_noLock((_SlCmdCtrl_t *)&_SlNetAppSendTokenValueCmdCtrl, &Msg, &CmdExt));
1164 
1165  return Msg.Rsp.status;
1166 }
1167 
1168 /*****************************************************************************/
1169 /* sl_NetAppSendResponse */
1170 /*****************************************************************************/
1171 typedef union
1172 {
1174  _BasicResponse_t Rsp;
1175 }_SlNetAppMsgSendResponse_u;
1176 
1177 const _SlCmdCtrl_t _SlNetAppSendResponseCmdCtrl =
1178 {
1179  SL_OPCODE_NETAPP_RESPONSE,
1181  sizeof(_BasicResponse_t)
1182 };
1183 
1184 _u16 _SlNetAppSendResponse( _u16 handle, SlNetAppResponse_t *NetAppResponse)
1185 {
1186  _SlNetAppMsgSendResponse_u Msg;
1187  _SlCmdExt_t CmdExt;
1188  _SlReturnVal_t RetVal;
1189  _u16 dataLen;
1190 
1191  _SlDrvMemZero(&CmdExt, (_u16)sizeof(_SlCmdExt_t));
1192 
1193  dataLen = NetAppResponse->ResponseData.MetadataLen + NetAppResponse->ResponseData.PayloadLen;
1194 
1195  if ((NetAppResponse->ResponseData.MetadataLen <= SL_NETAPP_REQUEST_MAX_METADATA_LEN) && (dataLen <= SL_NETAPP_REQUEST_MAX_DATA_LEN))
1196  {
1197  if (dataLen > 0)
1198  {
1199  /* Zero copy of the two parts: metadata + payload */
1200  CmdExt.pTxPayload1 = NetAppResponse->ResponseData.pMetadata;
1201  CmdExt.TxPayload1Len = NetAppResponse->ResponseData.MetadataLen;
1202 
1203  CmdExt.pTxPayload2 = NetAppResponse->ResponseData.pPayload;
1204  CmdExt.TxPayload2Len = NetAppResponse->ResponseData.PayloadLen;
1205  }
1206  else
1207  {
1208  CmdExt.pTxPayload1 = NULL;
1209  CmdExt.pTxPayload2 = NULL;
1210  }
1211 
1212  CmdExt.RxPayloadLen = 0;
1213  CmdExt.pRxPayload = NULL;
1214 
1215  Msg.Cmd.Handle = handle;
1216  Msg.Cmd.status = NetAppResponse->Status;
1217  Msg.Cmd.MetadataLen = NetAppResponse->ResponseData.MetadataLen;
1218  Msg.Cmd.PayloadLen = NetAppResponse->ResponseData.PayloadLen;
1219  Msg.Cmd.Flags = NetAppResponse->ResponseData.Flags;
1220 
1221  RetVal = _SlDrvCmdSend_noLock((_SlCmdCtrl_t *)&_SlNetAppSendResponseCmdCtrl, &Msg, &CmdExt);
1222  }
1223  else
1224  {
1225  /* TODO: how to return the error code asynchronously? */
1226  RetVal = SL_ERROR_BSD_ENOMEM;
1227  }
1228 
1229  return RetVal;
1230 }
1231 
1232 /*****************************************************************************/
1233 /* sl_NetAppRecv */
1234 /*****************************************************************************/
1235 typedef union
1236 {
1238  _BasicResponse_t Rsp; /* Not used. do we need it? */
1239 }_SlNetAppReceiveMsg_u;
1240 
1241 #if _SL_INCLUDE_FUNC(sl_NetAppRecv)
1242 
1243 const _SlCmdCtrl_t _SlNetAppReceiveCmdCtrl =
1244 {
1245  SL_OPCODE_NETAPP_RECEIVEREQUEST,
1247  sizeof(_BasicResponse_t) /* Where is this used? */
1248 };
1249 
1250 _SlReturnVal_t sl_NetAppRecv( _u16 Handle, _u16 *DataLen, _u8 *pData, _u32 *Flags)
1251 {
1252  _SlNetAppReceiveMsg_u Msg;
1253  _SlCmdExt_t CmdExt;
1254  SlProtocolNetAppReceive_t AsyncRsp; /* Will be filled when SL_OPCODE_NETAPP_RECEIVE async event is arrived */
1255 
1256  _SlReturnVal_t RetVal;
1257  _i16 ObjIdx = MAX_CONCURRENT_ACTIONS;
1258  _SlArgsData_t pArgsData;
1259 
1260  /* Validate input arguments */
1261  if ((NULL == pData) || (0==DataLen))
1262  {
1263  return SL_ERROR_BSD_EINVAL;
1264  }
1265 
1266  /* Save the user RX bufer. Rx data will be copied into it on the SL_OPCODE_NETAPP_RECEIVE async event */
1267  _SlDrvResetCmdExt(&CmdExt);
1268  CmdExt.RxPayloadLen = *DataLen;
1269  CmdExt.pRxPayload = pData;
1270 
1271  /* Prepare the command args */
1272  Msg.Cmd.Handle = Handle;
1273  Msg.Cmd.MaxBufferLen = *DataLen;
1274  Msg.Cmd.Flags = *Flags;
1275 
1276  /* Use Obj to issue the command, if not available try later */
1277  ObjIdx = _SlDrvWaitForPoolObj(NETAPP_RECEIVE_ID, SL_MAX_SOCKETS);
1278 
1279  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
1280  {
1281  return SL_POOL_IS_EMPTY;
1282  }
1283  if (SL_RET_CODE_STOP_IN_PROGRESS == ObjIdx)
1284  {
1285  return SL_RET_CODE_STOP_IN_PROGRESS;
1286  }
1287 
1288  /* Save the AsyncRsp and cmdExt information for the SL_OPCODE_NETAPP_RECEIVE async event */
1289  AsyncRsp.Handle = Handle; /* Handle we are waiting for */
1290  AsyncRsp.Flags = 0;
1291  AsyncRsp.PayloadLen = 0; /* 0 will indicate an error in the SL_OPCODE_NETAPP_RECEIVE async event and that no data arrived. */
1292 
1293  _SlDrvProtectionObjLockWaitForever();
1294 
1295  pArgsData.pData = (_u8 *) &CmdExt;
1296  pArgsData.pArgs = (_u8 *) &AsyncRsp;
1297 
1298  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&pArgsData;
1299 
1300  _SlDrvProtectionObjUnLock();
1301 
1302  /* Send the command */
1303  RetVal = _SlDrvCmdSend((_SlCmdCtrl_t *)&_SlNetAppReceiveCmdCtrl, &Msg, &CmdExt);
1304 
1305  if(SL_OS_RET_CODE_OK == RetVal)
1306  {
1307  /* Wait for SL_OPCODE_NETAPP_RECEIVE async event. Will be signaled by _SlNetAppHandleAsync_NetAppReceive. */
1308  VERIFY_RET_OK(_SlDrvWaitForInternalAsyncEvent(ObjIdx, 0, 0));
1309 
1310  /* Update information for the user */
1311  *DataLen = AsyncRsp.PayloadLen;
1312  *Flags = AsyncRsp.Flags;
1313  }
1314 
1315  _SlDrvReleasePoolObj(ObjIdx);
1316 
1317  return RetVal;
1318 }
1319 
1320 
1321 /*****************************************************************************/
1322 /* _SlNetAppHandleAsync_NetAppReceive */
1323 /*****************************************************************************/
1324 void _SlNetAppHandleAsync_NetAppReceive(void *pVoidBuf)
1325 {
1326  _u8 *pData;
1327  _u16 len;
1328  SlProtocolNetAppReceive_t *AsyncRsp;
1329  _SlCmdExt_t *CmdExt;
1330  SlProtocolNetAppReceive_t *pMsgArgs = (SlProtocolNetAppReceive_t *)_SL_RESP_ARGS_START(pVoidBuf);
1331 
1332  pData = (_u8 *)((SlProtocolNetAppReceive_t *)pMsgArgs + 1); /* Points to the netapp receive payload */
1333 
1334  _SlDrvProtectionObjLockWaitForever();
1335 
1336  if (NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs)
1337  {
1338  AsyncRsp = (SlProtocolNetAppReceive_t *) ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))-> pArgs;
1339  CmdExt = (_SlCmdExt_t *) ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))-> pData;
1340 
1341  if (pMsgArgs->Handle == AsyncRsp->Handle)
1342  {
1343  if (pMsgArgs->PayloadLen <= CmdExt->RxPayloadLen)
1344  {
1345  len = pMsgArgs->PayloadLen;
1346  }
1347  else
1348  {
1349  len = CmdExt->RxPayloadLen;
1350  }
1351 
1352  /* Copy the data to the user buffer */
1353  sl_Memcpy (CmdExt->pRxPayload, pData, len);
1354 
1355  /* Update len and flags */
1356  AsyncRsp->PayloadLen = len;
1357  AsyncRsp->Flags = pMsgArgs->Flags;
1358  }
1359  }
1360 
1361  _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
1362  _SlDrvProtectionObjUnLock();
1363 
1364  return;
1365 }
1366 
1367 #endif
1368 
1369 /*****************************************************************************/
1370 /* sl_NetAppSend */
1371 /*****************************************************************************/
1372 typedef union
1373 {
1375  _BasicResponse_t Rsp;
1376 }_SlNetAppMsgSend_u;
1377 
1378 const _SlCmdCtrl_t _SlNetAppSendCmdCtrl =
1379 {
1380  SL_OPCODE_NETAPP_SEND,
1381  sizeof(SlProtocolNetAppSend_t),
1382  sizeof(_BasicResponse_t)
1383 };
1384 
1385 _u16 sl_NetAppSend( _u16 Handle, _u16 DataLen, _u8* pData, _u32 Flags)
1386 {
1387  _SlNetAppMsgSend_u Msg;
1388  _SlCmdExt_t CmdExt;
1389 
1390  _SlDrvMemZero(&CmdExt, (_u16)sizeof(_SlCmdExt_t));
1391 
1392  if ((((Flags & SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) == SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) && (DataLen <= SL_NETAPP_REQUEST_MAX_METADATA_LEN)) ||
1393  (((Flags & SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) == 0) && (DataLen <= SL_NETAPP_REQUEST_MAX_DATA_LEN)))
1394  {
1395  CmdExt.TxPayload1Len = (DataLen+3) & (~3);
1396  CmdExt.pTxPayload1 = (_u8 *) pData;
1397 
1398  Msg.Cmd.Handle = Handle;
1399  Msg.Cmd.DataLen = DataLen;
1400  Msg.Cmd.Flags = Flags;
1401 
1402  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSendCmdCtrl, &Msg, &CmdExt));
1403  }
1404  else
1405  {
1406  Msg.Rsp.status = SL_ERROR_BSD_ENOMEM;
1407  }
1408 
1409  return Msg.Rsp.status;
1410 }
1411 
1412 /*****************************************************************************/
1413 /* sl_NetAppGet */
1414 /*****************************************************************************/
1415 typedef union
1416 {
1417  SlNetAppSetGet_t Cmd;
1418  SlNetAppSetGet_t Rsp;
1419 }_SlNetAppMsgGet_u;
1420 
1421 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
1422 static const _SlCmdCtrl_t _SlNetAppGetCmdCtrl =
1423 {
1424  SL_OPCODE_NETAPP_NETAPPGET,
1425  (_SlArgSize_t)sizeof(SlNetAppSetGet_t),
1426  (_SlArgSize_t)sizeof(SlNetAppSetGet_t)
1427 };
1428 
1429 _i16 sl_NetAppGet(const _u8 AppId, const _u8 Option,_u8 *pOptionLen, _u8 *pOptionValue)
1430 {
1431  _SlNetAppMsgGet_u Msg;
1432  _SlCmdExt_t CmdExt;
1433 
1434  /* verify that this api is allowed. if not allowed then
1435  ignore the API execution and return immediately with an error */
1436  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1437 
1438  if (*pOptionLen == 0)
1439  {
1440  return SL_EZEROLEN;
1441  }
1442 
1443  _SlDrvResetCmdExt(&CmdExt);
1444  CmdExt.RxPayloadLen = (_i16)(*pOptionLen);
1445  CmdExt.pRxPayload = (_u8 *)pOptionValue;
1446 
1447  Msg.Cmd.AppId = AppId;
1448  Msg.Cmd.ConfigOpt = Option;
1449  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppGetCmdCtrl, &Msg, &CmdExt));
1450 
1451 
1452  if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
1453  {
1454  *pOptionLen = (_u8)CmdExt.RxPayloadLen;
1455  return SL_ESMALLBUF;
1456  }
1457  else
1458  {
1459  *pOptionLen = (_u8)CmdExt.ActualRxPayloadLen;
1460  }
1461 
1462  return (_i16)Msg.Rsp.Status;
1463 }
1464 #endif
1465 
1466 /*****************************************************************************/
1467 /* _SlNetAppEventHandler */
1468 /*****************************************************************************/
1469 _SlReturnVal_t _SlNetAppEventHandler(void* pArgs)
1470 {
1471  _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs;
1472 #if defined(slcb_NetAppHttpServerHdlr) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
1473  SlNetAppHttpServerEvent_t httpServerEvent;
1474  SlNetAppHttpServerResponse_t httpServerResponse;
1475 #endif
1476  switch(pHdr->GenHeader.Opcode)
1477  {
1478  case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE:
1479  case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6:
1480  _SlNetAppHandleAsync_DnsGetHostByName(pArgs);
1481  break;
1482  case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE:
1483  case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE_V6:
1484  _SlNetAppHandleAsync_DnsGetHostByService(pArgs);
1485  break;
1486  case SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE:
1487  _SlNetAppHandleAsync_PingResponse(pArgs);
1488  break;
1489 
1490  case SL_OPCODE_NETAPP_HTTPGETTOKENVALUE:
1491  {
1492 #if defined(slcb_NetAppHttpServerHdlr) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
1493  _u8 *pTokenName;
1494  SlNetAppHttpServerData_t Token_value;
1495  SlNetAppHttpServerGetToken_t *httpGetToken = (SlNetAppHttpServerGetToken_t *)_SL_RESP_ARGS_START(pHdr);
1496  pTokenName = (_u8 *)((SlNetAppHttpServerGetToken_t *)httpGetToken + 1);
1497 
1498  httpServerResponse.Response = SL_NETAPP_HTTPSETTOKENVALUE;
1499  httpServerResponse.ResponseData.TokenValue.Len = SL_NETAPP_MAX_TOKEN_VALUE_LEN;
1500 
1501  /* Reuse the async buffer for getting the token value response from the user */
1502  httpServerResponse.ResponseData.TokenValue.pData = (_u8 *)_SL_RESP_ARGS_START(pHdr) + SL_NETAPP_MAX_TOKEN_NAME_LEN;
1503 
1504  httpServerEvent.Event = SL_NETAPP_EVENT_HTTP_TOKEN_GET;
1505  httpServerEvent.EventData.HttpTokenName.Len = httpGetToken->TokenNameLen;
1506  httpServerEvent.EventData.HttpTokenName.pData = pTokenName;
1507 
1508  Token_value.pTokenName = pTokenName;
1509 
1510  _SlDrvDispatchHttpServerEvents (&httpServerEvent, &httpServerResponse);
1511 
1512  Token_value.ValueLen = httpServerResponse.ResponseData.TokenValue.Len;
1513  Token_value.NameLen = httpServerEvent.EventData.HttpTokenName.Len;
1514  Token_value.pTokenValue = httpServerResponse.ResponseData.TokenValue.pData;
1515 
1516  _SlNetAppSendTokenValue(&Token_value);
1517 #else
1518 
1519  _u8 *pTokenName;
1520  SlNetAppHttpServerData_t Token_value;
1521  SlNetAppHttpServerGetToken_t *httpGetToken = (SlNetAppHttpServerGetToken_t*)_SL_RESP_ARGS_START(pHdr);
1522  pTokenName = (_u8 *)((SlNetAppHttpServerGetToken_t *)httpGetToken + 1);
1523 
1524  Token_value.pTokenName = pTokenName;
1525  Token_value.ValueLen = 0;
1526  Token_value.NameLen = httpGetToken->TokenNameLen;
1527  Token_value.pTokenValue = NULL;
1528 
1529  _SlNetAppSendTokenValue(&Token_value);
1530 #endif
1531  }
1532  break;
1533 
1534  case SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE:
1535  {
1536 #if defined(slcb_NetAppHttpServerHdlr) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
1537  _u8 *pPostParams;
1538 
1539  SlNetAppHttpServerPostToken_t *httpPostTokenArgs = (SlNetAppHttpServerPostToken_t *)_SL_RESP_ARGS_START(pHdr);
1540  pPostParams = (_u8 *)((SlNetAppHttpServerPostToken_t *)httpPostTokenArgs + 1);
1541 
1542  httpServerEvent.Event = SL_NETAPP_EVENT_HTTP_TOKEN_POST;
1543 
1544  httpServerEvent.EventData.HttpPostData.Action.Len = httpPostTokenArgs->PostActionLen;
1545  httpServerEvent.EventData.HttpPostData.Action.pData = pPostParams;
1546  pPostParams+=httpPostTokenArgs->PostActionLen;
1547 
1548  httpServerEvent.EventData.HttpPostData.TokenName.Len = httpPostTokenArgs->TokenNameLen;
1549  httpServerEvent.EventData.HttpPostData.TokenName.pData = pPostParams;
1550  pPostParams+=httpPostTokenArgs->TokenNameLen;
1551 
1552  httpServerEvent.EventData.HttpPostData.TokenValue.Len = httpPostTokenArgs->TokenValueLen;
1553  httpServerEvent.EventData.HttpPostData.TokenValue.pData = pPostParams;
1554 
1555  httpServerResponse.Response = SL_NETAPP_HTTPRESPONSE_NONE;
1556 
1557  _SlDrvDispatchHttpServerEvents (&httpServerEvent, &httpServerResponse);
1558 #endif
1559  }
1560  break;
1561 
1562  case SL_OPCODE_NETAPP_REQUEST:
1563  {
1564 #if defined(slcb_NetAppRequestHdlr) || defined(EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS)
1565  _u8 *pData;
1566  SlNetAppRequest_t NetAppRequest;
1567  SlNetAppResponse_t NetAppResponse;
1568  _u16 status;
1569 
1570  /* Points to the Netapp request Arguments */
1571  SlProtocolNetAppRequest_t *protocol_NetAppRequest = (SlProtocolNetAppRequest_t*)_SL_RESP_ARGS_START(pHdr);
1572 
1573  NetAppRequest.AppId = protocol_NetAppRequest->AppId;
1574  NetAppRequest.Type = protocol_NetAppRequest->RequestType;
1575  NetAppRequest.Handle = protocol_NetAppRequest->Handle;
1576  NetAppRequest.requestData.Flags = protocol_NetAppRequest->Flags;
1577 
1578  /* Prepare the Metadata*/
1579  pData = (_u8 *)((SlProtocolNetAppRequest_t *)protocol_NetAppRequest + 1);/* Points to the netapp request Data (start of Metadata + payload) */
1580  NetAppRequest.requestData.pMetadata = pData; /* Just pass the pointer */
1581  NetAppRequest.requestData.MetadataLen = protocol_NetAppRequest->MetadataLen;
1582 
1583  /* Preare the Payload */
1584  pData+=protocol_NetAppRequest->MetadataLen;
1585  NetAppRequest.requestData.pPayload = pData; /* Just pass the pointer */
1586  NetAppRequest.requestData.PayloadLen = protocol_NetAppRequest->PayloadLen;
1587 
1588  /* Just in case - clear the response outout data */
1589  sl_Memset(&NetAppResponse, 0, sizeof (NetAppResponse));
1590  NetAppResponse.Status = SL_NETAPP_HTTP_RESPONSE_404_NOT_FOUND;
1591 
1592  /* Call the request handler dispatcher */
1593  _SlDrvDispatchNetAppRequestEvents (&NetAppRequest, &NetAppResponse);
1594 
1595  /* Handle the response */
1596  status = _SlNetAppSendResponse(protocol_NetAppRequest->Handle, &NetAppResponse);
1597 
1598 #if (defined(SL_RUNTIME_EVENT_REGISTERATION) || defined(slcb_NetAppRequestMemFree))
1599  if(1 == _SlIsEventRegistered(SL_EVENT_HDL_MEM_FREE))
1600  {
1601  if ((NetAppResponse.ResponseData.MetadataLen > 0) && (NetAppResponse.ResponseData.pMetadata != NULL))
1602  {
1603  _SlDrvHandleNetAppRequestMemFreeEvents (NetAppResponse.ResponseData.pMetadata);
1604  }
1605 
1606  if ((NetAppResponse.ResponseData.PayloadLen > 0) && (NetAppResponse.ResponseData.pPayload != NULL))
1607  {
1608  _SlDrvHandleNetAppRequestMemFreeEvents (NetAppResponse.ResponseData.pPayload);
1609  }
1610  }
1611 #endif
1612 
1613  if (status != 0 )
1614  {
1615  /* Error - just send resource not found */
1616  NetAppResponse.Status = SL_NETAPP_HTTP_RESPONSE_404_NOT_FOUND;
1617  NetAppResponse.ResponseData.pMetadata = NULL;
1618  NetAppResponse.ResponseData.MetadataLen = 0;
1619  NetAppResponse.ResponseData.pPayload = NULL;
1620  NetAppResponse.ResponseData.PayloadLen = 0;
1621  NetAppResponse.ResponseData.Flags = 0;
1622 
1623  /* Handle the response */
1624  _SlNetAppSendResponse(protocol_NetAppRequest->Handle, &NetAppResponse);
1625  }
1626 #else
1627 
1628  SlNetAppResponse_t NetAppResponse;
1629 
1630  /* Points to the Netapp request Arguments */
1631  SlProtocolNetAppRequest_t *protocol_NetAppRequest = (SlProtocolNetAppRequest_t *)_SL_RESP_ARGS_START(pHdr);
1632 
1633  /* Prepare the response */
1634  NetAppResponse.Status = SL_NETAPP_HTTP_RESPONSE_404_NOT_FOUND;
1635  NetAppResponse.ResponseData.pMetadata = NULL;
1636  NetAppResponse.ResponseData.MetadataLen = 0;
1637  NetAppResponse.ResponseData.pPayload = NULL;
1638  NetAppResponse.ResponseData.PayloadLen = 0;
1639  NetAppResponse.ResponseData.Flags = 0;
1640 
1641  /* Handle the response */
1642  _SlNetAppSendResponse(protocol_NetAppRequest->Handle, &NetAppResponse);
1643 #endif
1644 
1645  }
1646  break;
1647 
1648  default:
1649  // SL_ERROR_TRACE2(MSG_305, "ASSERT: _SlNetAppEventHandler : invalid opcode = 0x%x = %1", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode);
1650  VERIFY_PROTOCOL(0);
1651  }
1652 
1653  return SL_OS_RET_CODE_OK;
1654 }
Definition: protocol.h:975
_i16 sl_NetAppArpFlush(void)
Flush IPv4 ARP table.
Definition: netapp.c:151
_i16 sl_NetAppSet(const _u8 AppId, const _u8 Option, const _u8 OptionLen, const _u8 *pOptionValue)
Setting network application configurations.
Definition: netapp.c:1110
_i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName, const _u8 ServiceNameLen, _u32 Options)
Unregister mDNS service This function deletes the mDNS service from the mDNS package and the database...
Definition: netapp.c:502
_SlReturnVal_t sl_NetAppRecv(_u16 Handle, _u16 *DataLen, _u8 *pData, _u32 *Flags)
Function for retrieving data from the network processor following a Netapp request event (i...
Definition: netapp.c:1250
_i16 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 The user sets a s...
Definition: netapp.c:613
_i16 sl_NetAppDnsGetHostByName(_i8 *pHostName, const _u16 NameLen, _u32 *OutIpAddr, const _u8 Family)
Get host IP by name Obtain the IP Address of machine on network, by machine name. ...
Definition: netapp.c:841
_i16 sl_NetAppPing(const SlNetAppPingCommand_t *pPingParams, const _u8 Family, SlNetAppPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback)
send ICMP ECHO_REQUEST to network hosts
Definition: netapp.c:985
_i16 sl_NetAppStart(const _u32 AppBitMap)
Starts a network application.
Definition: netapp.c:103
_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 This function registers a new mDNS service to the mDNS package and the D...
Definition: netapp.c:453
_i16 sl_NetAppNdFlush(void)
Flush IPv6 Neighbor Discovery table.
Definition: netapp.c:168
_i16 sl_NetAppGetServiceList(const _u8 IndexOffest, const _u8 MaxServiceCount, const _u8 Flags, _i8 *pBuffer, const _u32 BufferLength)
Get service list Insert into out pBuffer a list of peer&#39;s services that are in the NWP without issui...
Definition: netapp.c:205
_i16 sl_NetAppStop(const _u32 AppBitMap)
Stops a network application.
Definition: netapp.c:129
_u16 sl_NetAppSend(_u16 Handle, _u16 DataLen, _u8 *pData, _u32 Flags)
Function for sending Netapp response or data following a Netapp request event (i.e. HTTP GET request)
Definition: netapp.c:1385
_i16 sl_NetAppGet(const _u8 AppId, const _u8 Option, _u8 *pOptionLen, _u8 *pOptionValue)
Getting network applications configurations.
Definition: netapp.c:1429