summaryrefslogtreecommitdiff
path: root/nuttx/net/udp/udp.h
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/net/udp/udp.h')
-rw-r--r--nuttx/net/udp/udp.h193
1 files changed, 190 insertions, 3 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);