SimpleLink CC3120/CC3220 Host Driver  Version 2.0.1.22
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

§ sl_NetAppDnsGetHostByName()

_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

Definition at line 856 of file netapp.c.

857 {
858  _SlGetHostByNameMsg_u Msg;
859  _SlCmdExt_t ExtCtrl;
860  _GetHostByNameAsyncResponse_u AsyncRsp;
861  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
862 
863  /* verify that this api is allowed. if not allowed then
864  ignore the API execution and return immediately with an error */
865  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
866 
867  _SlDrvResetCmdExt(&ExtCtrl);
868  ExtCtrl.TxPayload1Len = NameLen;
869  ExtCtrl.pTxPayload1 = (_u8 *)pHostName;
870 
871  Msg.Cmd.Len = NameLen;
872  Msg.Cmd.Family = Family;
873 
874  /*Use Obj to issue the command, if not available try later */
875  ObjIdx = (_u8)_SlDrvWaitForPoolObj(GETHOSYBYNAME_ID,SL_MAX_SOCKETS);
876  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
877  {
878  return SL_POOL_IS_EMPTY;
879  }
880 
881  SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
882 
883  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&AsyncRsp;
884  /*set bit to indicate IPv6 address is expected */
885  if (SL_AF_INET6 == Family)
886  {
887  g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK;
888  }
889 
890  SL_DRV_PROTECTION_OBJ_UNLOCK();
891 
892  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByNameCtrl, &Msg, &ExtCtrl));
893 
894  if(SL_RET_CODE_OK == Msg.Rsp.status)
895  {
896  SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj);
897 
898  Msg.Rsp.status = (_i16)AsyncRsp.IpV4.Status;
899 
900  if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status)
901  {
902  sl_Memcpy((_i8 *)OutIpAddr,
903  (_i8 *)&AsyncRsp.IpV4.Ip0,
904  (SL_AF_INET == Family) ? SL_IPV4_ADDRESS_SIZE : SL_IPV6_ADDRESS_SIZE);
905  }
906  }
907  _SlDrvReleasePoolObj(ObjIdx);
908  return Msg.Rsp.status;
909 }

§ sl_NetAppDnsGetHostByService()

_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 614 of file netapp.c.

622 {
623  _SlGetHostByServiceMsg_u Msg;
624  _SlCmdExt_t CmdExt ;
625  _GetHostByServiceAsyncResponse_t AsyncRsp;
626  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
627 
628  /* verify that this api is allowed. if not allowed then
629  ignore the API execution and return immediately with an error */
630  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
631  _SlDrvMemZero(&AsyncRsp, sizeof(_GetHostByServiceAsyncResponse_t));
632 
633 /*
634  Note:
635  1. The return's attributes are belonged to first service that is found.
636  It can be other services with the same service name will response to
637  the query. The results of these responses are saved in the peer cache of the NWP, and
638  should be read by another API.
639 
640  2. Text length can be 120 bytes only - not more
641  It is because of constraints in the NWP on the buffer that is allocated for the Async event.
642 
643  3.The API waits to Async event by blocking. It means that the API is finished only after an Async event
644  is sent by the NWP.
645 
646  4.No rolling option!!! - only PTR type is sent.
647 
648 
649 */
650  /*build the attribute part of the command.
651  It contains the constant parameters of the command */
652 
653  Msg.Cmd.ServiceLen = ServiceLen;
654  Msg.Cmd.AddrLen = Family;
655 
656  /*Build the payload part of the command
657  Copy the service name and text to one buffer.*/
658 
659  _SlDrvResetCmdExt(&CmdExt);
660  CmdExt.TxPayload1Len = ServiceLen;
661  CmdExt.pTxPayload1 = (_u8 *)pServiceName;
662 
663  /*set pointers to the output parameters (the returned parameters).
664  This pointers are belonged to local struct that is set to global Async response parameter.
665  It is done in order not to run more than one sl_DnsGetHostByService at the same time.
666  The API should be run only if global parameter is pointed to NULL. */
667  AsyncRsp.out_pText = pText;
668  AsyncRsp.inout_TextLen = (_u16* )pTextLen;
669  AsyncRsp.out_pPort = pPort;
670  AsyncRsp.out_pAddr = (_u32 *)&pAddr[0];
671 
672  ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, GETHOSYBYSERVICE_ID, SL_MAX_SOCKETS);
673 
674  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
675  {
676  return SL_POOL_IS_EMPTY;
677  }
678 
679 
680  if (SL_AF_INET6 == Family)
681  {
682  g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK;
683  }
684  /* Send the command */
685  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByServiceCtrl, &Msg, &CmdExt));
686 
687 
688 
689  /* If the immediate reponse is O.K. than wait for aSYNC event response. */
690  if(SL_RET_CODE_OK == Msg.Rsp.status)
691  {
692  SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj);
693 
694  /* If we are - it means that Async event was sent.
695  The results are copied in the Async handle return functions */
696 
697  Msg.Rsp.status = AsyncRsp.Status;
698  }
699 
700  _SlDrvReleasePoolObj(ObjIdx);
701  return Msg.Rsp.status;
702 }

