The function sends ping request to the given IP Address.
This function gets the index of the protocol negotiated via ALPN. It should be called when a SSL socket connection succeeds, in order to determine which application-layer protocol must be used.
- Parameters
-
[in] | sock | Socket ID obtained by a call to socket. This is the SSL socket to which the ALPN applies. |
- Returns
- The function returns:
- >0: 1-based index of negotiated protocol with respect to the list previously provided to set_alpn_list.
- 0: No negotiation occurred (eg TLS peer did not support ALPN).
- <0: Invalid parameters (socket is not in use, or not an SSL socket).
- See Also
- Example
This function gets detail about a socket failure. The application can call this when notified of a socket failure via SOCKET_MSG_CONNECT or SOCKET_MSG_RECV. If used, it must be called before close.
- Parameters
-
[in] | sock | Socket ID obtained by a call to socket. |
[out] | pstrErr | Pointer to structure to be populated with the details of the socket failure. |
- Returns
- The function returns SOCK_ERR_NO_ERROR if the request is successful. In this case pstrErr has been populated. The function returns a negative value if the request is not successful. In this case pstrErr has not been populated.
The function request to send ping request to the given IP Address.
- Parameters
-
[in] | u32DstIP | Target Destination IP Address for the ping request. It must be represented in Network byte order. The function nmi_inet_addr could be used to translate the dotted decimal notation IP to its Network bytes order integer representative. |
[in] | u8TTL | IP TTL value for the ping request. If set to ZERO, the default value SHALL be used. |
[in] | fpPingCb | Callback will be called to deliver the ping statistics. |
- Warning
- This API should only be used to request one ping at a time; calling this API invalidates callbacks for previous ping requests.
- See Also
- nmi_inet_addr
- Returns
- The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
- Parameters
-
[in] | u32DstIP | Target Destination IP Address for the ping request. It must be represented in Network byte order. The function nmi_inet_addr could be used to translate the dotted decimal notation IP to its Network bytes order integer representative. |
[in] | u8TTL | IP TTL value for the ping request. If set to ZERO, the default value SHALL be used. |
[in] | fpPingCb | Callback will be called to deliver the ping statistics. |
- Warning
- This API should only be used to request one ping at a time; calling this API invalidates callbacks for previous ping requests.
- See Also
- nmi_inet_addr
- Returns
- The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
sint8 set_alpn_list |
( |
SOCKET |
sock, |
|
|
const char * |
pcProtocolList |
|
) |
| |
This function sets the protocol list used for application-layer protocol negotiation (ALPN). If used, it must be called after creating a SSL socket (using socket) and before connecting/binding (using connect or bind) or securing (using secure).
- Parameters
-
[in] | sock | Socket ID obtained by a call to socket. This is the SSL socket to which the ALPN list applies. |
[in] | pcProtocolList | Pointer to the list of protocols available in the application.
The entries in the list must:
- be separated with ' ' (space).
- not contain ' ' (space) or '\0' (NUL).
- be non-zero length.
The list itself must:
- be terminated with '\0' (NUL).
- be no longer than ALPN_LIST_MAX_APP_LENGTH, including separators (spaces) and terminator (NUL).
- contain at least one entry.
|
- Returns
- The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Example
The example demonstrates an application using set_alpn_list and get_alpn_index to negotiate secure HTTP/2 (with fallback option of HTTP/1.1).
Main Function
* if (TcpClientSocket >= 0)
* {
* };
*
connect(TcpClientSocket, &Serv_Addr,
sizeof(Serv_Addr));
* }
*
Socket Callback
* {
* {
* switch (alpn_index)
* {
* case 1:
* printf("Negotiated HTTP/2\n");
* break;
* case 2:
* printf("Negotiated HTTP/1.1\n");
* break;
* case 0:
* printf("Protocol negotiation did not occur\n");
* break;
* }
* }
* }
*