SimpleLink CC3120/CC3220 Host Driver  Version 2.0.1.18
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 834 of file netapp.c.

835 {
836  _SlGetHostByNameMsg_u Msg;
837  _SlCmdExt_t ExtCtrl;
838  _GetHostByNameAsyncResponse_u AsyncRsp;
839  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
840 
841  /* verify that this api is allowed. if not allowed then
842  ignore the API execution and return immediately with an error */
843  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
844 
845  _SlDrvResetCmdExt(&ExtCtrl);
846  ExtCtrl.TxPayload1Len = NameLen;
847  ExtCtrl.pTxPayload1 = (_u8 *)pHostName;
848 
849  Msg.Cmd.Len = NameLen;
850  Msg.Cmd.Family = Family;
851 
852  /*Use Obj to issue the command, if not available try later */
853  ObjIdx = (_u8)_SlDrvWaitForPoolObj(GETHOSYBYNAME_ID,SL_MAX_SOCKETS);
854  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
855  {
856  return SL_POOL_IS_EMPTY;
857  }
858 
859  SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
860 
861  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&AsyncRsp;
862  /*set bit to indicate IPv6 address is expected */
863  if (SL_AF_INET6 == Family)
864  {
865  g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK;
866  }
867 
868  SL_DRV_PROTECTION_OBJ_UNLOCK();
869 
870  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByNameCtrl, &Msg, &ExtCtrl));
871 
872  if(SL_RET_CODE_OK == Msg.Rsp.status)
873  {
874  SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj);
875 
876  Msg.Rsp.status = (_i16)AsyncRsp.IpV4.Status;
877 
878  if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status)
879  {
880  sl_Memcpy((_i8 *)OutIpAddr,
881  (_i8 *)&AsyncRsp.IpV4.Ip0,
882  (SL_AF_INET == Family) ? SL_IPV4_ADDRESS_SIZE : SL_IPV6_ADDRESS_SIZE);
883  }
884  }
885  _SlDrvReleasePoolObj(ObjIdx);
886  return Msg.Rsp.status;
887 }

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

§ 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 1440 of file netapp.c.

1441 {
1442  _SlNetAppMsgGet_u Msg;
1443  _SlCmdExt_t CmdExt;
1444 
1445  /* verify that this api is allowed. if not allowed then
1446  ignore the API execution and return immediately with an error */
1447  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1448 
1449  if (*pOptionLen == 0)
1450  {
1451  return SL_EZEROLEN;
1452  }
1453 
1454  _SlDrvResetCmdExt(&CmdExt);
1455  CmdExt.RxPayloadLen = (_i16)(*pOptionLen);
1456  CmdExt.pRxPayload = (_u8 *)pOptionValue;
1457 
1458  Msg.Cmd.AppId = AppId;
1459  Msg.Cmd.ConfigOpt = Option;
1460  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppGetCmdCtrl, &Msg, &CmdExt));
1461 
1462 
1463  if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
1464  {
1465  *pOptionLen = (_u8)CmdExt.RxPayloadLen;
1466  return SL_ESMALLBUF;
1467  }
1468  else
1469  {
1470  *pOptionLen = (_u8)CmdExt.ActualRxPayloadLen;
1471  }
1472 
1473  return (_i16)Msg.Rsp.Status;
1474 }

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

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

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

§ 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 980 of file netapp.c.

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

§ 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 1261 of file netapp.c.