§ sl_NetAppGet()

_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:
    _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
    sl_NetAppGet(SL_NETAPP_DHCP_SERVER_ID, SL_NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (_u8* )&dhcpParams);
    printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
    SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
    SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
    SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
    SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
    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"
    _u8 my_device_name[SL_NETAPP_MAX_DEVICE_URN_LEN];
    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
    _u8 pOptionLen = sizeof(time);
    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):
    _u32 AppBitMap;
    _u8 pOptionLen = sizeof(AppBitMap);
    sl_NetAppGet (SL_NETAPP_STATUS, SL_NETAPP_STATUS_ACTIVE_APP, &pOptionLen, (_u8 *)&AppBitMap);

Definition at line 1462 of file netapp.c.

1463 {
1464  _SlNetAppMsgGet_u Msg;
1465  _SlCmdExt_t CmdExt;
1466 
1467  /* verify that this api is allowed. if not allowed then
1468  ignore the API execution and return immediately with an error */
1469  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1470 
1471  if (*pOptionLen == 0)
1472  {
1473  return SL_EZEROLEN;
1474  }
1475 
1476  _SlDrvResetCmdExt(&CmdExt);
1477  CmdExt.RxPayloadLen = (_i16)(*pOptionLen);
1478  CmdExt.pRxPayload = (_u8 *)pOptionValue;
1479 
1480  Msg.Cmd.AppId = AppId;
1481  Msg.Cmd.ConfigOpt = Option;
1482  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppGetCmdCtrl, &Msg, &CmdExt));
1483 
1484 
1485  if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
1486  {
1487  *pOptionLen = (_u8)CmdExt.RxPayloadLen;
1488  return SL_ESMALLBUF;
1489  }
1490  else
1491  {
1492  *pOptionLen = (_u8)CmdExt.ActualRxPayloadLen;
1493  }
1494 
1495  return (_i16)Msg.Rsp.Status;
1496 }

§ sl_NetAppGetServiceList()

_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 179 of file netapp.c.

185 {
186 
187  _i32 retVal= 0;
188  _SlNetappGetServiceListMsg_u Msg;
189  _SlCmdExt_t CmdExt;
190  _u16 ServiceSize = 0;
191  _u16 BufferSize = 0;
192 
193  /* verify that this api is allowed. if not allowed then
194  ignore the API execution and return immediately with an error */
195  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
196 
197  /*
198  Calculate RX pBuffer size
199  WARNING:
200  if this size is BufferSize than 1480 error should be returned because there
201  is no place in the RX packet.
202  */
203  ServiceSize = NetAppServiceSizeLUT[Flags & SL_NETAPP_SERVICE_SIZE_MASK];
204  BufferSize = MaxServiceCount * ServiceSize;
205 
206  /* Check the size of the requested services is smaller than size of the user buffer.
207  If not an error is returned in order to avoid overwriting memory. */
208  if(BufferLength < BufferSize)
209  {
210  return SL_ERROR_NET_APP_RX_BUFFER_LENGTH;
211  }
212 
213  _SlDrvResetCmdExt(&CmdExt);
214  CmdExt.RxPayloadLen = (_i16)BufferSize;
215  CmdExt.pRxPayload = (_u8 *)pBuffer;
216 
217  Msg.Cmd.IndexOffest = IndexOffest;
218  Msg.Cmd.MaxServiceCount = MaxServiceCount;
219  Msg.Cmd.Flags = Flags;
220  Msg.Cmd.Padding = 0;
221 
222  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetServiceListeCtrl, &Msg, &CmdExt));
223  retVal = Msg.Rsp.status;
224 
225  return (_i16)retVal;
226 }

