Socket API#

Modules#

cmsghdr

in6_addr

in6_pktinfo

iovec

ip6_mtuinfo

ipv6_mreq

msghdr

sockaddr

sockaddr_in6

Ancillary data object information MACROS#

#define

Returns the length of the data with the required alignment.

#define

Returns the number of bytes an ancillary element with payload of the passed data length occupies.

#define
CMSG_LEN (len)

Returns the value to store in the cmsg_len member of the cmsghdr structure.

#define

Returns a pointer to the first control message header in the given msghdr structure.

#define
CMSG_NXTHDR (mhdr, cmsg)

Returns a pointer to the next control message header in the ancillary data buffer.

#define
CMSG_DATA (cmsg)

Returns a pointer to the data portion of a cmsghdr.

Flags we can use with recv(), recvfrom() and recvmsg()#

#define
MSG_TRUNC 0x0001

Normal data truncated, to be used as msg_flags field in the msghdr structure.

#define
MSG_CTRUNC 0x0002

Control data truncated, to be used as msg_flags field in the msghdr structure.

#define
MSG_PEEK 0x0004

Leave received data in queue, to be used as the flags parameter.

Protocol levels used for socket_setsockopt.#

#define

Socket option level.

#define

Application socket option level.

#define

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

#define
#define
SOCKET_EVENT_MODE SO_EVENT_MODE
#define

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

#define
#define

Specify send buffer size in payload bytes.

#define

Specify send low water mark in payload bytes.

#define

Non-standard POSIX option SO_WRITABLE.

#define

Non-standard POSIX option SO_READABLE.

Socket DSCP (Differentiated Services Code Point) QoS supported levels.#

#define

Standard priority and it is socket default.

#define

Application high priority service: Stack priorities these messages over the default priority messages.

#define

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

#define

IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet classification.

#define

Set the unicast hop limit for the socket, as int.

#define

Set the multicast hop limit for the socket, as int.

#define

Specify PMTU preference, as int; Valid values -1 (PMTUD for unicast, default), 0 (PMTUD always), 1 (PMTUD off).

#define

Ancillary data option on sendmsg()/recvmsg(), value to be used for single ongoing packet, as int; Valid values 0-255, -1 for default.

#define

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.

#define

Specify whether outgoing multicast packets are looped back, as int.

#define

Join a multicast group.

#define
IPV6_JOIN_GROUP 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.

#define

Leave a multicast group.

#define
IPV6_LEAVE_GROUP 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.

#define

Specify control messages packet info for recvmsg() as struct in6_pktinfo.

#define

Set delivery of the IPV6_PKTINFO control message on incoming datagrams, as int.

#define

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.

#define

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.

#define

Experimental: Enable Extended Directed Frame Exchange mode.

#define
SOCKET_EDFE_MODE 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.

Enumerations#

enum
SL_WISUN_SOCKET_EVENT_MODE_INDICATION = 0
SL_WISUN_SOCKET_EVENT_MODE_POLLING = 1
}

Enumerations for socket event mode.

enum
AF_INET6 = 0
}

Supported address families.

enum
IPPROTO_IP = 0
IPPROTO_ICMP = 1
IPPROTO_TCP = 2
IPPROTO_UDP = 3
}

IP protocols.

enum
SOCK_STREAM = 1
SOCK_DGRAM = 2
SOCK_RAW = 3
}

Socket types.

Typedefs#

typedef struct cmsghdr

Control messages.

typedef struct in6_addr

IPv6 Internet address.

typedef struct in6_pktinfo

Structure to store the IPv6 packet information.

typedef struct iovec

Structure to store scatter/gather array elements.

typedef struct ip6_mtuinfo

Structure to store the IPv6 MTU (Maximum Transmission Unit) information.

typedef struct ipv6_mreq

Structure to specify the multicast group and the interface.

typedef struct msghdr

The msghdr structure is used by the recvmsg() and sendmsg() functions.

typedef uint32_t

