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