§ sl_NetAppMDNSRegisterService()

_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:
    const signed char AddService[40] = "PC1._ipp._tcp.local";
    _u32 Options;
    Options = SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT | SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT;
    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:
    Please Note! Update is for text only! Importent to apply the same persistent flag options as original service registration.\n
    Options = SL_NETAPP_MDNS_OPTION_UPDATE_TEXT | SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT;
    sl_NetAppMDNSRegisterService(AddService,sizeof(AddService),"Service 5;payper=A4;size=10",strlen("Service 5;payper=A4;size=10"),1000,120,Options);

Definition at line 440 of file netapp.c.

448 {
449 
450  /* verify that this api is allowed. if not allowed then
451  ignore the API execution and return immediately with an error */
452  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
453 
454  /*
455 
456  NOTE - pay attention
457 
458  1. Temporary - there is an allocation on stack of internal buffer.
459  Its size is SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
460  It means that the sum of the text length and service name length cannot be bigger than
461  SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
462  If it is - An error is returned.
463 
464  2. According to now from certain constraints the variables parameters are set in the
465  attribute part (contain constant parameters)
466 
467  */
468 
469  /*Set the add service bit in the options parameter.
470  In order not use different opcodes for the register service and unregister service
471  bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added
472  if it is cleared it means that the service should be deleted and there is only meaning to pServiceName
473  and ServiceNameLen values. */
474  Options |= SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT;
475 
476  return _SlNetAppMDNSRegisterUnregisterService( pServiceName,
477  ServiceNameLen,
478  pText,
479  TextLen,
480  Port,
481  TTL,
482  Options);
483 
484 
485 }

§ sl_NetAppMDNSUnRegisterService()

_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 494 of file netapp.c.

498 {
499 
500  /* verify that this api is allowed. if not allowed then
501  ignore the API execution and return immediately with an error */
502  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
503 
504  /*
505 
506  NOTE - pay attention
507 
508  The size of the service length should be smaller than 255,
509  Until the simplelink drive supports to variable length through SPI command.
510 
511 
512  */
513 
514  /*Clear the add service bit in the options parameter.
515  In order not use different opcodes for the register service and unregister service
516  bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added
517  if it is cleared it means that the service should be deleted and there is only meaning to pServiceName
518  and ServiceNameLen values.*/
519 
520  Options &= (~SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT);
521 
522  return _SlNetAppMDNSRegisterUnregisterService( pServiceName,
523  ServiceNameLen,
524  NULL,
525  0,
526  0,
527  0,
528  Options);
529 
530 
531 }

§ sl_NetAppPing()

_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:
    // callback routine
    void pingRes(SlNetAppPingReport_t* pReport)
    {
    // handle ping results
    }
    // ping activation
    void PingTest()
    {
    SlNetAppPingCommand_t pingCommand;
    pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200
    pingCommand.PingSize = 150; // size of ping, in bytes
    pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds
    pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds
    pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever
    pingCommand.Flags = 0; // report only when finished
    sl_NetAppPing( &pingCommand, SL_AF_INET, &report, pingRes ) ;
    }

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

Definition at line 1002 of file netapp.c.