Address family.

typedef enum socket_domain

Supported address families.

typedef enum socket_protocol

IP protocols.

typedef enum socket_type

Socket types.

typedef int
typedef struct sockaddr_in6

IPv6 address format.

typedef uint32_t

Socket address length type definition.

Variables#

IPv6 wildcard address.

Functions#

int
accept(int sockid, struct sockaddr *addr, socklen_t *addrlen)

Accept a connection on a socket.

int
bind(int sockid, const struct sockaddr *addr, socklen_t addrlen)

Bind a name to a socket.

int
close(int sockid)

Close a socket.

int
connect(int sockid, const struct sockaddr *addr, socklen_t addrlen)

Initiate a connection on a socket.

int
getpeername(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len)

Get the address of the peer connected to the socket.

int
getsockname(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len)

Retrieves the local address of a socket.

int
getsockopt(int sockid, int level, int optname, void *optval, socklen_t *optlen)

Get socket option.

int
listen(int sockid, int backlog)

Listen for connections on a socket.

ssize_t
recv(int sockid, void *buf, size_t len, int flags)

Receive a message from a socket.

ssize_t
recvfrom(int sockid, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)

Receive messages from a socket.

ssize_t
recvmsg(int socket, struct msghdr *message, int flags)

Receive a message from a socket.

ssize_t
send(int sockid, const void *buff, size_t len, int flags)

Send a message on a socket.

ssize_t
sendmsg(int socket, const struct msghdr *message, int flags)

Send a message through a connection-mode or connectionless-mode socket.

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.

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.

int
socket(int domain, int type, int protocol)

Create an endpoint for communication and returns an Id that refers to that endpoint.

Macros#

#define
APP_LEVEL_SOCKET SOL_APPLICATION

For backward compatibility.

#define

Size of an IPv6 address.

