SimpleLink CC3120/CC3220 Host Driver  Version 2.0.1.15
Simplifies the implementation of Internet connectivity
NetApp

Activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS. More...

Functions

_i16 sl_NetAppStart (const _u32 AppBitMap)
 Starts a network application. More...
 
_i16 sl_NetAppStop (const _u32 AppBitMap)
 Stops a network application. More...
 
_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. More...
 
_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 service name Full/Part (see example below), and should get: More...
 
_i16 sl_NetAppGetServiceList (const _u8 IndexOffset, 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 issuing any queries (relying on pervious collected data).
The list is in a form of service struct. The user should chose the type of the service struct like: More...
 
_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. More...
 
_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 DB.
This registered service is a service offered by the application. The service name should be full service name according to RFC of the DNS-SD - meaning the value in name field in the SRV answer.
Example for service name: More...
 
_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 More...
 
_i16 sl_NetAppSet (const _u8 AppId, const _u8 Option, const _u8 OptionLen, const _u8 *pOptionValue)
 Setting network application configurations. More...
 
_i16 sl_NetAppGet (const _u8 AppId, const _u8 Option, _u8 *pOptionLen, _u8 *pOptionValue)
 Getting network applications configurations. More...
 
_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) More...
 
_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.e. HTTP POST request) More...
 

Typedefs

typedef void(* P_SL_DEV_PING_CALLBACK) (SlNetAppPingReport_t *)
 

Enumerations

enum  SlNetAppEventId_e {
  SL_NETAPP_EVENT_IPV4_ACQUIRED = 1,
  SL_NETAPP_EVENT_IPV6_ACQUIRED,
  SL_NETAPP_EVENT_IP_COLLISION,
  SL_NETAPP_EVENT_DHCPV4_LEASED,
  SL_NETAPP_EVENT_DHCPV4_RELEASED,
  SL_NETAPP_EVENT_HTTP_TOKEN_GET,
  SL_NETAPP_EVENT_HTTP_TOKEN_POST,
  SL_NETAPP_EVENT_IPV4_LOST,
  SL_NETAPP_EVENT_DHCP_IPV4_ACQUIRE_TIMEOUT,
  SL_NETAPP_EVENT_IPV6_LOST,
  SL_NETAPP_EVENT_MAX
}
 
enum  SlIpV6AcquiredAsyncType_e {
  SL_BSD_IPV6_ACQUIRED_TYPE_LOCAL = 1,
  SL_BSD_IPV6_ACQUIRED_TYPE_GLOBAL = 2
}
 
enum  SlNetAppMetadataHTTPTypes_e {
  SL_NETAPP_REQUEST_METADATA_TYPE_STATUS = 0,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_VERSION,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_REQUEST_URI,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_QUERY_STRING,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_LEN,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_TYPE,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_LOCATION,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_SERVER,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_USER_AGENT,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_COOKIE,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_SET_COOKIE,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_UPGRADE,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_REFERER,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_ACCEPT,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_ENCODING,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_DISPOSITION,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONNECTION,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_ETAG,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_DATE,
  SL_NETAPP_REQUEST_METADATA_TYPE_HEADER_HOST,
  SL_NETAPP_REQUEST_METADATA_TYPE_ACCEPT_ENCODING,
  SL_NETAPP_REQUEST_METADATA_TYPE_ACCEPT_LANGUAGE,
  SL_NETAPP_REQUEST_METADATA_TYPE_CONTENT_LANGUAGE,
  SL_NETAPP_REQUEST_METADATA_TYPE_ORIGIN,
  SL_NETAPP_REQUEST_METADATA_TYPE_ORIGIN_CONTROL_ACCESS,
  SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_NONE
}
 
enum  SlNetAppResponseCode_e {
  SL_NETAPP_RESPONSE_NONE = 0,
  SL_NETAPP_RESPONSE_PENDING = 1,
  SL_NETAPP_HTTP_RESPONSE_101_SWITCHING_PROTOCOLS = 101,
  SL_NETAPP_HTTP_RESPONSE_200_OK = 200,
  SL_NETAPP_HTTP_RESPONSE_201_CREATED = 201,
  SL_NETAPP_HTTP_RESPONSE_202_ACCEPTED = 202,
  SL_NETAPP_HTTP_RESPONSE_204_OK_NO_CONTENT = 204,
  SL_NETAPP_HTTP_RESPONSE_301_MOVED_PERMANENTLY = 301,
  SL_NETAPP_HTTP_RESPONSE_302_MOVED_TEMPORARILY = 302,
  SL_NETAPP_HTTP_RESPONSE_303_SEE_OTHER = 303,
  SL_NETAPP_HTTP_RESPONSE_304_NOT_MODIFIED = 304,
  SL_NETAPP_HTTP_RESPONSE_400_BAD_REQUEST = 400,
  SL_NETAPP_HTTP_RESPONSE_403_FORBIDDEN = 403,
  SL_NETAPP_HTTP_RESPONSE_404_NOT_FOUND = 404,
  SL_NETAPP_HTTP_RESPONSE_405_METHOD_NOT_ALLOWED = 405,
  SL_NETAPP_HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR = 500,
  SL_NETAPP_HTTP_RESPONSE_503_SERVICE_UNAVAILABLE = 503,
  SL_NETAPP_HTTP_RESPONSE_504_GATEWAY_TIMEOUT = 504
}
 
