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

811 {
812  _SlGetHostByNameMsg_u Msg;
813  _SlCmdExt_t ExtCtrl;
814  _GetHostByNameAsyncResponse_u AsyncRsp;
815  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
816 
817  /* verify that this api is allowed. if not allowed then
818  ignore the API execution and return immediately with an error */
819  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
820 
821  _SlDrvResetCmdExt(&ExtCtrl);
822  ExtCtrl.TxPayload1Len = NameLen;
823  ExtCtrl.pTxPayload1 = (_u8 *)pHostName;
824 
825  Msg.Cmd.Len = NameLen;
826  Msg.Cmd.Family = Family;
827 
828  /*Use Obj to issue the command, if not available try later */
829  ObjIdx = (_u8)_SlDrvWaitForPoolObj(GETHOSYBYNAME_ID,SL_MAX_SOCKETS);
830  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
831  {
832  return SL_POOL_IS_EMPTY;
833  }
834 
835  SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
836 
837  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&AsyncRsp;
838  /*set bit to indicate IPv6 address is expected */
839  if (SL_AF_INET6 == Family)
840  {
841  g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK;
842  }
843 
844  SL_DRV_PROTECTION_OBJ_UNLOCK();
845 
846  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByNameCtrl, &Msg, &ExtCtrl));
847 
848  if(SL_RET_CODE_OK == Msg.Rsp.status)
849  {
850  SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj);
851 
852  Msg.Rsp.status = (_i16)AsyncRsp.IpV4.Status;
853 
854  if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status)
855  {
856  sl_Memcpy((_i8 *)OutIpAddr,
857  (_i8 *)&AsyncRsp.IpV4.Ip0,
858  (SL_AF_INET == Family) ? SL_IPV4_ADDRESS_SIZE : SL_IPV6_ADDRESS_SIZE);
859  }
860  }
861  _SlDrvReleasePoolObj(ObjIdx);
862  return Msg.Rsp.status;
863 }

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

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

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

1398 {
1399  _SlNetAppMsgGet_u Msg;
1400  _SlCmdExt_t CmdExt;
1401 
1402  /* verify that this api is allowed. if not allowed then
1403  ignore the API execution and return immediately with an error */
1404  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1405 
1406  if (*pOptionLen == 0)
1407  {
1408  return SL_EZEROLEN;
1409  }
1410 
1411  _SlDrvResetCmdExt(&CmdExt);
1412  CmdExt.RxPayloadLen = (_i16)(*pOptionLen);
1413  CmdExt.pRxPayload = (_u8 *)pOptionValue;
1414 
1415  Msg.Cmd.AppId = AppId;
1416  Msg.Cmd.ConfigOpt = Option;
1417  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppGetCmdCtrl, &Msg, &CmdExt));
1418 
1419 
1420  if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
1421  {
1422  *pOptionLen = (_u8)CmdExt.RxPayloadLen;
1423  return SL_ESMALLBUF;
1424  }
1425  else
1426  {
1427  *pOptionLen = (_u8)CmdExt.ActualRxPayloadLen;
1428  }
1429 
1430  return (_i16)Msg.Rsp.Status;
1431 }

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

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

§ 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! Important 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 420 of file netapp.c.

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 }

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

471 {
472 
473  /* verify that this api is allowed. if not allowed then
474  ignore the API execution and return immediately with an error */
475  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
476 
477  /*
478 
479  NOTE - pay attention
480 
481  The size of the service length should be smaller than 255,
482  Until the simplelink drive supports to variable length through SPI command.
483 
484 
485  */
486 
487  /*Clear the add service bit in the options parameter.
488  In order not use different opcodes for the register service and unregister service
489  bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added
490  if it is cleared it means that the service should be deleted and there is only meaning to pServiceName
491  and ServiceNameLen values.*/
492 
493  Options &= (~SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT);
494 
495  return _SlNetAppMDNSRegisterUnregisterService( pServiceName,
496  ServiceNameLen,
497  NULL,
498  0,
499  0,
500  0,
501  Options);
502 
503 
504 }

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

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

§ 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 processor. 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 until all data is receive from the network processor.

Definition at line 1221 of file netapp.c.

