WE310F5  39.00.000
m2mb_socket.h File Reference

general Socket support More...

#include <stdint.h>
#include <string.h>
#include "m2mb_types.h"

Go to the source code of this file.

Data Structures

struct  M2MB_SOCKET_BSD_LINGER
 
struct  M2MB_SOCKET_BSD_SOCKADDR
 
struct  M2MB_SOCKET_BSD_IN_ADDR
 
struct  M2MB_SOCKET_BSD_IN6_ADDR
 Structure for storing IPV6. More...
 
struct  M2MB_SOCKET_BSD_IPV6_ADDR
 Structure for storing IPV6. More...
 
struct  M2MB_SOCKET_BSD_SOCKADDR_IN
 
struct  M2MB_SOCKET_BSD_SOCKADDR_IN6
 
struct  M2MB_SOCKET_BSD_HOSTENT
 
struct  M2MB_SOCKET_BSD_TIMEVAL
 
struct  M2MB_SOCKET_BSD_FD_SET
 
struct  M2MB_IP6_ADDR
 IPv6 Internet address. More...
 
struct  M2MB_IP_MREQ
 Argument structure for M2MB_SOCKET_BSD_IP_ADD_MEMBERSHIP and M2MB_SOCKET_BSD_IP_DROP_MEMBERSHIP. More...
 
struct  M2MB_IP46_ADDR
 Socket IPv4/IPv6 Internet address union. More...
 

Macros

#define M2MB_SOCKET_BSD_INVALID_SOCKET   (M2MB_SOCKET_BSD_SOCKET)(~0)
 
#define M2MB_SOCKET_BSD_SOCK_STREAM   1
 
#define M2MB_SOCKET_BSD_SOCK_DGRAM   2
 
#define M2MB_SOCKET_BSD_SOCK_RAW   3
 
#define M2MB_SOCKET_BSD_AF_UNSPEC   0
 
#define M2MB_SOCKET_BSD_AF_INET   2
 
#define M2MB_SOCKET_BSD_AF_INET6   3
 
#define M2MB_SOCKET_BSD_AF_INET_DUAL46   4
 
#define M2MB_SOCKET_BSD_AF_PACKET   5
 
#define M2MB_SOCKET_BSD_PF_UNSPEC   0
 
#define M2MB_SOCKET_BSD_PF_INET   2
 
#define M2MB_SOCKET_BSD_IPPROTO_DFLT   0
 
#define M2MB_SOCKET_BSD_IPPROTO_TCP   6
 
#define M2MB_SOCKET_BSD_IPPROTO_UDP   17
 
#define M2MB_SOCKET_BSD_IPPROTO_ICMP   1
 
#define M2MB_SOCKET_BSD_SOL_SOCKET   (0xfff)
 
#define M2MB_SOCKET_BSD_SO_DEBUG   0x0001
 
#define M2MB_SOCKET_BSD_SO_ACCEPTCONN   0x0002
 
#define M2MB_SOCKET_BSD_SO_REUSEADDR   0x0004
 
#define M2MB_SOCKET_BSD_SO_KEEPALIVE   0x0008
 
#define M2MB_SOCKET_BSD_SO_DONTROUTE   0x0010
 
#define M2MB_SOCKET_BSD_SO_BROADCAST   0x0020
 
#define M2MB_SOCKET_BSD_SO_USELOOPBACK   0x0040
 
#define M2MB_SOCKET_BSD_SO_LINGER   0x0080
 
#define M2MB_SOCKET_BSD_SO_OOBINLINE   0x0100
 
#define M2MB_SOCKET_BSD_SO_DONTLINGER   (INT32)(~M2MB_SOCKET_BSD_SO_LINGER) /* Dont Linger, supported */
 
#define M2MB_SOCKET_BSD_SO_REUSEPORT   0x0200 /* Unimplemented: allow local address & port reuse */
 
#define M2MB_SOCKET_BSD_SO_SNDBUF   0x1001
 
#define M2MB_SOCKET_BSD_SO_RCVBUF   0x1002
 
#define M2MB_SOCKET_BSD_SO_SNDLOWAT   0x1003
 
#define M2MB_SOCKET_BSD_SO_RCVLOWAT   0x1004
 
#define M2MB_SOCKET_BSD_SO_SNDTIMEO   0x1005
 
#define M2MB_SOCKET_BSD_SO_RCVTIMEO   0x1006
 
#define M2MB_SOCKET_BSD_SO_ERROR   0x1007
 
#define M2MB_SOCKET_BSD_SO_TYPE   0x1008
 
#define M2MB_SOCKET_BSD_SO_CONTIMEO   0x1009
 
#define M2MB_SOCKET_BSD_SO_NO_CHECK   0x1010
 
#define M2MB_SOCKET_BSD_SO_BINDTODEVICE   0x100b
 
#define M2MB_SOCKET_BSD_IPPROTO_IP   0
 
#define M2MB_SOCKET_BSD_IP_TOS   1
 
#define M2MB_SOCKET_BSD_IP_TTL   2
 
#define M2MB_SOCKET_BSD_IP_ADD_MEMBERSHIP   3
 
#define M2MB_SOCKET_BSD_IP_DROP_MEMBERSHIP   4
 
#define M2MB_SOCKET_BSD_IP_MULTICAST_TTL   5
 
#define M2MB_SOCKET_BSD_IP_MULTICAST_IF   6
 
#define M2MB_SOCKET_BSD_IP_MULTICAST_LOOP   7
 
#define M2MB_SOCKET_BSD_IP_PKTINFO   8
 
#define M2MB_SOCKET_BSD_IPPROTO_IPV6   41
 
#define M2MB_SOCKET_IPV6_CHECKSUM   7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
 
#define M2MB_SOCKET_IPV6_V6ONLY   27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
 
#define M2MB_SOCKET_BSD_IPV6_JOIN_GROUP   12
 
#define M2MB_SOCKET_BSD_IPV6_LEAVE_GROUP   13
 
#define M2MB_SOCKET_BSD_IPV6_ADD_MEMBERSHIP   M2MB_SOCKET_BSD_IPV6_JOIN_GROUP
 
#define M2MB_SOCKET_BSD_IPV6_DROP_MEMBERSHIP   M2MB_SOCKET_BSD_IPV6_LEAVE_GROUP
 
#define M2MB_SOCKET_BSD_IPPROTO_TCP   6
 
#define M2MB_SOCKET_BSD_TCP_NODELAY   0x01
 
#define M2MB_SOCKET_BSD_TCP_KEEPALIVE   0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
 
#define M2MB_SOCKET_BSD_TCP_KEEPIDLE   0x03 /* Set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
 
#define M2MB_SOCKET_BSD_TCP_KEEPINTVL   0x04 /* Set pcb->keep_intvl - Use seconds for get/setsockopt */
 
#define M2MB_SOCKET_BSD_TCP_KEEPCNT   0x05 /* Set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
 
#define M2MB_SOCKET_BSD_IPPROTO_UDPLITE   136
 
#define M2MB_SOCKET_BSD_UDPLITE_SEND_CSCOV   0x01 /* sender checksum coverage */
 
#define M2MB_SOCKET_BSD_UDPLITE_RECV_CSCOV   0x02 /* minimal receiver checksum coverage */
 
#define M2MB_SOCKET_BSD_SO_TCPSACK   0x00200
 
#define M2MB_SOCKET_BSD_SO_WINSCALE   0x00400
 
#define M2MB_SOCKET_BSD_SO_TIMESTAMP   0x00800
 
#define M2MB_SOCKET_BSD_SO_BIGCWND   0x01000
 
#define M2MB_SOCKET_BSD_SO_HDRINCL   0x02000
 
#define M2MB_SOCKET_BSD_SO_NOSLOWSTART   0x04000
 
#define M2MB_SOCKET_BSD_SO_FULLMSS   0x08000
 
#define M2MB_SOCKET_BSD_SO_HOPCNT   0x1009
 
#define M2MB_SOCKET_BSD_SO_MAXMSG   0x1010
 
#define M2MB_SOCKET_BSD_SO_RXDATA   0x1011
 
#define M2MB_SOCKET_BSD_SO_TXDATA   0x1012
 
#define M2MB_SOCKET_BSD_SO_MYADDR   0x1013
 
#define M2MB_SOCKET_BSD_SO_NBIO   0x1014
 
#define M2MB_SOCKET_BSD_SO_BIO   0x1015
 
#define M2MB_SOCKET_BSD_SO_NONBLOCK   0x1016
 
#define M2MB_SOCKET_BSD_SO_CALLBACK   0x1017
 
#define M2MB_SOCKET_BSD_SO_UDPCALLBACK   0x1019
 
#define M2MB_SOCKET_BSD_IPV6_MULTICAST_IF   80
 
#define M2MB_SOCKET_BSD_IPV6_MULTICAST_HOPS   81
 
#define M2MB_SOCKET_BSD_IPV6_MULTICAST_LOOP   82
 
#define M2MB_SOCKET_BSD_IP_HDRINCL   2
 
#define M2MB_SOCKET_BSD_IP_TTL_OPT   4
 
#define M2MB_SOCKET_BSD_IP_OPTIONS   1
 
#define M2MB_SOCKET_BSD_IPV6_SCOPEID   14
 
#define M2MB_SOCKET_BSD_IPV6_UNICAST_HOPS   15
 
#define M2MB_SOCKET_BSD_IPV6_TCLASS   16
 
#define M2MB_SOCKET_BSD_INADDR_ANY   (UINT32) 0x00000000
 
#define M2MB_SOCKET_BSD_INADDR_LOOPBACK   (UINT32) 0x7f000001
 