enum  SlNetAppGetServiceListType_e {
  SL_NETAPP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
  SL_NETAPP_FULL_SERVICE_IPV4_TYPE,
  SL_NETAPP_SHORT_SERVICE_IPV4_TYPE,
  SL_NETAPP_FULL_SERVICE_WITH_TEXT_IPV6_TYPE,
  SL_NETAPP_FULL_SERVICE_IPV6_TYPE,
  SL_NETAPP_SHORT_SERVICE_IPV6_TYPE
}
 

Detailed Description

Activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS.

Function Documentation

_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.

Parameters
[in]pHostNameHost name
[in]NameLenName length
[out]OutIpAddrThis parameter is filled in with host IP address. In case that host name is not resolved, out_ip_addr is zero.
[in]FamilyProtocol family
Returns
Zero on success, or negative on failure.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS Possible DNS error codes:
  • SL_NETAPP_DNS_QUERY_NO_RESPONSE
  • SL_NETAPP_DNS_NO_SERVER
  • SL_NETAPP_DNS_QUERY_FAILED
  • SL_NETAPP_DNS_MALFORMED_PACKET
  • SL_NETAPP_DNS_MISMATCHED_RESPONSE
See also
Note
Only one sl_NetAppDnsGetHostByName can be handled at a time.
Calling this API while the same command is called from another thread, may result in one of the two scenarios:
  1. The command will wait (internal) until the previous command finish, and then be executed.
  2. There are not enough resources and POOL_IS_EMPTY error will return.
    In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try again later to issue the command.
Warning
In case an IP address in a string format is set as input, without any prefix (e.g. "1.2.3.4") the device will not try to access the DNS and it will return the input address on the 'out_ip_addr' field
Example
  • Getting host by name:
    1 _u32 DestinationIP;
    2 _u32 AddrSize;
    3 _i16 SockId;
    4 SlSockAddrIn_t Addr;
    5 
    6 sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET);
    7 
    8 Addr.sin_family = SL_AF_INET;
    9 Addr.sin_port = sl_Htons(80);
    10 Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
    11 AddrSize = sizeof(SlSockAddrIn_t);
    12 SockId = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);

Definition at line 833 of file netapp.c.

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 }
_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 service name Full/Part (see example below), and should get:

  • IP of service
  • The port of service
  • The text of service Hence it can make a connection to the specific service and use it. It is similar to sl_NetAppDnsGetHostByName method.
    It is done by a single shot ipv4 & ipv6 (if enabled) query with PTR type on the service name. The command that is sent is from constant parameters and variables parameters.
Parameters
[in]pServiceNameService name can be full or partial.
Example for full service name:
  1. PC1._ipp._tcp.local
  2. PC2_server._ftp._tcp.local
Example for partial service name:
  1. _ipp._tcp.local
  2. _ftp._tcp.local
[in]ServiceLenThe length of the service name (in_pService).
[in]FamilyIPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
[out]pAddrContains the IP address of the service.
[out]pPortContains the port of the service.
[out]pTextLenHas 2 options. One as Input field and the other one as output:
  • Input:
    Contains the max length of the text that the user wants to get.
    It means that if the text len of service is bigger that its value than the text is cut to inout_TextLen value.
  • Output:
    Contain the length of the text that is returned. Can be full text or part of the text (see above).
[out]pTextContains the text of the service full or partial
Returns
Zero on success,
SL_POOL_IS_EMPTY may be return in case there are no resources in the system, In this case try again later or increase MAX_CONCURRENT_ACTIONS
In case No service is found error SL_NETAPP_DNS_NO_ANSWER will be returned
See also
sl_NetAppDnsGetHostByName
Note
The returns attributes belongs to the first service found. There may be other services with the same service name that will response to the query. The results of these responses are saved in the peer cache of the Device and should be read by another API.
Only one sl_NetAppDnsGetHostByService can be handled at a time.
Calling this API while the same command is called from another thread, may result in one of the two scenarios:
  1. The command will wait (internal) until the previous command finish, and then be executed.
  2. There are not enough resources and SL_POOL_IS_EMPTY error will return. In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try again later to issue the command.
Warning
Text length can be 120 bytes only

Definition at line 592 of file netapp.c.

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 }
_i16 sl_NetAppGet ( const _u8  AppId,
const _u8  Option,
_u8 *  pOptionLen,
_u8 *  pOptionValue 
)

Getting network applications configurations.

Parameters
[in]AppIdApplication id, could be one of the following:
  • SL_NETAPP_HTTP_SERVER_ID
  • SL_NETAPP_DHCP_SERVER_ID
  • SL_NETAPP_DNS_SERVER_ID
  • SL_NETAPP_DEVICE_ID
  • SL_NETAPP_DNS_CLIENT_ID