1222 {
1223  _SlNetAppReceiveMsg_u Msg;
1224  _SlCmdExt_t CmdExt;
1225  SlProtocolNetAppReceive_t AsyncRsp; /* Will be filled when SL_OPCODE_NETAPP_RECEIVE async event is arrived */
1226 
1227  _SlReturnVal_t RetVal;
1228  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
1229  _SlArgsData_t pArgsData;
1230 
1231  /* Validate input arguments */
1232  if ((NULL == pData) || (0==DataLen))
1233  {
1234  return SL_ERROR_BSD_EINVAL;
1235  }
1236 
1237  /* Save the user RX bufer. Rx data will be copied into it on the SL_OPCODE_NETAPP_RECEIVE async event */
1238  _SlDrvResetCmdExt(&CmdExt);
1239  CmdExt.RxPayloadLen = *DataLen;
1240  CmdExt.pRxPayload = pData;
1241 
1242  /* Prepare the command args */
1243  Msg.Cmd.Handle = Handle;
1244  Msg.Cmd.MaxBufferLen = *DataLen;
1245  Msg.Cmd.Flags = *Flags;
1246 
1247  /* Use Obj to issue the command, if not available try later */
1248  ObjIdx = (_u8)_SlDrvWaitForPoolObj(NETAPP_RECEIVE_ID, SL_MAX_SOCKETS);
1249 
1250  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
1251  {
1252  return SL_POOL_IS_EMPTY;
1253  }
1254 
1255  /* Save the AsyncRsp and cmdExt information for the SL_OPCODE_NETAPP_RECEIVE async event */
1256  AsyncRsp.Handle = Handle; /* Handle we are waiting for */
1257  AsyncRsp.Flags = 0;
1258  AsyncRsp.PayloadLen = 0; /* 0 will indicate an error in the SL_OPCODE_NETAPP_RECEIVE async event and that no data arrived. */
1259 
1260  _SlDrvProtectionObjLockWaitForever();
1261 
1262  pArgsData.pData = (_u8 *) &CmdExt;
1263  pArgsData.pArgs = (_u8 *) &AsyncRsp;
1264 
1265  g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&pArgsData;
1266 
1267  _SlDrvProtectionObjUnLock();
1268 
1269  /* Send the command */
1270  RetVal = _SlDrvCmdSend((_SlCmdCtrl_t *)&_SlNetAppReceiveCmdCtrl, &Msg, &CmdExt);
1271 
1272  if(SL_OS_RET_CODE_OK == RetVal)
1273  {
1274  /* Wait for SL_OPCODE_NETAPP_RECEIVE async event. Will be signaled by _SlNetAppHandleAsync_NetAppReceive. */
1275  _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
1276 
1277  /* Update information for the user */
1278  *DataLen = AsyncRsp.PayloadLen;
1279  *Flags = AsyncRsp.Flags;
1280  }
1281 
1282  _SlDrvReleasePoolObj(ObjIdx);
1283 
1284  return RetVal;
1285 }

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

1354 {
1355  _SlNetAppMsgSend_u Msg;
1356  _SlCmdExt_t CmdExt;
1357 
1358  _SlDrvMemZero(&CmdExt, (_u16)sizeof(_SlCmdExt_t));
1359 
1360  if ((((Flags & SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) == SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) && (DataLen <= SL_NETAPP_REQUEST_MAX_METADATA_LEN)) ||
1361  (((Flags & SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA) == 0) && (DataLen <= SL_NETAPP_REQUEST_MAX_DATA_LEN)))
1362  {
1363  CmdExt.TxPayload1Len = (DataLen+3) & (~3);
1364  CmdExt.pTxPayload1 = (_u8 *) pData;
1365 
1366  Msg.Cmd.Handle = Handle;
1367  Msg.Cmd.DataLen = DataLen;
1368  Msg.Cmd.Flags = Flags;
1369 
1370  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSendCmdCtrl, &Msg, &CmdExt));
1371  }
1372  else
1373  {
1374  Msg.Rsp.status = SL_ERROR_BSD_ENOMEM;
1375  }
1376 
1377  return Msg.Rsp.status;
1378 }

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

1081 {
1082  _SlNetAppMsgSet_u Msg;
1083  _SlCmdExt_t CmdExt;
1084 
1085  /* verify that this api is allowed. if not allowed then
1086  ignore the API execution and return immediately with an error */
1087  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETAPP);
1088 
1089  _SlDrvResetCmdExt(&CmdExt);
1090  CmdExt.TxPayload1Len = (OptionLen+3) & (~3);
1091  CmdExt.pTxPayload1 = (_u8 *)pOptionValue;
1092 
1093  Msg.Cmd.AppId = AppId;
1094  Msg.Cmd.ConfigLen = OptionLen;
1095  Msg.Cmd.ConfigOpt = Option;
1096 
1097  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSetCmdCtrl, &Msg, &CmdExt));
1098 
1099  return (_i16)Msg.Rsp.status;
1100 }

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

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

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

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