#define M2MB_SOCKET_BSD_INADDR_BROADCAST   (UINT32) 0xffffffff
 
#define M2MB_SOCKET_BSD_SHUT_RD   0x00
 
#define M2MB_SOCKET_BSD_SHUT_WR   0x01
 
#define M2MB_SOCKET_BSD_SHUT_RDWR   0x02
 
#define M2MB_SOCKET_BSD_FIONREAD   0
 
#define M2MB_SOCKET_BSD_FIONBIO   1
 
#define M2MB_SOCKET_BSD_SOCKET_ERROR   (-1)
 
#define M2MB_SOCKET_BSD_SOCKNOERROR   0
 
#define M2MB_SOCKET_BSD_ENOBUFS   1
 
#define M2MB_SOCKET_BSD_ETIMEDOUT   2
 
#define M2MB_SOCKET_BSD_EISCONN   3
 
#define M2MB_SOCKET_BSD_EOPNOTSUPP   4
 
#define M2MB_SOCKET_BSD_ECONNABORTED   5
 
#define M2MB_SOCKET_BSD_EWOULDBLOCK   6
 
#define M2MB_SOCKET_BSD_ECONNREFUSED   7
 
#define M2MB_SOCKET_BSD_ECONNRESET   8
 
#define M2MB_SOCKET_BSD_ENOTCONN   9
 
#define M2MB_SOCKET_BSD_EBADF   9
 
#define M2MB_SOCKET_BSD_EALREADY   10
 
#define M2MB_SOCKET_BSD_EINVAL   11
 
#define M2MB_SOCKET_BSD_EMSGSIZE   12
 
#define M2MB_SOCKET_BSD_EPIPE   13
 
#define M2MB_SOCKET_BSD_EDESTADDRREQ   14
 
#define M2MB_SOCKET_BSD_ESHUTDOWN   15
 
#define M2MB_SOCKET_BSD_ENOPROTOOPT   16
 
#define M2MB_SOCKET_BSD_EHAVEOOB   17
 
#define M2MB_SOCKET_BSD_ENOMEM   18
 
#define M2MB_SOCKET_BSD_EADDRNOTAVAIL   19
 
#define M2MB_SOCKET_BSD_EADDRINUSE   20
 
#define M2MB_SOCKET_BSD_EAFNOSUPPORT   21
 
#define M2MB_SOCKET_BSD_EINPROGRESS   22
 
#define M2MB_SOCKET_BSD_ELOWER   23
 
#define M2MB_SOCKET_BSD_ENOTSOCK   24
 
#define M2MB_SOCKET_BSD_EIEIO   27
 
#define M2MB_SOCKET_BSD_ETOOMANYREFS   28
 
#define M2MB_SOCKET_BSD_EFAULT   29
 
#define M2MB_SOCKET_BSD_ENETUNREACH   30
 
#define M2MB_SOCKET_HOST_NOT_FOUND   210
 
#define M2MB_SOCKET_NO_DATA   211
 
#define M2MB_SOCKET_NO_RECOVERY   212
 
#define M2MB_SOCKET_TRY_AGAIN   213
 
#define M2MB_SOCKET_ERANGE   214
 
#define addr8_s   v6_v.addr8
 
#define addr16_s   v6_v.addr16
 
#define addr32_s   v6_v.addr32
 
#define Addr4   a.addr4
 
#define Addr6   a.addr6
 
Flags for recv() and send()
#define M2MB_SOCKET_MSG_OOB   0x04
 
#define M2MB_SOCKET_MSG_PEEK   0x01
 
#define M2MB_SOCKET_MSG_DONTROUTE   0x14
 
#define M2MB_SOCKET_MSG_DONTWAIT   0x08
 
#define M2MB_SOCKET_MSG_ZEROCOPYSEND   0x1000
 
#define M2MB_SOCKET_BSD_FD_SETSIZE   32
 

max number of sockets supported.

#define M2MB_SOCKET_MAX_SUPPORTED   16
 
#define MAKEIP(a, b, c, d)   ((ULONG)d<<24 | (ULONG)c << 16 | (ULONG)b << 8 | (ULONG)a )
 making an IP in the integer format. More...
 
#define m2mb_socket_bsd_htonl(l)
 Conversion between host and network byte order. More...
 
#define m2mb_socket_bsd_ntohl(l)   m2mb_socket_bsd_htonl(l)
 Conversion between host and network byte order. More...
 
#define m2mb_socket_bsd_htons(s)   ((((s) >> 8) & 0xff) | (((s) << 8) & 0xff00))
 Conversion between host and network byte order. More...
 
#define m2mb_socket_bsd_ntohs(s)   m2mb_socket_bsd_htons(s)
 Conversion between host and network byte order. More...
 
typedef iHANDLE M2MB_SOCKET_BSD_SOCKET
 
typedef struct M2MB_SOCKET_BSD_LINGER M2MB_SOCKET_BSD_LINGER_T
 
typedef struct M2MB_SOCKET_BSD_SOCKADDR M2MB_SOCKET_BSD_SOCKADDR_T
 
typedef struct M2MB_SOCKET_BSD_IN_ADDR M2MB_SOCKET_BSD_IN_ADDR_T
 
typedef struct M2MB_SOCKET_BSD_IN6_ADDR M2MB_SOCKET_BSD_IN6_ADDR_T
 Structure for storing IPV6. More...
 
typedef struct M2MB_SOCKET_BSD_IPV6_ADDR M2MB_SOCKET_BSD_IPV6_ADDR_T
 Structure for storing IPV6. More...
 
typedef struct M2MB_SOCKET_BSD_SOCKADDR_IN M2MB_SOCKET_BSD_SOCKADDR_IN_T
 
typedef struct M2MB_SOCKET_BSD_SOCKADDR_IN6 M2MB_SOCKET_BSD_SOCKADDR_IN6_T
 
typedef struct M2MB_SOCKET_BSD_HOSTENT M2MB_SOCKET_BSD_HOSTENT_T
 
typedef struct M2MB_SOCKET_BSD_TIMEVAL M2MB_SOCKET_BSD_TIMEVAL_T
 
typedef struct M2MB_SOCKET_BSD_FD_SET M2MB_SOCKET_BSD_FD_SET_T
 
typedef struct M2MB_IP6_ADDR M2MB_IP6_ADDR_T
 IPv6 Internet address. More...
 
typedef unsigned long M2MB_IP4_ADDR_T
 IPv4 Internet address. More...
 
typedef struct M2MB_IP_MREQ M2MB_IP_MREQ_T
 Argument structure for M2MB_SOCKET_BSD_IP_ADD_MEMBERSHIP and M2MB_SOCKET_BSD_IP_DROP_MEMBERSHIP. More...
 
typedef struct M2MB_IP46_ADDR M2MB_IP46_ADDR_T
 Socket IPv4/IPv6 Internet address union. More...
 
typedef INT32(* M2MB_NET_TCP_ZEROCOPY_CB) (void *so, void *packet, INT32 errcode)
 TCP zero-copy application RX callback handler. More...
 
typedef INT32(* M2MB_NET_UDP_ZEROCOPY_CB) (void *so, void *packet, INT32 errcode, void *from, INT32 family)
 UDP zero-copy application RX callback handler. More...
 
VOID M2MB_IPv6_CHANGE_ENDIAN (UINT32 *a)
 Conversion between host and network byte order. More...
 
M2MB_SOCKET_BSD_SOCKET m2mb_socket_bsd_socket (INT32 domain, INT32 type, INT32 protocol)
 Create an endpoint for communication. More...
 
INT32 m2mb_socket_bsd_bind (M2MB_SOCKET_BSD_SOCKET s, struct M2MB_SOCKET_BSD_SOCKADDR *name, INT32 namelen)
 Bind the address with the socket. More...
 
INT32 m2mb_socket_bsd_connect (M2MB_SOCKET_BSD_SOCKET s, const struct M2MB_SOCKET_BSD_SOCKADDR *name, INT32 namelen)
 connect a socket More...
 
INT32 m2mb_socket_bsd_listen (M2MB_SOCKET_BSD_SOCKET s, INT32 backlog)
 Listen for connections on a socket. More...
 
M2MB_SOCKET_BSD_SOCKET m2mb_socket_bsd_accept (M2MB_SOCKET_BSD_SOCKET s, struct M2MB_SOCKET_BSD_SOCKADDR *name, INT32 *namelen)
 Accept a connection on a socket. More...
 
INT32 m2mb_socket_bsd_close (M2MB_SOCKET_BSD_SOCKET s)
 Close a socket. More...
 
INT32 m2mb_socket_bsd_get_peer_name (M2MB_SOCKET_BSD_SOCKET s, struct M2MB_SOCKET_BSD_SOCKADDR *name, INT32 *namelen)
 Get the name of the peer socket. More...
 
INT32 m2mb_socket_bsd_get_sock_name (M2MB_SOCKET_BSD_SOCKET s, struct M2MB_SOCKET_BSD_SOCKADDR *name, INT32 *namelen)
 Get socket name. More...
 
INT32 m2mb_socket_bsd_recv (M2MB_SOCKET_BSD_SOCKET s, void *buf, INT32 len, INT32 flags)
 Receive a message from a socket. More...
 
INT32 m2mb_socket_bsd_recv_from (M2MB_SOCKET_BSD_SOCKET s, void *buf, INT32 len, INT32 flags, M2MB_SOCKET_BSD_SOCKADDR_T *from, INT32 *fromlen)
 Receive a message from a socket. More...
 
INT32 m2mb_socket_bsd_send (M2MB_SOCKET_BSD_SOCKET s, const void *buf, INT32 len, INT32 flags)
 Send a message on a socket. More...
 
