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