NET: Most of the contents of include/nuttx/net/udp.h moved to net/pkt/udp.h
This commit is contained in:
parent
dc8cba763d
commit
47a502a5e2
@ -68,26 +68,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Type Definitions
|
* Public Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Representation of a uIP UDP connection */
|
|
||||||
|
|
||||||
struct net_driver_s; /* Forward reference */
|
|
||||||
struct devif_callback_s; /* Forward reference */
|
|
||||||
|
|
||||||
struct udp_conn_s
|
|
||||||
{
|
|
||||||
dq_entry_t node; /* Supports a doubly linked list */
|
|
||||||
net_ipaddr_t ripaddr; /* The IP address of the remote peer */
|
|
||||||
uint16_t lport; /* The local port number in network byte order */
|
|
||||||
uint16_t rport; /* The remote port number in network byte order */
|
|
||||||
uint8_t ttl; /* Default time-to-live */
|
|
||||||
uint8_t crefs; /* Reference counts on this instance */
|
|
||||||
|
|
||||||
/* Defines the list of UDP callbacks */
|
|
||||||
|
|
||||||
struct devif_callback_s *list;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The UDP and IP headers */
|
/* The UDP and IP headers */
|
||||||
|
|
||||||
struct udp_iphdr_s
|
struct udp_iphdr_s
|
||||||
@ -152,57 +132,4 @@ struct udp_stats_s
|
|||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* uIP application functions
|
|
||||||
*
|
|
||||||
* Functions used by an application running of top of uIP. This includes
|
|
||||||
* functions for opening and closing connections, sending and receiving
|
|
||||||
* data, etc.
|
|
||||||
*
|
|
||||||
* Find a free connection structure and allocate it for use. This is
|
|
||||||
* normally something done by the implementation of the socket() API
|
|
||||||
*/
|
|
||||||
|
|
||||||
FAR struct udp_conn_s *udp_alloc(void);
|
|
||||||
|
|
||||||
/* Free a connection structure that is no longer in use. This should
|
|
||||||
* be done by the implementation of close()
|
|
||||||
*/
|
|
||||||
|
|
||||||
void udp_free(FAR struct udp_conn_s *conn);
|
|
||||||
|
|
||||||
/* Bind a UDP connection to a local address */
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
int udp_bind(FAR struct udp_conn_s *conn,
|
|
||||||
FAR const struct sockaddr_in6 *addr);
|
|
||||||
#else
|
|
||||||
int udp_bind(FAR struct udp_conn_s *conn,
|
|
||||||
FAR const struct sockaddr_in *addr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This function sets up a new UDP connection. The function will
|
|
||||||
* automatically allocate an unused local port for the new
|
|
||||||
* connection. However, another port can be chosen by using the
|
|
||||||
* udp_bind() call, after the udp_connect() function has been
|
|
||||||
* called.
|
|
||||||
*
|
|
||||||
* This function is called as part of the implementation of sendto
|
|
||||||
* and recvfrom.
|
|
||||||
*
|
|
||||||
* addr The address of the remote host.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
int udp_connect(FAR struct udp_conn_s *conn,
|
|
||||||
FAR const struct sockaddr_in6 *addr);
|
|
||||||
#else
|
|
||||||
int udp_connect(FAR struct udp_conn_s *conn,
|
|
||||||
FAR const struct sockaddr_in *addr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable/disable UDP callbacks on a connection */
|
|
||||||
|
|
||||||
void udp_enable(FAR struct udp_conn_s *conn);
|
|
||||||
void udp_disable(FAR struct udp_conn_s *conn);
|
|
||||||
|
|
||||||
#endif /* __INCLUDE_NUTTX_NET_UDP_H */
|
#endif /* __INCLUDE_NUTTX_NET_UDP_H */
|
||||||
|
@ -50,8 +50,9 @@
|
|||||||
#include <nuttx/net/tcp.h>
|
#include <nuttx/net/tcp.h>
|
||||||
#include <nuttx/net/udp.h>
|
#include <nuttx/net/udp.h>
|
||||||
|
|
||||||
#include "socket/socket.h"
|
|
||||||
#include "netdev/netdev.h"
|
#include "netdev/netdev.h"
|
||||||
|
#include "udp/udp.h"
|
||||||
|
#include "socket/socket.h"
|
||||||
|
|
||||||
#ifdef CONFIG_NET
|
#ifdef CONFIG_NET
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include <nuttx/net/tcp.h>
|
#include <nuttx/net/tcp.h>
|
||||||
#include <nuttx/net/udp.h>
|
#include <nuttx/net/udp.h>
|
||||||
|
|
||||||
|
#include "udp/udp.h"
|
||||||
#include "socket/socket.h"
|
#include "socket/socket.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#include "netdev/netdev.h"
|
#include "netdev/netdev.h"
|
||||||
#include "devif/devif.h"
|
#include "devif/devif.h"
|
||||||
#include "tcp/tcp.h"
|
#include "tcp/tcp.h"
|
||||||
|
#include "udp/udp.h"
|
||||||
#include "pkt/pkt.h"
|
#include "pkt/pkt.h"
|
||||||
#include "socket/socket.h"
|
#include "socket/socket.h"
|
||||||
|
|
||||||
|
193
net/udp/udp.h
193
net/udp/udp.h
@ -59,6 +59,24 @@
|
|||||||
* Public Type Definitions
|
* Public Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Representation of a uIP UDP connection */
|
||||||
|
|
||||||
|
struct devif_callback_s; /* Forward reference */
|
||||||
|
|
||||||
|
struct udp_conn_s
|
||||||
|
{
|
||||||
|
dq_entry_t node; /* Supports a doubly linked list */
|
||||||
|
net_ipaddr_t ripaddr; /* The IP address of the remote peer */
|
||||||
|
uint16_t lport; /* The local port number in network byte order */
|
||||||
|
uint16_t rport; /* The remote port number in network byte order */
|
||||||
|
uint8_t ttl; /* Default time-to-live */
|
||||||
|
uint8_t crefs; /* Reference counts on this instance */
|
||||||
|
|
||||||
|
/* Defines the list of UDP callbacks */
|
||||||
|
|
||||||
|
struct devif_callback_s *list;
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -75,28 +93,197 @@ extern "C"
|
|||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Defined in udp_conn.c ****************************************************/
|
|
||||||
|
|
||||||
struct udp_iphdr_s; /* Forward reference */
|
struct udp_iphdr_s; /* Forward reference */
|
||||||
struct udp_conn_s; /* Forward reference */
|
struct net_driver_s; /* Forward reference */
|
||||||
|
|
||||||
|
/* Defined in udp_conn.c ****************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_initialize()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the UDP connection structures. Called once and only from
|
||||||
|
* the UIP layer.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
void udp_initialize(void);
|
void udp_initialize(void);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_alloc()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Allocate a new, uninitialized UDP connection structure. This is
|
||||||
|
* normally something done by the implementation of the socket() API
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct udp_conn_s *udp_alloc(void);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_free()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Free a UDP connection structure that is no longer in use. This should be
|
||||||
|
* done by the implementation of close().
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void udp_free(FAR struct udp_conn_s *conn);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_active()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Find a connection structure that is the appropriate
|
||||||
|
* connection to be used within the provided TCP/IP header
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* This function is called from UIP logic at interrupt level
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct udp_conn_s *udp_active(FAR struct udp_iphdr_s *buf);
|
FAR struct udp_conn_s *udp_active(FAR struct udp_iphdr_s *buf);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_nextconn()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Traverse the list of allocated UDP connections
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* This function is called from UIP logic at interrupt level (or with
|
||||||
|
* interrupts disabled).
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct udp_conn_s *udp_nextconn(FAR struct udp_conn_s *conn);
|
FAR struct udp_conn_s *udp_nextconn(FAR struct udp_conn_s *conn);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_bind()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function implements the UIP specific parts of the standard UDP
|
||||||
|
* bind() operation.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* This function is called from normal user level code.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in6 *addr);
|
||||||
|
#else
|
||||||
|
int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_connect()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function sets up a new UDP connection. The function will
|
||||||
|
* automatically allocate an unused local port for the new
|
||||||
|
* connection. However, another port can be chosen by using the
|
||||||
|
* udp_bind() call, after the udp_connect() function has been
|
||||||
|
* called.
|
||||||
|
*
|
||||||
|
* This function is called as part of the implementation of sendto
|
||||||
|
* and recvfrom.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* conn - A reference to UDP connection structure
|
||||||
|
* addr - The address of the remote host.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* This function is called user code. Interrupts may be enabled.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
int udp_connect(FAR struct udp_conn_s *conn,
|
||||||
|
FAR const struct sockaddr_in6 *addr);
|
||||||
|
#else
|
||||||
|
int udp_connect(FAR struct udp_conn_s *conn,
|
||||||
|
FAR const struct sockaddr_in *addr);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Defined in udp_poll.c ****************************************************/
|
/* Defined in udp_poll.c ****************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_poll
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Poll a UDP "connection" structure for availability of TX data
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* dev - The device driver structure to use in the send operation
|
||||||
|
* conn - The UDP "connection" to poll for TX data
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Called from the interrupt level or with interrupts disabled.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn);
|
void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn);
|
||||||
|
|
||||||
/* Defined in udp_send.c ****************************************************/
|
/* Defined in udp_send.c ****************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_send
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set-up to send a UDP packet
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* dev - The device driver structure to use in the send operation
|
||||||
|
* conn - The UDP "connection" structure holding port information
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Called from the interrupt level or with interrupts disabled.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn);
|
void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn);
|
||||||
|
|
||||||
/* Defined in udp_input.c ***************************************************/
|
/* Defined in udp_input.c ***************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: udp_input
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Handle incoming UDP input
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* dev - The device driver structure containing the received UDP packet
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* OK The packet has been processed and can be deleted
|
||||||
|
* ERROR Hold the packet and try again later. There is a listening socket
|
||||||
|
* but no receive in place to catch the packet yet.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Called from the interrupt level or with interrupts disabled.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
int udp_input(FAR struct net_driver_s *dev);
|
int udp_input(FAR struct net_driver_s *dev);
|
||||||
|
|
||||||
/* Defined in udp_callback.c ************************************************/
|
/* Defined in udp_callback.c ************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: udp_callback
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Inform the application holding the UDP socket of a change in state.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK if packet has been processed, otherwise ERROR.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* This function is called at the interrupt level with interrupts disabled.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
uint16_t udp_callback(FAR struct net_driver_s *dev,
|
uint16_t udp_callback(FAR struct net_driver_s *dev,
|
||||||
FAR struct udp_conn_s *conn, uint16_t flags);
|
FAR struct udp_conn_s *conn, uint16_t flags);
|
||||||
|
@ -230,7 +230,8 @@ void udp_initialize(void)
|
|||||||
* Name: udp_alloc()
|
* Name: udp_alloc()
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a new, uninitialized UDP connection structure.
|
* Allocate a new, uninitialized UDP connection structure. This is
|
||||||
|
* normally something done by the implementation of the socket() API
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -264,8 +265,7 @@ FAR struct udp_conn_s *udp_alloc(void)
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Free a UDP connection structure that is no longer in use. This should be
|
* Free a UDP connection structure that is no longer in use. This should be
|
||||||
* done by the implementation of close(). udp_disable must have been
|
* done by the implementation of close().
|
||||||
* previously called.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -423,10 +423,12 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
|
|||||||
* udp_bind() call, after the udp_connect() function has been
|
* udp_bind() call, after the udp_connect() function has been
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* udp_enable() must be called before the connection is made active (i.e.,
|
* This function is called as part of the implementation of sendto
|
||||||
* is eligible for callbacks.
|
* and recvfrom.
|
||||||
*
|
*
|
||||||
* addr The address of the remote host.
|
* Input Parameters:
|
||||||
|
* conn - A reference to UDP connection structure
|
||||||
|
* addr - The address of the remote host.
|
||||||
*
|
*
|
||||||
* Assumptions:
|
* Assumptions:
|
||||||
* This function is called user code. Interrupts may be enabled.
|
* This function is called user code. Interrupts may be enabled.
|
||||||
|
Loading…
Reference in New Issue
Block a user