INT32 m2mb_socket_bsd_send_to (M2MB_SOCKET_BSD_SOCKET s, const void *buf, INT32 len, INT32 flags, const struct M2MB_SOCKET_BSD_SOCKADDR *to, INT32 tolen)
 send a message on a socket More...
 
INT32 m2mb_socket_bsd_get_sock_opt (M2MB_SOCKET_BSD_SOCKET s, INT32 level, INT32 optname, void *optval, INT32 *optlen)
 Get options from sockets. More...
 
INT32 m2mb_socket_bsd_set_sock_opt (M2MB_SOCKET_BSD_SOCKET s, INT32 level, INT32 optname, const void *optval, INT32 optlen)
 Set options on sockets. More...
 
INT32 m2mb_socket_bsd_ioctl (M2MB_SOCKET_BSD_SOCKET s, INT32 cmd, void *argp)
 IO control function. More...
 
INT32 m2mb_socket_bsd_select (INT32 nfds, M2MB_SOCKET_BSD_FD_SET_T *readfds, M2MB_SOCKET_BSD_FD_SET_T *writefds, M2MB_SOCKET_BSD_FD_SET_T *exceptfds, const struct M2MB_SOCKET_BSD_TIMEVAL *timeout)
 synchronous I/O multiplexing More...
 
INT32 m2mb_socket_bsd_fd_zero_func (M2MB_SOCKET_BSD_FD_SET_T *set)
 Used for m2mb_socket_bsd_select() More...
 
INT32 m2mb_socket_bsd_fd_set_func (INT32 fd, M2MB_SOCKET_BSD_FD_SET_T *set)
 Used for m2mb_socket_bsd_select() More...
 
INT32 m2mb_socket_bsd_fd_clr_func (INT32 fd, M2MB_SOCKET_BSD_FD_SET_T *set)
 Used for m2mb_socket_bsd_select() More...
 
INT32 m2mb_socket_bsd_fd_isset_func (INT32 fd, M2MB_SOCKET_BSD_FD_SET_T *set)
 Used for m2mb_socket_bsd_select() More...
 
INT32 m2mb_socket_errno (INT32 fd)
 Gets the last error occurred. More...
 
CHARm2mb_socket_bsd_inet_ntop (INT32 af, const void *src, CHAR *dst, INT32 size)
 Converts IPv4 and IPv6 addresses from binary to text form. More...
 
INT32 m2mb_socket_bsd_inet_pton (INT32 af, const CHAR *src, void *dst)
 Converts IPv4 and IPv6 addresses from text to binary form. More...
 
INT32 m2mb_socket_bsd_get_host_by_name_2_r_cid (const CHAR *name, INT32 af, struct M2MB_SOCKET_BSD_HOSTENT *ret, CHAR *buf, INT32 buflen, struct M2MB_SOCKET_BSD_HOSTENT **result, INT32 *h_errnop, UINT8 cid)
 Get network host entry. More...
 
INT32 m2mb_socket_set_cid (M2MB_SOCKET_BSD_SOCKET s, UINT8 cid)
 Link a socket to a CID. More...
 
INT32 m2mb_socket_TCP_Keepalive_Set (INT32 idle_Time, INT32 resp_Timeout)
 Set TCP Keepalive parameters. More...
 
INT32 m2mb_socket_TCP_Keepalive_Get (INT32 *idle_Time, INT32 *resp_Timeout)
 Get TCP Keepalive parameters. More...
 

Detailed Description

general Socket support

we866e4/epl/inc/nwk/m2mb_socket.h

socket APIs from BSD and Linux

Note
Dependencies:
"#include <m2mb_types.h>"
"#include <m2mb_netutils.h>"
"#include <m2mb_socket.h>"
"#include <m2mb_trace.h>"
Author
Tejashwini Hiremath
Date
20/02/2017

Definition in file m2mb_socket.h.

Macro Definition Documentation

◆ addr16_s

#define addr16_s   v6_v.addr16

Definition at line 306 of file m2mb_socket.h.

◆ addr32_s

#define addr32_s   v6_v.addr32

Definition at line 307 of file m2mb_socket.h.

◆ Addr4

#define Addr4   a.addr4

Definition at line 399 of file m2mb_socket.h.

◆ Addr6

#define Addr6   a.addr6

Definition at line 400 of file m2mb_socket.h.

◆ addr8_s

#define addr8_s   v6_v.addr8

Definition at line 305 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_AF_INET

#define M2MB_SOCKET_BSD_AF_INET   2

Address Family IPv4

Definition at line 55 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_AF_INET6

#define M2MB_SOCKET_BSD_AF_INET6   3

Address Family IPv6

Definition at line 56 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_AF_INET_DUAL46

#define M2MB_SOCKET_BSD_AF_INET_DUAL46   4

Address Family IPv4 and IPv6

Definition at line 57 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_AF_PACKET

#define M2MB_SOCKET_BSD_AF_PACKET   5

Address family is packet.

Definition at line 58 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_AF_UNSPEC

#define M2MB_SOCKET_BSD_AF_UNSPEC   0

M2M Socket Address Families Unspecified Address Family

Definition at line 54 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EADDRINUSE

#define M2MB_SOCKET_BSD_EADDRINUSE   20

Address is already in use.

Definition at line 221 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EADDRNOTAVAIL

#define M2MB_SOCKET_BSD_EADDRNOTAVAIL   19

Cannot assign the requested address.

Definition at line 220 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EAFNOSUPPORT

#define M2MB_SOCKET_BSD_EAFNOSUPPORT   21

Address family is not supported by the protocol family.

Definition at line 222 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EALREADY

#define M2MB_SOCKET_BSD_EALREADY   10

Operation is already in progress.

Definition at line 211 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EBADF

#define M2MB_SOCKET_BSD_EBADF   9

An invalid descriptor was specified.

Definition at line 210 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ECONNABORTED

#define M2MB_SOCKET_BSD_ECONNABORTED   5

Software caused a connection abort.

Definition at line 205 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ECONNREFUSED

#define M2MB_SOCKET_BSD_ECONNREFUSED   7

Connection was refused.

Definition at line 207 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ECONNRESET

#define M2MB_SOCKET_BSD_ECONNRESET   8

Connection was reset by a peer.

Definition at line 208 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EDESTADDRREQ

#define M2MB_SOCKET_BSD_EDESTADDRREQ   14

Destination address is required.

Definition at line 215 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EFAULT

#define M2MB_SOCKET_BSD_EFAULT   29

Bad address.

Definition at line 228 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EHAVEOOB

#define M2MB_SOCKET_BSD_EHAVEOOB   17

Out of band.

Definition at line 218 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EIEIO

#define M2MB_SOCKET_BSD_EIEIO   27

I/O error.

Definition at line 226 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EINPROGRESS

#define M2MB_SOCKET_BSD_EINPROGRESS   22

Operation is now in progress.

Definition at line 223 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EINVAL

#define M2MB_SOCKET_BSD_EINVAL   11

Invalid argument was passed.

Definition at line 212 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EISCONN

#define M2MB_SOCKET_BSD_EISCONN   3

Socket is already connected.

Definition at line 203 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ELOWER

#define M2MB_SOCKET_BSD_ELOWER   23

Lower layer (IP) error.

Definition at line 224 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EMSGSIZE

#define M2MB_SOCKET_BSD_EMSGSIZE   12

Message is too long.

Definition at line 213 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ENETUNREACH

#define M2MB_SOCKET_BSD_ENETUNREACH   30

Network is unreachable.

Definition at line 229 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ENOBUFS

#define M2MB_SOCKET_BSD_ENOBUFS   1

No buffer space is available.

Definition at line 201 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ENOMEM

#define M2MB_SOCKET_BSD_ENOMEM   18

No memory is available.

Definition at line 219 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ENOPROTOOPT

#define M2MB_SOCKET_BSD_ENOPROTOOPT   16

Protocol is not available.

Definition at line 217 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ENOTCONN

#define M2MB_SOCKET_BSD_ENOTCONN   9

Socket is not connected.

Definition at line 209 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ENOTSOCK

#define M2MB_SOCKET_BSD_ENOTSOCK   24

Socket operation is on a nonsocket.

Definition at line 225 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EOPNOTSUPP

#define M2MB_SOCKET_BSD_EOPNOTSUPP   4

Operation is not supported.

Definition at line 204 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EPIPE

#define M2MB_SOCKET_BSD_EPIPE   13

Local end has been shut down on a connection-oriented socket.

Definition at line 214 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ESHUTDOWN

#define M2MB_SOCKET_BSD_ESHUTDOWN   15

Cannot send after a socket shutdown.

Definition at line 216 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ETIMEDOUT

#define M2MB_SOCKET_BSD_ETIMEDOUT   2

Operation timed out.

Definition at line 202 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_ETOOMANYREFS

#define M2MB_SOCKET_BSD_ETOOMANYREFS   28

Too many references.

Definition at line 227 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_EWOULDBLOCK

#define M2MB_SOCKET_BSD_EWOULDBLOCK   6

The socket is marked nonblocking and the requested operation would block.

Definition at line 206 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_FD_SETSIZE

#define M2MB_SOCKET_BSD_FD_SETSIZE   32

FD set size used by M2MB_SOCKET_bsd_select().

Definition at line 252 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_FIONBIO

#define M2MB_SOCKET_BSD_FIONBIO   1

command to select the blocking or non-blocking mode

Definition at line 192 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_FIONREAD

#define M2MB_SOCKET_BSD_FIONREAD   0

M2MB Socket I/O control options for m2mb_socket_bsd_ioctl() command to get the number of bytes to read

