summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-07-05 13:59:22 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-07-05 13:59:22 -0600
commit38bcf8b809ca54b970a179d42051b7e57e655bf4 (patch)
tree24be334c43ac60b1e5d9d42bc6ddee1c643c434d
parentbcde33e42fcaf628825fe4305a9276c18ebb5160 (diff)
downloadpx4-nuttx-38bcf8b809ca54b970a179d42051b7e57e655bf4.tar.gz
px4-nuttx-38bcf8b809ca54b970a179d42051b7e57e655bf4.tar.bz2
px4-nuttx-38bcf8b809ca54b970a179d42051b7e57e655bf4.zip
NET: Most of the contents of include/nuttx/net/pkt.h moved to net/pkt/pkt.h
-rw-r--r--nuttx/include/nuttx/net/netstats.h3
-rw-r--r--nuttx/include/nuttx/net/pkt.h41
-rw-r--r--nuttx/net/pkt/pkt.h123
-rw-r--r--nuttx/net/pkt/pkt_callback.c1
-rw-r--r--nuttx/net/pkt/pkt_conn.c4
-rw-r--r--nuttx/net/pkt/pkt_poll.c1
-rw-r--r--nuttx/net/pkt/pkt_send.c1
-rw-r--r--nuttx/net/socket/bind.c2
-rw-r--r--nuttx/net/socket/net_close.c1
-rw-r--r--nuttx/net/socket/recvfrom.c2
-rw-r--r--nuttx/net/socket/socket.c1
11 files changed, 128 insertions, 52 deletions
diff --git a/nuttx/include/nuttx/net/netstats.h b/nuttx/include/nuttx/net/netstats.h
index e5d96bf95..a624360dc 100644
--- a/nuttx/include/nuttx/net/netstats.h
+++ b/nuttx/include/nuttx/net/netstats.h
@@ -50,9 +50,6 @@
#include <nuttx/net/netconfig.h>
-#ifdef CONFIG_NET_PKT
-# include <nuttx/net/pkt.h>
-#endif
#ifdef CONFIG_NET_TCP
# include <nuttx/net/tcp.h>
#endif
diff --git a/nuttx/include/nuttx/net/pkt.h b/nuttx/include/nuttx/net/pkt.h
index 55e04db51..2c3515eb0 100644
--- a/nuttx/include/nuttx/net/pkt.h
+++ b/nuttx/include/nuttx/net/pkt.h
@@ -46,32 +46,12 @@
#include <nuttx/config.h>
-#include <stdint.h>
-#include <queue.h>
-
#include <nuttx/net/netconfig.h>
/****************************************************************************
* Public Type Definitions
****************************************************************************/
-/* Representation of a uIP packet socket connection */
-
-struct devif_callback_s; /* Forward reference */
-
-struct pkt_conn_s
-{
- dq_entry_t node; /* Supports a double linked list */
- uint8_t lmac[6]; /* The local Ethernet address in network byte order */
- uint8_t ifindex;
- uint16_t proto;
- uint8_t crefs; /* Reference counts on this instance */
-
- /* Defines the list of packet callbacks */
-
- struct devif_callback_s *list;
-};
-
/****************************************************************************
* Public Data
****************************************************************************/
@@ -79,25 +59,12 @@ struct pkt_conn_s
/****************************************************************************
* 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 pkt_conn_s *pkt_alloc(void);
-
-/* Free a connection structure that is no longer in use. This should
- * be done by the implementation of close()
+/* This function provides the interface between Ethernet device drivers and
+ * packet socket logic. All frames that are received should be provided to
+ * pkt_input() prior to other routing.
*/
-void pkt_free(FAR struct pkt_conn_s *conn);
-void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn);
+struct net_driver_s; /* Forward reference */
int pkt_input(FAR struct net_driver_s *dev);
#endif /* __INCLUDE_NUTTX_NET_PKT_H */
diff --git a/nuttx/net/pkt/pkt.h b/nuttx/net/pkt/pkt.h
index dee1fecbf..61fd45387 100644
--- a/nuttx/net/pkt/pkt.h
+++ b/nuttx/net/pkt/pkt.h
@@ -59,6 +59,23 @@
* Public Type Definitions
****************************************************************************/
+/* Representation of a uIP packet socket connection */
+
+struct devif_callback_s; /* Forward reference */
+
+struct pkt_conn_s
+{
+ dq_entry_t node; /* Supports a double linked list */
+ uint8_t lmac[6]; /* The local Ethernet address in network byte order */
+ uint8_t ifindex;
+ uint16_t proto;
+ uint8_t crefs; /* Reference counts on this instance */
+
+ /* Defines the list of packet callbacks */
+
+ struct devif_callback_s *list;
+};
+
/****************************************************************************
* Public Data
****************************************************************************/
@@ -76,24 +93,127 @@ extern "C"
****************************************************************************/
struct eth_hdr_s; /* Forward reference */
-struct pkt_conn_s; /* Forward refernce */
/* Defined in pkt_conn.c ****************************************************/
+/****************************************************************************
+ * Name: pkt_initialize()
+ *
+ * Description:
+ * Initialize the packet socket connection structures. Called once and
+ * only from the UIP layer.
+ *
+ ****************************************************************************/
void pkt_initialize(void);
+
+/****************************************************************************
+ * Name: pkt_palloc()
+ *
+ * Description:
+ * Allocate a new, uninitialized packet socket connection structure. This
+ * is normally something done by the implementation of the socket() API
+ *
+ ****************************************************************************/
+
FAR struct pkt_conn_s *pkt_alloc(void);
+
+/****************************************************************************
+ * Name: pkt_free()
+ *
+ * Description:
+ * Free a packet socket connection structure that is no longer in use.
+ * This should be done by the implementation of close().
+ *
+ ****************************************************************************/
+
void pkt_free(FAR struct pkt_conn_s *conn);
+
+/****************************************************************************
+ * Name: pkt_active()
+ *
+ * Description:
+ * Find a connection structure that is the appropriate
+ * connection to be used with the provided Ethernet header
+ *
+ * Assumptions:
+ * This function is called from UIP logic at interrupt level
+ *
+ ****************************************************************************/
+
struct pkt_conn_s *pkt_active(FAR struct eth_hdr_s *buf);
+
+/****************************************************************************
+ * Name: pkt_nextconn()
+ *
+ * Description:
+ * Traverse the list of allocated packet connections
+ *
+ * Assumptions:
+ * This function is called from UIP logic at interrupt level (or with
+ * interrupts disabled).
+ *
+ ****************************************************************************/
+
struct pkt_conn_s *pkt_nextconn(FAR struct pkt_conn_s *conn);
/* Defined in pkt_callback.c ************************************************/
+/****************************************************************************
+ * Function: pkt_callback
+ *
+ * Description:
+ * Inform the application holding the packet 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 pkt_callback(FAR struct net_driver_s *dev,
FAR struct pkt_conn_s *conn, uint16_t flags);
/* Defined in pkt_input.c ***************************************************/
+/****************************************************************************
+ * Name: pkt_input
+ *
+ * Description:
+ * Handle incoming packet input
+ *
+ * Parameters:
+ * dev - The device driver structure containing the received 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 recv in place to catch the packet yet.
+ *
+ * Assumptions:
+ * Called from the interrupt level or with interrupts disabled.
+ *
+ ****************************************************************************/
+
+/* pkt_input() is prototyped in include/nuttx/net/pkt.h */
/* Defined in pkt_poll.c ****************************************************/
+/****************************************************************************
+ * Name: pkt_poll
+ *
+ * Description:
+ * Poll a packet "connection" structure for availability of TX data
+ *
+ * Parameters:
+ * dev - The device driver structure to use in the send operation
+ * conn - The packet "connection" to poll for TX data
+ *
+ * Return:
+ * None
+ *
+ * Assumptions:
+ * Called from the interrupt level or with interrupts disabled.
+ *
+ ****************************************************************************/
void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn);
@@ -158,7 +278,6 @@ struct socket;
ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
size_t len);
-
#undef EXTERN
#ifdef __cplusplus
}
diff --git a/nuttx/net/pkt/pkt_callback.c b/nuttx/net/pkt/pkt_callback.c
index dcc9e2c59..443cc8acc 100644
--- a/nuttx/net/pkt/pkt_callback.c
+++ b/nuttx/net/pkt/pkt_callback.c
@@ -45,7 +45,6 @@
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
-#include <nuttx/net/pkt.h>
#include "devif/devif.h"
#include "pkt/pkt.h"
diff --git a/nuttx/net/pkt/pkt_conn.c b/nuttx/net/pkt/pkt_conn.c
index 471de1d3b..50a71c0c8 100644
--- a/nuttx/net/pkt/pkt_conn.c
+++ b/nuttx/net/pkt/pkt_conn.c
@@ -54,7 +54,6 @@
#include <nuttx/net/net.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/arp.h>
-#include <nuttx/net/pkt.h>
#include "devif/devif.h"
#include "pkt/pkt.h"
@@ -139,7 +138,8 @@ void pkt_initialize(void)
* Name: pkt_palloc()
*
* Description:
- * Alloc a new, uninitialized packet socket connection structure.
+ * Allocate a new, uninitialized packet socket connection structure. This
+ * is normally something done by the implementation of the socket() API
*
****************************************************************************/
diff --git a/nuttx/net/pkt/pkt_poll.c b/nuttx/net/pkt/pkt_poll.c
index 4701456be..130ca5a94 100644
--- a/nuttx/net/pkt/pkt_poll.c
+++ b/nuttx/net/pkt/pkt_poll.c
@@ -50,7 +50,6 @@
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/udp.h>
-#include <nuttx/net/pkt.h>
#include "devif/devif.h"
#include "pkt/pkt.h"
diff --git a/nuttx/net/pkt/pkt_send.c b/nuttx/net/pkt/pkt_send.c
index 1d3f94f7f..5e548fcef 100644
--- a/nuttx/net/pkt/pkt_send.c
+++ b/nuttx/net/pkt/pkt_send.c
@@ -56,7 +56,6 @@
#include <nuttx/net/net.h>
#include <nuttx/net/arp.h>
#include <nuttx/net/ip.h>
-#include <nuttx/net/pkt.h>
#include "netdev/netdev.h"
#include "devif/devif.h"
diff --git a/nuttx/net/socket/bind.c b/nuttx/net/socket/bind.c
index f399d3c99..2a6739dd5 100644
--- a/nuttx/net/socket/bind.c
+++ b/nuttx/net/socket/bind.c
@@ -51,12 +51,12 @@
#include <nuttx/net/tcp.h>
#include <nuttx/net/udp.h>
-#include <nuttx/net/pkt.h>
#include "socket/socket.h"
#include "netdev/netdev.h"
#include "tcp/tcp.h"
#include "udp/udp.h"
+#include "pkt/pkt.h"
/****************************************************************************
* Private Functions
diff --git a/nuttx/net/socket/net_close.c b/nuttx/net/socket/net_close.c
index 503dbab15..0fe973c0e 100644
--- a/nuttx/net/socket/net_close.c
+++ b/nuttx/net/socket/net_close.c
@@ -52,7 +52,6 @@
#include <nuttx/net/netdev.h>
#include <nuttx/net/tcp.h>
#include <nuttx/net/udp.h>
-#include <nuttx/net/pkt.h>
#ifdef CONFIG_NET_SOLINGER
# include <nuttx/clock.h>
diff --git a/nuttx/net/socket/recvfrom.c b/nuttx/net/socket/recvfrom.c
index fbf03f9c7..388281a28 100644
--- a/nuttx/net/socket/recvfrom.c
+++ b/nuttx/net/socket/recvfrom.c
@@ -61,7 +61,6 @@
#include <nuttx/net/ip.h>
#include <nuttx/net/tcp.h>
#include <nuttx/net/udp.h>
-#include <nuttx/net/pkt.h>
#include "netdev/netdev.h"
#include "devif/devif.h"
@@ -70,7 +69,6 @@
#include "pkt/pkt.h"
#include "socket/socket.h"
-
/****************************************************************************
* Definitions
****************************************************************************/
diff --git a/nuttx/net/socket/socket.c b/nuttx/net/socket/socket.c
index 2c7e7a071..f9af58fd1 100644
--- a/nuttx/net/socket/socket.c
+++ b/nuttx/net/socket/socket.c
@@ -47,7 +47,6 @@
#include <nuttx/net/tcp.h>
#include <nuttx/net/udp.h>
-#include <nuttx/net/pkt.h>
#include "socket/socket.h"
#include "tcp/tcp.h"