summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-06-12 12:29:58 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-06-12 12:29:58 -0600
commit892dd7a41ab29d8c10ec6f3a8d192c69deb72db8 (patch)
tree36dec6c2ba96c25758f46aa71956695be69f6a4d
parentd5184409f5bef547f8d784dfbb548e9330099d71 (diff)
downloadnuttx-892dd7a41ab29d8c10ec6f3a8d192c69deb72db8.tar.gz
nuttx-892dd7a41ab29d8c10ec6f3a8d192c69deb72db8.tar.bz2
nuttx-892dd7a41ab29d8c10ec6f3a8d192c69deb72db8.zip
Raw sockets: Additional changes for error-free/warning-free compilation
-rw-r--r--apps/examples/netpkt/.gitignore11
-rw-r--r--nuttx/include/netpacket/packet.h2
-rw-r--r--nuttx/net/Kconfig42
-rw-r--r--nuttx/net/bind.c27
-rw-r--r--nuttx/net/net_send_unbuffered.c2
-rw-r--r--nuttx/net/recvfrom.c7
-rw-r--r--nuttx/net/uip/uip_pktconn.c27
7 files changed, 60 insertions, 58 deletions
diff --git a/apps/examples/netpkt/.gitignore b/apps/examples/netpkt/.gitignore
new file mode 100644
index 000000000..fa1ec7579
--- /dev/null
+++ b/apps/examples/netpkt/.gitignore
@@ -0,0 +1,11 @@
+/Make.dep
+/.depend
+/.built
+/*.asm
+/*.obj
+/*.rel
+/*.lst
+/*.sym
+/*.adb
+/*.lib
+/*.src
diff --git a/nuttx/include/netpacket/packet.h b/nuttx/include/netpacket/packet.h
index be9076e65..522464ca6 100644
--- a/nuttx/include/netpacket/packet.h
+++ b/nuttx/include/netpacket/packet.h
@@ -55,7 +55,7 @@ struct sockaddr_ll
{
uint16_t sll_family;
uint16_t sll_protocol;
- sint16_t sll_ifindex;
+ int16_t sll_ifindex;
};
#endif /* __INCLUDE_NETPACKET_PACKET_H */
diff --git a/nuttx/net/Kconfig b/nuttx/net/Kconfig
index 0a5944b7f..b251be951 100644
--- a/nuttx/net/Kconfig
+++ b/nuttx/net/Kconfig
@@ -83,25 +83,6 @@ config NET_SOLINGER
endif # NET_SOCKOPTS
-config NET_PKT
- bool "Socket packet socket support"
- default n
- ---help---
- Enable or disbale support for packet sockets.
- Packet sockets allow receiving and transmitting frames without
- a transport protocol in between. Frames received are copied into
- a packet socket tap before they enter uIP. Data written into a
- packet socket will bypass uIP altogether and be placed in the
- transmission buffer of the network interface driver.
-
-if NET_PKT
-
-config NET_PKT_CONNS
- int "Max packet sockets"
- default 1
-
-endif # NET_PKT
-
config NET_BUFSIZE
int "Network packet buffer size (MTU)"
default 1294 if !NET_SLIP && NET_IPv6
@@ -129,6 +110,29 @@ config NET_TCPURGDATA
compiled in. Urgent data (out-of-band data) is a rarely used TCP feature
that is very seldom would be required.
+menu "Raw Socket Support"
+
+config NET_PKT
+ bool "Socket packet socket support"
+ default n
+ ---help---
+ Enable or disable support for packet sockets.
+
+ Packet sockets allow receiving and transmitting frames without
+ a transport protocol in between. Frames received are copied into
+ a packet socket tap before they enter uIP. Data written into a
+ packet socket will bypass uIP altogether and be placed in the
+ transmission buffer of the network interface driver.
+
+if NET_PKT
+
+config NET_PKT_CONNS
+ int "Max packet sockets"
+ default 1
+
+endif # NET_PKT
+endmenu # Packet Sockets
+
menu "TCP/IP Networking"
config NET_TCP
diff --git a/nuttx/net/bind.c b/nuttx/net/bind.c
index 6de8443f8..48e0ad3af 100644
--- a/nuttx/net/bind.c
+++ b/nuttx/net/bind.c
@@ -160,19 +160,30 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
/* Verify that a valid address has been provided */
-#ifdef CONFIG_NET_IPv6
- if ((addr->sa_family != AF_PACKET && addr->sa_family != AF_INET6) ||
- (addr->sa_family == AF_PACKET && addrlen < sizeof(struct sockaddr_ll)) ||
- (addr->sa_family == AF_INET6 && addrlen < sizeof(struct sockaddr_in6)))
+ if (
+ (
+#if defined(CONFIG_NET_PKT)
+ addr->sa_family != AF_PACKET &&
+#endif
+#if defined(CONFIG_NET_IPv6)
+ addr->sa_family != AF_INET6
#else
- if ((addr->sa_family != AF_PACKET && addr->sa_family != AF_INET) ||
+ addr->sa_family != AF_INET
+#endif
+ ) ||
+#if defined(CONFIG_NET_PKT)
(addr->sa_family == AF_PACKET && addrlen < sizeof(struct sockaddr_ll)) ||
- (addr->sa_family == AF_INET && addrlen < sizeof(struct sockaddr_in)))
#endif
- {
+#if defined(CONFIG_NET_IPv6)
+ (addr->sa_family == AF_INET6 && addrlen < sizeof(struct sockaddr_in6))
+#else
+ (addr->sa_family == AF_INET && addrlen < sizeof(struct sockaddr_in))
+#endif
+ )
+ {
err = EBADF;
goto errout;
- }
+ }
/* Perform the binding depending on the protocol type */
diff --git a/nuttx/net/net_send_unbuffered.c b/nuttx/net/net_send_unbuffered.c
index bcf40b72e..375e362c5 100644
--- a/nuttx/net/net_send_unbuffered.c
+++ b/nuttx/net/net_send_unbuffered.c
@@ -228,7 +228,7 @@ static ssize_t pktsend(FAR struct socket *psock, FAR const void *buf,
struct send_s state;
uip_lock_t save;
int err;
- int ret;
+ int ret = OK;
/* Verify that the sockfd corresponds to valid, allocated socket */
diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c
index aaf6b9236..efe8fe272 100644
--- a/nuttx/net/recvfrom.c
+++ b/nuttx/net/recvfrom.c
@@ -558,7 +558,8 @@ static uint16_t recvfrom_pktinterrupt(FAR struct uip_driver_s *dev,
****************************************************************************/
#ifdef CONFIG_NET_TCP
-static inline void recvfrom_tcpsender(struct uip_driver_s *dev, struct recvfrom_s *pstate)
+static inline void recvfrom_tcpsender(FAR struct uip_driver_s *dev,
+ FAR struct recvfrom_s *pstate)
{
#ifdef CONFIG_NET_IPv6
FAR struct sockaddr_in6 *infrom = pstate->rf_from;
@@ -1101,7 +1102,9 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
ret = -EBUSY;
}
+#if 0 /* Not used */
errout_with_state:
+#endif
uip_unlock(save);
recvfrom_uninit(&state);
return ret;
@@ -1521,7 +1524,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
else
#endif
{
- ndbg("ERROR: Unsupported socket type: %d\n", psock->s_type
+ ndbg("ERROR: Unsupported socket type: %d\n", psock->s_type);
ret = -ENOSYS;
}
diff --git a/nuttx/net/uip/uip_pktconn.c b/nuttx/net/uip/uip_pktconn.c
index 2bca680a1..7990cb6e9 100644
--- a/nuttx/net/uip/uip_pktconn.c
+++ b/nuttx/net/uip/uip_pktconn.c
@@ -103,33 +103,6 @@ static inline void _uip_semtake(sem_t *sem)
#define _uip_semgive(sem) sem_post(sem)
/****************************************************************************
- * Name: uip_find_conn()
- *
- * Description:
- * Find the packet socket connection that uses this interface index
- * number. Called only from user user level code, but with interrupts
- * disabled.
- *
- ****************************************************************************/
-
-static struct uip_pkt_conn *uip_find_conn(uint8_t ifindex)
-{
- int i;
-
- /* Now search each connection structure. */
-
- for (i = 0; i < CONFIG_NET_PKT_CONNS; i++)
- {
- if (g_pkt_connections[ i ].ifindex == ifindex)
- {
- return &g_pkt_connections[ i ];
- }
- }
-
- return NULL;
-}
-
-/****************************************************************************
* Public Functions
****************************************************************************/