[in]OptionGet option, could be one of the following:
  • SL_NETAPP_DHCP_SERVER_ID:
    • SL_NETAPP_DHCP_SRV_BASIC_OPT
  • SL_NETAPP_HTTP_SERVER_ID:
    • SL_NETAPP_HTTP_PRIMARY_PORT_NUMBER
    • SL_NETAPP_HTTP_AUTH_CHECK
    • SL_NETAPP_HTTP_AUTH_NAME
    • SL_NETAPP_HTTP_AUTH_PASSWORD
    • SL_NETAPP_HTTP_AUTH_REALM
    • SL_NETAPP_HTTP_ROM_PAGES_ACCESS
    • SL_NETAPP_HTTP_SECONDARY_PORT_NUMBER
    • SL_NETAPP_HTTP_SECONDARY_PORT_ENABLE
    • SL_NETAPP_HTTP_PRIMARY_PORT_SECURITY_MODE
  • SL_NETAPP_MDNS_ID:
    • SL_NETAPP_MDNS_CONT_QUERY_OPT
    • SL_NETAPP_MDNS_QEVETN_MASK_OPT
    • SL_NETAPP_MDNS_TIMING_PARAMS_OPT
  • SL_NETAPP_DEVICE_ID:
    • SL_NETAPP_DEVICE_URN
    • SL_NETAPP_DEVICE_DOMAIN
  • SL_NETAPP_DNS_CLIENT_ID:
    • SL_NETAPP_DNS_CLIENT_TIME