1262 {
1263  _SlNetAppReceiveMsg_u Msg;
1264  _SlCmdExt_t CmdExt;
1265  SlProtocolNetAppReceive_t AsyncRsp; /* Will be filled when SL_OPCODE_NETAPP_RECEIVE async event is arrived */
1266 
1267  _SlReturnVal_t RetVal;
1268  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
1269  _SlArgsData_t pArgsData;
1270 
1271  /* Validate input arguments */
1272  if ((NULL == pData) || (0==DataLen))
1273  {
1274  return SL_ERROR_BSD_EINVAL;
1275  }
1276 
1277  /* Save the user RX bufer. Rx data will be copied into it on the SL_OPCODE_NETAPP_RECEIVE async event */
1278  _SlDrvResetCmdExt(&CmdExt);
1279  CmdExt.RxPayloadLen = *DataLen;
1280  CmdExt.pRxPayload = pData;
1281 
1282  /* Prepare the command args */
1283  Msg.Cmd.Handle = Handle;
1284  Msg.Cmd.MaxBufferLen = *DataLen;
1285  Msg.Cmd.Flags = *Flags;
1286 
1287  /* Use Obj to issue the command, if not available try later */
1288  ObjIdx = (_u8)_SlDrvWaitForPoolObj(NETAPP_RECEIVE_ID, SL_MAX_SOCKETS);
1289 
1290  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
1291  {
1292  return SL_POOL_IS_EMPTY;
1293  }
1294 
1295  /* Save the AsyncRsp and cmdExt information for the SL_OPCODE_NETAPP_RECEIVE async event */
1296  AsyncRsp.Handle = Handle; /* Handle we are waiting for */
1297  AsyncRsp.Flags = 0;
1298  AsyncRsp.PayloadLen = 0; /* 0 will indicate an error in the SL_OPCODE_NETAPP_RECEIVE async event and that no data arrived. */
1299 
1300  _SlDrvProtectionObjLockWaitForever();
1301 
1302  pArgsData.pData = (_u8 *) &CmdExt;
1303  pArgsData.pArgs = (_u8 *) &AsyncRsp;
1304 
1305  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&pArgsData;
1306 
1307  _SlDrvProtectionObjUnLock();
1308 
1309  /* Send the command */
1310  RetVal = _SlDrvCmdSend((_SlCmdCtrl_t *)&_SlNetAppReceiveCmdCtrl, &Msg, &CmdExt);
1311 
1312  if(SL_OS_RET_CODE_OK == RetVal)
1313  {
1314  /* Wait for SL_OPCODE_NETAPP_RECEIVE async event. Will be signaled by _SlNetAppHandleAsync_NetAppReceive. */
1315  _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
1316 
1317  /* Update information for the user */
1318  *DataLen = AsyncRsp.PayloadLen;
1319  *Flags = AsyncRsp.Flags;
1320  }
1321 
1322  _SlDrvReleasePoolObj(ObjIdx);
1323 
1324  return RetVal;
1325 }

§ 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 1394 of file netapp.c.

1395 {
1396  _SlNetAppMsgSend_u Msg;
1397  _SlCmdExt_t CmdExt;
1398 
1399  _SlDrvMemZero(&CmdExt, (_u16)sizeof(_SlCmdExt_t));
1400 
1401  if ((((Flags & SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) == SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) && (DataLen <= SL_NETAPP_REQUEST_MAX_METADATA_LEN)) ||
1402  (((Flags & SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) == 0) && (DataLen <= SL_NETAPP_REQUEST_MAX_DATA_LEN)))
1403  {
1404  CmdExt.TxPayload1Len = (DataLen+3) & (~3);
1405  CmdExt.pTxPayload1 = (_u8 *) pData;
1406 
1407  Msg.Cmd.Handle = Handle;
1408  Msg.Cmd.DataLen = DataLen;
1409  Msg.Cmd.Flags = Flags;
1410 
1411  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSendCmdCtrl, &Msg, &CmdExt));
1412  }
1413  else
1414  {
1415  Msg.Rsp.status = SL_ERROR_BSD_ENOMEM;
1416  }
1417 
1418  return Msg.Rsp.status;
1419 }

§ 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 1113 of file netapp.c.

1114 {
1115  _SlNetAppMsgSet_u Msg;
1116  _SlCmdExt_t CmdExt;
1117 
1118  /* verify that this api is allowed. if not allowed then
1119  ignore the API execution and return immediately with an error */
1120  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1121 
1122  _SlDrvResetCmdExt(&CmdExt);
1123  CmdExt.TxPayload1Len = (OptionLen+3) & (~3);
1124  CmdExt.pTxPayload1 = (_u8 *)pOptionValue;
1125 
1126 
1127  Msg.Cmd.AppId = AppId;
1128  Msg.Cmd.ConfigLen = OptionLen;
1129  Msg.Cmd.ConfigOpt = Option;
1130 
1131  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSetCmdCtrl, &Msg, &CmdExt));
1132 
1133  return (_i16)Msg.Rsp.status;
1134 }

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

§ 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 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

§ SlIpV4AcquiredAsync_t

struct SlIpV4AcquiredAsync_t

Definition at line 187 of file netapp.h.

Data Fields
_u32 Dns
_u32 Gateway
_u32 Ip

§ SlIpV6AcquiredAsync_t

struct SlIpV6AcquiredAsync_t

Definition at line 201 of file netapp.h.

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

