Portable interface#

Modules#

sl_iperf_socket_addr

sl_iperf_socket_in6addr

sl_iperf_time

Enumerations#

enum
SL_IPERF_IPROTOV6_UDP = 0
SL_IPERF_IPROTOV6_TCP
SL_IPERF_IPROTOV4_UDP
SL_IPERF_IPROTOV4_TCP
}

iPerf socket IP protocol type definition enum

Typedefs#

typedef enum sl_iperf_protocol

iPerf socket IP protocol type definition enum

typedef struct sl_iperf_socket_addr

Socket address type definition wrapper.

Raw ip address byes.

typedef struct sl_iperf_time

iPerf time data type definition

typedef uint64_t

iPerf timestamp millisecond data type deifinition

Variables#

Functions#

void
sl_iperf_delay_ms(const uint32_t ms)

iPerf millisec delay

__STATIC_INLINE void
sl_iperf_get_socket_addr(const sl_iperf_socket_addr_t *const src_addr, void *const dest_addr)

Get socket address.

void
sl_iperf_get_socket_addr_ip(const sl_iperf_socket_addr_t *const addr, void *const ip)

Get IP address bytes from iPerf address structure.

uint16_t
sl_iperf_get_socket_addr_port(const sl_iperf_socket_addr_t *const addr)

Get port number of iperf address structure.

Get millisec timestamp.

const char *
sl_iperf_inet_ntop(const sl_iperf_socket_addr_t *const src_addr, char *const dst_str, const size_t size)

Convert IPv4 and IPv6 addresses from binary to text form.

int32_t
sl_iperf_inet_pton(const char *src_str, sl_iperf_socket_addr_t *const dst_addr)

Convert addresses from text to binary form.

int32_t
sl_iperf_join_multicast_group(const int32_t sockid, const sl_iperf_socket_addr_t *const multicast_addr)

Join multicast group.

int32_t
sl_iperf_leave_multicast_group(const int32_t sockid, const sl_iperf_socket_addr_t *const multicast_addr)

Leave multicast group.

uint32_t

iPerf host to network long

uint16_t

iPerf host to network short

bool

Check network connection.

uint32_t

iPerf network to host long

uint16_t

iPerf network to host short

void

Init iPerf Network Interface.

__STATIC_INLINE void
sl_iperf_set_socket_addr(sl_iperf_socket_addr_t *const dest_addr, const void *const src_addr)

Set iPerf socket address.

void
sl_iperf_set_socket_addr_family(sl_iperf_socket_addr_t *const addr)

Set iPerf socket address family.

void
sl_iperf_set_socket_addr_ip(sl_iperf_socket_addr_t *const addr, const void *const ip)

Set IP address bytes in iPerf address structure.

void
sl_iperf_set_socket_addr_port(sl_iperf_socket_addr_t *const addr, const uint16_t port)

Set port in iperf address structure.

int32_t
sl_iperf_socket_accept(int32_t sockid, sl_iperf_socket_addr_t *addr)

Accept a connection on a socket.

int32_t
sl_iperf_socket_bind(int32_t sockid, const sl_iperf_socket_addr_t *addr)

Bind a name to an iPerf socket.

int32_t
sl_iperf_socket_close(int32_t sockid)

Close socket.

int32_t
sl_iperf_socket_connect(int32_t sockid, const sl_iperf_socket_addr_t *addr)

Initiate a connection on a socket.

int32_t
sl_iperf_socket_create(sl_iperf_protocol_t protocol)

Create iPerf socket.

int32_t
sl_iperf_socket_getsockopt(int32_t sockid, int32_t level, int32_t optname, void *optval, size_t *optlen)

Get socket option.

int32_t
sl_iperf_socket_listen(int32_t sockid, int32_t backlog)

Listen for connections on an iPerf socket.

int32_t
sl_iperf_socket_recv(int32_t sockid, void *buff, size_t len)

Receive a message from a socket.

int32_t
sl_iperf_socket_recvfrom(int32_t sockid, void *buf, uint32_t len, sl_iperf_socket_addr_t *src_addr)

Receive messages from a socket.

int32_t
sl_iperf_socket_send(int32_t sockid, const void *buff, size_t len)

Send a message on a socket,.

int32_t
sl_iperf_socket_sendto(int32_t sockid, const void *buff, uint32_t len, const sl_iperf_socket_addr_t *dest_addr)

Send a message on a socket.

int32_t
sl_iperf_socket_setsockopt(int32_t sockid, int32_t level, int32_t optname, const void *optval, size_t optlen)