Definition at line 191 of file m2mb_socket.h.

◆ m2mb_socket_bsd_htonl

#define m2mb_socket_bsd_htonl (   l)
Value:
(((((l) >> 24) & 0x000000ff)) | \
((((l) >> 8) & 0x0000ff00)) | \
(((l) & 0x0000ff00) << 8) | \
(((l) & 0x000000ff) << 24))

Conversion between host and network byte order.

Converts the unsigned integer x from host byte order to network byte order.

Parameters
[in]lUnsigned integer to be converted
Returns
Result of the conversion
Note
<Notes>

Example

<C code example>

Definition at line 460 of file m2mb_socket.h.

◆ m2mb_socket_bsd_htons

#define m2mb_socket_bsd_htons (   s)    ((((s) >> 8) & 0xff) | (((s) << 8) & 0xff00))

Conversion between host and network byte order.

Converts the unsigned short integer x from host byte order to network byte order

Parameters
[in]sUnsigned short integer to be converted
Returns
Result of the conversion
Note
<Notes>

Example

<C code example>

Definition at line 512 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_INADDR_ANY

#define M2MB_SOCKET_BSD_INADDR_ANY   (UINT32) 0x00000000

END of M2M Socket Option Flags

M2M Internet address. Any internet address.

Definition at line 174 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_INADDR_BROADCAST

#define M2MB_SOCKET_BSD_INADDR_BROADCAST   (UINT32) 0xffffffff

Broadcast internet address.

Definition at line 178 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_INADDR_LOOPBACK

#define M2MB_SOCKET_BSD_INADDR_LOOPBACK   (UINT32) 0x7f000001

Loopback internet address.

Definition at line 176 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_ADD_MEMBERSHIP

#define M2MB_SOCKET_BSD_IP_ADD_MEMBERSHIP   3

Add an IPv4 group membership.

Definition at line 101 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_DROP_MEMBERSHIP

#define M2MB_SOCKET_BSD_IP_DROP_MEMBERSHIP   4

Drop an IPv4 group membership.

Definition at line 102 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_HDRINCL

#define M2MB_SOCKET_BSD_IP_HDRINCL   2

IP header is included with the data.

Definition at line 160 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_MULTICAST_IF

#define M2MB_SOCKET_BSD_IP_MULTICAST_IF   6

Interface multicast datagrams should be sent from

Definition at line 107 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_MULTICAST_LOOP

#define M2MB_SOCKET_BSD_IP_MULTICAST_LOOP   7

Enable/disable loopback for multicast.

Definition at line 108 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_MULTICAST_TTL

#define M2MB_SOCKET_BSD_IP_MULTICAST_TTL   5

The TTL for subsequent multicast datagrams to be set to any value from 0 to 255

Definition at line 106 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_OPTIONS

#define M2MB_SOCKET_BSD_IP_OPTIONS   1

For use with [gs]etsockopt() at IP_OPTIONS 'level'.

Definition at line 163 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_PKTINFO

#define M2MB_SOCKET_BSD_IP_PKTINFO   8

Allows an application to enable or disable the return of packet information on an IPv4 socket

Definition at line 109 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_TOS

#define M2MB_SOCKET_BSD_IP_TOS   1

IPv4 type of service and precedence.

Definition at line 99 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_TTL

#define M2MB_SOCKET_BSD_IP_TTL   2

Changes the default value set by the TCP/IP service provider in the TTL field of the IP header in outgoing datagrams

Definition at line 100 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IP_TTL_OPT

#define M2MB_SOCKET_BSD_IP_TTL_OPT   4

IPv4 time to live.

Definition at line 161 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPPROTO_DFLT

#define M2MB_SOCKET_BSD_IPPROTO_DFLT   0

M2M Socket Protocols Default protocol

Definition at line 65 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPPROTO_ICMP

#define M2MB_SOCKET_BSD_IPPROTO_ICMP   1

Internet Control Message Protocol

Definition at line 68 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPPROTO_IP

#define M2MB_SOCKET_BSD_IPPROTO_IP   0

For use with [gs]etsockopt() at IPPROTO_IP 'level'.

Definition at line 98 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPPROTO_IPV6

#define M2MB_SOCKET_BSD_IPPROTO_IPV6   41

Option level for IPv6

Definition at line 111 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPPROTO_TCP [1/2]

#define M2MB_SOCKET_BSD_IPPROTO_TCP   6

Transmission Control Protocol

IPPROTO_TCP option level

Definition at line 122 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPPROTO_TCP [2/2]

#define M2MB_SOCKET_BSD_IPPROTO_TCP   6

Transmission Control Protocol

IPPROTO_TCP option level

Definition at line 122 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPPROTO_UDP

#define M2MB_SOCKET_BSD_IPPROTO_UDP   17

User Datagram Protocol

Definition at line 67 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPPROTO_UDPLITE

#define M2MB_SOCKET_BSD_IPPROTO_UDPLITE   136

IPPROTO_UDPLITE option level

Definition at line 129 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_ADD_MEMBERSHIP

#define M2MB_SOCKET_BSD_IPV6_ADD_MEMBERSHIP   M2MB_SOCKET_BSD_IPV6_JOIN_GROUP

Add an IPv6 group membership.

Definition at line 119 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_DROP_MEMBERSHIP

#define M2MB_SOCKET_BSD_IPV6_DROP_MEMBERSHIP   M2MB_SOCKET_BSD_IPV6_LEAVE_GROUP

Drop an IPv6 group membership.

Definition at line 120 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_JOIN_GROUP

#define M2MB_SOCKET_BSD_IPV6_JOIN_GROUP   12

Join an IPv6 MC group.

Definition at line 117 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_LEAVE_GROUP

#define M2MB_SOCKET_BSD_IPV6_LEAVE_GROUP   13

Leave an IPv6 MC group.

Definition at line 118 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_MULTICAST_HOPS

#define M2MB_SOCKET_BSD_IPV6_MULTICAST_HOPS   81

Set the number of hops.

Definition at line 157 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_MULTICAST_IF

#define M2MB_SOCKET_BSD_IPV6_MULTICAST_IF   80

Set the egress interface for multicast traffic.

Definition at line 156 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_MULTICAST_LOOP

#define M2MB_SOCKET_BSD_IPV6_MULTICAST_LOOP   82

Enable/disable loopback for multicast.

Definition at line 158 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_SCOPEID

#define M2MB_SOCKET_BSD_IPV6_SCOPEID   14

IPv6 IF scope ID.

Definition at line 164 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_TCLASS

#define M2MB_SOCKET_BSD_IPV6_TCLASS   16

IPv6 traffic class.

Definition at line 166 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_IPV6_UNICAST_HOPS

#define M2MB_SOCKET_BSD_IPV6_UNICAST_HOPS   15

IPv6 hop limit.

Definition at line 165 of file m2mb_socket.h.

◆ m2mb_socket_bsd_ntohl

#define m2mb_socket_bsd_ntohl (   l)    m2mb_socket_bsd_htonl(l)

Conversion between host and network byte order.

Converts the unsigned integer x from network byte order to host byte order.

Parameters
[in]lUnsigned integer to be converted
Returns
Result of the conversion
Note
<Notes>

Example

<C code example>

Definition at line 487 of file m2mb_socket.h.

◆ m2mb_socket_bsd_ntohs

#define m2mb_socket_bsd_ntohs (   s)    m2mb_socket_bsd_htons(s)

Conversion between host and network byte order.

Converts the unsigned short integer x from network byte order to host byte order

Parameters
[in]sUnsigned short integer to be converted
Returns
Result of the conversion
Note
<Notes>

Example

<C code example>

Definition at line 537 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_PF_INET

#define M2MB_SOCKET_BSD_PF_INET   2

Internetwork: UDP, TCP, etc.

Definition at line 62 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_PF_UNSPEC

#define M2MB_SOCKET_BSD_PF_UNSPEC   0

M2M Socket Protocol Families Unspecified Protocol Family

Definition at line 61 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SHUT_RD

#define M2MB_SOCKET_BSD_SHUT_RD   0x00

M2M Socket constants for m2mb_socket_bsd_shutdown() Read socket

Definition at line 184 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SHUT_RDWR

#define M2MB_SOCKET_BSD_SHUT_RDWR   0x02

Read Write socket

Definition at line 186 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SHUT_WR

#define M2MB_SOCKET_BSD_SHUT_WR   0x01

Write socket

Definition at line 185 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_ACCEPTCONN

#define M2MB_SOCKET_BSD_SO_ACCEPTCONN   0x0002

Socket has had listen(), supported

Definition at line 76 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_BIGCWND

#define M2MB_SOCKET_BSD_SO_BIGCWND   0x01000

Large initial TCP congenstion window.

Definition at line 140 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_BINDTODEVICE

#define M2MB_SOCKET_BSD_SO_BINDTODEVICE   0x100b

bind to device interface

Definition at line 96 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_BIO

#define M2MB_SOCKET_BSD_SO_BIO   0x1015

Set socket to Blocking mode.

Definition at line 151 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_BROADCAST

#define M2MB_SOCKET_BSD_SO_BROADCAST   0x0020

Permit sending of broadcast msgs, supported

Definition at line 80 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_CALLBACK

#define M2MB_SOCKET_BSD_SO_CALLBACK   0x1017

Set/get the TCP zero_copy callback routine.

Definition at line 153 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_CONTIMEO

#define M2MB_SOCKET_BSD_SO_CONTIMEO   0x1009

connect timeout, Not supported

Definition at line 94 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_DEBUG

#define M2MB_SOCKET_BSD_SO_DEBUG   0x0001

