mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
Raw sockets: Additional changes for error-free/warning-free compilation
This commit is contained in:
@@ -55,7 +55,7 @@ struct sockaddr_ll
|
|||||||
{
|
{
|
||||||
uint16_t sll_family;
|
uint16_t sll_family;
|
||||||
uint16_t sll_protocol;
|
uint16_t sll_protocol;
|
||||||
sint16_t sll_ifindex;
|
int16_t sll_ifindex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __INCLUDE_NETPACKET_PACKET_H */
|
#endif /* __INCLUDE_NETPACKET_PACKET_H */
|
||||||
|
|||||||
+23
-19
@@ -83,25 +83,6 @@ config NET_SOLINGER
|
|||||||
|
|
||||||
endif # NET_SOCKOPTS
|
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
|
config NET_BUFSIZE
|
||||||
int "Network packet buffer size (MTU)"
|
int "Network packet buffer size (MTU)"
|
||||||
default 1294 if !NET_SLIP && NET_IPv6
|
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
|
compiled in. Urgent data (out-of-band data) is a rarely used TCP feature
|
||||||
that is very seldom would be required.
|
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"
|
menu "TCP/IP Networking"
|
||||||
|
|
||||||
config NET_TCP
|
config NET_TCP
|
||||||
|
|||||||
+21
-10
@@ -160,19 +160,30 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
|
|||||||
|
|
||||||
/* Verify that a valid address has been provided */
|
/* Verify that a valid address has been provided */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
if (
|
||||||
if ((addr->sa_family != AF_PACKET && addr->sa_family != AF_INET6) ||
|
(
|
||||||
(addr->sa_family == AF_PACKET && addrlen < sizeof(struct sockaddr_ll)) ||
|
#if defined(CONFIG_NET_PKT)
|
||||||
(addr->sa_family == AF_INET6 && addrlen < sizeof(struct sockaddr_in6)))
|
addr->sa_family != AF_PACKET &&
|
||||||
#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)))
|
|
||||||
#endif
|
#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;
|
err = EBADF;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform the binding depending on the protocol type */
|
/* Perform the binding depending on the protocol type */
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ static ssize_t pktsend(FAR struct socket *psock, FAR const void *buf,
|
|||||||
struct send_s state;
|
struct send_s state;
|
||||||
uip_lock_t save;
|
uip_lock_t save;
|
||||||
int err;
|
int err;
|
||||||
int ret;
|
int ret = OK;
|
||||||
|
|
||||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -558,7 +558,8 @@ static uint16_t recvfrom_pktinterrupt(FAR struct uip_driver_s *dev,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_TCP
|
#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
|
#ifdef CONFIG_NET_IPv6
|
||||||
FAR struct sockaddr_in6 *infrom = pstate->rf_from;
|
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;
|
ret = -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* Not used */
|
||||||
errout_with_state:
|
errout_with_state:
|
||||||
|
#endif
|
||||||
uip_unlock(save);
|
uip_unlock(save);
|
||||||
recvfrom_uninit(&state);
|
recvfrom_uninit(&state);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1521,7 +1524,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ndbg("ERROR: Unsupported socket type: %d\n", psock->s_type
|
ndbg("ERROR: Unsupported socket type: %d\n", psock->s_type);
|
||||||
ret = -ENOSYS;
|
ret = -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,33 +102,6 @@ static inline void _uip_semtake(sem_t *sem)
|
|||||||
|
|
||||||
#define _uip_semgive(sem) sem_post(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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user