1003 {
1004  _SlCmdCtrl_t CmdCtrl = {0, (_SlArgSize_t)sizeof(SlNetAppPingCommand_t), (_SlArgSize_t)sizeof(_BasicResponse_t)};
1005  _SlPingStartMsg_u Msg;
1006  SlPingReportResponse_t PingRsp;
1007  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
1008  _u32 PingTimeout = 0;
1009 
1010  /* verify that this api is allowed. if not allowed then
1011  ignore the API execution and return immediately with an error */
1012  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1013 
1014  if(NULL != pPingParams)
1015  {
1016 
1017  if(SL_AF_INET == Family)
1018  {
1019  CmdCtrl.Opcode = SL_OPCODE_NETAPP_PINGSTART;
1020  sl_Memcpy(&Msg.Cmd.Ip, &pPingParams->Ip, SL_IPV4_ADDRESS_SIZE);
1021  }
1022  else
1023  {
1024  CmdCtrl.Opcode = SL_OPCODE_NETAPP_PINGSTART_V6;
1025  sl_Memcpy(&Msg.Cmd.Ip, &pPingParams->Ip, SL_IPV6_ADDRESS_SIZE);
1026  }
1027 
1028  Msg.Cmd.PingIntervalTime = pPingParams->PingIntervalTime;
1029  Msg.Cmd.PingSize = pPingParams->PingSize;
1030  Msg.Cmd.PingRequestTimeout = pPingParams->PingRequestTimeout;
1031  Msg.Cmd.TotalNumberOfAttempts = pPingParams->TotalNumberOfAttempts;
1032  Msg.Cmd.Flags = pPingParams->Flags;
1033 
1034 
1035  /* calculate the ping timeout according to the parmas + the guard interval */
1036  PingTimeout = SL_NETAPP_PING_GUARD_INTERVAL + (pPingParams->PingIntervalTime * pPingParams->TotalNumberOfAttempts);
1037 
1038  if (Msg.Cmd.Ip != 0)
1039  {
1040 
1041  /* If the following conditions are met, return an error
1042  Wrong ping parameters - ping cannot be called with the following parameters:
1043  1. infinite ping packet
1044  2. report only when finished
1045  3. no callback supplied */
1046  if ((pPingCallback == NULL) && (pPingParams->Flags == 0) && (pPingParams->TotalNumberOfAttempts == 0))
1047  {
1048  return SL_RET_CODE_NET_APP_PING_INVALID_PARAMS;
1049  }
1050 
1051  if( pPingCallback )
1052  {
1053  pPingCallBackFunc = pPingCallback;
1054  }
1055  else
1056  {
1057  /* Use Obj to issue the command, if not available try later */
1058  ObjIdx = (_u8)_SlDrvWaitForPoolObj(PING_ID,SL_MAX_SOCKETS);
1059  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
1060  {
1061  return SL_POOL_IS_EMPTY;
1062  }
1063  OSI_RET_OK_CHECK(sl_LockObjLock(&g_pCB->ProtectionLockObj, SL_OS_WAIT_FOREVER));
1064  /* async response handler for non callback mode */
1065  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&PingRsp;
1066  pPingCallBackFunc = NULL;
1067  OSI_RET_OK_CHECK(sl_LockObjUnlock(&g_pCB->ProtectionLockObj));
1068  }
1069  }
1070  }
1071  /* Issue Stop Command */
1072  else
1073  {
1074  CmdCtrl.Opcode = SL_OPCODE_NETAPP_PINGSTART;
1075  Msg.Cmd.Ip = 0;
1076  }
1077  /* send the command */
1078  VERIFY_RET_OK(_SlDrvCmdOp(&CmdCtrl, &Msg, NULL));
1079  if (Msg.Cmd.Ip != 0)
1080  {
1081  if(CMD_PING_TEST_RUNNING == (_i16)Msg.Rsp.Status || CMD_PING_TEST_STOPPED == (_i16)Msg.Rsp.Status )
1082  {
1083  /* block waiting for results if no callback function is used */
1084  if( NULL == pPingCallback )
1085  {
1086 #ifdef SL_TINY
1087  _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
1088 #else
1089  SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj,
1090  PingTimeout,
1091  SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE
1092  );
1093 #endif
1094 
1095  if( SL_OS_RET_CODE_OK == (_i16)PingRsp.Status )
1096  {
1097  _SlNetAppCopyPingResultsToReport(&PingRsp,pReport);
1098  }
1099  _SlDrvReleasePoolObj(ObjIdx);
1100 
1101  }
1102  }
1103  else
1104  { /* ping failure, no async response */
1105  if( NULL == pPingCallback )
1106  {
1107  _SlDrvReleasePoolObj(ObjIdx);
1108  }
1109  }
1110 
1111  }
1112  return (_i16)Msg.Rsp.Status;
1113 }

§ sl_NetAppRecv()

_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 1283 of file netapp.c.

