Socket API#
Modules#
Ancillary data object information MACROS#
Returns the length of the data with the required alignment.
Returns the number of bytes an ancillary element with payload of the passed data length occupies.
Returns the value to store in the cmsg_len member of the cmsghdr structure.
Returns a pointer to the first control message header in the given msghdr structure.
Returns a pointer to the next control message header in the ancillary data buffer.
Returns a pointer to the data portion of a cmsghdr.
Flags we can use with recv(), recvfrom() and recvmsg()#
Normal data truncated, to be used as msg_flags field in the msghdr structure.
Control data truncated, to be used as msg_flags field in the msghdr structure.
Leave received data in queue, to be used as the flags parameter.
Protocol levels used for socket_setsockopt.#
Socket option level.
Application socket option level.
IPV6 socket option level.
application level socket options#
application level socket options summaryopt_name data type set/get sendmsg recvmsg SO_EVENT_MODE int16_t Set only No Yes SO_NONBLOCK int16_t Set only Yes Yes
Enable/disable nonblocking mode.
socket level options#
socket level options summaryopt_name data type set/get sendmsg recvmsg SO_RCVBUF int32_t Set/Get No Yes SO_SNDBUF int32_t Set/Get Yes No SO_SNDLOWAT int32_t Set/Get Yes No SO_WRITABLE int32_t Get No No SO_READABLE int32_t Get No No
Specify send buffer size in payload bytes.
Specify send low water mark in payload bytes.
Non-standard POSIX option SO_WRITABLE.
Non-standard POSIX option SO_READABLE.
Socket DSCP (Differentiated Services Code Point) QoS supported levels.#
Standard priority and it is socket default.
Application high priority service: Stack priorities these messages over the default priority messages.
Expedited Forwarding (EF) QoS level enable high priority state: low loss, low delay, and low jitter services.
IPv6 socket options#
IPv6 socket options summaryopt_name Data type set/getsockopt sendmsg recvmsg IPV6_TCLASS int Set/Get Yes No IPV6_UNICAST_HOPS int Set/Get No No IPV6_MULTICAST_HOPS int Set/Get No No IPV6_USE_MIN_MTU int Set/Get Yes No IPV6_HOPLIMIT int None Yes Yes IPV6_RECVHOPLIMIT int Set/Get No No IPV6_MULTICAST_LOOP int Set/Get Yes No IPV6_JOIN_GROUP ipv6_mreq_t Set only No No IPV6_ADD_MEMBERSHIP ipv6_mreq_t Set only No No IPV6_LEAVE_GROUP ipv6_mreq_t Set only No No IPV6_DROP_MEMBERSHIP ipv6_mreq_t Set only No No IPV6_PKTINFO in6_pktinfo_t None Yes Yes IPV6_RCVPKTINFO int Set/Get No No IPV6_RECVTCLASS int Set/Get No No IPV6_DONTFRAG int Set/Get Yes No SO_EDFE_MODE uint32_t Set only Yes No
IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.
Set the unicast hop limit for the socket, as int.
Set the multicast hop limit for the socket, as int.
Specify PMTU preference, as int; Valid values -1 (PMTUD for unicast, default), 0 (PMTUD always), 1 (PMTUD off).
Ancillary data option on sendmsg()/recvmsg(), value to be used for single ongoing packet, as int; Valid values 0-255, -1 for default.
Ancillary data option on recvmsg(), specifies hop-limit for the single received ongoing packet, as int; A nonzero value enables the option; a value of 0 disables the option.
Specify whether outgoing multicast packets are looped back, as int.
Join a multicast group.
IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.
Leave a multicast group.
IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.
Specify control messages packet info for recvmsg() as struct in6_pktinfo.
Set delivery of the IPV6_PKTINFO control message on incoming datagrams, as int.
Enables the application to receive the value of the traffic class field from the IPv6 header, as int; A nonzero value enables the option; a value of 0 disables the option.
Specify not to fragment datagrams, as int; For Wi-SUN, direct neighbors can receive frames up to 1504 bytes, while the other nodes can receive frames up to 1280 bytes.
Experimental: Enable Extended Directed Frame Exchange mode.
IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.
Enumerations#
Enumerations for socket event mode.
Typedefs#
IPv6 Internet address.
Structure to store the IPv6 packet information.
Structure to store the IPv6 MTU (Maximum Transmission Unit) information.
Structure to specify the multicast group and the interface.
Address family.
Supported address families.
IP protocols.
Socket types.
Socket id.
IPv6 address format.
Socket address length type definition.
Variables#
IPv6 wildcard address.
Functions#
Accept a connection on a socket.
Bind a name to a socket.
Close a socket.
Initiate a connection on a socket.
Get the address of the peer connected to the socket.
Retrieves the local address of a socket.
Get socket option.
Listen for connections on a socket.
Receive a message from a socket.
Receive messages from a socket.
Receive a message from a socket.
Send a message on a socket.
Send a message through a connection-mode or connectionless-mode socket.
Send a message to a given address.
Set socket option designated by optname at a given protocol level to the value pointed by optval.
Create an endpoint for communication and returns an Id that refers to that endpoint.
Macros#
For backward compatibility.
Size of an IPv6 address.
When bitwise ored with socket's type, it sets the O_NONBLOCK status flag on the opened socket file description.
Ancillary data object information MACROS Documentation#
CMSG_ALIGN#
#define CMSG_ALIGNValue:
(len)
Returns the length of the data with the required alignment.
Returns
The aligned length of the data, rounded up to the nearest multiple of uint32_t
77
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
CMSG_SPACE#
#define CMSG_SPACEValue:
(len)
Returns the number of bytes an ancillary element with payload of the passed data length occupies.
Returns
The size of the control message structure plus the aligned data length
83
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
CMSG_LEN#
#define CMSG_LENValue:
(len)
Returns the value to store in the cmsg_len member of the cmsghdr structure.
Returns
The size of the control message structure plus the data length
89
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
CMSG_FIRSTHDR#
#define CMSG_FIRSTHDRValue:
Returns a pointer to the first control message header in the given msghdr structure.
Returns
A pointer to the first cmsghdr structure, or NULL if the buffer is empty or invalid
95
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
CMSG_NXTHDR#
#define CMSG_NXTHDRValue:
(mhdr, cmsg)
Returns a pointer to the next control message header in the ancillary data buffer.
Returns
A pointer to the next cmsghdr structure, or NULL if there is no more space left in the buffer
105
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
CMSG_DATA#
#define CMSG_DATAValue:
(cmsg)
Returns a pointer to the data portion of a cmsghdr.
Returns
A pointer to the data following the cmsghdr, casted to uint8_t *
111
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
Flags we can use with recv(), recvfrom() and recvmsg() Documentation#
MSG_TRUNC#
#define MSG_TRUNCValue:
0x0001
Normal data truncated, to be used as msg_flags field in the msghdr structure.
116
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
MSG_CTRUNC#
#define MSG_CTRUNCValue:
0x0002
Control data truncated, to be used as msg_flags field in the msghdr structure.
117
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
MSG_PEEK#
#define MSG_PEEKValue:
0x0004
Leave received data in queue, to be used as the flags parameter.
118
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
Protocol levels used for socket_setsockopt. Documentation#
SOL_SOCKET#
#define SOL_SOCKETValue:
0
Socket option level.
123
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SOL_APPLICATION#
#define SOL_APPLICATIONValue:
1
Application socket option level.
124
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPPROTO_IPV6#
#define IPPROTO_IPV6Value:
41
IPV6 socket option level.
125
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
application level socket options Documentation#
SO_EVENT_MODE#
#define SO_EVENT_MODEValue:
10
Specify event mode of a socket. When set, optval must point to an uint32_t.
Possible values are:
SL_WISUN_SOCKET_EVENT_MODE_INDICATION: received data is included in SL_WISUN_MSG_SOCKET_DATA_IND_ID indication
SL_WISUN_SOCKET_EVENT_MODE_POLLING: only the amount of received data is included SL_WISUN_MSG_SOCKET_DATA_AVAILABLE_IND_ID indication. recv() or recvfrom() shouldbe invoked after indication reception to retrieve data
154
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SOCKET_EVENT_MODE#
#define SOCKET_EVENT_MODEValue:
SO_EVENT_MODE
Specify event mode of a socket. When set, optval must point to an uint32_t.
Possible values are:
SL_WISUN_SOCKET_EVENT_MODE_INDICATION: received data is included in SL_WISUN_MSG_SOCKET_DATA_IND_ID indication
SL_WISUN_SOCKET_EVENT_MODE_POLLING: only the amount of received data is included SL_WISUN_MSG_SOCKET_DATA_AVAILABLE_IND_ID indication. recv() or recvfrom() shouldbe invoked after indication reception to retrieve data
155
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SO_NONBLOCK#
#define SO_NONBLOCKValue:
11
Enable/disable nonblocking mode.
This option takes an uint32_t value.
Possible values are:
(1) enables nonblocking mode
(0) disables nonblocking mode
163
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
socket level options Documentation#
SO_RCVBUF#
#define SO_RCVBUFValue:
1
Specify receive buffer size in payload bytes. When set, optval must point to an int32_t.
0 means unread data are dropped, unless read in data callback.
186
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SO_SNDBUF#
#define SO_SNDBUFValue:
2
Specify send buffer size in payload bytes.
When set, optval must point to an int32_t.
Used only for stream sockets.
192
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SO_SNDLOWAT#
#define SO_SNDLOWATValue:
4
Specify send low water mark in payload bytes.
When set, optval must point to an int32_t.
196
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SO_WRITABLE#
#define SO_WRITABLEValue:
5
Non-standard POSIX option SO_WRITABLE.
This option returns a non-zero value (amount of free space in bytes) if the socket is writable.
A socket is considered writable if: The number of bytes of available space in the socket send buffer is greater than or equal the current size of the send low-water mark and either: The socket is connected (TCP). The socket does not require a connection (e.g., UDP).
Returns
Non-zero value (amount of free space in bytes) if the socket is readable, 0 otherwise.
211
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SO_READABLE#
#define SO_READABLEValue:
6
Non-standard POSIX option SO_READABLE.
This option returns a non-zero value (amount of available bytes) if the socket is readable. A socket is considered readable under the following conditions:
The number of bytes of data in the socket receive buffer is greater than or equal to the current size of the recv low-water mark. The default is 1 for TCP and UDP. The read half of the connection is closed (i.e., a TCP connection that has received a FIN). The socket is a listening socket and the number of completed connections is nonzero.
Returns
Non-zero value (amount of data in bytes) if the socket is readable, 0 otherwise.
226
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
Socket DSCP (Differentiated Services Code Point) QoS supported levels. Documentation#
DSCP_DEFAULT#
#define DSCP_DEFAULTValue:
0
Standard priority and it is socket default.
234
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
DSCP_AF11#
#define DSCP_AF11Value:
10
Application high priority service: Stack priorities these messages over the default priority messages.
236
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
DSCP_EF#
#define DSCP_EFValue:
46
Expedited Forwarding (EF) QoS level enable high priority state: low loss, low delay, and low jitter services.
238
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPv6 socket options Documentation#
IPV6_TCLASS#
#define IPV6_TCLASSValue:
1
IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.
By default the packet class level is set to 0 DSCP_DEFAULT. Specify traffic class for outgoing packets, as int; valid values:
Level | Description |
---|---|
DSCP_DEFAULT | Default level for normal data usage |
DSCP_AF11 | Higher Application data service for prioritize packet forwarding. |
DSCP_EF | Expedited Forwarding (EF) for short messages. Allows low loss, low delay, and low jitter services. |
This is meant for very important messages like alerts. EF packet length should be kept in | |
minimum. This should not be used for any other purpose as it will block other network traffic. |
281
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_UNICAST_HOPS#
#define IPV6_UNICAST_HOPSValue:
2
Set the unicast hop limit for the socket, as int.
Valid values 0 and 255, -1 for using the route default.
284
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_MULTICAST_HOPS#
#define IPV6_MULTICAST_HOPSValue:
3
Set the multicast hop limit for the socket, as int.
Valid values 0 and 255, -1 for using the route default.
287
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_USE_MIN_MTU#
#define IPV6_USE_MIN_MTUValue:
5
Specify PMTU preference, as int; Valid values -1 (PMTUD for unicast, default), 0 (PMTUD always), 1 (PMTUD off).
290
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_HOPLIMIT#
#define IPV6_HOPLIMITValue:
8
Ancillary data option on sendmsg()/recvmsg(), value to be used for single ongoing packet, as int; Valid values 0-255, -1 for default.
293
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_RECVHOPLIMIT#
#define IPV6_RECVHOPLIMITValue:
11
Ancillary data option on recvmsg(), specifies hop-limit for the single received ongoing packet, as int; A nonzero value enables the option; a value of 0 disables the option.
296
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_MULTICAST_LOOP#
#define IPV6_MULTICAST_LOOPValue:
14
Specify whether outgoing multicast packets are looped back, as int.
A nonzero value enables the option; a value of 0 disables the option.
299
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_ADD_MEMBERSHIP#
#define IPV6_ADD_MEMBERSHIPValue:
15
Join a multicast group.
Only valid for SOCK_DGRAM or SOCK_RAW sockets. When set, optval is a pointer to a struct ipv6_mreq.
302
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_JOIN_GROUP#
#define IPV6_JOIN_GROUPValue:
IPV6_ADD_MEMBERSHIP
IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.
By default the packet class level is set to 0 DSCP_DEFAULT. Specify traffic class for outgoing packets, as int; valid values:
Level | Description |
---|---|
DSCP_DEFAULT | Default level for normal data usage |
DSCP_AF11 | Higher Application data service for prioritize packet forwarding. |
DSCP_EF | Expedited Forwarding (EF) for short messages. Allows low loss, low delay, and low jitter services. |
This is meant for very important messages like alerts. EF packet length should be kept in | |
minimum. This should not be used for any other purpose as it will block other network traffic. |
303
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_DROP_MEMBERSHIP#
#define IPV6_DROP_MEMBERSHIPValue:
16
Leave a multicast group.
Only valid for SOCK_DGRAM or SOCK_RAW sockets. When set, optval is a pointer to a struct ipv6_mreq.
306
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_LEAVE_GROUP#
#define IPV6_LEAVE_GROUPValue:
IPV6_DROP_MEMBERSHIP
IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.
By default the packet class level is set to 0 DSCP_DEFAULT. Specify traffic class for outgoing packets, as int; valid values:
Level | Description |
---|---|
DSCP_DEFAULT | Default level for normal data usage |
DSCP_AF11 | Higher Application data service for prioritize packet forwarding. |
DSCP_EF | Expedited Forwarding (EF) for short messages. Allows low loss, low delay, and low jitter services. |
This is meant for very important messages like alerts. EF packet length should be kept in | |
minimum. This should not be used for any other purpose as it will block other network traffic. |
307
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_PKTINFO#
#define IPV6_PKTINFOValue:
9
Specify control messages packet info for recvmsg() as struct in6_pktinfo.
309
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_RECVPKTINFO#
#define IPV6_RECVPKTINFOValue:
10
Set delivery of the IPV6_PKTINFO control message on incoming datagrams, as int.
Such control messages contain a struct in6_pktinfo, as per RFC 3542. Allowed only for SOCK_DGRAM or SOCK_RAW sockets.
313
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_RECVTCLASS#
#define IPV6_RECVTCLASSValue:
12
Enables the application to receive the value of the traffic class field from the IPv6 header, as int; A nonzero value enables the option; a value of 0 disables the option.
316
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_DONTFRAG#
#define IPV6_DONTFRAGValue:
6
Specify not to fragment datagrams, as int; For Wi-SUN, direct neighbors can receive frames up to 1504 bytes, while the other nodes can receive frames up to 1280 bytes.
0 (fragment to path MTU). 1 (no fragmentation, TX fails if bigger than PMTU).
321
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SO_EDFE_MODE#
#define SO_EDFE_MODEValue:
0xfb
Experimental: Enable Extended Directed Frame Exchange mode.
When set, optval must point to an uint32_t.
325
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SOCKET_EDFE_MODE#
#define SOCKET_EDFE_MODEValue:
SO_EDFE_MODE
IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.
By default the packet class level is set to 0 DSCP_DEFAULT. Specify traffic class for outgoing packets, as int; valid values:
Level | Description |
---|---|
DSCP_DEFAULT | Default level for normal data usage |
DSCP_AF11 | Higher Application data service for prioritize packet forwarding. |
DSCP_EF | Expedited Forwarding (EF) for short messages. Allows low loss, low delay, and low jitter services. |
This is meant for very important messages like alerts. EF packet length should be kept in | |
minimum. This should not be used for any other purpose as it will block other network traffic. |
326
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
Enumeration Documentation#
sl_wisun_socket_event_mode_t#
sl_wisun_socket_event_mode_t
Enumerations for socket event mode.
Enumerator | |
---|---|
SL_WISUN_SOCKET_EVENT_MODE_INDICATION | SL_WISUN_MSG_SOCKET_DATA_IND_ID is sent to the app with the packet contained in the indication. |
SL_WISUN_SOCKET_EVENT_MODE_POLLING | SL_WISUN_MSG_SOCKET_DATA_AVAILABLE_IND_ID is sent to the app indicating the amount of data received recv() or recvfrom() should be invoked after indication reception to retrieve data This is the default socket event mode option. |
346
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
socket_domain#
socket_domain
Supported address families.
Enumerator | |
---|---|
AF_INET6 | IP version 6. |
356
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
socket_protocol#
socket_protocol
IP protocols.
Enumerator | |
---|---|
IPPROTO_IP | Dummy protocol. |
IPPROTO_ICMP | Internet Control Message Protocol. |
IPPROTO_TCP | Transmission Control Protocol. |
IPPROTO_UDP | User Datagram Protocol. |
368
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
socket_type#
socket_type
Socket types.
Enumerator | |
---|---|
SOCK_STREAM | stream (connection) socket (TCP) |
SOCK_DGRAM | datagram (connectionless) socket (UDP) |
SOCK_RAW | raw socket |
361
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
Typedef Documentation#
cmsghdr_t#
typedef struct cmsghdr cmsghdr_t
Control messages.
414
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
in6_addr_t#
typedef struct in6_addr in6_addr_t
IPv6 Internet address.
384
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
in6_pktinfo_t#
typedef struct in6_pktinfo in6_pktinfo_t
Structure to store the IPv6 packet information.
420
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
iovec_t#
typedef struct iovec iovec_t
Structure to store scatter/gather array elements.
426
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
ip6_mtuinfo_t#
typedef struct ip6_mtuinfo ip6_mtuinfo_t
Structure to store the IPv6 MTU (Maximum Transmission Unit) information.
434
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
ipv6_mreq_t#
typedef struct ipv6_mreq ipv6_mreq_t
Structure to specify the multicast group and the interface.
442
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
msghdr_t#
typedef struct msghdr msghdr_t
The msghdr structure is used by the recvmsg() and sendmsg() functions.
407
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
sa_family_t#
typedef uint32_t sa_family_t
Address family.
340
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
sl_socket_domain_t#
typedef enum socket_domain sl_socket_domain_t
Supported address families.
358
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
sl_socket_protocol_t#
typedef enum socket_protocol sl_socket_protocol_t
IP protocols.
373
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
sl_socket_type_t#
typedef enum socket_type sl_socket_type_t
Socket types.
365
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
sl_wisun_socket_id_t#
typedef int sl_wisun_socket_id_t
Socket id.
343
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
sockaddr_in6_t#
typedef struct sockaddr_in6 sockaddr_in6_t
IPv6 address format.
396
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
socklen_t#
typedef uint32_t socklen_t
Socket address length type definition.
337
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
Variable Documentation#
in6addr_any#
const in6_addr_t in6addr_any
IPv6 wildcard address.
387
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
Function Documentation#
accept#
int accept (int sockid, struct sockaddr * addr, socklen_t * addrlen)
Accept a connection on a socket.
[in] | sockid | socket descriptor |
[inout] | addr | A pointer to sockaddr structure filled in with the address of the peer (remote) socket. When addr is NULL, nothing is filled in; in this case, addrlen is not used, and should also be NULL. |
[inout] | addrlen | The caller must initialize it to contain the size (in bytes) of the structure pointed to by addr. On return it will contain the actual size of the peer address. |
Returns
The socket id of the accepted socket on success, -1 if an error occurred.
Used with connection-based socket types (TCP). It extracts the first connection request on the queue of pending connections for the listening socket.
600
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
bind#
int bind (int sockid, const struct sockaddr * addr, socklen_t addrlen)
Bind a name to a socket.
[in] | sockid | socket id |
[in] | addr | address structure ptr |
[in] | addrlen | address structure size |
Returns
0 on success, -1 on failure.
Assigns the address to the socket, referred to by the socket ID, as specified by addr. It is normally necessary to assign a local address using bind() before a SOCK_STREAM socket may receive connections.
493
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
close#
int close (int sockid)
Close a socket.
[in] | sockid | socket id |
Returns
0 on success, -1 on failure.
Close a socket and remove from the socket handler storage.
479
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
connect#
int connect (int sockid, const struct sockaddr * addr, socklen_t addrlen)
Initiate a connection on a socket.
[in] | sockid | socket descriptor. |
[in] | addr | If the socket sockid is of type SOCK_DGRAM, addr is the address to which datagrams are sent by default and the only address from which datagrams are received. If the socket is of type SOCK_STREAM, this call attempts to make a connection to the socket that is bound to the address specified by addr. |
[in] | addrlen | length of the supplied sockaddr structure. |
Returns
0 on connection or binding success, -1 if an error occurred.
Connects the socket referred to by the sockid to the address specified by address.
616
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
getpeername#
int getpeername (int socket, struct sockaddr *restrict address, socklen_t *restrict address_len)
Get the address of the peer connected to the socket.
[in] | socket | The socket file descriptor. |
[out] | address | A pointer to a sockaddr structure where the peer's address will be stored. |
[inout] | address_len | A pointer to a socklen_t variable that specifies the size of the 'address' structure. |
This function retrieves the address of the peer connected to the specified socket. The peer's address is stored in the provided 'address' structure, and the length of the address is stored in 'address_len'.
Returns
0 on success, -1 on failure and sets
errno
appropriately.
723
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
getsockname#
int getsockname (int socket, struct sockaddr *restrict address, socklen_t *restrict address_len)
Retrieves the local address of a socket.
[in] | socket | The socket descriptor. |
[out] | address | A pointer to a |
[inout] | address_len | A pointer to a |
Returns
On success, returns zero. On failure, returns -1 and sets
errno
appropriately.
This function retrieves the local address associated with a socket. It populates the provided address
structure with the local address information.
706
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
getsockopt#
int getsockopt (int sockid, int level, int optname, void * optval, socklen_t * optlen)
Get socket option.
[in] | sockid | socket descriptor. |
[in] | level | socket protocol level. |
[in] | optname | Option name. Supported options:
|
[out] | optval | option value structure pointer. |
[in] | optlen | size of the option value structure. |
Returns
0 on success, -1 if an error occurred.
The function gets socket option by optname, and copies option data to optval ptr.
687
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
listen#
int listen (int sockid, int backlog)
Listen for connections on a socket.
[in] | sockid | socket id |
[in] | backlog | Argument defines the maximum length to which the queue of pending connections for sockid may grow. Not implemented for Wi-SUN, the connection queue size is always 1 |
Returns
0 on success, -1 if an error occurred.
Marks the socket referred to by sockid as a passive socket, that is, as a socket that will be used to accept incoming connection requests using accept.
630
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
recv#
ssize_t recv (int sockid, void * buf, size_t len, int flags)
Receive a message from a socket.
[in] | sockid | descriptor of socket to receive the message from. |
[out] | buf | pointer to destination data buffer. |
[in] | len | length of destination data buffer. |
[in] | flags | flags to select type of message reception. Ignored in our implementation. |
Returns
The number of bytes received on success, -1 if an error occurred.
Should be used for connection-oriented protocol (TCP)
566
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
recvfrom#
ssize_t recvfrom (int sockid, void * buf, size_t len, int flags, struct sockaddr * src_addr, socklen_t * addrlen)
Receive messages from a socket.
[in] | sockid | descriptor of socket to receive the message from. |
[out] | buf | pointer to destination data buffer. |
[in] | len | length of destination data buffer. |
[in] | flags | flags to select type of message reception. Ignored in our implementation. |
[in] | src_addr | pointer to a sockaddr structure in which the sending address is to be stored. |
[in] | addrlen | length of the supplied sockaddr structure. |
Returns
The number of bytes received on success, -1 if an error occurred.
Receives data on a socket whether or not it is connection-oriented.
551
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
recvmsg#
ssize_t recvmsg (int socket, struct msghdr * message, int flags)
Receive a message from a socket.
[in] | socket | Specifies the socket file descriptor. |
[inout] | message | Points to a msghdr structure, containing both the buffer to store the source address and the buffers for the incoming message. |
[in] | flags | Specifies the type of message reception. |
Returns
The number of bytes received on success, -1 if an error occurred.
This function is typically used with connectionless-mode sockets because it permits the application to retrieve the source address of received data.
581
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
send#
ssize_t send (int sockid, const void * buff, size_t len, int flags)
Send a message on a socket.
[in] | sockid | socket descriptor. |
[in] | buff | pointer to data buffer to send. |
[in] | len | length of data buffer to send. |
[in] | flags | flags to select send options. Ignored in our implementation. |
Returns
The number of bytes sent on success, -1 if an error occurred.
Preferred with connection-oriented sockets (TCP).
506
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
sendmsg#
ssize_t sendmsg (int socket, const struct msghdr * message, int flags)
Send a message through a connection-mode or connectionless-mode socket.
[in] | socket | Specifies the socket file descriptor. |
[in] | message | Points to a msghdr structure, containing both the destination address and the buffers for the outgoing message. |
[in] | flags | Specifies the type of message transmission. |
Returns
The number of bytes received on success, -1 if an error occurred.
534
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
sendto#
ssize_t sendto (int sockid, const void * buff, size_t len, int flags, const struct sockaddr * dest_addr, socklen_t addr_len)
Send a message to a given address.
[in] | sockid | socket descriptor. |
[in] | buff | pointer to data buffer to send. |
[in] | len | length of data buffer to send. |
[in] | flags | flags to select send options. Ignored in our implementation. |
[in] | dest_addr | pointer to destination address buffer; Required for datagram sockets. |
[in] | addr_len | length of destination address buffer. |
Returns
The number of bytes sent on success, -1 if an error occurred.
Preferred in datagram mode (UDP).
521
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
setsockopt#
int setsockopt (int sockid, int level, int optname, const void * optval, socklen_t optlen)
Set socket option designated by optname at a given protocol level to the value pointed by optval.
[in] | sockid | socket ID |
[in] | level | protocol level at which the option resides. it could be: |
[in] | optname | option name. it could be: |
[in] | optval | Pointer to the socket option new value. The type of variable pointed by optval depends level and optname values. |
[in] | optlen | Must be the size of the symbol pointed by optval. |
Returns
0 on success, -1 if an error occurred.
This function can set socket properties.
664
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
socket#
int socket (int domain, int type, int protocol)
Create an endpoint for communication and returns an Id that refers to that endpoint.
[in] | domain | Specifies a communication domain. It selects the protocol family which will be used for communication. Must be set to AF_INET6 (IPv6 network socket) |
[in] | type | The communication semantics It can be:
|
[in] | protocol | Specifies the particular protocol to be used. It can be:
|
Returns
The socket's id on success, (-1) on failure.
463
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
Macro Definition Documentation#
APP_LEVEL_SOCKET#
#define APP_LEVEL_SOCKETValue:
SOL_APPLICATION
For backward compatibility.
129
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
IPV6_ADDR_SIZE#
#define IPV6_ADDR_SIZEValue:
16
Size of an IPv6 address.
330
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h
SOCK_NONBLOCK#
#define SOCK_NONBLOCKValue:
0X00010000
When bitwise ored with socket's type, it sets the O_NONBLOCK status flag on the opened socket file description.
334
of file /mnt/raid/workspaces/ws.wIWINzxl8/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h