[in]pOptionLenThe length of the allocated memory as input, when the function complete, the value of this parameter would be the len that actually read from the device.
If the device return length that is longer from the input value, the function will cut the end of the returned structure and will return ESMALLBUF
[out]pOptionValuepointer to the option structure which will be filled with the response from the device
Returns
Zero on success, or negative value if an error occurred.
See also
sl_NetAppSet
Note
Warning
Example
  • Getting DHCP Server parameters example:
    1 SlNetAppDhcpServerBasicOpt_t dhcpParams;
    2 _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
    3 sl_NetAppGet(SL_NETAPP_DHCP_SERVER_ID, SL_NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (_u8* )&dhcpParams);
    4 
    5 printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
    6  SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
    7  SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
    8  SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
    9  SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
    10  dhcpParams.lease_time);

  • Getting device URN name:
    Maximum length of 32 characters of device name. Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P) in case no device URN name set, the default name is "mysimplelink"
    1 _u8 my_device_name[SL_NETAPP_MAX_DEVICE_URN_LEN];
    2 sl_NetAppGet (SL_NETAPP_DEVICE_ID, SL_NETAPP_DEVICE_URN, strlen(my_device_name), (_u8 *)my_device_name);

  • Getting DNS client time:
    Get DNS client (sl_NetAppDnsGetHostByName) timeout, two parameters max_response_time and number_retries. number_retries: Max number of DNS request before sl_NetAppDnsGetHostByName failed. max_response_time: DNS request timeout changed every retry, it`s start with 100 millisecond and increased every retry up to max_response_time milliseconds
    1 SlNetAppDnsClientTime_t time;
    2 _u8 pOptionLen = sizeof(time);
    3 sl_NetAppGet (SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_TIME, &pOptionLen, (_u8 *)&time);

  • Getting active applications:
    Get active applications for active role. return value is mask of the active application (similar defines as sl_NetAppStart):
    1 _u32 AppBitMap;
    2 _u8 pOptionLen = sizeof(AppBitMap);
    3 sl_NetAppGet (SL_NETAPP_STATUS, SL_NETAPP_STATUS_ACTIVE_APP, &pOptionLen, (_u8 *)&AppBitMap);

Definition at line 1439 of file netapp.c.

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 }
_i16 sl_NetAppGetServiceList ( const _u8  IndexOffset,
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 issuing any queries (relying on pervious collected data).
The list is in a form of service struct. The user should chose the type of the service struct like:

  • Full service parameters with text.
  • Full service parameters.
  • Short service parameters (port and IP only) especially for tiny hosts.

The different types of struct are made to give the possibility to save memory in the host.
The user can also chose how many max services to get and start point index NWP peer cache.
For example:

  1. Get max of 3 full services from index 0.
    • Up to 3 full services from index 0 are inserted into pBuffer (services that are in indexes 0,1,2).
  2. Get max of 4 full services from index 3.
    • Up to 4 full services from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6).
  3. Get max of 2 int services from index 6.
    • Up to 2 int services from index 6 are inserted into pBuffer (services that are in indexes 6,7). See below - command parameters.
Parameters
[in]IndexOffset- The start index in the peer cache that from it the first service is returned.
[in]MaxServiceCount- The Max services that can be returned if existed or if not exceed the max index in the peer cache
[in]Flags- an ENUM number that means which service struct to use (means which types of service to fill)
[out]pBuffer- The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags input parameter.
[in]BufferLength- The allocated buffer length (pointed by pBuffer).
Returns
ServiceFoundCount - The number of the services that were inserted into the buffer.
Zero means no service is found negative number means an error
See also
sl_NetAppMDNSRegisterService
Note
Warning
If the out pBuffer size is bigger than an RX packet(1480), than an error is returned because there is no place in the RX packet.
The size is a multiply of MaxServiceCount and size of service struct(that is set according to flag value).

Definition at line 157 of file netapp.c.

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 }
_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 DB.
This registered service is a service offered by the application. The service name should be full service name according to RFC of the DNS-SD - meaning the value in name field in the SRV answer.
Example for service name:

  1. PC1._ipp._tcp.local
  2. PC2_server._ftp._tcp.local

If the option is_unique is set, mDNS probes the service name to make sure it is unique before starting to announce the service on the network. Instance is the instance portion of the service name.

Parameters
[in]ServiceNameLenThe length of the service.
[in]TextLenThe length of the service should be smaller than 64.
[in]PortThe port on this target host port.
[in]TTLThe TTL of the service
[in]Optionsbitwise parameters:
  • SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT bit 0 - service is unique per interface (means that the service needs to be unique)
  • SL_NETAPP_MDNS_IPV6_IPV4_SERVICE bit 27 - add this service to IPv6 interface, if exist (default is IPv4 service only)
  • SL_NETAPP_MDNS_IPV6_ONLY_SERVICE bit 28 - add this service to IPv6 interface, but remove it from IPv4 (only IPv6 is available)
  • SL_NETAPP_MDNS_OPTION_UPDATE_TEXT bit 29 - for update text fields (without reregister the service)
  • SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT bit 30 - for setting a non persistent service
  • SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT bit 31 - for internal use if the service should be added or deleted (set means ADD).
[in]pServiceNameThe service name.
[in]pTextThe description of the service. should be as mentioned in the RFC (according to type of the service IPP,FTP...)
Returns
Zero on success, or negative error code on failure
See also
sl_NetAppMDNSUnRegisterService
Warning
1) Temporary - there is an allocation on stack of internal buffer. Its size is SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
It means that the sum of the text length and service name length cannot be bigger than SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
If it is - An error is returned.
2) According to now from certain constraints the variables parameters are set in the attribute part (contain constant parameters)
Examples:
  • Register a new service:
    1 const signed char AddService[40] = "PC1._ipp._tcp.local";
    2 _u32 Options;
    3 
    4 Options = SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT | SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT;
    5 sl_NetAppMDNSRegisterService(AddService,sizeof(AddService),"Service 1;payper=A3;size=5",strlen("Service 1;payper=A3;size=5"),1000,120,Options);

  • Update text for existing service:
    1 Please Note! Update is for text only! Importent to apply the same persistent flag options as original service registration.\n
    2 
    3 Options = SL_NETAPP_MDNS_OPTION_UPDATE_TEXT | SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT;
    4 sl_NetAppMDNSRegisterService(AddService,sizeof(AddService),"Service 5;payper=A4;size=10",strlen("Service 5;payper=A4;size=10"),1000,120,Options);

Definition at line 418 of file netapp.c.

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 }
_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.

The mDNS service that is to be unregistered is a service that the application no longer wishes to provide.
The service name should be the full service name according to RFC of the DNS-SD - meaning the value in name field in the SRV answer.

Examples for service names:

  1. PC1._ipp._tcp.local
  2. PC2_server._ftp._tcp.local
Parameters
[in]pServiceNameFull service name.
[in]ServiceNameLenThe length of the service.
[in]Optionsbitwise parameters:
  • SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT bit 0 - service is unique per interface (means that the service needs to be unique)
  • SL_NETAPP_MDNS_IPV6_IPV4_SERVICE bit 27 - add this service to IPv6 interface, if exist (default is IPv4 service only)
  • SL_NETAPP_MDNS_IPV6_ONLY_SERVICE bit 28 - add this service to IPv6 interface, but remove it from IPv4 (only IPv6 is available)
  • SL_NETAPP_MDNS_OPTION_UPDATE_TEXT bit 29 - for update text fields (without reregister the service)
  • SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT bit 30 - for setting a non persistent service
  • SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT bit 31 - for internal use if the service should be added or deleted (set means ADD).
Returns
Zero on success, or negative error code on failure
See also
sl_NetAppMDNSRegisterService
Note
Warning
The size of the service length should be smaller than 255.

Definition at line 472 of file netapp.c.

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 }
_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

Ping uses the ICMP protocol's mandatory ECHO_REQUEST

Parameters
[in]pPingParamsPointer to the ping request structure:
  • If flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts).
  • If flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts.
  • If flags parameter is set to 2, ping will stop after the first successful ping, and report back for the successful ping, as well as any preceding failed ones.
  • If flags parameter is set to 4, for ipv4 - don`t fragment the ping packet. This flag can be set with other flags. For stopping an ongoing ping activity, set parameters IP address to 0
[in]FamilySL_AF_INET or SL_AF_INET6
[out]pReportPing pReport
[out]pPingCallbackCallback function upon completion.
If callback is NULL, the API is blocked until data arrives
Returns
Zero on success, or negative error code on failure.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system In this case try again later or increase MAX_CONCURRENT_ACTIONS
See also
Note
Only one sl_NetAppPing can be handled at a time. Calling this API while the same command is called from another thread, may result in one of the two scenarios:
  1. The command will wait (internal) until the previous command finish, and then be executed.
  2. There are not enough resources and SL_POOL_IS_EMPTY error will return. In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try again later to issue the command.