Data Structure Documentation

§ SlIpV4AcquiredAsync_t

struct SlIpV4AcquiredAsync_t

Definition at line 208 of file netapp.h.

Data Fields
_u32 Dns
_u32 Gateway
_u32 Ip

§ SlIpV6AcquiredAsync_t

struct SlIpV6AcquiredAsync_t

Definition at line 221 of file netapp.h.

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

§ SlIpLeasedAsync_t

struct SlIpLeasedAsync_t

Definition at line 227 of file netapp.h.

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

§ SlIpReleasedAsync_t

struct SlIpReleasedAsync_t

Definition at line 235 of file netapp.h.

Data Fields
_u32 IpAddress
_u8 Mac[6]
_u16 Reason

§ SlIpCollisionAsync_t

struct SlIpCollisionAsync_t

Definition at line 242 of file netapp.h.

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

§ SlIpV4Lost_t

struct SlIpV4Lost_t

Definition at line 249 of file netapp.h.

Data Fields
_u16 Padding
_i16 Status

§ SlIpV6Lost_t

struct SlIpV6Lost_t

Definition at line 255 of file netapp.h.

Data Fields
_u32 IpLost[4]

§ SlDhcpIpAcquireTimeout_t

struct SlDhcpIpAcquireTimeout_t

Definition at line 260 of file netapp.h.

Data Fields
_u16 Padding
_i16 Status

§ SlNetAppEventData_u

union SlNetAppEventData_u

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

Data Fields
SlNetAppEventData_u Data
_u32 Id

§ SlNetAppPingReport_t

struct SlNetAppPingReport_t

Definition at line 285 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 295 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 308 of file netapp.h.

Data Fields
_u8 Len
_u8 * pData

§ SlNetAppHttpServerData_t

struct SlNetAppHttpServerData_t

Definition at line 314 of file netapp.h.

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

§ SlNetAppHttpServerPostData_t

struct SlNetAppHttpServerPostData_t

Definition at line 322 of file netapp.h.

Data Fields
SlNetAppHttpServerString_t Action
SlNetAppHttpServerString_t TokenName
SlNetAppHttpServerString_t TokenValue

§ SlNetAppHttpServerEventData_u

union SlNetAppHttpServerEventData_u

Definition at line 329 of file netapp.h.

Data Fields
SlNetAppHttpServerPostData_t HttpPostData
SlNetAppHttpServerString_t HttpTokenName

§ SlNetAppHttpServerResponsedata_u

union SlNetAppHttpServerResponsedata_u

Definition at line 335 of file netapp.h.

Data Fields
SlNetAppHttpServerString_t TokenValue

§ SlNetAppHttpServerEvent_t

struct SlNetAppHttpServerEvent_t

Definition at line 340 of file netapp.h.

Data Fields
_u32 Event
SlNetAppHttpServerEventData_u EventData

§ SlNetAppHttpServerResponse_t

struct SlNetAppHttpServerResponse_t

Definition at line 346 of file netapp.h.

Data Fields
_u32 Response
SlNetAppHttpServerResponsedata_u ResponseData

§ SlNetAppData_t

struct SlNetAppData_t

Definition at line 425 of file netapp.h.

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

§ SlNetAppRequest_t

struct SlNetAppRequest_t

Definition at line 434 of file netapp.h.

Data Fields
_u8 AppId
_u16 Handle
SlNetAppData_t requestData
_u8 Type

§ SlNetAppResponse_t

struct SlNetAppResponse_t

Definition at line 442 of file netapp.h.

Data Fields
SlNetAppData_t ResponseData
_u16 Status

§ SlNetAppDhcpServerBasicOpt_t

struct SlNetAppDhcpServerBasicOpt_t

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

Data Fields
_u16 Reserved
_u32 service_ipv4
_u16 service_port

§ SlNetAppGetFullServiceIpv4List_t

struct SlNetAppGetFullServiceIpv4List_t

Definition at line 473 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 482 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 493 of file netapp.h.

Data Fields
_u16 Reserved
_u32 service_ipv6[4]
_u16 service_port

§ SlNetAppGetFullServiceIpv6List_t

struct SlNetAppGetFullServiceIpv6List_t

Definition at line 500 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 509 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 519 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 543 of file netapp.h.

Data Fields
_u16 MaxResponseTime
_u16 NumOfRetries