§ SlIpLeasedAsync_t

struct SlIpLeasedAsync_t

Definition at line 207 of file netapp.h.

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

§ SlIpReleasedAsync_t

struct SlIpReleasedAsync_t

Definition at line 215 of file netapp.h.

Data Fields
_u32 IpAddress
_u8 Mac[6]
_u16 Reason

§ SlIpCollisionAsync_t

struct SlIpCollisionAsync_t

Definition at line 222 of file netapp.h.

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

§ SlIpV4Lost_t

struct SlIpV4Lost_t

Definition at line 229 of file netapp.h.

Data Fields
_u16 Padding
_i16 Status

§ SlIpV6Lost_t

struct SlIpV6Lost_t

Definition at line 235 of file netapp.h.

Data Fields
_u32 IpLost[4]

§ SlDhcpIpAcquireTimeout_t

struct SlDhcpIpAcquireTimeout_t

Definition at line 240 of file netapp.h.

Data Fields
_u16 Padding
_i16 Status

§ SlNetAppEventData_u

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

§ SlNetAppEvent_t

struct SlNetAppEvent_t

Definition at line 260 of file netapp.h.

Data Fields
SlNetAppEventData_u Data
_u32 Id

§ SlNetAppPingReport_t

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

§ SlNetAppPingCommand_t

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

§ SlNetAppHttpServerString_t

struct SlNetAppHttpServerString_t

Definition at line 290 of file netapp.h.

Data Fields
_u8 Len
_u8 * pData

§ SlNetAppHttpServerData_t

struct SlNetAppHttpServerData_t

Definition at line 296 of file netapp.h.

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

§ SlNetAppHttpServerPostData_t

struct SlNetAppHttpServerPostData_t

Definition at line 304 of file netapp.h.

Data Fields
SlNetAppHttpServerString_t Action
SlNetAppHttpServerString_t TokenName
SlNetAppHttpServerString_t TokenValue

§ SlNetAppHttpServerEventData_u

union SlNetAppHttpServerEventData_u

Definition at line 311 of file netapp.h.

Data Fields
SlNetAppHttpServerPostData_t HttpPostData
SlNetAppHttpServerString_t HttpTokenName

§ SlNetAppHttpServerResponsedata_u

union SlNetAppHttpServerResponsedata_u

Definition at line 317 of file netapp.h.

Data Fields
SlNetAppHttpServerString_t TokenValue

§ SlNetAppHttpServerEvent_t

struct SlNetAppHttpServerEvent_t

Definition at line 322 of file netapp.h.

Data Fields
_u32 Event
SlNetAppHttpServerEventData_u EventData

§ SlNetAppHttpServerResponse_t

struct SlNetAppHttpServerResponse_t

Definition at line 328 of file netapp.h.

Data Fields
_u32 Response
SlNetAppHttpServerResponsedata_u ResponseData

§ SlNetAppData_t

struct SlNetAppData_t

Definition at line 408 of file netapp.h.

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

§ SlNetAppRequest_t

struct SlNetAppRequest_t

Definition at line 417 of file netapp.h.

Data Fields
_u8 AppId
_u16 Handle
SlNetAppData_t requestData
_u8 Type

§ SlNetAppResponse_t

struct SlNetAppResponse_t

Definition at line 426 of file netapp.h.

Data Fields
SlNetAppData_t ResponseData
_u16 Status

§ SlNetAppDhcpServerBasicOpt_t

struct SlNetAppDhcpServerBasicOpt_t

Definition at line 434 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 452 of file netapp.h.

Data Fields
_u16 Reserved
_u32 service_ipv4
_u16 service_port

§ SlNetAppGetFullServiceIpv4List_t

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

§ SlNetAppGetFullServiceWithTextIpv4List_t

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]

§ SlNetAppGetShortServiceIpv6List_t

struct SlNetAppGetShortServiceIpv6List_t

Definition at line 479 of file netapp.h.

Data Fields
_u16 Reserved
_u32 service_ipv6[4]
_u16 service_port

§ SlNetAppGetFullServiceIpv6List_t

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

§ SlNetAppGetFullServiceWithTextIpv6List_t

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]

§ SlNetAppServiceAdvertiseTimingParameters_t

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

§ SlNetAppDnsClientTime_t

struct SlNetAppDnsClientTime_t

Definition at line 531 of file netapp.h.

Data Fields
_u16 MaxResponseTime
_u16 NumOfRetries