Warning
Example:
  • Sending 20 ping requests and reporting results to a callback routine when all requests are sent:
    1 // callback routine
    2 void pingRes(SlNetAppPingReport_t* pReport)
    3 {
    4 // handle ping results
    5 }
    6 
    7 // ping activation
    8 void PingTest()
    9 {
    10  SlNetAppPingReport_t report;
    11  SlNetAppPingCommand_t pingCommand;
    12 
    13  pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200
    14  pingCommand.PingSize = 150; // size of ping, in bytes
    15  pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds
    16  pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds
    17  pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever
    18  pingCommand.Flags = 0; // report only when finished
    19 
    20  sl_NetAppPing( &pingCommand, SL_AF_INET, &report, pingRes ) ;
    21 }

  • Stopping Ping command:
    1 Status = sl_NetAppPing(0, 0, 0, 0 ) ;

Definition at line 979 of file netapp.c.

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 }
_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.e. HTTP POST request)

Parameters
[in]HandleHandle to receive data from. Should match the handle received in the Netapp request event
[in,out]*DataLenMax buffer size (in) / Actual data received (out)
[out]*pDataData received
[in,out]*FlagsCan have the following values:
  • SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION (out)
  • More data is pending in the network procesor. Application should continue reading the data by calling sl_NetAppRecv again
Returns
Zero on success, or negative error code on failure
See also
sl_NetAppSend
Note
Warning
handle is received in the sl_NetAppRequestHandler callback. Handle is valid untill all data is receive from the network processor.

Definition at line 1260 of file netapp.c.

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 }
_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)

Parameters
[in]HandleHandle to send the data to. Should match the handle received in the Netapp request event
[in]DataLenData Length
[in]pDataData to send. Can be just data payload or metadata (depends on flags)
[out]FlagsCan have the following values:
  • SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION - More data will arrive in subsequent calls to NetAppSend
  • SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA - 0 - data is payload, 1 - data is metadata
  • SL_NETAPP_REQUEST_RESPONSE_FLAGS_ACCUMULATION - The network processor should accumulate the data chunks and will process it when it is completelly received
Returns
Zero on success, or negative error code on failure
See also
sl_NetAppRecv
Note
Warning

Definition at line 1393 of file netapp.c.

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 }
_i16 sl_NetAppSet ( const _u8  AppId,
const _u8  Option,
const _u8  OptionLen,
const _u8 *  pOptionValue 
)

Setting network application configurations.

Parameters
[in]AppIdApplication id, could be one of the following:
  • SL_NETAPP_HTTP_SERVER_ID
  • SL_NETAPP_DHCP_SERVER_ID (AP Role only)
  • SL_NETAPP_MDNS_ID
  • SL_NETAPP_DNS_SERVER_ID
  • SL_NETAPP_DEVICE_ID
  • SL_NETAPP_DNS_CLIENT_ID
[in]OptionSet option, could be one of the following:
  • For SL_NETAPP_HTTP_SERVER_ID
    • SL_NETAPP_HTTP_PRIMARY_PORT_NUMBER
    • SL_NETAPP_HTTP_AUTH_CHECK
    • SL_NETAPP_HTTP_AUTH_NAME
    • SL_NETAPP_HTTP_AUTH_PASSWORD
    • SL_NETAPP_HTTP_AUTH_REALM
    • SL_NETAPP_HTTP_ROM_PAGES_ACCESS
    • SL_NETAPP_HTTP_SECONDARY_PORT_NUMBER
    • SL_NETAPP_HTTP_SECONDARY_PORT_ENABLE
    • SL_NETAPP_HTTP_PRIMARY_PORT_SECURITY_MODE
    • SL_NETAPP_HTTP_PRIVATE_KEY_FILENAME
    • SL_NETAPP_HTTP_DEVICE_CERTIFICATE_FILENAME
    • SL_NETAPP_HTTP_CA_CERTIFICATE_FILE_NAME
    • SL_NETAPP_HTTP_TEMP_REGISTER_MDNS_SERVICE_NAME
    • SL_NETAPP_HTTP_TEMP_UNREGISTER_MDNS_SERVICE_NAME
  • For SL_NETAPP_DHCP_SERVER_ID:
    • SL_NETAPP_DHCP_SERVER_BASIC_OPT
  • For SL_NETAPP_MDNS_ID:
    • SL_NETAPP_MDNS_CONT_QUERY_OPT
    • SL_NETAPP_MDNS_QEVETN_MASK_OPT
    • SL_NETAPP_MDNS_TIMING_PARAMS_OPT
  • For SL_NETAPP_DEVICE_ID:
    • SL_NETAPP_DEVICE_URN
    • SL_NETAPP_DEVICE_DOMAIN
  • For SL_NETAPP_DNS_CLIENT_ID:
    • SL_NETAPP_DNS_CLIENT_TIME
[in]OptionLenOption structure length
[in]pOptionValuePointer to the option structure
Persistent
Reset:
  • SL_NETAPP_DHCP_SERVER_BASIC_OPT