1284 {
1285  _SlNetAppReceiveMsg_u Msg;
1286  _SlCmdExt_t CmdExt;
1287  SlProtocolNetAppReceive_t AsyncRsp; /* Will be filled when SL_OPCODE_NETAPP_RECEIVE async event is arrived */
1288 
1289  _SlReturnVal_t RetVal;
1290  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
1291  _SlArgsData_t pArgsData;
1292 
1293  /* Validate input arguments */
1294  if ((NULL == pData) || (0==DataLen))
1295  {
1296  return SL_ERROR_BSD_EINVAL;
1297  }
1298 
1299  /* Save the user RX bufer. Rx data will be copied into it on the SL_OPCODE_NETAPP_RECEIVE async event */
1300  _SlDrvResetCmdExt(&CmdExt);
1301  CmdExt.RxPayloadLen = *DataLen;
1302  CmdExt.pRxPayload = pData;
1303 
1304  /* Prepare the command args */
1305  Msg.Cmd.Handle = Handle;
1306  Msg.Cmd.MaxBufferLen = *DataLen;
1307  Msg.Cmd.Flags = *Flags;
1308 
1309  /* Use Obj to issue the command, if not available try later */
1310  ObjIdx = (_u8)_SlDrvWaitForPoolObj(NETAPP_RECEIVE_ID, SL_MAX_SOCKETS);
1311 
1312  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
1313  {
1314  return SL_POOL_IS_EMPTY;
1315  }
1316 
1317  /* Save the AsyncRsp and cmdExt information for the SL_OPCODE_NETAPP_RECEIVE async event */
1318  AsyncRsp.Handle = Handle; /* Handle we are waiting for */
1319  AsyncRsp.Flags = 0;
1320  AsyncRsp.PayloadLen = 0; /* 0 will indicate an error in the SL_OPCODE_NETAPP_RECEIVE async event and that no data arrived. */
1321 
1322  _SlDrvProtectionObjLockWaitForever();
1323 
1324  pArgsData.pData = (_u8 *) &CmdExt;
1325  pArgsData.pArgs = (_u8 *) &AsyncRsp;
1326 
1327  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&pArgsData;
1328 
1329  _SlDrvProtectionObjUnLock();
1330 
1331  /* Send the command */
1332  RetVal = _SlDrvCmdSend((_SlCmdCtrl_t *)&_SlNetAppReceiveCmdCtrl, &Msg, &CmdExt);
1333 
1334  if(SL_OS_RET_CODE_OK == RetVal)
1335  {
1336  /* Wait for SL_OPCODE_NETAPP_RECEIVE async event. Will be signaled by _SlNetAppHandleAsync_NetAppReceive. */
1337  _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
1338 
1339  /* Update information for the user */
1340  *DataLen = AsyncRsp.PayloadLen;
1341  *Flags = AsyncRsp.Flags;
1342  }
1343 
1344  _SlDrvReleasePoolObj(ObjIdx);
1345 
1346  return RetVal;
1347 }

§ sl_NetAppSend()

_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 1416 of file netapp.c.

1417 {
1418  _SlNetAppMsgSend_u Msg;
1419  _SlCmdExt_t CmdExt;
1420 
1421  _SlDrvMemZero(&CmdExt, (_u16)sizeof(_SlCmdExt_t));
1422 
1423  if ((((Flags & SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) == SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) && (DataLen <= SL_NETAPP_REQUEST_MAX_METADATA_LEN)) ||
1424  (((Flags & SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) == 0) && (DataLen <= SL_NETAPP_REQUEST_MAX_DATA_LEN)))
1425  {
1426  CmdExt.TxPayload1Len = (DataLen+3) & (~3);
1427  CmdExt.pTxPayload1 = (_u8 *) pData;
1428 
1429  Msg.Cmd.Handle = Handle;
1430  Msg.Cmd.DataLen = DataLen;
1431  Msg.Cmd.Flags = Flags;
1432 
1433  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSendCmdCtrl, &Msg, &CmdExt));
1434  }
1435  else
1436  {
1437  Msg.Rsp.status = SL_ERROR_BSD_ENOMEM;
1438  }
1439 
1440  return Msg.Rsp.status;
1441 }

§ sl_NetAppSet()