M2M Socket Option Flags Turn on debugging info recording, Not supported

Definition at line 75 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_DONTLINGER

#define M2MB_SOCKET_BSD_SO_DONTLINGER   (INT32)(~M2MB_SOCKET_BSD_SO_LINGER) /* Dont Linger, supported */

Definition at line 84 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_DONTROUTE

#define M2MB_SOCKET_BSD_SO_DONTROUTE   0x0010

Just use interface addresses, Not supported

Definition at line 79 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_ERROR

#define M2MB_SOCKET_BSD_SO_ERROR   0x1007

Get error status and clear

Definition at line 92 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_FULLMSS

#define M2MB_SOCKET_BSD_SO_FULLMSS   0x08000

Not used.

Definition at line 143 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_HDRINCL

#define M2MB_SOCKET_BSD_SO_HDRINCL   0x02000

User access to the IP header for SOCK_RAW.

Definition at line 141 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_HOPCNT

#define M2MB_SOCKET_BSD_SO_HOPCNT   0x1009

Not used.

Definition at line 145 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_KEEPALIVE

#define M2MB_SOCKET_BSD_SO_KEEPALIVE   0x0008

Keep connections alive, not enabled by default

Definition at line 78 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_LINGER

#define M2MB_SOCKET_BSD_SO_LINGER   0x0080

Linger on close if data present, supported

Definition at line 82 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_MAXMSG

#define M2MB_SOCKET_BSD_SO_MAXMSG   0x1010

TCP max segment size (MSS).

Definition at line 146 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_MYADDR

#define M2MB_SOCKET_BSD_SO_MYADDR   0x1013

Return my IP address.

Definition at line 149 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_NBIO

#define M2MB_SOCKET_BSD_SO_NBIO   0x1014

Set socket to Nonblocking mode.

Definition at line 150 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_NO_CHECK

#define M2MB_SOCKET_BSD_SO_NO_CHECK   0x1010

don't create UDP checksum

Definition at line 95 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_NONBLOCK

#define M2MB_SOCKET_BSD_SO_NONBLOCK   0x1016

Set/get the blocking mode via the optval parameter.

Definition at line 152 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_NOSLOWSTART

#define M2MB_SOCKET_BSD_SO_NOSLOWSTART   0x04000

Suppress slow start on this socket.

Definition at line 142 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_OOBINLINE

#define M2MB_SOCKET_BSD_SO_OOBINLINE   0x0100

Leave received OOB data in line, Not supported

Definition at line 83 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_RCVBUF

#define M2MB_SOCKET_BSD_SO_RCVBUF   0x1002

Receive buffer size, supported

Definition at line 87 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_RCVLOWAT

#define M2MB_SOCKET_BSD_SO_RCVLOWAT   0x1004

Receive low-water mark, Not supported

Definition at line 89 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_RCVTIMEO

#define M2MB_SOCKET_BSD_SO_RCVTIMEO   0x1006

Receive timeout, supported

Definition at line 91 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_REUSEADDR

#define M2MB_SOCKET_BSD_SO_REUSEADDR   0x0004

Allow local address reuse, always set

Definition at line 77 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_REUSEPORT

#define M2MB_SOCKET_BSD_SO_REUSEPORT   0x0200 /* Unimplemented: allow local address & port reuse */

Definition at line 85 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_RXDATA

#define M2MB_SOCKET_BSD_SO_RXDATA   0x1011

Receive buffer size, supported

Definition at line 147 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_SNDBUF

#define M2MB_SOCKET_BSD_SO_SNDBUF   0x1001

Send buffer size, Not supported

Definition at line 86 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_SNDLOWAT

#define M2MB_SOCKET_BSD_SO_SNDLOWAT   0x1003

Send low-water mark, Not supported

Definition at line 88 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_SNDTIMEO

#define M2MB_SOCKET_BSD_SO_SNDTIMEO   0x1005

Send timeout, supported

Definition at line 90 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_TCPSACK

#define M2MB_SOCKET_BSD_SO_TCPSACK   0x00200

Allow TCP SACK (selective acknowledgment).

Definition at line 137 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_TIMESTAMP

#define M2MB_SOCKET_BSD_SO_TIMESTAMP   0x00800

Set the TCP timestamp option.

Definition at line 139 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_TXDATA

#define M2MB_SOCKET_BSD_SO_TXDATA   0x1012

Send buffer size, supported

Definition at line 148 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_TYPE

#define M2MB_SOCKET_BSD_SO_TYPE   0x1008

Get socket type, supported

Definition at line 93 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_UDPCALLBACK

#define M2MB_SOCKET_BSD_SO_UDPCALLBACK   0x1019

Set/get the UDP zero_copy callback routine. Not supported

Definition at line 154 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_USELOOPBACK

#define M2MB_SOCKET_BSD_SO_USELOOPBACK   0x0040

Permit sending of broadcast msgs, Not supported

Definition at line 81 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SO_WINSCALE

#define M2MB_SOCKET_BSD_SO_WINSCALE   0x00400

Set the scaling window option.

Definition at line 138 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SOCK_DGRAM

#define M2MB_SOCKET_BSD_SOCK_DGRAM   2

Datagram socket type used for UDP

Definition at line 50 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SOCK_RAW

#define M2MB_SOCKET_BSD_SOCK_RAW   3

Raw socket type

Definition at line 51 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SOCK_STREAM

#define M2MB_SOCKET_BSD_SOCK_STREAM   1

M2M Socket Types Stream socket type used for TCP

Definition at line 49 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SOCKET_ERROR

#define M2MB_SOCKET_BSD_SOCKET_ERROR   (-1)

M2MB Socket Error Types
Errors can be retrieved via the m2mb_socket_errno()

Definition at line 199 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SOCKNOERROR

#define M2MB_SOCKET_BSD_SOCKNOERROR   0

Definition at line 200 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_SOL_SOCKET

#define M2MB_SOCKET_BSD_SOL_SOCKET   (0xfff)

Level number for m2mb_socket_bsd_get_sock_opt() and m2mb_socket_bsd_set_sock_opt() to apply to socket itself. options for socket level

Definition at line 73 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_TCP_KEEPALIVE

#define M2MB_SOCKET_BSD_TCP_KEEPALIVE   0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */

Definition at line 124 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_TCP_KEEPCNT

#define M2MB_SOCKET_BSD_TCP_KEEPCNT   0x05 /* Set pcb->keep_cnt - Use number of probes sent for get/setsockopt */

Definition at line 127 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_TCP_KEEPIDLE

#define M2MB_SOCKET_BSD_TCP_KEEPIDLE   0x03 /* Set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */

Definition at line 125 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_TCP_KEEPINTVL

#define M2MB_SOCKET_BSD_TCP_KEEPINTVL   0x04 /* Set pcb->keep_intvl - Use seconds for get/setsockopt */

Definition at line 126 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_TCP_NODELAY

#define M2MB_SOCKET_BSD_TCP_NODELAY   0x01

Don't delay send to coalesce packets, supported

Definition at line 123 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_UDPLITE_RECV_CSCOV

#define M2MB_SOCKET_BSD_UDPLITE_RECV_CSCOV   0x02 /* minimal receiver checksum coverage */

Definition at line 134 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_UDPLITE_SEND_CSCOV

#define M2MB_SOCKET_BSD_UDPLITE_SEND_CSCOV   0x01 /* sender checksum coverage */

Definition at line 133 of file m2mb_socket.h.

◆ M2MB_SOCKET_ERANGE

#define M2MB_SOCKET_ERANGE   214

Definition at line 239 of file m2mb_socket.h.

◆ M2MB_SOCKET_HOST_NOT_FOUND

#define M2MB_SOCKET_HOST_NOT_FOUND   210

Errors used by the DNS API functions, h_errno can be one of them

Definition at line 235 of file m2mb_socket.h.

◆ M2MB_SOCKET_IPV6_CHECKSUM

#define M2MB_SOCKET_IPV6_CHECKSUM   7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */

Definition at line 115 of file m2mb_socket.h.

◆ M2MB_SOCKET_IPV6_V6ONLY

#define M2MB_SOCKET_IPV6_V6ONLY   27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */

Definition at line 116 of file m2mb_socket.h.

◆ M2MB_SOCKET_MAX_SUPPORTED

#define M2MB_SOCKET_MAX_SUPPORTED   16

Definition at line 258 of file m2mb_socket.h.

◆ M2MB_SOCKET_MSG_DONTROUTE

#define M2MB_SOCKET_MSG_DONTROUTE   0x14

Send without using routing tables.

Definition at line 247 of file m2mb_socket.h.

◆ M2MB_SOCKET_MSG_DONTWAIT

#define M2MB_SOCKET_MSG_DONTWAIT   0x08

Send/receive is nonblocking.

Definition at line 248 of file m2mb_socket.h.

◆ M2MB_SOCKET_MSG_OOB

#define M2MB_SOCKET_MSG_OOB   0x04

Send/receive out-of-band data.

Definition at line 245 of file m2mb_socket.h.

◆ M2MB_SOCKET_MSG_PEEK

#define M2MB_SOCKET_MSG_PEEK   0x01

Peek at an incoming message.

Definition at line 246 of file m2mb_socket.h.

◆ M2MB_SOCKET_MSG_ZEROCOPYSEND

#define M2MB_SOCKET_MSG_ZEROCOPYSEND   0x1000

Send with zero-copy.

Definition at line 249 of file m2mb_socket.h.

◆ M2MB_SOCKET_NO_DATA

#define M2MB_SOCKET_NO_DATA   211

Definition at line 236 of file m2mb_socket.h.

◆ M2MB_SOCKET_NO_RECOVERY