Set socket option.

Macros#

#define

Assert socket address length macro function.

#define

Size definition of IPv6 address.

#define

Define network api ERROR value.

Enumeration Documentation#

sl_iperf_protocol#

sl_iperf_protocol

iPerf socket IP protocol type definition enum

Enumerator
SL_IPERF_IPROTOV6_UDP

UDP IPv6 protocol.

SL_IPERF_IPROTOV6_TCP

TCP IPv6 protocol.

SL_IPERF_IPROTOV4_UDP

UDP IPv4 protocol.

SL_IPERF_IPROTOV4_TCP

TCP IPv4 protocol.


Definition at line 99 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

Typedef Documentation#

sl_iperf_protocol_t#

typedef enum sl_iperf_protocol sl_iperf_protocol_t

iPerf socket IP protocol type definition enum


Definition at line 108 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_addr_t#

typedef struct sl_iperf_socket_addr sl_iperf_socket_addr_t

Socket address type definition wrapper.


Definition at line 120 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_in6addr_t#

typedef struct sl_iperf_socket_in6addr sl_iperf_socket_in6addr_t

Raw ip address byes.


Definition at line 114 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_time_t#

typedef struct sl_iperf_time sl_iperf_time_t

iPerf time data type definition


Definition at line 96 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_ts_ms_t#

typedef uint64_t sl_iperf_ts_ms_t

iPerf timestamp millisecond data type deifinition


Definition at line 88 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

Variable Documentation#

sl_iperf_socket_inaddr_any#

const sl_iperf_socket_in6addr_t sl_iperf_socket_inaddr_any

Anyaddress constant.


Definition at line 134 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

Function Documentation#

sl_iperf_delay_ms#

void sl_iperf_delay_ms (const uint32_t ms)

iPerf millisec delay

Parameters
[in]ms

Millisec value

Customizable delay function


Definition at line 375 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_get_socket_addr#

__STATIC_INLINE void sl_iperf_get_socket_addr (const sl_iperf_socket_addr_t *const src_addr, void *const dest_addr)

Get socket address.

Parameters
[in]src_addr

Source address (iPerf type)

[inout]dest_addr

Destination address (custom type)

Create a full copy from iperf source address into the custom destination address.


Definition at line 438 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_get_socket_addr_ip#

void sl_iperf_get_socket_addr_ip (const sl_iperf_socket_addr_t *const addr, void *const ip)

Get IP address bytes from iPerf address structure.

Parameters
[in]addr

iPerf address

[out]ip

IP address destination buffer

Getter function of IP address


Definition at line 321 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_get_socket_addr_port#

uint16_t sl_iperf_get_socket_addr_port (const sl_iperf_socket_addr_t *const addr)

Get port number of iperf address structure.

Parameters
[in]addr

iPerf address

Getter function of port property Returns

  • uint16_t Port number


Definition at line 305 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_get_timestamp_ms#

sl_iperf_ts_ms_t sl_iperf_get_timestamp_ms (void )

Get millisec timestamp.

Parameters
N/A

Get CPU tick convert to millisec Returns

  • sl_iperf_ts_ms_t Timestamp in millisec


Definition at line 368 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_inet_ntop#

const char * sl_iperf_inet_ntop (const sl_iperf_socket_addr_t *const src_addr, char *const dst_str, const size_t size)

Convert IPv4 and IPv6 addresses from binary to text form.

Parameters
[in]src_addr

Source address in byte form

[out]dst_str

Destination buffer ptr

[in]size

Size of the destination buffer.

Converts the network address structure src in the af address family into a character string. Returns

  • It returns a non-null pointer to dst. NULL is returned if there was an error


Definition at line 397 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_inet_pton#

int32_t sl_iperf_inet_pton (const char * src_str, sl_iperf_socket_addr_t *const dst_addr)

Convert addresses from text to binary form.

Parameters
[in]src_str

Source string

[out]dst_addr

Destination address pointer

It converts the character string src into a network address structure. Returns

  • 1 on succes, -1 on error (POSIX described the 0 value too)


Definition at line 384 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_join_multicast_group#

int32_t sl_iperf_join_multicast_group (const int32_t sockid, const sl_iperf_socket_addr_t *const multicast_addr)

Join multicast group.

Parameters
[in]sockid

Socket ID to join

[in]multicast_addr

Multicast groupt address

Join socket to multicast group to get packets on group address Returns

  • int32_t


Definition at line 408 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_leave_multicast_group#