_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:
    _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
    dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address
    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)
    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)
    sl_NetAppStop(SL_NETAPP_DHCP_SERVER_ID); // Stop DHCP server before settings
    sl_NetAppSet(SL_NETAPP_DHCP_SERVER_ID, SL_NETAPP_DHCP_SRV_BASIC_OPT, outLen, (_u8* )&dhcpParams); // set parameters
    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 '-'
    _u8 *my_device = "MY-SIMPLELINK-DEV";
    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):
    _u8 *my_http_temp_name = "New - Bonjour Service Name";
    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) :
    _u8 *old_http_name = "0800285A7891@mysimplelink-022";
    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)
    time.MaxResponseTime = 2000;
    time.NumOfRetries = 30;
    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
    const signed char AddService[40] = "Printer._ipp._tcp.local";
    _i16 Status;
    Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT,strlen(AddService) , &AddService);

  • Stop MDNS:
    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
    _i16 Status;
    Timing.t = 200; // 2 seconds
    Timing.p = 2; // 2 repetitions
    Timing.k = 2; // Telescopic factor 2
    Timing.RetransInterval = 0;
    Timing.Maxinterval = 0xFFFFFFFF;
    Timing.max_time = 5;
    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:
    // bit 0: _ipp
    // bit 1: _device-info
    // bit 2: _http
    // bit 3: _https
    // bit 4: _workstation
    // bit 5: _guid
    // bit 6: _h323
    // bit 7: _ntp
    // bit 8: _objective
    // bit 9: _rdp
    // bit 10: _remote
    // bit 11: _rtsp
    // bit 12: _sip
    // bit 13: _smb
    // bit 14: _soap
    // bit 15: _ssh
    // bit 16: _telnet
    // bit 17: _tftp
    // bit 18: _xmpp-client
    // bit 19: _raop
    _u32 EventMask;
    _i16 Status;
    EventMask = BIT0 | BIT1 | BIT18;
    Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_QEVETN_MASK_OPT,sizeof(EventMask),&EventMask)

Definition at line 1135 of file netapp.c.

1136 {
1137  _SlNetAppMsgSet_u Msg;
1138  _SlCmdExt_t CmdExt;
1139 
1140  /* verify that this api is allowed. if not allowed then
1141  ignore the API execution and return immediately with an error */
1142  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1143 
1144  _SlDrvResetCmdExt(&CmdExt);
1145  CmdExt.TxPayload1Len = (OptionLen+3) & (~3);
1146  CmdExt.pTxPayload1 = (_u8 *)pOptionValue;
1147 
1148 
1149  Msg.Cmd.AppId = AppId;
1150  Msg.Cmd.ConfigLen = OptionLen;
1151  Msg.Cmd.ConfigOpt = Option;
1152 
1153  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSetCmdCtrl, &Msg, &CmdExt));
1154 
1155  return (_i16)Msg.Rsp.status;
1156 }

§ sl_NetAppStart()

_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:
    sl_NetAppStart(SL_NETAPP_HTTP_SERVER_ID | SL_NETAPP_DHCP_SERVER_ID)

Definition at line 108 of file netapp.c.

109 {
110  _SlNetAppStartStopMsg_u Msg;
111  Msg.Cmd.AppId = AppBitMap;
112 
113  /* verify that this api is allowed. if not allowed then
114  ignore the API execution and return immediately with an error */
115  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
116  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppStartCtrl, &Msg, NULL));
117 
118  return Msg.Rsp.status;
119 }

§ sl_NetAppStop()

_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:
    sl_NetAppStop(SL_NETAPP_HTTP_SERVER_ID);

Definition at line 137 of file netapp.c.

138 {
139  _SlNetAppStartStopMsg_u Msg;
140 
141  /* verify that this api is allowed. if not allowed then
142  ignore the API execution and return immediately with an error */
143  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
144  Msg.Cmd.AppId = AppBitMap;
145  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppStopCtrl, &Msg, NULL));
146 
147  return Msg.Rsp.status;
148 }

Data Structure Documentation

§ SlIpV4AcquiredAsync_t

struct SlIpV4AcquiredAsync_t

Definition at line 209 of file netapp.h.

Data Fields
_u32 Dns
_u32 Gateway
_u32 Ip

§ SlIpV6AcquiredAsync_t

struct SlIpV6AcquiredAsync_t

Definition at line 223 of file netapp.h.

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

§ SlIpLeasedAsync_t

struct SlIpLeasedAsync_t

Definition at line 229 of file netapp.h.

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

§ SlIpReleasedAsync_t

struct SlIpReleasedAsync_t

Definition at line 237 of file netapp.h.

Data Fields
_u32 IpAddress
_u8 Mac[6]
_u16 Reason

§ SlIpCollisionAsync_t

struct SlIpCollisionAsync_t

Definition at line 244 of file netapp.h.

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

§ SlIpV4Lost_t

struct SlIpV4Lost_t

Definition at line 251 of file netapp.h.

Data Fields
_u16 Padding
_i16 Status

§ SlIpV6Lost_t

struct SlIpV6Lost_t

Definition at line 257 of file netapp.h.

Data Fields
_u32 IpLost[4]

§ SlDhcpIpAcquireTimeout_t

struct SlDhcpIpAcquireTimeout_t

Definition at line 262 of file netapp.h.