#define M2MB_SOCKET_NO_RECOVERY   212

Definition at line 237 of file m2mb_socket.h.

◆ M2MB_SOCKET_TRY_AGAIN

#define M2MB_SOCKET_TRY_AGAIN   213

Definition at line 238 of file m2mb_socket.h.

◆ MAKEIP

#define MAKEIP (   a,
  b,
  c,
 
)    ((ULONG)d<<24 | (ULONG)c << 16 | (ULONG)b << 8 | (ULONG)a )

making an IP in the integer format.

Definition at line 263 of file m2mb_socket.h.

Typedef Documentation

◆ M2MB_IP46_ADDR_T

Socket IPv4/IPv6 Internet address union.

◆ M2MB_IP4_ADDR_T

typedef unsigned long M2MB_IP4_ADDR_T

IPv4 Internet address.

Definition at line 371 of file m2mb_socket.h.

◆ M2MB_IP6_ADDR_T

IPv6 Internet address.

◆ M2MB_IP_MREQ_T

typedef struct M2MB_IP_MREQ M2MB_IP_MREQ_T

Argument structure for M2MB_SOCKET_BSD_IP_ADD_MEMBERSHIP and M2MB_SOCKET_BSD_IP_DROP_MEMBERSHIP.

◆ M2MB_NET_TCP_ZEROCOPY_CB

typedef INT32(* M2MB_NET_TCP_ZEROCOPY_CB) (void *so, void *packet, INT32 errcode)

TCP zero-copy application RX callback handler.

Definition at line 406 of file m2mb_socket.h.

◆ M2MB_NET_UDP_ZEROCOPY_CB

typedef INT32(* M2MB_NET_UDP_ZEROCOPY_CB) (void *so, void *packet, INT32 errcode, void *from, INT32 family)

UDP zero-copy application RX callback handler.

Definition at line 420 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_FD_SET_T

Note: This is already under investigation.

FD set used by m2mb_socket_bsd_select(). Users please do not access to this structure directly, instead use the APIs m2mb_socket_bsd_fd_zero_func, m2mb_socket_bsd_fd_set_func, m2mb_socket_bsd_fd_clr_func,m2mb_socket_bsd_fd_isset_func

◆ M2MB_SOCKET_BSD_HOSTENT_T

Structure returned by network data base library.

◆ M2MB_SOCKET_BSD_IN6_ADDR_T

Structure for storing IPV6.

◆ M2MB_SOCKET_BSD_IN_ADDR_T

◆ M2MB_SOCKET_BSD_IPV6_ADDR_T

Structure for storing IPV6.

◆ M2MB_SOCKET_BSD_LINGER_T

Structure used for manipulating linger option.

◆ M2MB_SOCKET_BSD_SOCKADDR_IN6_T

IPV6 Socket address, internet style.

◆ M2MB_SOCKET_BSD_SOCKADDR_IN_T

IPV4Socket address, internet style.

◆ M2MB_SOCKET_BSD_SOCKADDR_T

Structure used by TCP/IP stack to store most addresses.

◆ M2MB_SOCKET_BSD_SOCKET

Definition at line 267 of file m2mb_socket.h.

◆ M2MB_SOCKET_BSD_TIMEVAL_T

Structure used in M2MB_SOCKET_bsd_select() call.

Function Documentation

◆ M2MB_IPv6_CHANGE_ENDIAN()

VOID M2MB_IPv6_CHANGE_ENDIAN ( UINT32 a)
inline

Conversion between host and network byte order.

Converts the unsigned integer x from host byte order to network byte order.

Parameters
[in]aipv6 address pointer to be converted
Returns
Note
<Notes>

Example

<C code example>

Definition at line 561 of file m2mb_socket.h.

◆ m2mb_socket_bsd_accept()

M2MB_SOCKET_BSD_SOCKET m2mb_socket_bsd_accept ( M2MB_SOCKET_BSD_SOCKET  s,
struct M2MB_SOCKET_BSD_SOCKADDR name,
INT32 namelen 
)

Accept a connection on a socket.

Allows an incoming connection attempt on the specified socket. Accept is used on the server side. It accepts a received incoming attempt to create a new TCP connection from the remote client, and creates a new socket associated with the socket address pair of this connection

Parameters
[in]sSpecifies the file descriptor of the socket
[in]nameIt is a pointer to a sockaddr structure. This structure is filled in with the address of the peer socket
[in]namelenIt is a value-result argument: the caller must initialize it to contain the size (in bytes) of the structure pointed to by name; on return, it will contain the actual size of the peer address
Returns
a handle for the new socket - On success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_listen(sockfd, backlog) == -1)
{
//failed.
}
else
//success.
if((Client_sd = m2mb_socket_bsd_accept(sockfd,
(M2MB_SOCKET_BSD_SOCKADDR_T *)&from, &fromlen)) != -1)
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_bind()

INT32 m2mb_socket_bsd_bind ( M2MB_SOCKET_BSD_SOCKET  s,
struct M2MB_SOCKET_BSD_SOCKADDR name,
INT32  namelen 
)

Bind the address with the socket.

Bind is typically used on the server side and associates a socket with a socket address structure, i.e. a specified local port number and IP address

Parameters
[in]sSpecifies the file descriptor of the socket to be bound
[in]namePoints to a sockaddr structure containing the address to be bound to the socket. The length and format of the address depend on the address family of the socket: M2MB_SOCKET_BSD_SOCKADDR_IN is used for IPv4 Internet protocols M2MB_SOCKET_BSD_SOCKADDR_IN6 is used for IPv6 Internet protocols
[in]namelenSpecifies the length of the sockaddr structure pointed to by name
Returns
0 - On success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_close()

INT32 m2mb_socket_bsd_close ( M2MB_SOCKET_BSD_SOCKET  s)

Close a socket.

Closes a file descriptor, so that it no longer refers to any file and may be reused

Parameters
[in]sSpecifies the file descriptor of the socket
Returns
0 - On success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_connect()

INT32 m2mb_socket_bsd_connect ( M2MB_SOCKET_BSD_SOCKET  s,
const struct M2MB_SOCKET_BSD_SOCKADDR name,
INT32  namelen 
)

connect a socket

Establishes a connection to the specified address

Parameters
[in]sspecifies the file descriptor of the socket
[in]namepoints to a sockaddr structure containing the peer address. The length and format of the address depend on the address family of the socket: M2MB_SOCKET_BSD_SOCKADDR_IN is used for IPv4 Internet protocols M2MB_SOCKET_BSD_SOCKADDR_IN6 is used for IPv6 Internet protocols
[in]namelenspecifies the length of the sockaddr structure pointed to by name
Returns
0 - On success, -1 -On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_fd_clr_func()

INT32 m2mb_socket_bsd_fd_clr_func ( INT32  fd,
M2MB_SOCKET_BSD_FD_SET_T set 
)

Used for m2mb_socket_bsd_select()

Remove a file descriptor from a set

Parameters
[in]fdFile descriptor
[in]setSet of file descriptors
Returns
0 - on success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
time.m_tv_sec = 0;
time.m_tv_usec = 500000;
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( sockfd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
m2mb_socket_bsd_fd_set_func( sockfd, &readfds );
if( m2mb_socket_bsd_select( 0, &readfds, NULL, NULL,
(const M2MB_SOCKET_BSD_TIMEVAL_T *)&time ) != 0 )
{
//process events
}
m2mb_socket_bsd_fd_clr_func( sockfd, &readfds );
}

◆ m2mb_socket_bsd_fd_isset_func()

INT32 m2mb_socket_bsd_fd_isset_func ( INT32  fd,
M2MB_SOCKET_BSD_FD_SET_T set 
)

Used for m2mb_socket_bsd_select()

Tests to see if a file descriptor is part of a set

Parameters
[in]fdFile descriptor
[in]setSet of file descriptors
Returns
0 - on success if the socket is not a member; 1 - if the socket is a member. -1 - On error.
Note
<Notes>

Example

