The friendly Operating System for the Internet of Things

Connection submodule for UDP connections. More...

Detailed Description

Deprecated:
Please use UDP sock API instead

Files

file  conn/udp.h
 UDP connection definitions.
 

Typedefs

typedef struct conn_udp conn_udp_t
 Implementation-specific type of a UDP connection object.
 

Functions

int conn_udp_create (conn_udp_t *conn, const void *addr, size_t addr_len, int family, uint16_t port)
 Creates a new UDP connection object. More...
 
void conn_udp_close (conn_udp_t *conn)
 Closes a UDP connection. More...
 
int conn_udp_getlocaladdr (conn_udp_t *conn, void *addr, uint16_t *port)
 Gets the local address of a UDP connection. More...
 
int conn_udp_recvfrom (conn_udp_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len, uint16_t *port)
 Receives a UDP message. More...
 
int conn_udp_sendto (const void *data, size_t len, const void *src, size_t src_len, const void *dst, size_t dst_len, int family, uint16_t sport, uint16_t dport)
 Sends a UDP message. More...
 

Function Documentation

void conn_udp_close ( conn_udp_t conn)
Parameters
[in,out]connA UDP connection object.
int conn_udp_create ( conn_udp_t conn,
const void *  addr,
size_t  addr_len,
int  family,
uint16_t  port 
)
Parameters
[out]connPreallocated connection object. Must fill the size of the stack-specific connection desriptor.
[in]addrThe local network layer address for conn.
[in]addr_lenThe length of addr. Must be fitting for the family.
[in]familyThe family of addr (see UNIX address families).
[in]portThe local UDP port for conn.
Todo:
With Generic (GNRC) network stack conn_udp_recvfrom needs to be called from the same thread as for this function. This is undesired behavior and will be fixed in upcoming versions of RIOT.
Returns
0 on success.
any other negative number in case of an error. For portability implementations should draw inspiration of the errno values from the POSIX' bind() function specification.
int conn_udp_getlocaladdr ( conn_udp_t conn,
void *  addr,
uint16_t *  port 
)
Parameters
[in]connA UDP connection object.
[out]addrThe local network layer address. Must have space for any address of the connection's family.
[out]portThe local UDP port.
Returns
length of addr on success.
any other negative number in case of an error. For portability implementations should draw inspiration of the errno values from the POSIX' getsockname() function specification.
int conn_udp_recvfrom ( conn_udp_t conn,
void *  data,
size_t  max_len,
void *  addr,
size_t *  addr_len,
uint16_t *  port 
)
Parameters
[in]connA UDP connection object.
[out]dataPointer where the received data should be stored.
[in]max_lenMaximum space available at data.
[out]addrNULL pointer or the sender's network layer address. Must have space for any address of the connection's family.
[out]addr_lenLength of addr. Can be NULL if addr is NULL.
[out]portNULL pointer or the sender's UDP port.
Note
Function may block.
Todo:
With Generic (GNRC) network stack this function needs to be called from the same thread as conn_udp_create. This is undesired behavior and will be fixed in upcoming versions of RIOT.
Returns
The number of bytes received on success.
0, if no received data is available, but everything is in order.
any other negative number in case of an error. For portability, implementations should draw inspiration of the errno values from the POSIX' recv(), recvfrom(), or recvmsg() function specification.
int conn_udp_sendto ( const void *  data,
size_t  len,
const void *  src,
size_t  src_len,
const void *  dst,
size_t  dst_len,
int  family,
uint16_t  sport,
uint16_t  dport 
)
Parameters
[in]dataPointer to the data to send.
[in]lenLength of the data to send.
[in]srcThe source address. May be NULL for any interface address.
[in]src_lenLength of src. May be 0 if src is NULL
[in]dstThe receiver's network address.
[in]dst_lenLength of dst.
[in]familyThe family of src and dst (see UNIX address families).
[in]sportThe source UDP port.
[in]dportThe receiver's UDP port.
Note
Function may block.
Returns
The number of bytes sent on success.
any other negative number in case of an error. For portability, implementations should draw inspiration of the errno values from the POSIX' send(), sendfrom(), or sendmsg() function specification.