Raw sockets: Additional changes for error-free/warning-free compilation

This commit is contained in:
Gregory Nutt 2014-06-12 12:29:58 -06:00
parent faaf641490
commit bf8f8d3937
6 changed files with 51 additions and 60 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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)))
#else
if ((addr->sa_family != AF_PACKET && addr->sa_family != AF_INET) ||
(addr->sa_family == AF_PACKET && addrlen < sizeof(struct sockaddr_ll)) ||
(addr->sa_family == AF_INET && addrlen < sizeof(struct sockaddr_in)))
if (
(
#if defined(CONFIG_NET_PKT)
addr->sa_family != AF_PACKET &&
#endif
{
#if defined(CONFIG_NET_IPv6)
addr->sa_family != AF_INET6
#else
addr->sa_family != AF_INET
#endif
) ||
#if defined(CONFIG_NET_PKT)
(addr->sa_family == AF_PACKET && addrlen < sizeof(struct sockaddr_ll)) ||
#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 */

View File

@ -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 */

View File

@ -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;
}

View File

@ -102,33 +102,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
****************************************************************************/