#define
SOCK_NONBLOCK 0X00010000

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_ALIGN
Value:
(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


Definition at line 77 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

CMSG_SPACE#

#define CMSG_SPACE
Value:
(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


Definition at line 83 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

CMSG_LEN#

#define CMSG_LEN
Value:
(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


Definition at line 89 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

CMSG_FIRSTHDR#

#define CMSG_FIRSTHDR
Value:
((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
(struct cmsghdr *)(mhdr)->msg_control : \
(struct cmsghdr *) NULL)

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


Definition at line 95 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

CMSG_NXTHDR#

#define CMSG_NXTHDR
Value:
(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


Definition at line 105 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

CMSG_DATA#

#define CMSG_DATA
Value:
(cmsg)

Returns a pointer to the data portion of a cmsghdr.

Returns

  • A pointer to the data following the cmsghdr, casted to uint8_t *


Definition at line 111 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

Flags we can use with recv(), recvfrom() and recvmsg() Documentation#

MSG_TRUNC#

#define MSG_TRUNC
Value:
0x0001

Normal data truncated, to be used as msg_flags field in the msghdr structure.


Definition at line 116 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

MSG_CTRUNC#

#define MSG_CTRUNC
Value:
0x0002

Control data truncated, to be used as msg_flags field in the msghdr structure.


Definition at line 117 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

MSG_PEEK#

#define MSG_PEEK
Value:
0x0004

Leave received data in queue, to be used as the flags parameter.


Definition at line 118 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

Protocol levels used for socket_setsockopt. Documentation#

SOL_SOCKET#

#define SOL_SOCKET
Value:
0

Socket option level.


Definition at line 123 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SOL_APPLICATION#

#define SOL_APPLICATION
Value:
1

Application socket option level.


Definition at line 124 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPPROTO_IPV6#

#define IPPROTO_IPV6
Value:
41

IPV6 socket option level.


Definition at line 125 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

application level socket options Documentation#

SO_EVENT_MODE#

#define SO_EVENT_MODE
Value:
10

Specify event mode of a socket. When set, optval must point to an uint32_t.

Possible values are:


Definition at line 154 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SOCKET_EVENT_MODE#

#define SOCKET_EVENT_MODE
Value:
SO_EVENT_MODE

Specify event mode of a socket. When set, optval must point to an uint32_t.

Possible values are:


Definition at line 155 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SO_NONBLOCK#

#define SO_NONBLOCK
Value:
11

Enable/disable nonblocking mode.

This option takes an uint32_t value.

Possible values are:

  • (1) enables nonblocking mode

  • (0) disables nonblocking mode


Definition at line 163 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

socket level options Documentation#

SO_RCVBUF#

#define SO_RCVBUF
Value:
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.


Definition at line 186 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SO_SNDBUF#

#define SO_SNDBUF
Value:
2

Specify send buffer size in payload bytes.

When set, optval must point to an int32_t.

Used only for stream sockets.


Definition at line 192 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SO_SNDLOWAT#

#define SO_SNDLOWAT
Value:
4

Specify send low water mark in payload bytes.

When set, optval must point to an int32_t.


Definition at line 196 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SO_WRITABLE#

#define SO_WRITABLE
Value:
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.


Definition at line 211 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SO_READABLE#

#define SO_READABLE
Value:
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.


Definition at line 226 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

Socket DSCP (Differentiated Services Code Point) QoS supported levels. Documentation#

DSCP_DEFAULT#

#define DSCP_DEFAULT
Value:
0

Standard priority and it is socket default.


Definition at line 234 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

DSCP_AF11#

#define DSCP_AF11
Value:
10

Application high priority service: Stack priorities these messages over the default priority messages.


Definition at line 236 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

DSCP_EF#

#define DSCP_EF
Value:
46

Expedited Forwarding (EF) QoS level enable high priority state: low loss, low delay, and low jitter services.


Definition at line 238 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPv6 socket options Documentation#

IPV6_TCLASS#

#define IPV6_TCLASS
Value:
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.


Definition at line 281 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_UNICAST_HOPS#

#define IPV6_UNICAST_HOPS
Value:
2

Set the unicast hop limit for the socket, as int.

Valid values 0 and 255, -1 for using the route default.


Definition at line 284 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_MULTICAST_HOPS#

#define IPV6_MULTICAST_HOPS
Value:
3

Set the multicast hop limit for the socket, as int.

Valid values 0 and 255, -1 for using the route default.


Definition at line 287 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_USE_MIN_MTU#

#define IPV6_USE_MIN_MTU
Value:
5

Specify PMTU preference, as int; Valid values -1 (PMTUD for unicast, default), 0 (PMTUD always), 1 (PMTUD off).


Definition at line 290 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_HOPLIMIT#

#define IPV6_HOPLIMIT
Value:
8

Ancillary data option on sendmsg()/recvmsg(), value to be used for single ongoing packet, as int; Valid values 0-255, -1 for default.


Definition at line 293 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_RECVHOPLIMIT#

#define IPV6_RECVHOPLIMIT
Value:
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.


Definition at line 296 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_MULTICAST_LOOP#

#define IPV6_MULTICAST_LOOP
Value:
14

Specify whether outgoing multicast packets are looped back, as int.

A nonzero value enables the option; a value of 0 disables the option.


Definition at line 299 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_ADD_MEMBERSHIP#

#define IPV6_ADD_MEMBERSHIP
Value:
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.


Definition at line 302 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_JOIN_GROUP#

#define IPV6_JOIN_GROUP
Value:
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.


Definition at line 303 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_DROP_MEMBERSHIP#

#define IPV6_DROP_MEMBERSHIP
Value:
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.


Definition at line 306 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_LEAVE_GROUP#

#define IPV6_LEAVE_GROUP
Value:
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.


Definition at line 307 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_PKTINFO#

#define IPV6_PKTINFO
Value:
9

Specify control messages packet info for recvmsg() as struct in6_pktinfo.


Definition at line 309 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_RECVPKTINFO#

#define IPV6_RECVPKTINFO
Value:
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.


Definition at line 313 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_RECVTCLASS#

#define IPV6_RECVTCLASS
Value:
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.


Definition at line 316 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_DONTFRAG#

#define IPV6_DONTFRAG
Value:
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).


Definition at line 321 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SO_EDFE_MODE#

#define SO_EDFE_MODE
Value:
0xfb

Experimental: Enable Extended Directed Frame Exchange mode.

When set, optval must point to an uint32_t.


Definition at line 325 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SOCKET_EDFE_MODE#

#define SOCKET_EDFE_MODE
Value:
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.


Definition at line 326 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.


Definition at line 346 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

socket_domain#

socket_domain

Supported address families.

Enumerator
AF_INET6

IP version 6.


Definition at line 356 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.


Definition at line 368 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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


Definition at line 361 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

Typedef Documentation#

cmsghdr_t#

typedef struct cmsghdr cmsghdr_t

Control messages.


Definition at line 414 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

in6_addr_t#

typedef struct in6_addr in6_addr_t

IPv6 Internet address.


Definition at line 384 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.


Definition at line 420 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

iovec_t#

typedef struct iovec iovec_t

Structure to store scatter/gather array elements.


Definition at line 426 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.


Definition at line 434 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.


Definition at line 442 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.


Definition at line 407 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

sa_family_t#

typedef uint32_t sa_family_t

Address family.


Definition at line 340 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

sl_socket_domain_t#

typedef enum socket_domain sl_socket_domain_t

Supported address families.


Definition at line 358 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

sl_socket_protocol_t#

typedef enum socket_protocol sl_socket_protocol_t

IP protocols.


Definition at line 373 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

sl_socket_type_t#

typedef enum socket_type sl_socket_type_t

Socket types.


Definition at line 365 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

sl_wisun_socket_id_t#

typedef int sl_wisun_socket_id_t

Socket id.


Definition at line 343 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

sockaddr_in6_t#

typedef struct sockaddr_in6 sockaddr_in6_t

IPv6 address format.


Definition at line 396 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

socklen_t#

typedef uint32_t socklen_t

Socket address length type definition.


Definition at line 337 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

Variable Documentation#

in6addr_any#

const in6_addr_t in6addr_any

IPv6 wildcard address.


Definition at line 387 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 600 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 493 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

close#

int close (int sockid)

Close a socket.

Parameters
[in]sockid

socket id

Returns

  • 0 on success, -1 on failure.

Close a socket and remove from the socket handler storage.


Definition at line 479 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 616 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 723 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[in]socket

The socket descriptor.

[out]address

A pointer to a struct sockaddr where the local address information will be stored.

[inout]address_len

A pointer to a socklen_t variable that specifies the size of the address structure. Upon successful completion, it contains the actual size of the address data.

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.


Definition at line 706 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 687 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

listen#

int listen (int sockid, int backlog)

Listen for connections on a socket.

Parameters
[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.


Definition at line 630 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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)


Definition at line 566 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 551 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 581 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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).


Definition at line 506 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 534 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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).


Definition at line 521 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 664 of file /mnt/raid/workspaces/ws.z1SfSYxIV/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.

Parameters
[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.


Definition at line 463 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

Macro Definition Documentation#

APP_LEVEL_SOCKET#

#define APP_LEVEL_SOCKET
Value:
SOL_APPLICATION

For backward compatibility.


Definition at line 129 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

IPV6_ADDR_SIZE#

#define IPV6_ADDR_SIZE
Value:
16

Size of an IPv6 address.


Definition at line 330 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h

SOCK_NONBLOCK#

#define SOCK_NONBLOCK
Value:
0X00010000

When bitwise ored with socket's type, it sets the O_NONBLOCK status flag on the opened socket file description.


Definition at line 334 of file /mnt/raid/workspaces/ws.z1SfSYxIV/overlay/gsdk/protocol/wisun/stack/inc/socket/socket.h