int32_t sl_iperf_leave_multicast_group (const int32_t sockid, const sl_iperf_socket_addr_t *const multicast_addr)

Leave multicast group.

Parameters
[in]sockid

Socket ID to join

[in]multicast_addr

Multicast groupt address

Remove socket from multicast group Returns

  • int32_t


Definition at line 418 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_network_htonl#

uint32_t sl_iperf_network_htonl (uint32_t val)

iPerf host to network long

Parameters
[in]val

Value

htonl implementation for iPerf Returns

  • uint32_t Converted value


Definition at line 353 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_network_htons#

uint16_t sl_iperf_network_htons (uint16_t val)

iPerf host to network short

Parameters
[in]val

Value

htons implementation for iPerf Returns

  • uint16_t Converted value


Definition at line 337 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_network_is_connected#

bool sl_iperf_network_is_connected (void )

Check network connection.

Parameters
N/A

Checking the connection status. Returns

  • true Network is connected

  • false Network is NOT connected


Definition at line 329 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_network_ntohl#

uint32_t sl_iperf_network_ntohl (uint32_t val)

iPerf network to host long

Parameters
[in]val

Value

ntohl implementatino for iPerf Returns

  • uint32_t Converted value


Definition at line 361 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_network_ntohs#

uint16_t sl_iperf_network_ntohs (uint16_t val)

iPerf network to host short

Parameters
[in]val

Value

ntohs implementation for iPerf Returns

  • uint16_t Converted value


Definition at line 345 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_nw_interface_init#

void sl_iperf_nw_interface_init (void )

Init iPerf Network Interface.

Parameters
N/A

Initialize network interface


Definition at line 144 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_set_socket_addr#

__STATIC_INLINE void sl_iperf_set_socket_addr (sl_iperf_socket_addr_t *const dest_addr, const void *const src_addr)

Set iPerf socket address.

Parameters
[inout]dest_addr

Destination address (custom type)

[in]src_addr

Source address (iPerf type)

Cerate a full copy of custom source address to the destination iperf address.


Definition at line 427 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_set_socket_addr_family#

void sl_iperf_set_socket_addr_family (sl_iperf_socket_addr_t *const addr)

Set iPerf socket address family.

Parameters
[out]addr

Socket address structure

Set address family in socket address structure


Definition at line 289 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_set_socket_addr_ip#

void sl_iperf_set_socket_addr_ip (sl_iperf_socket_addr_t *const addr, const void *const ip)

Set IP address bytes in iPerf address structure.

Parameters
[inout]addr

iPerf address

[in]ip

IP address source buffer

Setter function of IP address


Definition at line 313 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_set_socket_addr_port#

void sl_iperf_set_socket_addr_port (sl_iperf_socket_addr_t *const addr, const uint16_t port)

Set port in iperf address structure.

Parameters
[inout]addr

iPerf address

[out]port

Port number

Setter function of port property


Definition at line 297 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_accept#

int32_t sl_iperf_socket_accept (int32_t sockid, sl_iperf_socket_addr_t * addr)

Accept a connection on a socket.

Parameters
[in]sockid

socket id

[inout]addr

Is filled in with the address of the peer (remote) socket In Wi-SUN case, it shouldn't be NULL ptr, but for external sockets should be.

It is used with connection-based socket types (TCP). It extracts the first connection request on the queue of pending connections for the listening socket. Returns

  • On success, return with the socket id for accepted socket, on error -1 is returned.


Definition at line 196 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_bind#

int32_t sl_iperf_socket_bind (int32_t sockid, const sl_iperf_socket_addr_t * addr)

Bind a name to an iPerf socket.

Parameters
[in]sockid

socket id

[in]addr

address structure ptr

Assigns the address specified by addr to the socket referred to by the socket id. It is normally necessary to assign a local address using bind() before a SOCK_STREAM socket may receive connections Returns

  • On success, zero is returned. On error, -1 is returned


Definition at line 171 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_close#

int32_t sl_iperf_socket_close (int32_t sockid)

Close socket.

Parameters
[in]sockid

socket id

Close socket and remove from the socket handler storage Returns

  • if any error occurred, return with -1, otherwise return with the socket id


Definition at line 160 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_connect#

int32_t sl_iperf_socket_connect (int32_t sockid, const sl_iperf_socket_addr_t * addr)

Initiate a connection on a socket.

Parameters
[in]sockid

socket id

[in]addr

If the socket sockid is of type SOCK_DGRAM, then 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.

