diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-11-22 18:36:46 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-11-22 18:36:46 +0000 |
commit | c5148ad9e5d0c44c891f843bc7927bdcce0aee1a (patch) | |
tree | 6f54ddc25051c52d0ce5226bfac63c0054137b7c /nuttx/net | |
parent | 7d4b2f6253d8ac898def6839b2ccc2ae61e24135 (diff) | |
download | nuttx-c5148ad9e5d0c44c891f843bc7927bdcce0aee1a.tar.gz nuttx-c5148ad9e5d0c44c891f843bc7927bdcce0aee1a.tar.bz2 nuttx-c5148ad9e5d0c44c891f843bc7927bdcce0aee1a.zip |
TCP and ICMP protocols may now be disabled
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@398 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/Makefile | 8 | ||||
-rw-r--r-- | nuttx/net/accept.c | 4 | ||||
-rw-r--r-- | nuttx/net/bind.c | 7 | ||||
-rw-r--r-- | nuttx/net/connect.c | 22 | ||||
-rw-r--r-- | nuttx/net/net-close.c | 3 | ||||
-rw-r--r-- | nuttx/net/recvfrom.c | 34 | ||||
-rw-r--r-- | nuttx/net/send.c | 4 | ||||
-rw-r--r-- | nuttx/net/socket.c | 67 | ||||
-rw-r--r-- | nuttx/net/uip/Make.defs | 16 | ||||
-rw-r--r-- | nuttx/net/uip/uip-arp.c | 6 | ||||
-rw-r--r-- | nuttx/net/uip/uip-chksum.c | 2 | ||||
-rw-r--r-- | nuttx/net/uip/uip-initialize.c | 4 | ||||
-rw-r--r-- | nuttx/net/uip/uip-input.c | 11 | ||||
-rw-r--r-- | nuttx/net/uip/uip-internal.h | 21 | ||||
-rw-r--r-- | nuttx/net/uip/uip-poll.c | 8 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpappsend.c | 4 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpcallback.c | 4 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpconn.c | 4 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpinput.c | 7 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcppoll.c | 4 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpreadahead.c | 4 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpsend.c | 4 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcptimer.c | 4 |
23 files changed, 172 insertions, 80 deletions
diff --git a/nuttx/net/Makefile b/nuttx/net/Makefile index e429d6236..082b0a0d7 100644 --- a/nuttx/net/Makefile +++ b/nuttx/net/Makefile @@ -40,8 +40,12 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh ifeq ($(CONFIG_NET),y) SOCK_ASRCS = -SOCK_CSRCS = socket.c bind.c connect.c listen.c accept.c send.c sendto.c \ - recv.c recvfrom.c net-sockets.c net-close.c +SOCK_CSRCS = socket.c bind.c connect.c sendto.c recv.c recvfrom.c \ + net-sockets.c net-close.c + +ifeq ($(CONFIG_NET_TCP),y) +SOCK_CSRCS += send.c listen.c accept.c +endif ifeq ($(CONFIG_NET_SOCKOPTS),y) SOCK_CSRCS += setsockopt.c getsockopt.c diff --git a/nuttx/net/accept.c b/nuttx/net/accept.c index 02557d6fc..a348953f6 100644 --- a/nuttx/net/accept.c +++ b/nuttx/net/accept.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 +#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <sys/socket.h> @@ -354,4 +354,4 @@ errout: return ERROR; } -#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ +#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS && CONFIG_NET_TCP*/ diff --git a/nuttx/net/bind.c b/nuttx/net/bind.c index f5d36a9f1..d75245c8a 100644 --- a/nuttx/net/bind.c +++ b/nuttx/net/bind.c @@ -85,11 +85,15 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { FAR struct socket *psock = sockfd_socket(sockfd); + +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP) #ifdef CONFIG_NET_IPv6 FAR const struct sockaddr_in6 *inaddr = (const struct sockaddr_in6 *)addr; #else FAR const struct sockaddr_in *inaddr = (const struct sockaddr_in *)addr; #endif +#endif + int err; int ret; @@ -117,16 +121,19 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) switch (psock->s_type) { +#ifdef CONFIG_NET_TCP case SOCK_STREAM: ret = uip_tcpbind(psock->s_conn, inaddr); psock->s_flags |= _SF_BOUND; break; +#endif #ifdef CONFIG_NET_UDP case SOCK_DGRAM: ret = uip_udpbind(psock->s_conn, inaddr); break; #endif + default: err = EBADF; goto errout; diff --git a/nuttx/net/connect.c b/nuttx/net/connect.c index d4f40b30f..c0c722e99 100644 --- a/nuttx/net/connect.c +++ b/nuttx/net/connect.c @@ -54,17 +54,20 @@ * Private Types ****************************************************************************/ +#ifdef CONFIG_NET_TCP struct tcp_connect_s { FAR struct uip_conn *tc_conn; /* Reference to TCP connection structure */ sem_t tc_sem; /* Semaphore signals recv completion */ int tc_result; /* OK on success, otherwise a negated errno. */ }; +#endif /**************************************************************************** * Private Function Prototypes ****************************************************************************/ +#ifdef CONFIG_NET_TCP static void connection_event(struct uip_conn *conn, uint8 flags); static inline void tcp_setup_callbacks(struct uip_conn *conn, FAR struct socket *psock, FAR struct tcp_connect_s *pstate); @@ -76,6 +79,7 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in #else static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in *inaddr); #endif +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Private Functions @@ -99,6 +103,7 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in * ****************************************************************************/ +#ifdef CONFIG_NET_TCP static void connection_event(struct uip_conn *conn, uint8 flags) { FAR struct socket *psock = (FAR struct socket *)conn->connection_private; @@ -128,11 +133,13 @@ static void connection_event(struct uip_conn *conn, uint8 flags) } } } +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Function: tcp_setup_callbacks ****************************************************************************/ +#ifdef CONFIG_NET_TCP static inline void tcp_setup_callbacks(struct uip_conn *conn, FAR struct socket *psock, FAR struct tcp_connect_s *pstate) { @@ -146,11 +153,13 @@ static inline void tcp_setup_callbacks(struct uip_conn *conn, FAR struct socket conn->connection_private = (void*)psock; conn->connection_event = connection_event; } +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Function: tcp_teardown_callbacks ****************************************************************************/ +#ifdef CONFIG_NET_TCP static inline void tcp_teardown_callbacks(struct uip_conn *conn, int status) { /* Make sure that no further interrupts are processed */ @@ -170,6 +179,7 @@ static inline void tcp_teardown_callbacks(struct uip_conn *conn, int status) conn->connection_event = NULL; } } +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Function: tcp_connect_interrupt @@ -191,6 +201,7 @@ static inline void tcp_teardown_callbacks(struct uip_conn *conn, int status) * ****************************************************************************/ +#ifdef CONFIG_NET_TCP static uint8 tcp_connect_interrupt(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags) { @@ -262,6 +273,7 @@ static uint8 tcp_connect_interrupt(struct uip_driver_s *dev, return flags; } +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Function: tcp_connect @@ -281,6 +293,7 @@ static uint8 tcp_connect_interrupt(struct uip_driver_s *dev, * ****************************************************************************/ +#ifdef CONFIG_NET_TCP #ifdef CONFIG_NET_IPv6 static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in6 *inaddr) #else @@ -367,6 +380,7 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in irqrestore(flags); return ret; } +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Public Functions @@ -443,13 +457,17 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { FAR struct socket *psock = sockfd_socket(sockfd); + +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP) #ifdef CONFIG_NET_IPv6 FAR const struct sockaddr_in6 *inaddr = (const struct sockaddr_in6 *)addr; #else FAR const struct sockaddr_in *inaddr = (const struct sockaddr_in *)addr; #endif - int err; int ret; +#endif + + int err; /* Verify that the sockfd corresponds to valid, allocated socket */ @@ -475,6 +493,7 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) switch (psock->s_type) { +#ifdef CONFIG_NET_TCP case SOCK_STREAM: { /* Verify that the socket is not already connected */ @@ -495,6 +514,7 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) } } break; +#endif #ifdef CONFIG_NET_UDP case SOCK_DGRAM: diff --git a/nuttx/net/net-close.c b/nuttx/net/net-close.c index c06e635d1..76dd7693f 100644 --- a/nuttx/net/net-close.c +++ b/nuttx/net/net-close.c @@ -83,6 +83,7 @@ int net_close(int sockfd) switch (psock->s_type) { +#ifdef CONFIG_NET_TCP case SOCK_STREAM: { struct uip_conn *conn = psock->s_conn; @@ -90,12 +91,14 @@ int net_close(int sockfd) uip_tcpfree(conn); } break; +#endif #ifdef CONFIG_NET_UDP case SOCK_DGRAM: uip_udpfree(psock->s_conn); break; #endif + default: err = -EBADF; goto errout; diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index 906b5aa6e..0d4e1bf30 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -63,6 +63,7 @@ * Private Types ****************************************************************************/ +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP) struct recvfrom_s { #if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) @@ -75,6 +76,7 @@ struct recvfrom_s size_t rf_recvlen; /* The received length */ int rf_result; /* OK on success, otherwise a negated errno. */ }; +#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */ /**************************************************************************** * Private Functions @@ -98,6 +100,7 @@ struct recvfrom_s * ****************************************************************************/ +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP) static void recvfrom_newdata(struct uip_driver_s *dev, struct recvfrom_s *pstate) { size_t recvlen; @@ -128,6 +131,7 @@ static void recvfrom_newdata(struct uip_driver_s *dev, struct recvfrom_s *pstate dev->d_len = 0; } +#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */ /**************************************************************************** * Function: recvfrom_readahead @@ -147,7 +151,7 @@ static void recvfrom_newdata(struct uip_driver_s *dev, struct recvfrom_s *pstate * ****************************************************************************/ -#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 +#if defined(CONFIG_NET_TCP) && CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 static inline void recvfrom_readahead(struct recvfrom_s *pstate) { struct uip_conn *conn = (struct uip_conn *)pstate->rf_sock->s_conn; @@ -214,7 +218,7 @@ static inline void recvfrom_readahead(struct recvfrom_s *pstate) } while (readahead && pstate->rf_buflen > 0); } -#endif +#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */ /**************************************************************************** * Function: recvfrom_timeout @@ -233,6 +237,7 @@ static inline void recvfrom_readahead(struct recvfrom_s *pstate) * ****************************************************************************/ +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP) #if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) static int recvfrom_timeout(struct recvfrom_s *pstate) { @@ -279,6 +284,7 @@ static int recvfrom_timeout(struct recvfrom_s *pstate) return FALSE; } #endif /* CONFIG_NET_SOCKOPTS && !CONFIG_DISABLE_CLOCK */ +#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */ /**************************************************************************** * Function: recvfrom_tcpinterrupt @@ -300,6 +306,7 @@ static int recvfrom_timeout(struct recvfrom_s *pstate) * ****************************************************************************/ +#ifdef CONFIG_NET_TCP static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags) { @@ -406,6 +413,7 @@ static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev, } return flags; } +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Function: recvfrom_udpinterrupt @@ -508,7 +516,7 @@ static void recvfrom_udpinterrupt(struct uip_driver_s *dev, #endif /* CONFIG_NET_SOCKOPTS && !CONFIG_DISABLE_CLOCK */ } } -#endif +#endif /* CONFIG_NET_UDP */ /**************************************************************************** * Function: recvfrom_init @@ -529,6 +537,7 @@ static void recvfrom_udpinterrupt(struct uip_driver_s *dev, * ****************************************************************************/ +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP) static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len, struct recvfrom_s *pstate) { @@ -546,6 +555,7 @@ static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len, pstate->rf_starttime = g_system_timer; #endif } +#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */ /**************************************************************************** * Function: recvfrom_result @@ -564,6 +574,7 @@ static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len, * ****************************************************************************/ +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP) static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate) { int save_errno = *get_errno_ptr(); /* In case something we do changes it */ @@ -594,6 +605,7 @@ static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate) return pstate->rf_recvlen; } +#endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */ /**************************************************************************** * Function: udp_recvfrom @@ -698,6 +710,7 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * ****************************************************************************/ +#ifdef CONFIG_NET_TCP #ifdef CONFIG_NET_IPv6 static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, FAR const struct sockaddr_in6 *infrom ) @@ -766,6 +779,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, #warning "Needs to return server address" return recvfrom_result(ret, &state); } +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Global Functions @@ -827,11 +841,15 @@ ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, FAR struct so FAR socklen_t *fromlen) { FAR struct socket *psock; + +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP) #ifdef CONFIG_NET_IPv6 FAR const struct sockaddr_in6 *infrom = (const struct sockaddr_in6 *)from; #else FAR const struct sockaddr_in *infrom = (const struct sockaddr_in *)from; #endif +#endif + ssize_t ret; int err; @@ -874,17 +892,21 @@ ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, FAR struct so /* Perform the TCP/IP or UDP recv() operation */ -#ifdef CONFIG_NET_UDP +#if defined(CONFIG_NET_UDP) && defined(CONFIG_NET_TCP) if (psock->s_type == SOCK_STREAM) -#endif { ret = tcp_recvfrom(psock, buf, len, infrom); } -#ifdef CONFIG_NET_UDP else { ret = udp_recvfrom(psock, buf, len, infrom); } +#elif defined(CONFIG_NET_TCP) + ret = tcp_recvfrom(psock, buf, len, infrom); +#elif defined(CONFIG_NET_UDP) + ret = udp_recvfrom(psock, buf, len, infrom); +#else + ret = -ENOSYS; #endif /* Set the socket state to idle */ diff --git a/nuttx/net/send.c b/nuttx/net/send.c index 29633b380..6ded49e0e 100644 --- a/nuttx/net/send.c +++ b/nuttx/net/send.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <sys/socket.h> @@ -358,4 +358,4 @@ errout: return ERROR; } -#endif /* CONFIG_NET */ +#endif /* CONFIG_NET && CONFIG_NET_TCP */ diff --git a/nuttx/net/socket.c b/nuttx/net/socket.c index d7c21d01b..644f5a8c2 100644 --- a/nuttx/net/socket.c +++ b/nuttx/net/socket.c @@ -43,6 +43,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <errno.h> +#include <debug.h> #include "net-internal.h" @@ -106,10 +107,12 @@ int socket(int domain, int type, int protocol) /* Only SOCK_STREAM and possible SOCK_DRAM are supported */ -#ifdef CONFIG_NET_UDP +#if defined(CONFIG_NET_UDP) && defined(CONFIG_NET_TCP) if (protocol != 0 || (type != SOCK_STREAM && type != SOCK_DGRAM)) -#else +#elif defined(CONFIG_NET_TCP) if (protocol != 0 || type != SOCK_STREAM) +#elif defined(CONFIG_NET_UDP) + if (protocol != 0 || type != SOCK_DGRAM) #endif { err = EPROTONOSUPPORT; @@ -128,43 +131,49 @@ int socket(int domain, int type, int protocol) /* Initialize the socket structure */ psock = sockfd_socket(sockfd); - if (psock) + if (!psock) { - /* Save the protocol type */ + err = ENOSYS; /* should not happen */ + goto errout; + } + + /* Save the protocol type */ - psock->s_type = type; - psock->s_conn = NULL; + psock->s_type = type; + psock->s_conn = NULL; - /* Allocate the appropriate connection structure. This reserves the - * the connection structure is is unallocated at this point. It will - * not actually be initialized until the socket is connected. - */ + /* Allocate the appropriate connection structure. This reserves the + * the connection structure is is unallocated at this point. It will + * not actually be initialized until the socket is connected. + */ - switch (type) - { - case SOCK_STREAM: - psock->s_conn = uip_tcpalloc(); - break; + switch (type) + { +#ifdef CONFIG_NET_TCP + case SOCK_STREAM: + psock->s_conn = uip_tcpalloc(); + break; +#endif #ifdef CONFIG_NET_UDP - case SOCK_DGRAM: - psock->s_conn = uip_udpalloc(); - break; + case SOCK_DGRAM: + psock->s_conn = uip_udpalloc(); + break; #endif - default: - break; - } - /* Did we succesfully allocate some kind of connection structure? */ + default: + break; + } + + /* Did we succesfully allocate some kind of connection structure? */ - if (!psock->s_conn) - { - /* Failed to reserve a connection structure */ + if (!psock->s_conn) + { + /* Failed to reserve a connection structure */ - sockfd_release(sockfd); - err = ENFILE; - goto errout; - } + sockfd_release(sockfd); + err = ENFILE; + goto errout; } return sockfd; diff --git a/nuttx/net/uip/Make.defs b/nuttx/net/uip/Make.defs index 4256e72e9..c6a7f4d74 100644 --- a/nuttx/net/uip/Make.defs +++ b/nuttx/net/uip/Make.defs @@ -38,10 +38,10 @@ UIP_CSRCS = ifeq ($(CONFIG_NET),y) -# Common network source files +# Common IP source files UIP_CSRCS += uip-initialize.c uip-setipid.c uip-arp.c uip-input.c uip-send.c \ - uip-fw.c uip-split.c uip-poll.c uip-chksum.c + uip-poll.c uip-chksum.c ifeq ($(CONFIG_NET_IPv6),y) UIP_CSRCS += uip-neighbor.c @@ -49,10 +49,19 @@ endif # TCP source files +ifeq ($(CONFIG_NET_TCP),y) + UIP_CSRCS += uip-tcpconn.c uip-tcppoll.c uip-tcptimer.c uip-tcpsend.c \ uip-tcpinput.c uip-tcpappsend.c uip-listen.c uip-tcpcallback.c \ uip-tcpreadahead.c +# Follow can be used to add support for the "uipsplit uIP TCP throughput booster hack" +# but are not currently used + +UIP_CSRCS += uip-fw.c uip-split.c + +endif + # UDP source files ifeq ($(CONFIG_NET_UDP),y) @@ -64,8 +73,11 @@ endif #ICMP source files +ifeq ($(CONFIG_NET_ICMP),y) + UIP_CSRCS += uip-icmpinput.c endif +endif diff --git a/nuttx/net/uip/uip-arp.c b/nuttx/net/uip/uip-arp.c index 4d95d16d3..9b74d0507 100644 --- a/nuttx/net/uip/uip-arp.c +++ b/nuttx/net/uip/uip-arp.c @@ -364,8 +364,8 @@ void uip_arp_arpin(struct uip_driver_s *dev) uiphdr_ipaddr_copy(ARPBUF->ah_sipaddr, &dev->d_ipaddr); uip_arp_dump(ARPBUF); - ETHBUF->type = HTONS(UIP_ETHTYPE_ARP); - dev->d_len = sizeof(struct arp_hdr) + UIP_LLH_LEN; + ETHBUF->type = HTONS(UIP_ETHTYPE_ARP); + dev->d_len = sizeof(struct arp_hdr) + UIP_LLH_LEN; } break; @@ -482,8 +482,6 @@ void uip_arp_out(struct uip_driver_s *dev) uip_arp_dump(ARPBUF); ETHBUF->type = HTONS(UIP_ETHTYPE_ARP); - - dev->d_appdata = &dev->d_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN]; dev->d_len = sizeof(struct arp_hdr) + UIP_LLH_LEN; return; } diff --git a/nuttx/net/uip/uip-chksum.c b/nuttx/net/uip/uip-chksum.c index 6faaf9817..50602f481 100644 --- a/nuttx/net/uip/uip-chksum.c +++ b/nuttx/net/uip/uip-chksum.c @@ -54,7 +54,7 @@ * Definitions ****************************************************************************/ -#define BUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN]) +#define BUF ((struct uip_ip_hdr *)&dev->d_buf[UIP_LLH_LEN]) /**************************************************************************** * Private Data diff --git a/nuttx/net/uip/uip-initialize.c b/nuttx/net/uip/uip-initialize.c index a3338d082..decc60ff8 100644 --- a/nuttx/net/uip/uip-initialize.c +++ b/nuttx/net/uip/uip-initialize.c @@ -116,6 +116,7 @@ void uip_initialize(void) { /* Initialize the listening port structures */ +#ifdef CONFIG_NET_TCP uip_listeninit(); /* Initialize the TCP/IP connection structures */ @@ -127,14 +128,13 @@ void uip_initialize(void) #if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 uip_tcpreadaheadinit(); #endif +#endif /* CONFIG_NET_TCP */ /* Initialize the UDP connection structures */ #ifdef CONFIG_NET_UDP uip_udpinit(); #endif - - /* IPv4 initialization. */ } #endif /* CONFIG_NET */ diff --git a/nuttx/net/uip/uip-input.c b/nuttx/net/uip/uip-input.c index b8d8ebb7e..6ee748c89 100644 --- a/nuttx/net/uip/uip-input.c +++ b/nuttx/net/uip/uip-input.c @@ -102,8 +102,8 @@ /* Macros. */ -#define BUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN]) -#define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0]) +#define BUF ((struct uip_ip_hdr *)&dev->d_buf[UIP_LLH_LEN]) +#define FBUF ((struct uip_ip_hdr *)&uip_reassbuf[0]) /* IP fragment re-assembly */ @@ -294,9 +294,6 @@ nullreturn: void uip_input(struct uip_driver_s *dev) { - dev->d_snddata = &dev->d_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN]; - dev->d_appdata = &dev->d_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN]; - /* This is where the input processing starts. */ #ifdef CONFIG_NET_STATISTICS @@ -468,9 +465,11 @@ void uip_input(struct uip_driver_s *dev) switch (BUF->proto) { +#ifdef CONFIG_NET_TCP case UIP_PROTO_TCP: /* TCP input */ uip_tcpinput(dev); break; +#endif #ifdef CONFIG_NET_UDP case UIP_PROTO_UDP: /* UDP input */ @@ -480,6 +479,7 @@ void uip_input(struct uip_driver_s *dev) /* Check for ICMP input */ +#ifdef CONFIG_NET_ICMP #ifndef CONFIG_NET_IPv6 case UIP_PROTO_ICMP: /* ICMP input */ #else @@ -487,6 +487,7 @@ void uip_input(struct uip_driver_s *dev) #endif uip_icmpinput(dev); break; +#endif default: /* Unrecognized/unsupported protocol */ #ifdef CONFIG_NET_STATISTICS diff --git a/nuttx/net/uip/uip-internal.h b/nuttx/net/uip/uip-internal.h index ccc1c86bd..2aab6fbe3 100644 --- a/nuttx/net/uip/uip-internal.h +++ b/nuttx/net/uip/uip-internal.h @@ -118,6 +118,7 @@ extern "C" { #define EXTERN extern #endif +#ifdef CONFIG_NET_TCP /* Defined in uip_tcpconn.c *************************************************/ EXTERN void uip_tcpinit(void); @@ -165,6 +166,16 @@ EXTERN void uip_tcpinput(struct uip_driver_s *dev); EXTERN uint8 uip_tcpcallback(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags); +/* Defined in uip-tcpreadahead.c ********************************************/ + +#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 +EXTERN void uip_tcpreadaheadinit(void); +EXTERN struct uip_readahead_s *uip_tcpreadaheadalloc(void); +EXTERN void uip_tcpreadaheadrelease(struct uip_readahead_s *buf); +#endif /* CONFIG_NET_NTCP_READAHEAD_BUFFERS */ + +#endif /* CONFIG_NET_TCP */ + #ifdef CONFIG_NET_UDP /* Defined in uip_udpconn.c *************************************************/ @@ -190,17 +201,11 @@ EXTERN void uip_udpcallback(struct uip_driver_s *dev, struct uip_udp_conn *conn, uint8 flags); #endif /* CONFIG_NET_UDP */ +#ifdef CONFIG_NET_ICMP /* Defined in uip-icmpinput.c ***********************************************/ EXTERN void uip_icmpinput(struct uip_driver_s *dev); - -/* Defined in uip-tcpreadahead.c ********************************************/ - -#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 -EXTERN void uip_tcpreadaheadinit(void); -EXTERN struct uip_readahead_s *uip_tcpreadaheadalloc(void); -EXTERN void uip_tcpreadaheadrelease(struct uip_readahead_s *buf); -#endif /* CONFIG_NET_NTCP_READAHEAD_BUFFERS */ +#endif /* CONFIG_NET_ICMP */ #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/net/uip/uip-poll.c b/nuttx/net/uip/uip-poll.c index f17f42e75..1e8483ea6 100644 --- a/nuttx/net/uip/uip-poll.c +++ b/nuttx/net/uip/uip-poll.c @@ -108,6 +108,7 @@ static int uip_polludpconnections(struct uip_driver_s *dev, * ****************************************************************************/ +#ifdef CONFIG_NET_TCP static inline int uip_polltcpconnections(struct uip_driver_s *dev, uip_poll_callback_t callback) { @@ -129,6 +130,9 @@ static inline int uip_polltcpconnections(struct uip_driver_s *dev, return bstop; } +#else +# define uip_polltcpconnections(dev, callback) (0) +#endif /**************************************************************************** * Function: uip_polltcptimer @@ -143,6 +147,7 @@ static inline int uip_polltcpconnections(struct uip_driver_s *dev, * ****************************************************************************/ +#ifdef CONFIG_NET_TCP static inline int uip_polltcptimer(struct uip_driver_s *dev, uip_poll_callback_t callback, int hsec) { @@ -164,6 +169,9 @@ static inline int uip_polltcptimer(struct uip_driver_s *dev, return bstop; } +#else +# define uip_polltcptimer(dev, callback, hsec) (0) +#endif /**************************************************************************** * Public Functions diff --git a/nuttx/net/uip/uip-tcpappsend.c b/nuttx/net/uip/uip-tcpappsend.c index fa19c23f0..f26f897bb 100644 --- a/nuttx/net/uip/uip-tcpappsend.c +++ b/nuttx/net/uip/uip-tcpappsend.c @@ -42,7 +42,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <debug.h> @@ -235,4 +235,4 @@ void uip_tcprexmit(struct uip_driver_s *dev, struct uip_conn *conn, uint8 result dev->d_len = 0; } } -#endif /* CONFIG_NET */ +#endif /* CONFIG_NET && CONFIG_NET_TCP */ diff --git a/nuttx/net/uip/uip-tcpcallback.c b/nuttx/net/uip/uip-tcpcallback.c index 311323059..1694a9ab4 100644 --- a/nuttx/net/uip/uip-tcpcallback.c +++ b/nuttx/net/uip/uip-tcpcallback.c @@ -39,7 +39,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <string.h> @@ -210,4 +210,4 @@ uint8 uip_tcpcallback(struct uip_driver_s *dev, struct uip_conn *conn, uint8 fla return ret; } -#endif /* CONFIG_NET */ +#endif /* CONFIG_NET && CONFIG_NET_TCP */ diff --git a/nuttx/net/uip/uip-tcpconn.c b/nuttx/net/uip/uip-tcpconn.c index eb84d8f31..d2e211232 100644 --- a/nuttx/net/uip/uip-tcpconn.c +++ b/nuttx/net/uip/uip-tcpconn.c @@ -45,7 +45,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <string.h> @@ -655,4 +655,4 @@ int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr) return OK; } -#endif /* CONFIG_NET */ +#endif /* CONFIG_NET && CONFIG_NET_TCP */ diff --git a/nuttx/net/uip/uip-tcpinput.c b/nuttx/net/uip/uip-tcpinput.c index ba11fcb81..e3271263a 100644 --- a/nuttx/net/uip/uip-tcpinput.c +++ b/nuttx/net/uip/uip-tcpinput.c @@ -43,7 +43,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <debug.h> @@ -103,6 +103,9 @@ void uip_tcpinput(struct uip_driver_s *dev) int len; int i; + dev->d_snddata = &dev->d_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN]; + dev->d_appdata = &dev->d_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN]; + #ifdef CONFIG_NET_STATISTICS uip_stat.tcp.recv++; #endif @@ -741,4 +744,4 @@ drop: dev->d_len = 0; } -#endif /* CONFIG_NET */ +#endif /* CONFIG_NET && CONFIG_NET_TCP */ diff --git a/nuttx/net/uip/uip-tcppoll.c b/nuttx/net/uip/uip-tcppoll.c index 9b66ef707..18aa9541d 100644 --- a/nuttx/net/uip/uip-tcppoll.c +++ b/nuttx/net/uip/uip-tcppoll.c @@ -43,7 +43,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <debug.h> @@ -127,4 +127,4 @@ void uip_tcppoll(struct uip_driver_s *dev, struct uip_conn *conn) } } -#endif /* CONFIG_NET */ +#endif /* CONFIG_NET && CONFIG_NET_TCP */ diff --git a/nuttx/net/uip/uip-tcpreadahead.c b/nuttx/net/uip/uip-tcpreadahead.c index 6c4c78f1e..abadb4f50 100644 --- a/nuttx/net/uip/uip-tcpreadahead.c +++ b/nuttx/net/uip/uip-tcpreadahead.c @@ -39,7 +39,7 @@ ****************************************************************************/ #include <net/uip/uipopt.h> -#if defined(CONFIG_NET) && (CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0) +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) && (CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0) #include <sys/types.h> #include <queue.h> @@ -129,4 +129,4 @@ void uip_tcpreadaheadrelease(struct uip_readahead_s *buf) sq_addfirst(&buf->rh_node, &g_freebuffers); } -#endif /* CONFIG_NET && CONFIG_NET_NTCP_READAHEAD_BUFFERS*/ +#endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_NTCP_READAHEAD_BUFFERS*/ diff --git a/nuttx/net/uip/uip-tcpsend.c b/nuttx/net/uip/uip-tcpsend.c index ef4a1b7af..1729dd75b 100644 --- a/nuttx/net/uip/uip-tcpsend.c +++ b/nuttx/net/uip/uip-tcpsend.c @@ -42,7 +42,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <debug.h> @@ -362,4 +362,4 @@ void uip_tcpack(struct uip_driver_s *dev, struct uip_conn *conn, uint8 ack) uip_tcpsendcommon(dev, conn); } -#endif /* CONFIG_NET */ +#endif /* CONFIG_NET && CONFIG_NET_TCP */ diff --git a/nuttx/net/uip/uip-tcptimer.c b/nuttx/net/uip/uip-tcptimer.c index beb16bc0f..3679808d3 100644 --- a/nuttx/net/uip/uip-tcptimer.c +++ b/nuttx/net/uip/uip-tcptimer.c @@ -43,7 +43,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET +#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include <sys/types.h> #include <debug.h> @@ -247,4 +247,4 @@ done: return; } -#endif /* CONFIG_NET */ +#endif /* CONFIG_NET && CONFIG_NET_TCP */ |