void main(void)
{
time.m_tv_sec = 0;
time.m_tv_usec = 500000;
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( sockfd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
m2mb_socket_bsd_fd_set_func( sockfd, &readfds );
if( m2mb_socket_bsd_select( 0, &readfds, NULL, NULL,
(const M2MB_SOCKET_BSD_TIMEVAL_T *)&time ) != 0 )
{
//process events
}
}

◆ m2mb_socket_bsd_fd_set_func()

INT32 m2mb_socket_bsd_fd_set_func ( INT32  fd,
M2MB_SOCKET_BSD_FD_SET_T set 
)

Used for m2mb_socket_bsd_select()

Add a file descriptor to a set

Parameters
[in]fdFile descriptor
[in]setSet of file descriptors
Returns
0 - on success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
time.m_tv_sec = 0;
time.m_tv_usec = 500000;
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( sockfd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
m2mb_socket_bsd_fd_set_func( sockfd, &readfds );
if( m2mb_socket_bsd_select( 0, &readfds, NULL, NULL,
(const M2MB_SOCKET_BSD_TIMEVAL_T *)&time ) != 0 )
{
//process events
}
m2mb_socket_bsd_fd_clr_func( sockfd, &readfds );
}

◆ m2mb_socket_bsd_fd_zero_func()

INT32 m2mb_socket_bsd_fd_zero_func ( M2MB_SOCKET_BSD_FD_SET_T set)

Used for m2mb_socket_bsd_select()

Clears a set of file descriptors

Parameters
[in]setSet of file descriptors
Returns
0 - on success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
time.m_tv_sec = 0;
time.m_tv_usec = 500000;
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( sockfd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
m2mb_socket_bsd_fd_set_func( sockfd, &readfds );
if( m2mb_socket_bsd_select( 0, &readfds, NULL, NULL,
(const M2MB_SOCKET_BSD_TIMEVAL_T *)&time ) != 0 )
{
//process events
}
m2mb_socket_bsd_fd_clr_func( sockfd, &readfds );
}

◆ m2mb_socket_bsd_get_host_by_name_2_r_cid()

INT32 m2mb_socket_bsd_get_host_by_name_2_r_cid ( const CHAR name,
INT32  af,
struct M2MB_SOCKET_BSD_HOSTENT ret,
CHAR buf,
INT32  buflen,
struct M2MB_SOCKET_BSD_HOSTENT **  result,
INT32 h_errnop,
UINT8  cid 
)

Get network host entry.

Implements a "standard" Unix version of gethostbyname2_r() but with parameter "cid" to specify the PDP context to be used for transferring data

Parameters
[in]nameEither a hostname or an IPv4 address in standard dot notation or an IPv6 address in colon notation
[in]afAddress family. M2MB_SOCKET_BSD_AF_INET for IPv4, M2MB_SOCKET_BSD_AF_INET6 for IPv6
[in]retPre-allocated struct where to store the result
[in]bufPre-allocated buffer where to store additional data
[in]buflenSize of buf
[in]resultPointer to a hostent pointer that is set to ret on success and set to zero on error
[in]h_errnopPointer to an int where to store errors (instead of modifying the global h_errno)
[in]cidPDP context to be used
Returns
0 - on success. non-zero - on error ( additional error information is stored in *h_errnop instead of h_errno).
Note
<Notes>

Example

<C code example>

◆ m2mb_socket_bsd_get_peer_name()

INT32 m2mb_socket_bsd_get_peer_name ( M2MB_SOCKET_BSD_SOCKET  s,
struct M2MB_SOCKET_BSD_SOCKADDR name,
INT32 namelen 
)

Get the name of the peer socket.

Retrieves the peer address of the specified socket, store this address in the sockaddr structure pointed to by name, and store the length of this address in the object pointed to by namelen

Parameters
[in]sSpecifies the file descriptor of the socket
[in]namePointer to a sockaddr structure. This structure is filled in with the address of the peer socket
[in]namelenIt is a value-result argument: the caller must initialize it to contain the size (in bytes) of the structure pointed to by name; on return, it will contain the actual size of the peer address
Returns
0 - On success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_get_sock_name()

INT32 m2mb_socket_bsd_get_sock_name ( M2MB_SOCKET_BSD_SOCKET  s,
struct M2MB_SOCKET_BSD_SOCKADDR name,
INT32 namelen 
)

Get socket name.

Retrieve the local address of the specified socket, store this address in the sockaddr structure pointed to by name, and store the length of this address in the object pointed to by namelen

Parameters
[in]sSpecifies the file descriptor of the socket
[in]namePointer to a sockaddr structure. This structure is filled in with the local address of the socket
[in]namelenA value-result argument: the caller must initialize it to contain the size (in bytes) of the structure pointed to by name; on return, it will contain the actual size of the peer address
Returns
0 - On success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
INT32 len = sizeof(sockAddr), localport;
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
&len);
localport = m2mb_socket_bsd_ntohs(sockAddr.sin_port);
}

◆ m2mb_socket_bsd_get_sock_opt()

INT32 m2mb_socket_bsd_get_sock_opt ( M2MB_SOCKET_BSD_SOCKET  s,
INT32  level,
INT32  optname,
void *  optval,
INT32 optlen 
)

Get options from sockets.

This function is used to retrieve the current value of a particular socket option for the specified socket, see m2mb_socket_option_flags socket options

Parameters
[in]sSpecifies the file descriptor of the socket
[in]levelProtocol level the option exists at
[in]optnameName of the option
[in]optvalPointer to a buffer in which the value for the requested option is to be returned
[in]optlenThis parameter is ignored.
Returns
0 - on success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
const INT32 txqueue_size = 8192;
INT32 optlen;
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( sockfd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(sockfd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( sockfd, pBuf,buffsize,
{
//failed.
}
else
//success.
M2MB_SOCKET_BSD_SO_SNDBUF, &txqueue_size, &optlen );
}

◆ m2mb_socket_bsd_inet_ntop()

CHAR* m2mb_socket_bsd_inet_ntop ( INT32  af,
const void *  src,
CHAR dst,
INT32  size 
)

Converts IPv4 and IPv6 addresses from binary to text form.

this function converts the network address structure src in the af address family into a character string. The resulting string is copied to the buffer pointed to by dst, which must be a non-NULL pointer. The caller specifies the number of bytes available in this buffer in the argument size

Parameters
[in]afAddress family. M2MB_SOCKET_BSD_AF_INET for IPv4, M2MB_SOCKET_BSD_AF_INET6 for IPv6
[in]srcPointer to IPv4 or IPv6 address
[in]dstPointer to output buffer to contain IPv4/IPv6 address string
[in]sizeSize of output buffer in bytes
Returns
Non-NULL pointer to dst - on success. NULL - on failure.
Note
<Notes>

Example

void main(void)
{
UINT32 ipv4Addr; //IP address
char ip_str[20] = {0};
ip_str, sizeof(ip_str));
}

◆ m2mb_socket_bsd_inet_pton()

INT32 m2mb_socket_bsd_inet_pton ( INT32  af,
const CHAR src,
void *  dst 
)

Converts IPv4 and IPv6 addresses from text to binary form.

Converts the character string src into a network address structure in the af address family, then copies the network address structure to dst

Parameters
[in]afAddress family. M2MB_SOCKET_BSD_AF_INET for IPv4, M2MB_SOCKET_BSD_AF_INET6 for IPv6
[in]srcIPv4 or IPv6 address string (null-terminated)
[in]dstResulting IPv4/IPv6 address: struct M2MB_SOCKET_BSD_IN_ADDR in case of IPv4, struct M2MB_SOCKET_BSD_IPV6_ADDR in case of IPv6
Returns
1 - on success (network address was successfully converted). 0 - returned if src does not contain a character string representing a valid network address in the specified address family. -1 - If af does not contain a valid address family.
Note
<Notes>

Example

void main(void)
{
INT8* optval = "192.168.1.1";
INT32 OptVal[4] = {0}
//ipv6 address
return M2MB_ERROR;
//ipv4 address
return M2MB_ERROR;
}

◆ m2mb_socket_bsd_ioctl()

INT32 m2mb_socket_bsd_ioctl ( M2MB_SOCKET_BSD_SOCKET  s,
INT32  cmd,
void *  argp 
)

IO control function.

Used to set a socket to blocking or nonblocking mode (M2MB_SOCKET_BSD_FIONBIO) or to retrieve all pending data (M2MB_SOCKET_BSD_FIONREAD)

Parameters
[in]sSpecifies the file descriptor of the socket
[in]cmdName of the command: M2MB_SOCKET_BSD_FIONREAD,M2MB_SOCKET_BSD_FIONBIO
[in]argpPointer to the value (input parameter or output parameter)
Returns
0 - on success, -1 - On error.
Note
<Notes>

Example

<C code example>

◆ m2mb_socket_bsd_listen()

INT32 m2mb_socket_bsd_listen ( M2MB_SOCKET_BSD_SOCKET  s,
INT32  backlog 
)

Listen for connections on a socket.

Marks the socket referred to by sockfd as a passive socket, that is, as a socket that will be used to accept incoming connection requests using m2mb_socket_bsd_accept

Parameters
[in]sSpecifies the file descriptor of the socket
[in]backlogDefines the maximum length to which the queue of pending connections for s may grow
Returns
0 - On success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_listen(sockfd, backlog) == -1)
{
//failed.
}
else
//success.
if((Client_sd = m2mb_socket_bsd_accept(sockfd,
(M2MB_SOCKET_BSD_SOCKADDR_T *)&from, &fromlen)) != -1)
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_recv()

INT32 m2mb_socket_bsd_recv ( M2MB_SOCKET_BSD_SOCKET  s,
void *  buf,
INT32  len,
INT32  flags 
)

Receive a message from a socket.

This function should be invoked to receive the data on the specified socket. Depending on the socket configuration, this function can perform in a blocking or non-blocking mode. In case of blocking, this function will not return until data is received (not necessarily all requested data). In case of non-blocking, this function will return the data pending on the specified socket, but will not wait for additional data (in case the size requested is not reached)

Parameters
[in]sSpecifies the file descriptor of the socket
[in]bufPointer to a buffer for received message
[in]lenNumber of bytes to receive
[in]flagsOnly 0 supported
Returns
Number of bytes received - on success, -1 - if an error occurred. 0 - when the peer has performed an orderly shutdown
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv( pCid->sd, pBuf,buffsize, M2MB_SOCKET_MSG_DONTWAIT) <= 0)
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_recv_from()

INT32 m2mb_socket_bsd_recv_from ( M2MB_SOCKET_BSD_SOCKET  s,
void *  buf,
INT32  len,
INT32  flags,
M2MB_SOCKET_BSD_SOCKADDR_T from,
INT32 fromlen 
)

Receive a message from a socket.

This function receives the data on the given socket and stores the source address. This function shall be used only for datagram sockets. Depending on the socket configuration, this function can perform in a blocking or non-blocking mode. In case of blocking, this function will not return until data is received (not necessarily all requested data). In case of non-blocking, this function will return the data pending on the specified socket, but will not wait for additional data (in case the size requested is not reached)