Connects the socket referred to by the socketid to the address specified by addr. Returns

  • If the connection or binding succeeds, zero is returned. On error, -1 is returned.


Definition at line 209 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_create#

int32_t sl_iperf_socket_create (sl_iperf_protocol_t protocol)

Create iPerf socket.

Parameters
[in]protocol

Protocol

Create a socket by selected protocol and return with the socket ID Returns

  • int32_t Socket ID


Definition at line 152 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_getsockopt#

int32_t sl_iperf_socket_getsockopt (int32_t sockid, int32_t level, int32_t optname, void * optval, size_t * optlen)

Get socket option.

Parameters
[in]sockid

socket id

[in]level

Not used in Wi-SUN domain.

[in]optname

Option name.

[out]optval

Destination option value pointer

[in]optlen

Must be the size of sl_wisun_socket_option_data_t union

The function gets socket option by optname, and copy option data to optval ptr Returns

  • Return 0 on success, other wise -1


Definition at line 281 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_listen#

int32_t sl_iperf_socket_listen (int32_t sockid, int32_t backlog)

Listen for connections on an iPerf 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

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 Returns

  • On success, zero is returned. On error, -1 is returned


Definition at line 184 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_recv#

int32_t sl_iperf_socket_recv (int32_t sockid, void * buff, size_t len)

Receive a message from a socket.

Parameters
[in]sockid

socket id

[out]buff

destination buffer ptr

[in]len

length of data to read

It should be used for connection-oriented protocol (TCP) Returns

  • return the number of bytes received, or -1 if an error occurred


Definition at line 240 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_recvfrom#

int32_t sl_iperf_socket_recvfrom (int32_t sockid, void * buf, uint32_t len, sl_iperf_socket_addr_t * src_addr)

Receive messages from a socket.

Parameters
[in]sockid

socket id

[out]buf

destination buffer ptr

[in]len

length of data to read

[in]src_addr

Source address

It can be used to receive data on a socket whether or not it is connection-oriented. Returns

  • return the number of bytes received, or -1 if an error occurred


Definition at line 251 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_send#

int32_t sl_iperf_socket_send (int32_t sockid, const void * buff, size_t len)

Send a message on a socket,.

Parameters
[in]sockid

socket id

[in]buff

buffer pointer to send

[in]len

length of buffer to send

It is preferred with connection-oriented sockets (TCP). Returns

  • On success, these calls return the number of bytes sent. On error, -1 is returned


Definition at line 219 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_sendto#

int32_t sl_iperf_socket_sendto (int32_t sockid, const void * buff, uint32_t len, const sl_iperf_socket_addr_t * dest_addr)

Send a message on a socket.

Parameters
[in]sockid

socket id

[in]buff

buffer pointer to send

[in]len

length of buffer to send

[in]dest_addr

destination address ptr, the structure must be prepared for UDP sockets

It is preferred in datagram mode (UDP). Returns

  • On success, these calls return the number of bytes sent. On error, -1 is returned


Definition at line 230 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

sl_iperf_socket_setsockopt#

int32_t sl_iperf_socket_setsockopt (int32_t sockid, int32_t level, int32_t optname, const void * optval, size_t optlen)

Set socket option.

Parameters
[in]sockid

socket id

[in]level

Not used in Wi-SUN domain.

[in]optname

Option name.

[in]optval

Option value structure pointer. For Wi-SUN it is casted to sl_wisun_socket_option_t

[in]optlen

Must be the size of sl_wisun_socket_option_data_t union

This function can set socket properties. There are some limitation in Wi-SUN domain: optlen and level args are not used. optname and optval are casted to the corresponding Wi-SUN types: sl_wisun_socket_option_t and sl_wisun_socket_option_data_t. sl_wisun_socket_option_data_t is a union type to include all of implemented Wi-SUN socket options Returns

  • Return 0 on succes, other wise -1


Definition at line 268 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

Macro Definition Documentation#

sl_iperf_assert_sock_addr_len#

#define sl_iperf_assert_sock_addr_len
Value:
(__type)

Assert socket address length macro function.


Definition at line 123 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

SL_IPERF_IN6ADDR_SIZE#

#define SL_IPERF_IN6ADDR_SIZE
Value:
(16U)

Size definition of IPv6 address.


Definition at line 85 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h

SL_IPERF_NW_API_ERROR#

#define SL_IPERF_NW_API_ERROR
Value:
(-1)

Define network api ERROR value.


Definition at line 127 of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_network_interface.h