Data Fields
_u16 Padding
_i16 Status

§ SlNetAppEventData_u

union SlNetAppEventData_u

Definition at line 269 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

§ SlNetAppEvent_t

struct SlNetAppEvent_t

Definition at line 282 of file netapp.h.

Data Fields
SlNetAppEventData_u Data
_u32 Id

§ SlNetAppPingReport_t

struct SlNetAppPingReport_t

Definition at line 289 of file netapp.h.

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

§ SlNetAppPingCommand_t

struct SlNetAppPingCommand_t

Definition at line 299 of file netapp.h.

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

§ SlNetAppHttpServerString_t

struct SlNetAppHttpServerString_t

Definition at line 312 of file netapp.h.

Data Fields
_u8 Len
_u8 * pData

§ SlNetAppHttpServerData_t

struct SlNetAppHttpServerData_t

Definition at line 318 of file netapp.h.

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

§ SlNetAppHttpServerPostData_t

struct SlNetAppHttpServerPostData_t

Definition at line 326 of file netapp.h.

Data Fields
SlNetAppHttpServerString_t Action
SlNetAppHttpServerString_t TokenName
SlNetAppHttpServerString_t TokenValue

§ SlNetAppHttpServerEventData_u

union SlNetAppHttpServerEventData_u

Definition at line 333 of file netapp.h.

Data Fields
SlNetAppHttpServerPostData_t HttpPostData
SlNetAppHttpServerString_t HttpTokenName

§ SlNetAppHttpServerResponsedata_u

union SlNetAppHttpServerResponsedata_u

Definition at line 339 of file netapp.h.

Data Fields
SlNetAppHttpServerString_t TokenValue

§ SlNetAppHttpServerEvent_t

struct SlNetAppHttpServerEvent_t

Definition at line 344 of file netapp.h.

Data Fields
_u32 Event
SlNetAppHttpServerEventData_u EventData

§ SlNetAppHttpServerResponse_t

struct SlNetAppHttpServerResponse_t

Definition at line 350 of file netapp.h.

Data Fields
_u32 Response
SlNetAppHttpServerResponsedata_u ResponseData

§ SlNetAppData_t

struct SlNetAppData_t

Definition at line 430 of file netapp.h.

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

§ SlNetAppRequest_t

struct SlNetAppRequest_t

Definition at line 439 of file netapp.h.

Data Fields
_u8 AppId
_u16 Handle
SlNetAppData_t requestData
_u8 Type

§ SlNetAppResponse_t

struct SlNetAppResponse_t

Definition at line 448 of file netapp.h.

Data Fields
SlNetAppData_t ResponseData
_u16 Status

§ SlNetAppDhcpServerBasicOpt_t

struct SlNetAppDhcpServerBasicOpt_t

Definition at line 456 of file netapp.h.

Data Fields
_u32 ipv4_addr_last
_u32 ipv4_addr_start
_u32 lease_time

§ SlNetAppGetShortServiceIpv4List_t

struct SlNetAppGetShortServiceIpv4List_t

Definition at line 474 of file netapp.h.

Data Fields
_u16 Reserved
_u32 service_ipv4
_u16 service_port

§ SlNetAppGetFullServiceIpv4List_t

struct SlNetAppGetFullServiceIpv4List_t

Definition at line 481 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

§ SlNetAppGetFullServiceWithTextIpv4List_t

struct SlNetAppGetFullServiceWithTextIpv4List_t

Definition at line 490 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]

§ SlNetAppGetShortServiceIpv6List_t

struct SlNetAppGetShortServiceIpv6List_t

Definition at line 501 of file netapp.h.

Data Fields
_u16 Reserved
_u32 service_ipv6[4]
_u16 service_port

§ SlNetAppGetFullServiceIpv6List_t

struct SlNetAppGetFullServiceIpv6List_t

Definition at line 508 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

§ SlNetAppGetFullServiceWithTextIpv6List_t

struct SlNetAppGetFullServiceWithTextIpv6List_t

Definition at line 517 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]

§ SlNetAppServiceAdvertiseTimingParameters_t

struct SlNetAppServiceAdvertiseTimingParameters_t

Definition at line 528 of file netapp.h.

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

§ SlNetAppDnsClientTime_t

struct SlNetAppDnsClientTime_t

Definition at line 553 of file netapp.h.

Data Fields
_u16 MaxResponseTime
_u16 NumOfRetries