Parameters
[in]sSpecifies the file descriptor of the socket
[in]bufPointer to a buffer for received message
[in]lenNumber of bytes to receive
[in]flagsOnly 0 supported
[in]fromPointer to a sockaddr structure. This structure is filled in with the address of the peer socket
[in]fromlenA value-result argument: 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
Number of bytes received - on success, -1 - if an error occurred. 0 - when the peer has performed an orderly shutdown
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_select()

INT32 m2mb_socket_bsd_select ( INT32  nfds,
M2MB_SOCKET_BSD_FD_SET_T readfds,
M2MB_SOCKET_BSD_FD_SET_T writefds,
M2MB_SOCKET_BSD_FD_SET_T exceptfds,
const struct M2MB_SOCKET_BSD_TIMEVAL timeout 
)

synchronous I/O multiplexing

This function is used to prune a provided list of sockets for those that are: ready to read, ready to write or have any errors.

Parameters
[in]nfdsnfds is the highest-numbered file descriptor in any of the three sets, plus 1
[in]readfdsSet of file descriptors that will be watched to see if characters become available for reading. On exit, the set is modified in place to indicate which file descriptors actually changed status.
[in]writefdsSet of file descriptors that will be watched to see if a write will not block. On exit, the set is modified in place to indicate which file descriptors actually changed status.
[in]exceptfdsSet of file descriptors that will be watched for exceptions. On exit, the set is modified in place to indicate which file descriptors actually changed status.
[in]timeoutSpecifies the minimum interval that m2mb_socket_bsd_select() should block waiting for a file descriptor to become ready
Returns
Number of sockets which had an event occur at and become ready
Note
<Notes>

Example

void main(void)
{
time.m_tv_sec = 0;
time.m_tv_usec = 500000;
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( sockfd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
m2mb_socket_bsd_fd_set_func( sockfd, &readfds );
if( m2mb_socket_bsd_select( 0, &readfds, NULL, NULL,
(const M2MB_SOCKET_BSD_TIMEVAL_T *)&time ) != 0 )
{
//process events
}
m2mb_socket_bsd_fd_clr_func( sockfd, &readfds );
}

◆ m2mb_socket_bsd_send()

INT32 m2mb_socket_bsd_send ( M2MB_SOCKET_BSD_SOCKET  s,
const void *  buf,
INT32  len,
INT32  flags 
)

Send a message on a socket.

This function should be invoked to send data using the specified socket. Depending on the socket configuration, this function can perform in a blocking or non-blocking mode. In case of blocking, this function will not return until data is sent (not necessarily all requested data). In case of non-blocking, this function will send the data using only the stack available resources and will not wait for resources to be free

Parameters
[in]sSpecifies the file descriptor of the socket
[in]bufPointer to a buffer containing the message to be sent
[in]lenNumber of bytes to send
[in]flagsOnly 0 supported
Returns
Number of characters sent - on success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send(pCid->sd, buff, buffsize)))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_send_to()

INT32 m2mb_socket_bsd_send_to ( M2MB_SOCKET_BSD_SOCKET  s,
const void *  buf,
INT32  len,
INT32  flags,
const struct M2MB_SOCKET_BSD_SOCKADDR to,
INT32  tolen 
)

send a message on a socket

This function should be invoked to send data using the specified socket. Depending on the socket configuration, this function can perform in a blocking or non-blocking mode. In case of blocking, this function will not return until data is sent (not necessarily all requested data). In case of non-blocking, this function will send the data using only the stack available resources and will not wait for resources to be free

Parameters
[in]sSpecifies the file descriptor of the socket
[in]bufPointer to a buffer containing message to be sent
[in]lenNumber of bytes to send
[in]flagsonly 0 supported
[in]toPoints to a sockaddr structure containing the peer address. The length and format of the address depend on the address family of the socket
[in]tolenSpecifies the length of the sockaddr structure pointed to by to
Returns
Number of characters sent - on success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
}

◆ m2mb_socket_bsd_set_sock_opt()

INT32 m2mb_socket_bsd_set_sock_opt ( M2MB_SOCKET_BSD_SOCKET  s,
INT32  level,
INT32  optname,
const void *  optval,
INT32  optlen 
)

Set options on sockets.

This function is used to set a particular socket option for the specified socket, see m2mb_socket_option_flags socket options

Parameters
[in]sSpecifies the file descriptor of the socket
[in]levelProtocol level the option exists at
[in]optnameName of the option
[in]optvalPointer to a buffer with the requested option to be set
[in]optlenOption length in bytes
Returns
0 - on success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
const INT32 txqueue_size = 8192;
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(sockfd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( sockfd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(sockfd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( sockfd, pBuf,buffsize,
{
//failed.
}
else
//success.
M2MB_SOCKET_BSD_SO_SNDBUF, &txqueue_size, sizeof(INT32) );
}

◆ m2mb_socket_bsd_socket()

M2MB_SOCKET_BSD_SOCKET m2mb_socket_bsd_socket ( INT32  domain,
INT32  type,
INT32  protocol 
)

Create an endpoint for communication.

Creates an unbound socket in a communications domain, and returns a file descriptor that can be used in later function calls that operate on socket

Parameters
[in]domainSpecifies the communications domain in which a socket is to be created: M2MB_SOCKET_BSD_AF_INET - IPv4 Internet protocols M2MB_SOCKET_BSD_AF_INET6 - IPv6 Internet protocols M2MB_SOCKET_BSD_AF_PACKET – Packet socket to receive and send Ethernet frames
[in]typeSpecifies the type of socket to be created: M2MB_SOCKET_BSD_SOCK_STREAM - TCP M2MB_SOCKET_BSD_SOCK_DGRAM - UDP M2MB_SOCKET_BSD_SOCK_RAW - RAW
[in]protocolSpecifies a particular protocol to be used with the socket: M2MB_SOCKET_BSD_IPPROTO_TCP M2MB_SOCKET_BSD_IPPROTO_UDP M2MB_SOCKET_BSD_IPPROTO_DFLT causes m2mb_socket_bsd_socket() to use an unspecified default protocol appropriate for the requested socket type
Returns
a handle for the new socket - On success, -1 - On error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
}

◆ m2mb_socket_errno()

INT32 m2mb_socket_errno ( INT32  fd)

Gets the last error occurred.

Gets the last error occurred. Should be on a thread bases

Parameters
[in]fdFile descriptor
Returns
Socket error code - on success. M2MB_SOCKET_BSD_ENOTSOCK - on error.
Note
<Notes>

Example

void main(void)
{
{
//failed.
}
else
//success.
if (m2mb_socket_bsd_bind(pCid->sd, addr, addrlen) == -1)
{
//failed.
}
else
//success.
if (-1 == m2mb_socket_bsd_connect( pCid->sd, (struct M2MB_SOCKET_BSD_SOCKADDR *)&serveraddr, sizeof(serveraddr)))
{
//failed.
}
else
//success.
if(-1 == (status = m2mb_socket_bsd_send_to(pCid->sd, buff, buffsize,
0, (const M2MB_SOCKET_BSD_SOCKADDR_T *)pTo, sizeof(to))))
{
//failed.
}
else
//success.
if((received = m2mb_socket_bsd_recv_from( pCid->sd, pBuf,buffsize,
{
//failed.
}
else
//success.
err = m2mb_socket_errno( pCid->sd);
return;
}

◆ m2mb_socket_set_cid()

INT32 m2mb_socket_set_cid ( M2MB_SOCKET_BSD_SOCKET  s,
UINT8  cid 
)

Link a socket to a CID.

Specifies the PDP context to be used for transferring data on the socket

Parameters
[in]sSpecifies the file descriptor of the socket
[in]cidPDP context to be used
Returns
0 - on success, -1 - On error.
Note
<Notes>

Example

<C code example>

◆ m2mb_socket_TCP_Keepalive_Get()

INT32 m2mb_socket_TCP_Keepalive_Get ( INT32 idle_Time,
INT32 resp_Timeout 
)

Get TCP Keepalive parameters.

Parameters
[in]idle_TimePointer to an int which will contain the initial idle time (in seconds)
[out]resp_TimeoutPointer to an int which will contain the waiting time (in seconds) for the response after TCP Keepalive probe is sent
Returns
QAPI_OK on success, other value on error. 0 - on success, -1 - On error.
Note
<Notes>

Example

INT32 idle_sec = 75; // 2 hours
INT32 timeout_sec = 60;
m2mb_socket_TCP_Keepalive_Get(&idle_sec, &timeout_sec);
if((idle_sec == 0) &&(timeout_sec== 0))
{
idle_sec = 75;
timeout_sec = 60;
}
m2mb_socket_TCP_Keepalive_Set( idle_sec, timeout_sec);

◆ m2mb_socket_TCP_Keepalive_Set()

INT32 m2mb_socket_TCP_Keepalive_Set ( INT32  idle_Time,
INT32  resp_Timeout 
)

Set TCP Keepalive parameters.

The default initial idle time is 7,200 seconds (2 hours). The default waiting time for the response is 75 seconds after a TCP Keepalive probe is sent.

Parameters
[in]idle_TimeInitial idle time (in seconds). If idle_Time <= 0, then 7,200 is used.
[in]resp_Timeout
Waiting time (in seconds) for the response after a TCP Keepalive probe is sent. If resp_Timeout <= 0, then 75 is used.
Returns
0 - on success, -1 - On error.
Note
<Notes>

Example

INT32 idle_sec = 75; // 2 hours
INT32 timeout_sec = 60;
m2mb_socket_TCP_Keepalive_Get(&idle_sec, &timeout_sec);
if((idle_sec == 0) &&(timeout_sec== 0))
{
idle_sec = 75;
timeout_sec = 60;
}
m2mb_socket_TCP_Keepalive_Set( idle_sec, timeout_sec);