Non- Persistent:
  • SL_NETAPP_HTTP_TEMP_REGISTER_MDNS_SERVICE_NAME
  • SL_NETAPP_HTTP_TEMP_UNREGISTER_MDNS_SERVICE_NAME
System Persistent:
  • SL_NETAPP_HTTP_PRIMARY_PORT_NUMBER
  • SL_NETAPP_HTTP_AUTH_CHECK
  • SL_NETAPP_HTTP_AUTH_NAME
  • SL_NETAPP_HTTP_AUTH_PASSWORD
  • SL_NETAPP_HTTP_AUTH_REALM
  • SL_NETAPP_HTTP_ROM_PAGES_ACCESS
  • SL_NETAPP_HTTP_SECONDARY_PORT_NUMBER
  • SL_NETAPP_HTTP_SECONDARY_PORT_ENABLE
  • SL_NETAPP_HTTP_PRIMARY_PORT_SECURITY_MODE
  • SL_NETAPP_HTTP_PRIVATE_KEY_FILENAME
  • SL_NETAPP_HTTP_DEVICE_CERTIFICATE_FILE_NAME
  • SL_NETAPP_HTTP_CA_CERTIFICATE_FILENAME
  • SL_NETAPP_MDNS_CONT_QUERY_OPT
  • SL_NETAPP_MDNS_QEVETN_MASK_OPT
  • SL_NETAPP_MDNS_TIMING_PARAMS_OPT
  • SL_NETAPP_DEV_CONF_OPT_DEVICE_URN
  • SL_NETAPP_DEV_CONF_OPT_DOMAIN_NAME
