AM243x MCU+ SDK  09.00.00
IP network functions binding

Introduction

Files

file  cb_inet.h
 Bindings to POSIX network IP layer functions.
 

Data Structures

struct  cb_inetaddr_t
 Network address encapsulation structure for IPv4 or IPv6 address This structure is used to encapsulation of address type such that the implementation does not need to have separate containers for IPv4 and IPv6 address. It now supports either AF_INET or AF_INET6 network addresses. This structure may not hold both address type at a given time. Dual-stack implementation must assume that IPv4 can be effective in parallel with IPv6 address, thus it is expected that the the implementation uses two instances of this structure/. More...
 
struct  cb_inetaddr_map_t
 Network address to socket address mapping This structure is used to store mapping between network address and socket address. More...
 

Functions

CB_ADDRINFO_Tcb_name_to_addrinfo (int family, int socktype, const char *name, int port, bool numeric_only)
 Converts a name or ip address and port into CB_ADDRINFO_T. More...
 
int cb_sockaddr_to_ipaddr (CB_SOCKADDR_T *sa, CB_SOCKLEN_T salen, char *ip, size_t ip_size, int *port)
 Translates socket address structure to IP address. More...
 
int cb_addrinfo_to_ipaddr (const CB_ADDRINFO_T *ai, char *ip, size_t ip_size, int *port)
 Translate socket information to IP address. More...
 
bool cb_is_multicast_addr (CB_SOCKADDR_T *addr)
 Checks if the proveded socket address is a multicast address. More...
 

Macros

#define CB_ADDRINFO_T   struct addrinfo
 
#define CB_GETADDRINFO   getaddrinfo
 
#define CB_FREEADDRINFO   freeaddrinfo
 
#define CB_ADDRINFO_AI_FAMILY(x)   ((x)->ai_family)
 
#define CB_ADDRINFO_AI_SOCKTYPE(x)   ((x)->ai_socktype)
 
#define CB_ADDRINFO_AI_ADDR(x)   ((x)->ai_addr)
 
#define CB_ADDRINFO_AI_ADDRLEN(x)   ((x)->ai_addrlen)
 
#define CB_ADDRINFO_SA_FAMILY(x)   ((x)->ai_addr->sa_family)
 
#define CB_SOCKADDR_SA_FAMILY(x)   ((x)->sa_family)
 
#define CB_SOCKADDR_IN_ADDR(x)   (((CB_SOCKADDR_IN_T *)(x))->sin_addr.s_addr)
 
#define CB_SOCKADDR_IN6_ADDR(x)   (((CB_SOCKADDR_IN6_T *)(x))->sin6_addr)
 
#define CB_SOCK_BIND   bind
 
#define CB_GETSOCKNAME   getsockname
 
#define CB_GETNAMEINFO   getnameinfo
 
#define CB_ADDRINFO_FOREACH_ITER(list, node)    (node) = (list); (node); (node) = (node)->ai_next
 Traverse CB_ADDRINFO_T. More...
 

Macro Definition Documentation

◆ CB_ADDRINFO_T

#define CB_ADDRINFO_T   struct addrinfo

◆ CB_GETADDRINFO

#define CB_GETADDRINFO   getaddrinfo

◆ CB_FREEADDRINFO

#define CB_FREEADDRINFO   freeaddrinfo

◆ CB_ADDRINFO_AI_FAMILY

#define CB_ADDRINFO_AI_FAMILY (   x)    ((x)->ai_family)

◆ CB_ADDRINFO_AI_SOCKTYPE

#define CB_ADDRINFO_AI_SOCKTYPE (   x)    ((x)->ai_socktype)

◆ CB_ADDRINFO_AI_ADDR

#define CB_ADDRINFO_AI_ADDR (   x)    ((x)->ai_addr)

◆ CB_ADDRINFO_AI_ADDRLEN

#define CB_ADDRINFO_AI_ADDRLEN (   x)    ((x)->ai_addrlen)

◆ CB_ADDRINFO_SA_FAMILY

#define CB_ADDRINFO_SA_FAMILY (   x)    ((x)->ai_addr->sa_family)

◆ CB_SOCKADDR_SA_FAMILY

#define CB_SOCKADDR_SA_FAMILY (   x)    ((x)->sa_family)

◆ CB_SOCKADDR_IN_ADDR

#define CB_SOCKADDR_IN_ADDR (   x)    (((CB_SOCKADDR_IN_T *)(x))->sin_addr.s_addr)

◆ CB_SOCKADDR_IN6_ADDR

#define CB_SOCKADDR_IN6_ADDR (   x)    (((CB_SOCKADDR_IN6_T *)(x))->sin6_addr)

◆ CB_SOCK_BIND

#define CB_SOCK_BIND   bind

◆ CB_GETSOCKNAME

#define CB_GETSOCKNAME   getsockname

◆ CB_GETNAMEINFO

#define CB_GETNAMEINFO   getnameinfo

◆ CB_ADDRINFO_FOREACH_ITER

#define CB_ADDRINFO_FOREACH_ITER (   list,
  node 
)     (node) = (list); (node); (node) = (node)->ai_next

Traverse CB_ADDRINFO_T.

Function Documentation

◆ cb_name_to_addrinfo()

CB_ADDRINFO_T* cb_name_to_addrinfo ( int  family,
int  socktype,
const char *  name,
int  port,
bool  numeric_only 
)

Converts a name or ip address and port into CB_ADDRINFO_T.

Parameters
familyaddress protocol family type
socktypepreferred socket type
namename of the service
portport number of the service
numeric_onlyfilter result to include numeric hosts only

Pasing CB_AF_INET6 ensures that the list of CB_ADDRINFO_T returned are IPv6 address. Otherwise passing CB_AF_UNSPEC leads to unspecified results, caller need to confirm the results.

Note that this function allocates CB_ADDRINFO_T, the caller needs to perform CB_FREEADDRIINFO afterwards.

◆ cb_sockaddr_to_ipaddr()

int cb_sockaddr_to_ipaddr ( CB_SOCKADDR_T sa,
CB_SOCKLEN_T  salen,
char *  ip,
size_t  ip_size,
int *  port 
)

Translates socket address structure to IP address.

Parameters
sasocket address structure
salensocket address structure length
ipbuffer for the resulting IP address
ip_sizesize of the buffer
portresulting port number
Returns
0 for success, otherwise error

◆ cb_addrinfo_to_ipaddr()

int cb_addrinfo_to_ipaddr ( const CB_ADDRINFO_T ai,
char *  ip,
size_t  ip_size,
int *  port 
)

Translate socket information to IP address.

Parameters
aia ponter to an address information
ipbuffer for the resulting IP address
ip_sizesize of the buffer
portresulting port number
Returns
0 for success, otherwise error

◆ cb_is_multicast_addr()

bool cb_is_multicast_addr ( CB_SOCKADDR_T addr)

Checks if the proveded socket address is a multicast address.

Parameters
addrsocket address container
Returns
true if address is multicast, otherwise false