summaryrefslogtreecommitdiff
path: root/nuttx/net/udp
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-07-05 14:40:29 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-07-05 14:40:29 -0600
commitf825004170beb88dec1993ae6514e8307b9ef0fa (patch)
treed99ccb381765aaabc7eec0a75b8f779a492d1171 /nuttx/net/udp
parent38bcf8b809ca54b970a179d42051b7e57e655bf4 (diff)
downloadnuttx-f825004170beb88dec1993ae6514e8307b9ef0fa.tar.gz
nuttx-f825004170beb88dec1993ae6514e8307b9ef0fa.tar.bz2
nuttx-f825004170beb88dec1993ae6514e8307b9ef0fa.zip
NET: Most of the contents of include/nuttx/net/udp.h moved to net/pkt/udp.h
Diffstat (limited to 'nuttx/net/udp')
-rw-r--r--nuttx/net/udp/udp.h193
-rw-r--r--nuttx/net/udp/udp_conn.c14
2 files changed, 198 insertions, 9 deletions
diff --git a/nuttx/net/udp/udp.h b/nuttx/net/udp/udp.h
index 6d2c636b0..fd46eb310 100644
--- a/nuttx/net/udp/udp.h
+++ b/nuttx/net/udp/udp.h
@@ -59,6 +59,24 @@
* 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
****************************************************************************/
@@ -75,28 +93,197 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
-/* Defined in udp_conn.c ****************************************************/
-
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);
+
+/****************************************************************************
+ * 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);
+
+/****************************************************************************
+ * 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);
+/****************************************************************************
+ * 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 ****************************************************/
+/****************************************************************************
+ * 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);
/* 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);
/* 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);
/* 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,
FAR struct udp_conn_s *conn, uint16_t flags);
diff --git a/nuttx/net/udp/udp_conn.c b/nuttx/net/udp/udp_conn.c
index 51c9a1fc5..ffe8cb1a8 100644
--- a/nuttx/net/udp/udp_conn.c
+++ b/nuttx/net/udp/udp_conn.c
@@ -230,7 +230,8 @@ void udp_initialize(void)
* Name: udp_alloc()
*
* 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:
* 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
- * previously called.
+ * done by the implementation of close().
*
****************************************************************************/
@@ -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
* called.
*
- * udp_enable() must be called before the connection is made active (i.e.,
- * is eligible for callbacks.
+ * This function is called as part of the implementation of sendto
+ * 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:
* This function is called user code. Interrupts may be enabled.