Returns
Zero on success, or negative value if an error occurred.
See also
sl_NetAppGet
Note
Warning
Example
  • Setting DHCP Server (AP mode) parameters example:
    1 SlNetAppDhcpServerBasicOpt_t dhcpParams;
    2 _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
    3 dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address
    4 dhcpParams.ipv4_addr_start = SL_IPV4_VAL(192,168,1,10); // first IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
    5 dhcpParams.ipv4_addr_last = SL_IPV4_VAL(192,168,1,16); // last IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
    6 sl_NetAppStop(SL_NETAPP_DHCP_SERVER_ID); // Stop DHCP server before settings
    7 sl_NetAppSet(SL_NETAPP_DHCP_SERVER_ID, SL_NETAPP_DHCP_SRV_BASIC_OPT, outLen, (_u8* )&dhcpParams); // set parameters
    8 sl_NetAppStart(SL_NETAPP_DHCP_SERVER_ID); // Start DHCP server with new settings

  • Setting Device URN name:
    Device name, maximum length of 32 characters Device name affects URN name, and WPS file "device name" in WPS I.E (STA-WPS / P2P) In case no device URN name set, the default name is "mysimplelink" In case of setting the device name with length 0, device will return to default name "mysimplelink" Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-'
    1 _u8 *my_device = "MY-SIMPLELINK-DEV";
    2 sl_NetAppSet (SL_NETAPP_DEVICE_ID, SL_NETAPP_DEVICE_URN, strlen(my_device), (_u8 *) my_device);

  • Register new temporary HTTP service name for MDNS (not persistent):
    1 _u8 *my_http_temp_name = "New - Bonjour Service Name";
    2 sl_NetAppSet (SL_NETAPP_HTTP_SERVER_ID, SL_NETAPP_HTTP_TEMP_REGISTER_MDNS_SERVICE_NAME, strlen(my_http_temp_name), (_u8 *) my_http_temp_name);

  • Remove registration of current HTTP internal MDNS service (not persistent) :
    1 _u8 *old_http_name = "0800285A7891@mysimplelink-022";
    2 sl_NetAppSet (SL_NETAPP_HTTP_SERVER_ID, SL_NETAPP_HTTP_TEMP_UNREGISTER_MDNS_SERVICE_NAME, strlen(old_http_name), (_u8 *) old_http_name);

  • Set DNS client time example:
    Set DNS client (sl_NetAppDnsGetHostByName) timeout, two parameters max_response_time and number_retries. number_retries: Max number of DNS request before sl_NetAppDnsGetHostByName failed, (up to 100 retries). max_response_time: DNS request timeout changed every retry, it`s start with 100 millisecond and increased every retry up to max_response_time milliseconds, (up to 2 seconds)
    1 SlNetAppDnsClientTime_t time;
    2 time.MaxResponseTime = 2000;
    3 time.NumOfRetries = 30;
    4 sl_NetAppSet (SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_TIME, sizeof(time), (_u8 *)&time);

  • Start MDNS continuous querys:
    In a continuous mDNS query mode, the device keeps sending queries to the network according to a specific service name. The query will be sent in IPv4 and IPv6 (if enabled) format. To see the completed list of responding services sl_NetAppGetServiceList() need to be called
    1 const signed char AddService[40] = "Printer._ipp._tcp.local";
    2 _i16 Status;
    3 
    4 Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT,strlen(AddService) , &AddService);

  • Stop MDNS:
    1 Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT,0 , 0);

  • Set MDNS timing parameters for service advertisement:
    This option allows to control and reconfigures the timing parameters for service advertisement
    1 SlNetAppServiceAdvertiseTimingParameters_t Timing;
    2 _i16 Status;
    3 
    4 Timing.t = 200; // 2 seconds
    5 Timing.p = 2; // 2 repetitions
    6 Timing.k = 2; // Telescopic factor 2
    7 Timing.RetransInterval = 0;
    8 Timing.Maxinterval = 0xFFFFFFFF;
    9 Timing.max_time = 5;
    10 
    11 Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_TIMING_PARAMS_OPT,sizeof(Timing),&Timing);

  • User-defined service types to monitor:
    In cases that the user decides not to get responses from certain types of services it should set the adapt bit in the event mask that is related to:
    1 // bit 0: _ipp
    2 // bit 1: _device-info
    3 // bit 2: _http
    4 // bit 3: _https
    5 // bit 4: _workstation
    6 // bit 5: _guid
    7 // bit 6: _h323
    8 // bit 7: _ntp
    9 // bit 8: _objective
    10 // bit 9: _rdp
    11 // bit 10: _remote
    12 // bit 11: _rtsp
    13 // bit 12: _sip
    14 // bit 13: _smb
    15 // bit 14: _soap
    16 // bit 15: _ssh
    17 // bit 16: _telnet
    18 // bit 17: _tftp
    19 // bit 18: _xmpp-client
    20 // bit 19: _raop
    21 
    22 
    23 _u32 EventMask;
    24 _i16 Status;
    25 
    26 EventMask = BIT0 | BIT1 | BIT18;
    27 Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_QEVETN_MASK_OPT,sizeof(EventMask),&EventMask)

Definition at line 1112 of file netapp.c.

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 }
_i16 sl_NetAppStart ( const _u32  AppBitMap)

Starts a network application.

Gets and starts network application for the current WLAN mode

Parameters
[in]AppBitMapApplication bitmap, could be one or combination of the following:
  • SL_NETAPP_HTTP_SERVER_ID
  • SL_NETAPP_DHCP_SERVER_ID
  • SL_NETAPP_MDNS_ID
  • SL_NETAPP_DNS_SERVER_ID
Persistent - System Persistent
Returns
Zero on success, or negative error code on failure
See also
sl_NetAppStop
Note
This command activates the application for the current WLAN mode (AP or STA)
Warning
Example
  • Starting internal HTTP server + DHCP server:
    1 sl_NetAppStart(SL_NETAPP_HTTP_SERVER_ID | SL_NETAPP_DHCP_SERVER_ID)

Definition at line 86 of file netapp.c.

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 }
_i16 sl_NetAppStop ( const _u32  AppBitMap)

Stops a network application.

Gets and stops network application for the current WLAN mode

Parameters
[in]AppBitMapApplication id, could be one of the following:
  • SL_NETAPP_HTTP_SERVER_ID
  • SL_NETAPP_DHCP_SERVER_ID
  • SL_NETAPP_MDNS_ID
  • SL_NETAPP_DNS_SERVER_ID
Persistent - System Persistent
Returns
Zero on success, or nagative error code on failure
See also
sl_NetAppStart
Note
This command disables the application for the current active WLAN mode (AP or STA)
Warning
Example
  • Stopping internal HTTP server:
    1 sl_NetAppStop(SL_NETAPP_HTTP_SERVER_ID);

Definition at line 115 of file netapp.c.

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 }

Data Structure Documentation

struct SlIpV4AcquiredAsync_t

Definition at line 187 of file netapp.h.

Data Fields
_u32 Dns
_u32 Gateway
_u32 Ip
struct SlIpV6AcquiredAsync_t

Definition at line 201 of file netapp.h.

Data Fields
_u32 Dns[4]
_u32 Ip[4]
struct SlIpLeasedAsync_t

Definition at line 207 of file netapp.h.

Data Fields
_u32 IpAddress
_u32 LeaseTime
_u8 Mac[6]
_u16 Padding
struct SlIpReleasedAsync_t

Definition at line 215 of file netapp.h.

Data Fields
_u32 IpAddress
_u8 Mac[6]
_u16 Reason
struct SlIpCollisionAsync_t

Definition at line 222 of file netapp.h.

Data Fields
_u8 ConflictMac[6]
_u8 DhcpMac[6]
_u32 IpAddress
struct SlIpV4Lost_t

Definition at line 229 of file netapp.h.

Data Fields
_u16 Padding
_i16 Status
struct SlIpV6Lost_t

Definition at line 235 of file netapp.h.

Data Fields
_u32 IpLost[4]
struct SlDhcpIpAcquireTimeout_t

Definition at line 240 of file netapp.h.

Data Fields
_u16 Padding
_i16 Status
union SlNetAppEventData_u

Definition at line 247 of file netapp.h.

Data Fields
SlDhcpIpAcquireTimeout_t DhcpIpAcquireTimeout
SlIpV4AcquiredAsync_t IpAcquiredV4
SlIpV6AcquiredAsync_t IpAcquiredV6
SlIpCollisionAsync_t IpCollision
SlIpLeasedAsync_t IpLeased
SlIpReleasedAsync_t IpReleased
SlIpV4Lost_t IpV4Lost
SlIpV6Lost_t IpV6Lost
_u32 Sd
struct SlNetAppEvent_t

Definition at line 260 of file netapp.h.

Data Fields
SlNetAppEventData_u Data
_u32 Id
struct SlNetAppPingReport_t

Definition at line 267 of file netapp.h.

Data Fields
_u16 AvgRoundTime
_u16 MaxRoundTime
_u16 MinRoundTime
_u32 PacketsReceived
_u32 PacketsSent
_u32 TestTime
struct SlNetAppPingCommand_t

Definition at line 277 of file netapp.h.

Data Fields
_u32 Flags
_u32 Ip
_u32 Ip1OrPadding
_u32 Ip2OrPadding
_u32 Ip3OrPadding
_u32 PingIntervalTime
_u16 PingRequestTimeout
_u16 PingSize
_u32 TotalNumberOfAttempts
struct SlNetAppHttpServerString_t

Definition at line 290 of file netapp.h.

Data Fields
_u8 Len
_u8 * pData
struct SlNetAppHttpServerData_t

Definition at line 296 of file netapp.h.

Data Fields
_u8 NameLen
_u8 * pTokenName
_u8 * pTokenValue
_u8 ValueLen
struct SlNetAppHttpServerPostData_t

Definition at line 304 of file netapp.h.

Data Fields
SlNetAppHttpServerString_t Action
SlNetAppHttpServerString_t TokenName
SlNetAppHttpServerString_t TokenValue
union SlNetAppHttpServerEventData_u

Definition at line 311 of file netapp.h.

Data Fields
SlNetAppHttpServerPostData_t HttpPostData
SlNetAppHttpServerString_t HttpTokenName
union SlNetAppHttpServerResponsedata_u

Definition at line 317 of file netapp.h.

Data Fields
SlNetAppHttpServerString_t TokenValue
struct SlNetAppHttpServerEvent_t

Definition at line 322 of file netapp.h.

Data Fields
_u32 Event
SlNetAppHttpServerEventData_u EventData
struct SlNetAppHttpServerResponse_t

Definition at line 328 of file netapp.h.

Data Fields
_u32 Response
SlNetAppHttpServerResponsedata_u ResponseData
struct SlNetAppData_t

Definition at line 408 of file netapp.h.

Data Fields
_u32 Flags
_u16 MetadataLen
_u16 PayloadLen
_u8 * pMetadata
_u8 * pPayload
struct SlNetAppRequest_t

Definition at line 417 of file netapp.h.

Data Fields
_u8 AppId
_u16 Handle
SlNetAppData_t requestData
_u8 Type
struct SlNetAppResponse_t

Definition at line 426 of file netapp.h.

Data Fields
SlNetAppData_t ResponseData
_u16 Status
struct SlNetAppDhcpServerBasicOpt_t

Definition at line 434 of file netapp.h.

Data Fields
_u32 ipv4_addr_last
_u32 ipv4_addr_start
_u32 lease_time
struct SlNetAppGetShortServiceIpv4List_t

Definition at line 452 of file netapp.h.

Data Fields
_u16 Reserved
_u32 service_ipv4
_u16 service_port
struct SlNetAppGetFullServiceIpv4List_t

Definition at line 459 of file netapp.h.

Data Fields
_u16 Reserved
_u8 service_host[SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE]
_u32 service_ipv4
_u8 service_name[SL_NETAPP_MAX_SERVICE_NAME_SIZE]
_u16 service_port
struct SlNetAppGetFullServiceWithTextIpv4List_t

Definition at line 468 of file netapp.h.

Data Fields
_u16 Reserved
_u8 service_host[SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE]
_u32 service_ipv4
_u8 service_name[SL_NETAPP_MAX_SERVICE_NAME_SIZE]
_u16 service_port
_u8 service_text[SL_NETAPP_MAX_SERVICE_TEXT_SIZE]
struct SlNetAppGetShortServiceIpv6List_t

Definition at line 479 of file netapp.h.

Data Fields
_u16 Reserved
_u32 service_ipv6[4]
_u16 service_port
struct SlNetAppGetFullServiceIpv6List_t

Definition at line 486 of file netapp.h.

Data Fields
_u16 Reserved
_u8 service_host[SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE]
_u32 service_ipv6[4]
_u8 service_name[SL_NETAPP_MAX_SERVICE_NAME_SIZE]
_u16 service_port
struct SlNetAppGetFullServiceWithTextIpv6List_t

Definition at line 495 of file netapp.h.

Data Fields
_u16 Reserved
_u8 service_host[SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE]
_u32 service_ipv6[4]
_u8 service_name[SL_NETAPP_MAX_SERVICE_NAME_SIZE]
_u16 service_port
_u8 service_text[SL_NETAPP_MAX_SERVICE_TEXT_SIZE]
struct SlNetAppServiceAdvertiseTimingParameters_t

Definition at line 506 of file netapp.h.

Data Fields
_u32 k
_u32 max_time
_u32 Maxinterval
_u32 p
_u32 RetransInterval
_u32 t
struct SlNetAppDnsClientTime_t

Definition at line 531 of file netapp.h.

Data Fields
_u16 MaxResponseTime
_u16 NumOfRetries