From 2399e0d1f94d9ac375ec43ee728124cd2c137915 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 24 Jun 2014 10:14:15 -0600 Subject: Move the remaining files from include/nuttx/net/uip to include/nuttx/net; Rename *_internal.h header files in net/ to just *.h --- apps/examples/discover/discover_main.c | 2 +- apps/examples/igmp/igmp.c | 2 +- apps/examples/nettest/nettest.c | 2 +- apps/examples/tcpecho/tcpecho_main.c | 2 +- apps/examples/udp/target.c | 2 +- apps/examples/uip/uip_main.c | 2 +- apps/examples/wget/target.c | 2 +- apps/examples/xmlrpc/xmlrpc_main.c | 2 +- apps/include/netutils/httpd.h | 2 +- apps/include/netutils/smtp.h | 2 +- apps/netutils/dhcpc/dhcpc.c | 2 +- apps/netutils/smtp/smtp.c | 2 +- apps/netutils/tftpc/tftpc_get.c | 2 +- apps/netutils/tftpc/tftpc_packets.c | 2 +- apps/netutils/tftpc/tftpc_put.c | 2 +- apps/netutils/uiplib/uiplib.c | 2 +- apps/netutils/webserver/httpd.c | 2 +- apps/nshlib/nsh_netcmds.c | 4 +- nuttx/arch/arm/src/c5471/c5471_ethernet.c | 2 +- nuttx/arch/arm/src/kinetis/kinetis_enet.c | 2 +- nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c | 2 +- nuttx/arch/arm/src/sam34/sam_emac.c | 2 +- nuttx/arch/arm/src/sama5/sam_emaca.c | 2 +- nuttx/arch/arm/src/sama5/sam_emacb.c | 2 +- nuttx/arch/arm/src/sama5/sam_gmac.c | 2 +- nuttx/arch/arm/src/stm32/stm32_eth.c | 4 +- nuttx/arch/arm/src/tiva/tiva_ethernet.c | 2 +- nuttx/arch/hc/src/m9s12/m9s12_ethernet.c | 2 +- nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c | 2 +- nuttx/arch/sim/src/up_uipdriver.c | 2 +- nuttx/arch/z80/src/ez80/ez80_emac.c | 2 +- nuttx/drivers/net/cs89x0.c | 2 +- nuttx/drivers/net/dm90x0.c | 2 +- nuttx/drivers/net/e1000.c | 2 +- nuttx/drivers/net/enc28j60.c | 2 +- nuttx/drivers/net/encx24j600.c | 2 +- nuttx/drivers/net/skeleton.c | 2 +- nuttx/drivers/net/slip.c | 2 +- nuttx/drivers/net/vnet.c | 2 +- nuttx/fs/nfs/nfs_vfsops.c | 4 +- nuttx/include/nuttx/net/arp.h | 2 +- nuttx/include/nuttx/net/icmp.h | 211 +++++++++ nuttx/include/nuttx/net/igmp.h | 258 +++++++++++ nuttx/include/nuttx/net/ip.h | 251 +++++++++++ nuttx/include/nuttx/net/net.h | 2 +- nuttx/include/nuttx/net/netdev.h | 4 +- nuttx/include/nuttx/net/pkt.h | 106 +++++ nuttx/include/nuttx/net/tcp.h | 529 ++++++++++++++++++++++ nuttx/include/nuttx/net/udp.h | 206 +++++++++ nuttx/include/nuttx/net/uip.h | 584 +++++++++++++++++++++++++ nuttx/include/nuttx/net/uip/uip-icmp.h | 211 --------- nuttx/include/nuttx/net/uip/uip-igmp.h | 258 ----------- nuttx/include/nuttx/net/uip/uip-ipopt.h | 251 ----------- nuttx/include/nuttx/net/uip/uip-pkt.h | 106 ----- nuttx/include/nuttx/net/uip/uip-tcp.h | 529 ---------------------- nuttx/include/nuttx/net/uip/uip-udp.h | 206 --------- nuttx/include/nuttx/net/uip/uip.h | 584 ------------------------- nuttx/net/accept.c | 2 +- nuttx/net/arp/arp_timer.c | 2 +- nuttx/net/bind.c | 2 +- nuttx/net/connect.c | 4 +- nuttx/net/getsockname.c | 2 +- nuttx/net/getsockopt.c | 2 +- nuttx/net/icmp/icmp_input.c | 4 +- nuttx/net/icmp/icmp_ping.c | 6 +- nuttx/net/icmp/icmp_poll.c | 4 +- nuttx/net/icmp/icmp_send.c | 4 +- nuttx/net/igmp/igmp_group.c | 6 +- nuttx/net/igmp/igmp_init.c | 6 +- nuttx/net/igmp/igmp_input.c | 6 +- nuttx/net/igmp/igmp_join.c | 6 +- nuttx/net/igmp/igmp_leave.c | 6 +- nuttx/net/igmp/igmp_mcastmac.c | 4 +- nuttx/net/igmp/igmp_msg.c | 6 +- nuttx/net/igmp/igmp_poll.c | 4 +- nuttx/net/igmp/igmp_send.c | 8 +- nuttx/net/igmp/igmp_timer.c | 6 +- nuttx/net/listen.c | 2 +- nuttx/net/net.h | 239 ++++++++++ nuttx/net/net_addroute.c | 2 +- nuttx/net/net_allocroute.c | 2 +- nuttx/net/net_checksd.c | 2 +- nuttx/net/net_clone.c | 2 +- nuttx/net/net_close.c | 4 +- nuttx/net/net_delroute.c | 2 +- nuttx/net/net_dsec2timeval.c | 2 +- nuttx/net/net_dup.c | 2 +- nuttx/net/net_dup2.c | 2 +- nuttx/net/net_foreachroute.c | 2 +- nuttx/net/net_internal.h | 239 ---------- nuttx/net/net_monitor.c | 4 +- nuttx/net/net_poll.c | 6 +- nuttx/net/net_route.h | 2 +- nuttx/net/net_router.c | 2 +- nuttx/net/net_sendfile.c | 4 +- nuttx/net/net_sockets.c | 4 +- nuttx/net/net_timeo.c | 2 +- nuttx/net/net_timeval2dsec.c | 2 +- nuttx/net/net_vfcntl.c | 2 +- nuttx/net/netdev_carrier.c | 2 +- nuttx/net/netdev_count.c | 2 +- nuttx/net/netdev_findbyaddr.c | 2 +- nuttx/net/netdev_findbyname.c | 2 +- nuttx/net/netdev_foreach.c | 2 +- nuttx/net/netdev_ioctl.c | 6 +- nuttx/net/netdev_register.c | 2 +- nuttx/net/netdev_router.c | 2 +- nuttx/net/netdev_rxnotify.c | 2 +- nuttx/net/netdev_sem.c | 2 +- nuttx/net/netdev_txnotify.c | 2 +- nuttx/net/netdev_unregister.c | 2 +- nuttx/net/pkt/pkt_callback.c | 4 +- nuttx/net/pkt/pkt_conn.c | 4 +- nuttx/net/pkt/pkt_input.c | 6 +- nuttx/net/pkt/pkt_poll.c | 6 +- nuttx/net/pkt/pkt_send.c | 6 +- nuttx/net/recv.c | 2 +- nuttx/net/recvfrom.c | 4 +- nuttx/net/send.c | 2 +- nuttx/net/sendto.c | 4 +- nuttx/net/setsockopt.c | 2 +- nuttx/net/socket.c | 2 +- nuttx/net/tcp/tcp_appsend.c | 4 +- nuttx/net/tcp/tcp_backlog.c | 6 +- nuttx/net/tcp/tcp_callback.c | 4 +- nuttx/net/tcp/tcp_conn.c | 4 +- nuttx/net/tcp/tcp_input.c | 4 +- nuttx/net/tcp/tcp_listen.c | 2 +- nuttx/net/tcp/tcp_poll.c | 4 +- nuttx/net/tcp/tcp_readahead.c | 4 +- nuttx/net/tcp/tcp_send.c | 4 +- nuttx/net/tcp/tcp_send_buffered.c | 4 +- nuttx/net/tcp/tcp_send_unbuffered.c | 4 +- nuttx/net/tcp/tcp_seqno.c | 4 +- nuttx/net/tcp/tcp_timer.c | 4 +- nuttx/net/tcp/tcp_wrbuffer.c | 2 +- nuttx/net/tcp/tcp_wrbuffer_dump.c | 2 +- nuttx/net/udp/udp_callback.c | 4 +- nuttx/net/udp/udp_conn.c | 4 +- nuttx/net/udp/udp_input.c | 4 +- nuttx/net/udp/udp_poll.c | 4 +- nuttx/net/udp/udp_send.c | 4 +- nuttx/net/uip/uip.h | 296 +++++++++++++ nuttx/net/uip/uip_callback.c | 4 +- nuttx/net/uip/uip_chksum.c | 4 +- nuttx/net/uip/uip_initialize.c | 4 +- nuttx/net/uip/uip_input.c | 4 +- nuttx/net/uip/uip_internal.h | 296 ------------- nuttx/net/uip/uip_iobsend.c | 2 +- nuttx/net/uip/uip_lock.c | 2 +- nuttx/net/uip/uip_neighbor.h | 2 +- nuttx/net/uip/uip_pktsend.c | 2 +- nuttx/net/uip/uip_poll.c | 4 +- nuttx/net/uip/uip_send.c | 2 +- nuttx/net/uip/uip_setipid.c | 4 +- 155 files changed, 2888 insertions(+), 2888 deletions(-) create mode 100644 nuttx/include/nuttx/net/icmp.h create mode 100644 nuttx/include/nuttx/net/igmp.h create mode 100644 nuttx/include/nuttx/net/ip.h create mode 100644 nuttx/include/nuttx/net/pkt.h create mode 100644 nuttx/include/nuttx/net/tcp.h create mode 100644 nuttx/include/nuttx/net/udp.h create mode 100644 nuttx/include/nuttx/net/uip.h delete mode 100644 nuttx/include/nuttx/net/uip/uip-icmp.h delete mode 100644 nuttx/include/nuttx/net/uip/uip-igmp.h delete mode 100644 nuttx/include/nuttx/net/uip/uip-ipopt.h delete mode 100644 nuttx/include/nuttx/net/uip/uip-pkt.h delete mode 100644 nuttx/include/nuttx/net/uip/uip-tcp.h delete mode 100644 nuttx/include/nuttx/net/uip/uip-udp.h delete mode 100644 nuttx/include/nuttx/net/uip/uip.h create mode 100644 nuttx/net/net.h delete mode 100644 nuttx/net/net_internal.h create mode 100644 nuttx/net/uip/uip.h delete mode 100644 nuttx/net/uip/uip_internal.h diff --git a/apps/examples/discover/discover_main.c b/apps/examples/discover/discover_main.c index 0fc6e7b7b..50f8dccc4 100644 --- a/apps/examples/discover/discover_main.c +++ b/apps/examples/discover/discover_main.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include diff --git a/apps/examples/igmp/igmp.c b/apps/examples/igmp/igmp.c index d50ea4a93..cb8feb002 100644 --- a/apps/examples/igmp/igmp.c +++ b/apps/examples/igmp/igmp.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include diff --git a/apps/examples/nettest/nettest.c b/apps/examples/nettest/nettest.c index 81faf9b93..770d282d3 100644 --- a/apps/examples/nettest/nettest.c +++ b/apps/examples/nettest/nettest.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include "nettest.h" diff --git a/apps/examples/tcpecho/tcpecho_main.c b/apps/examples/tcpecho/tcpecho_main.c index 88b931def..831f1f483 100644 --- a/apps/examples/tcpecho/tcpecho_main.c +++ b/apps/examples/tcpecho/tcpecho_main.c @@ -54,7 +54,7 @@ #include #include -#include +#include #include #include diff --git a/apps/examples/udp/target.c b/apps/examples/udp/target.c index d7b64638d..229dc261b 100644 --- a/apps/examples/udp/target.c +++ b/apps/examples/udp/target.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include "udp-internal.h" diff --git a/apps/examples/uip/uip_main.c b/apps/examples/uip/uip_main.c index 68fc20bf5..03da23df3 100644 --- a/apps/examples/uip/uip_main.c +++ b/apps/examples/uip/uip_main.c @@ -54,7 +54,7 @@ #include #include -#include +#include #include #include diff --git a/apps/examples/wget/target.c b/apps/examples/wget/target.c index 62bb08978..9c795d1e2 100644 --- a/apps/examples/wget/target.c +++ b/apps/examples/wget/target.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include diff --git a/apps/examples/xmlrpc/xmlrpc_main.c b/apps/examples/xmlrpc/xmlrpc_main.c index 5d4e52299..e115bb0ae 100644 --- a/apps/examples/xmlrpc/xmlrpc_main.c +++ b/apps/examples/xmlrpc/xmlrpc_main.c @@ -63,7 +63,7 @@ #include #include -#include +#include #include #include diff --git a/apps/include/netutils/httpd.h b/apps/include/netutils/httpd.h index 706c3fd24..56e5da38a 100644 --- a/apps/include/netutils/httpd.h +++ b/apps/include/netutils/httpd.h @@ -44,7 +44,7 @@ * Included Files ****************************************************************************/ -#include +#include #include #include diff --git a/apps/include/netutils/smtp.h b/apps/include/netutils/smtp.h index 5392babc2..05b4d543e 100644 --- a/apps/include/netutils/smtp.h +++ b/apps/include/netutils/smtp.h @@ -45,7 +45,7 @@ ****************************************************************************/ #include -#include +#include /**************************************************************************** * Type Definitions diff --git a/apps/netutils/dhcpc/dhcpc.c b/apps/netutils/dhcpc/dhcpc.c index b34320230..fab4a3bcf 100644 --- a/apps/netutils/dhcpc/dhcpc.c +++ b/apps/netutils/dhcpc/dhcpc.c @@ -52,7 +52,7 @@ #include #include -#include +#include #include #include diff --git a/apps/netutils/smtp/smtp.c b/apps/netutils/smtp/smtp.c index 08ff295ef..d83e260c5 100644 --- a/apps/netutils/smtp/smtp.c +++ b/apps/netutils/smtp/smtp.c @@ -57,7 +57,7 @@ #include #include -#include +#include #include /**************************************************************************** diff --git a/apps/netutils/tftpc/tftpc_get.c b/apps/netutils/tftpc/tftpc_get.c index 0c92f4a73..96ed2b4eb 100644 --- a/apps/netutils/tftpc/tftpc_get.c +++ b/apps/netutils/tftpc/tftpc_get.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include "tftpc_internal.h" diff --git a/apps/netutils/tftpc/tftpc_packets.c b/apps/netutils/tftpc/tftpc_packets.c index d1e41f2d4..1df916a6a 100644 --- a/apps/netutils/tftpc/tftpc_packets.c +++ b/apps/netutils/tftpc/tftpc_packets.c @@ -52,7 +52,7 @@ #include #include -#include +#include #include #include "tftpc_internal.h" diff --git a/apps/netutils/tftpc/tftpc_put.c b/apps/netutils/tftpc/tftpc_put.c index e04a5dc43..19f33676e 100644 --- a/apps/netutils/tftpc/tftpc_put.c +++ b/apps/netutils/tftpc/tftpc_put.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include "tftpc_internal.h" diff --git a/apps/netutils/uiplib/uiplib.c b/apps/netutils/uiplib/uiplib.c index c8051233e..4644c61b0 100644 --- a/apps/netutils/uiplib/uiplib.c +++ b/apps/netutils/uiplib/uiplib.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include diff --git a/apps/netutils/webserver/httpd.c b/apps/netutils/webserver/httpd.c index 3f9863f6f..26989611b 100644 --- a/apps/netutils/webserver/httpd.c +++ b/apps/netutils/webserver/httpd.c @@ -61,7 +61,7 @@ # include #endif -#include +#include #include #include diff --git a/apps/nshlib/nsh_netcmds.c b/apps/nshlib/nsh_netcmds.c index b8e90b933..8ceadd182 100644 --- a/apps/nshlib/nsh_netcmds.c +++ b/apps/nshlib/nsh_netcmds.c @@ -59,11 +59,11 @@ #include #include -#include +#include #include #ifdef CONFIG_NET_STATISTICS -# include +# include #endif #if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) && \ diff --git a/nuttx/arch/arm/src/c5471/c5471_ethernet.c b/nuttx/arch/arm/src/c5471/c5471_ethernet.c index 6d35231ab..54628c6f1 100644 --- a/nuttx/arch/arm/src/c5471/c5471_ethernet.c +++ b/nuttx/arch/arm/src/c5471/c5471_ethernet.c @@ -58,7 +58,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/arch/arm/src/kinetis/kinetis_enet.c b/nuttx/arch/arm/src/kinetis/kinetis_enet.c index 10d58e838..51bf26ff1 100644 --- a/nuttx/arch/arm/src/kinetis/kinetis_enet.c +++ b/nuttx/arch/arm/src/kinetis/kinetis_enet.c @@ -53,7 +53,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c b/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c index ee3fd5bfb..31f326995 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c @@ -52,7 +52,7 @@ #include #include -#include +#include #include #include #include diff --git a/nuttx/arch/arm/src/sam34/sam_emac.c b/nuttx/arch/arm/src/sam34/sam_emac.c index da1647ddc..31da83f29 100644 --- a/nuttx/arch/arm/src/sam34/sam_emac.c +++ b/nuttx/arch/arm/src/sam34/sam_emac.c @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include diff --git a/nuttx/arch/arm/src/sama5/sam_emaca.c b/nuttx/arch/arm/src/sama5/sam_emaca.c index 315f68d21..09564ddaa 100644 --- a/nuttx/arch/arm/src/sama5/sam_emaca.c +++ b/nuttx/arch/arm/src/sama5/sam_emaca.c @@ -64,7 +64,7 @@ #include #include #include -#include +#include #include #include diff --git a/nuttx/arch/arm/src/sama5/sam_emacb.c b/nuttx/arch/arm/src/sama5/sam_emacb.c index 3e80ba685..318a61f00 100644 --- a/nuttx/arch/arm/src/sama5/sam_emacb.c +++ b/nuttx/arch/arm/src/sama5/sam_emacb.c @@ -71,7 +71,7 @@ #include #include #include -#include +#include #include #include diff --git a/nuttx/arch/arm/src/sama5/sam_gmac.c b/nuttx/arch/arm/src/sama5/sam_gmac.c index 3318cb45c..081835778 100644 --- a/nuttx/arch/arm/src/sama5/sam_gmac.c +++ b/nuttx/arch/arm/src/sama5/sam_gmac.c @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c index 8797c6472..f16f74076 100644 --- a/nuttx/arch/arm/src/stm32/stm32_eth.c +++ b/nuttx/arch/arm/src/stm32/stm32_eth.c @@ -53,11 +53,11 @@ #include #include -#include +#include #include #include #if defined(CONFIG_NET_PKT) -# include +# include #endif #include "up_internal.h" diff --git a/nuttx/arch/arm/src/tiva/tiva_ethernet.c b/nuttx/arch/arm/src/tiva/tiva_ethernet.c index 091f445e4..b605360f6 100644 --- a/nuttx/arch/arm/src/tiva/tiva_ethernet.c +++ b/nuttx/arch/arm/src/tiva/tiva_ethernet.c @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include diff --git a/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c b/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c index c03395cf6..14e49a571 100644 --- a/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c +++ b/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c b/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c index 9b2815b69..45ebbe599 100644 --- a/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c +++ b/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c @@ -55,7 +55,7 @@ #include #include -#include +#include #include #include #include diff --git a/nuttx/arch/sim/src/up_uipdriver.c b/nuttx/arch/sim/src/up_uipdriver.c index 255e3ad4f..9693bc0d2 100644 --- a/nuttx/arch/sim/src/up_uipdriver.c +++ b/nuttx/arch/sim/src/up_uipdriver.c @@ -53,7 +53,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/arch/z80/src/ez80/ez80_emac.c b/nuttx/arch/z80/src/ez80/ez80_emac.c index 11547ea48..3967b38e7 100644 --- a/nuttx/arch/z80/src/ez80/ez80_emac.c +++ b/nuttx/arch/z80/src/ez80/ez80_emac.c @@ -58,7 +58,7 @@ #include -#include +#include #include #include diff --git a/nuttx/drivers/net/cs89x0.c b/nuttx/drivers/net/cs89x0.c index 881be0d34..59a09f394 100644 --- a/nuttx/drivers/net/cs89x0.c +++ b/nuttx/drivers/net/cs89x0.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/drivers/net/dm90x0.c b/nuttx/drivers/net/dm90x0.c index d3d34283f..9bceaa429 100644 --- a/nuttx/drivers/net/dm90x0.c +++ b/nuttx/drivers/net/dm90x0.c @@ -64,7 +64,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/drivers/net/e1000.c b/nuttx/drivers/net/e1000.c index d010c37a0..fd4f0c940 100644 --- a/nuttx/drivers/net/e1000.c +++ b/nuttx/drivers/net/e1000.c @@ -54,7 +54,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/drivers/net/enc28j60.c b/nuttx/drivers/net/enc28j60.c index 02ed7f32e..e5c4e033b 100644 --- a/nuttx/drivers/net/enc28j60.c +++ b/nuttx/drivers/net/enc28j60.c @@ -61,7 +61,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/drivers/net/encx24j600.c b/nuttx/drivers/net/encx24j600.c index ee68f5cd3..a67d7453d 100644 --- a/nuttx/drivers/net/encx24j600.c +++ b/nuttx/drivers/net/encx24j600.c @@ -67,7 +67,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/drivers/net/skeleton.c b/nuttx/drivers/net/skeleton.c index bdbffdc32..bbe5a9673 100644 --- a/nuttx/drivers/net/skeleton.c +++ b/nuttx/drivers/net/skeleton.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/drivers/net/slip.c b/nuttx/drivers/net/slip.c index 734f3510a..01caecba6 100644 --- a/nuttx/drivers/net/slip.c +++ b/nuttx/drivers/net/slip.c @@ -57,7 +57,7 @@ #include #include -#include +#include #include #if defined(CONFIG_NET) && defined(CONFIG_NET_SLIP) diff --git a/nuttx/drivers/net/vnet.c b/nuttx/drivers/net/vnet.c index 7f94ec33c..a106c1a38 100644 --- a/nuttx/drivers/net/vnet.c +++ b/nuttx/drivers/net/vnet.c @@ -55,7 +55,7 @@ #include #include -#include +#include #include #include diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c index 0051184e1..0a45c0307 100644 --- a/nuttx/fs/nfs/nfs_vfsops.c +++ b/nuttx/fs/nfs/nfs_vfsops.c @@ -68,8 +68,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/nuttx/include/nuttx/net/arp.h b/nuttx/include/nuttx/net/arp.h index c64471ce5..524490bb4 100644 --- a/nuttx/include/nuttx/net/arp.h +++ b/nuttx/include/nuttx/net/arp.h @@ -52,7 +52,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-Processor Definitions diff --git a/nuttx/include/nuttx/net/icmp.h b/nuttx/include/nuttx/net/icmp.h new file mode 100644 index 000000000..87464c73f --- /dev/null +++ b/nuttx/include/nuttx/net/icmp.h @@ -0,0 +1,211 @@ +/**************************************************************************** + * include/nuttx/net/icmp.h + * Header file for the uIP ICMP stack. + * + * Copyright (C) 2007-2009, 2012, 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * This logic was leveraged from uIP which also has a BSD-style license: + * + * Author Adam Dunkels + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_NET_ICMP_H +#define __INCLUDE_NUTTX_NET_ICMP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* ICMP/ICMP6 definitions */ + +/* ICMP/ICMP6 Message Types */ + +#define ICMP_ECHO_REPLY 0 /* RFC 792 */ +#define ICMP_DEST_UNREACHABLE 3 /* RFC 792 */ +#define ICMP_SRC_QUENCH 4 /* RFC 792 */ +#define ICMP_REDIRECT 5 /* RFC 792 */ +#define ICMP_ALT_HOST_ADDRESS 6 +#define ICMP_ECHO_REQUEST 8 /* RFC 792 */ +#define ICMP_ROUTER_ADVERTISEMENT 9 /* RFC 1256 */ +#define ICMP_ROUTER_SOLICITATION 10 /* RFC 1256 */ +#define ICMP_TIME_EXCEEDED 11 /* RFC 792 */ +#define ICMP_PARAMETER_PROBLEM 12 +#define ICMP_TIMESTAMP_REQUEST 13 +#define ICMP_TIMESTAMP_REPLY 14 +#define ICMP_INFORMATION_REQUEST 15 +#define ICMP_INFORMATION_REPLY 16 +#define ICMP_ADDRESS_MASK_REQUEST 17 +#define ICMP_ADDRESS_MASK_REPLY 18 +#define ICMP_TRACEROUTE 30 +#define ICMP_CONVERSION_ERROR 31 +#define ICMP_MOBILE_HOST_REDIRECT 32 +#define ICMP_IPV6_WHEREAREYOU 33 +#define ICMP_IPV6_IAMHERE 34 +#define ICMP_MOBILE_REGIS_REQUEST 35 +#define ICMP_MOBILE_REGIS_REPLY 36 +#define ICMP_DOMAIN_NAME_REQUEST 37 +#define ICMP_DOMAIN_NAME_REPLY 38 +#define ICMP_SKIP_DISCOVERY_PROTO 39 +#define ICMP_PHOTURIS_SECURITY_FAIL 40 +#define ICMP_EXP_MOBILE_PROTO 41 /* RFC 4065 */ + +/* ICMP6 Message Types */ + +#define ICMP6_ECHO_REPLY 129 +#define ICMP6_ECHO_REQUEST 128 +#define ICMP6_NEIGHBOR_SOLICITATION 135 +#define ICMP6_NEIGHBOR_ADVERTISEMENT 136 + +#define ICMP6_FLAG_S (1 << 6) + +#define ICMP6_OPTION_SOURCE_LINK_ADDRESS 1 +#define ICMP6_OPTION_TARGET_LINK_ADDRESS 2 + +/* Header sizes */ + +#define UIP_ICMPH_LEN 4 /* Size of ICMP header */ +#define UIP_IPICMPH_LEN (UIP_ICMPH_LEN + UIP_IPH_LEN) /* Size of IP + ICMP header */ + +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +/* The ICMP and IP headers */ + +struct uip_icmpip_hdr +{ +#ifdef CONFIG_NET_IPv6 + + /* IPv6 Ip header */ + + uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ + uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */ + uint16_t flow; /* 16-bit flow label (LS) */ + uint8_t len[2]; /* 16-bit Payload length */ + uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ + uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ + uip_ip6addr_t srcipaddr; /* 128-bit Source address */ + uip_ip6addr_t destipaddr; /* 128-bit Destination address */ + +#else /* CONFIG_NET_IPv6 */ + + /* IPv4 IP header */ + + uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ + uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ + uint8_t len[2]; /* 16-bit Total length */ + uint8_t ipid[2]; /* 16-bit Identification */ + uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ + uint8_t ttl; /* 8-bit Time to Live */ + uint8_t proto; /* 8-bit Protocol */ + uint16_t ipchksum; /* 16-bit Header checksum */ + uint16_t srcipaddr[2]; /* 32-bit Source IP address */ + uint16_t destipaddr[2]; /* 32-bit Destination IP address */ + +#endif /* CONFIG_NET_IPv6 */ + + /* ICMP header */ + + uint8_t type; /* Defines the format of the ICMP message */ + uint8_t icode; /* Further qualifies the ICMP messsage */ + uint16_t icmpchksum; /* Checksum of ICMP header and data */ + + /* Data following the ICMP header contains the data specific to the + * message type indicated by the Type and Code fields. + */ + +#ifndef CONFIG_NET_IPv6 + + /* ICMP_ECHO_REQUEST and ICMP_ECHO_REPLY data */ + + uint16_t id; /* Used to match requests with replies */ + uint16_t seqno; /* " " "" " " " " " " " " */ + +#else /* !CONFIG_NET_IPv6 */ + + /* ICMP6_ECHO_REQUEST and ICMP6_ECHO_REPLY data */ + + uint8_t flags; + uint8_t reserved1; + uint8_t reserved2; + uint8_t reserved3; + uint8_t icmp6data[16]; + uint8_t options[1]; + +#endif /* !CONFIG_NET_IPv6 */ +}; + +/* The structure holding the ICMP statistics that are gathered if + * CONFIG_NET_STATISTICS is defined. + */ + +#ifdef CONFIG_NET_STATISTICS +struct uip_icmp_stats_s +{ + uip_stats_t drop; /* Number of dropped ICMP packets */ + uip_stats_t recv; /* Number of received ICMP packets */ + uip_stats_t sent; /* Number of sent ICMP packets */ + uip_stats_t typeerr; /* Number of ICMP packets with a wrong type */ +}; +#endif + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN int uip_ping(uip_ipaddr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen, int dsecs); + +#undef EXTERN +#ifdef __cplusplus +} +#endif +#endif /* __INCLUDE_NUTTX_NET_ICMP_H */ diff --git a/nuttx/include/nuttx/net/igmp.h b/nuttx/include/nuttx/net/igmp.h new file mode 100644 index 000000000..8f6c4daf8 --- /dev/null +++ b/nuttx/include/nuttx/net/igmp.h @@ -0,0 +1,258 @@ +/**************************************************************************** + * include/nuttx/net/igmp.h + * The definitions in this header file are intended only for internal use + * by the NuttX port of the uIP stack. + * + * Copyright (C) 2010, 2012, 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * The NuttX implementation of IGMP was inspired by the IGMP add-on for the + * lwIP TCP/IP stack by Steve Reynolds: + * + * Copyright (c) 2002 CITEL Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_NET_IGMP_H +#define __INCLUDE_NUTTX_NET_IGMP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include +#include + +#ifdef CONFIG_NET_IGMP + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_NET_IPv6 +# error "IGMP for IPv6 not supported" +#endif + +/* IGMP packet types */ + +#define IGMP_MEMBERSHIP_QUERY 0x11 /* Membership Query */ +#define IGMPv1_MEMBERSHIP_REPORT 0x12 /* IGMP Ver. 1 Membership Report */ +#define IGMPv2_MEMBERSHIP_REPORT 0x16 /* IGMP Ver. 2 Membership Report */ +#define IGMPv3_MEMBERSHIP_REPORT 0x22 /* IGMP Ver. 3 Membership Report */ +#define IGMP_LEAVE_GROUP 0x17 /* Leave Group */ + +/* Header sizes: + * + * UIP_IGMPH_LEN - Size of IGMP header in bytes + * UIP_IPIGMPH_LEN - Size of IP + Size of IGMP header + Size of router alert + */ + +#define UIP_IGMPH_LEN 8 +#define UIP_IPIGMPH_LEN (UIP_IGMPH_LEN + UIP_IPH_LEN + 4) + +/* Group flags */ + +#define IGMP_PREALLOCATED (1 << 0) +#define IGMP_LASTREPORT (1 << 1) +#define IGMP_IDLEMEMBER (1 << 2) +#define IGMP_SCHEDMSG (1 << 3) +#define IGMP_WAITMSG (1 << 4) + +#define SET_PREALLOCATED(f) do { (f) |= IGMP_PREALLOCATED; } while (0) +#define SET_LASTREPORT(f) do { (f) |= IGMP_LASTREPORT; } while (0) +#define SET_IDLEMEMBER(f) do { (f) |= IGMP_IDLEMEMBER; } while (0) +#define SET_SCHEDMSG(f) do { (f) |= IGMP_SCHEDMSG; } while (0) +#define SET_WAITMSG(f) do { (f) |= IGMP_WAITMSG; } while (0) + +#define CLR_PREALLOCATED(f) do { (f) &= ~IGMP_PREALLOCATED; } while (0) +#define CLR_LASTREPORT(f) do { (f) &= ~IGMP_LASTREPORT; } while (0) +#define CLR_IDLEMEMBER(f) do { (f) &= ~IGMP_IDLEMEMBER; } while (0) +#define CLR_SCHEDMSG(f) do { (f) &= ~IGMP_SCHEDMSG; } while (0) +#define CLR_WAITMSG(f) do { (f) &= ~IGMP_WAITMSG; } while (0) + +#define IS_PREALLOCATED(f) (((f) & IGMP_PREALLOCATED) != 0) +#define IS_LASTREPORT(f) (((f) & IGMP_LASTREPORT) != 0) +#define IS_IDLEMEMBER(f) (((f) & IGMP_IDLEMEMBER) != 0) +#define IS_SCHEDMSG(f) (((f) & IGMP_SCHEDMSG) != 0) +#define IS_WAITMSG(f) (((f) & IGMP_WAITMSG) != 0) + +#define IGMP_TTL 1 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* IGMPv2 packet structure as defined by RFC 2236. + * + * The Max Respone Time (maxresp) specifies the time limit for the + * corresponding report. The field has a resolution of 100 miliseconds, the + * value is taken directly. This field is meaningful only in Membership Query + * (0x11); in other messages it is set to 0 and ignored by the receiver. + */ + +struct uip_igmphdr_s +{ +#ifdef CONFIG_NET_IPv6 + + /* IPv6 Ip header */ + + uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ + uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */ + uint16_t flow; /* 16-bit flow label (LS) */ + uint8_t len[2]; /* 16-bit Payload length */ + uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ + uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ + uip_ip6addr_t srcipaddr; /* 128-bit Source address */ + uip_ip6addr_t destipaddr; /* 128-bit Destination address */ + +#else /* CONFIG_NET_IPv6 */ + + /* IPv4 IP header */ + + uint8_t vhl; /* 8-bit Version (4) and header length (6 with Router Alert) */ + uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ + uint8_t len[2]; /* 16-bit Total length */ + uint8_t ipid[2]; /* 16-bit Identification */ + uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ + uint8_t ttl; /* 8-bit Time to Live */ + uint8_t proto; /* 8-bit Protocol */ + uint16_t ipchksum; /* 16-bit Header checksum */ + uint16_t srcipaddr[2]; /* 32-bit Source IP address */ + uint16_t destipaddr[2]; /* 32-bit Destination IP address */ + +#endif /* CONFIG_NET_IPv6 */ + + /* Router Alert IP header option */ + + uint16_t ra[2]; + + /* IGMPv2 header: + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Type | Max Resp Time | Checksum | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Group Address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + uint8_t type; /* 8-bit IGMP packet type */ + uint8_t maxresp; /* 8-bit Max response time */ + uint16_t chksum; /* 16-bit Checksum */ + uint16_t grpaddr[2]; /* 32-bit Group address */ +}; + +#ifdef CONFIG_NET_STATISTICS +struct uip_igmp_stats_s +{ + uint32_t length_errors; + uint32_t chksum_errors; + uint32_t v1_received; + uint32_t joins; + uint32_t leaves; + uint32_t leave_sched; + uint32_t report_sched; + uint32_t poll_send; + uint32_t ucast_query; + uint32_t query_received; + uint32_t report_received; +}; + +# define IGMP_STATINCR(p) ((p)++) +#else +# define IGMP_STATINCR(p) +#endif + +/* This structure represents one group member. There is a list of groups + * for each device interface structure. + * + * There will be a group for the all systems group address but this + * will not run the state machine as it is used to kick off reports + * from all the other groups + */ + +typedef FAR struct wdog_s *WDOG_ID; +struct igmp_group_s +{ + struct igmp_group_s *next; /* Implements a singly-linked list */ + uip_ipaddr_t grpaddr; /* Group IP address */ + WDOG_ID wdog; /* WDOG used to detect timeouts */ + sem_t sem; /* Used to wait for message transmission */ + volatile uint8_t flags; /* See IGMP_ flags definitions */ + uint8_t msgid; /* Pending message ID (if non-zero) */ +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN uip_ipaddr_t g_allsystems; +EXTERN uip_ipaddr_t g_allrouters; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: uip_igmpdevinit + * + * Description: + * Called when a new network device is registered to configure that device + * for IGMP support. + * + ****************************************************************************/ + +EXTERN void uip_igmpdevinit(struct uip_driver_s *dev); +EXTERN int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr); +EXTERN int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* CONFIG_NET_IGMP */ +#endif /* __INCLUDE_NUTTX_NET_IGMP_H */ diff --git a/nuttx/include/nuttx/net/ip.h b/nuttx/include/nuttx/net/ip.h new file mode 100644 index 000000000..4cbfd824a --- /dev/null +++ b/nuttx/include/nuttx/net/ip.h @@ -0,0 +1,251 @@ +/************************************************************************************************************ + * include/nuttx/net/ip.h + * + * Defines values for the IP header options + * + * Copyright (C) 2010, 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************************************/ + +#ifndef __INCLUDE_NUTTX_NET_IP_H +#define __INCLUDE_NUTTX_NET_IP_H + +/************************************************************************************************************ + * Included Files + ************************************************************************************************************/ + +#include + +/************************************************************************************************************ + * Pre-processor Definitions + ************************************************************************************************************/ + +/* IP Header Options: + * + * The basic 20-byte IP header can be extended by up to another 40 bytes + * (in units of 4 bytes) to provide IP options. The format of a single IP + * option is as follows: + * + * Single byte options: + * + * Type: 8-bits + * + * Multi-byte options: + * + * Type: 8-bits + * Length: 8-bits + * Pointer: 8-bits: + * Option Data: (depends on Length) + * + * The IP Option Type byte consists of the following subfields: + */ + +#define IPOPT_TYPE_OPTION_SHIFT (0) /* Bits 0-5: Option number*/ +#define IPOPT_TYPE_OPTION_MASK (0x1f << IPOPT_TYPE_OPTION_SHIFT) +# define IPOPT_TYPE_OPTION_END (0 << IPOPT_TYPE_OPTION_SHIFT) /* End of options list (RFC 791) */ +# define IPOPT_TYPE_OPTION_NOOP (1 << IPOPT_TYPE_OPTION_SHIFT) /* No operation (RFC 791) */ +# define IPOPT_TYPE_OPTION_SEC (2 << IPOPT_TYPE_OPTION_SHIFT) /* Security (RFC 791, 1108) */ +# define IPOPT_TYPE_OPTION_LSRR (3 << IPOPT_TYPE_OPTION_SHIFT) /* Loose source and record route (RFC 791) */ +# define IPOPT_TYPE_OPTION_TIMESTAMP (4 << IPOPT_TYPE_OPTION_SHIFT) /* Timestamp (RFC 781, 791) */ +# define IPOPT_TYPE_OPTION_EXTSEC (5 << IPOPT_TYPE_OPTION_SHIFT) /* Extended security (RFC 1108) */ +# define IPOPT_TYPE_OPTION_COMMSEC (6 << IPOPT_TYPE_OPTION_SHIFT) /* Commercial security */ +# define IPOPT_TYPE_OPTION_RR (7 << IPOPT_TYPE_OPTION_SHIFT) /* Record route (RFC 791) */ +# define IPOPT_TYPE_OPTION_SSID (8 << IPOPT_TYPE_OPTION_SHIFT) /* Stream ID (RFC 791, 1122) */ +# define IPOPT_TYPE_OPTION_SSRR (9 << IPOPT_TYPE_OPTION_SHIFT) /* Strict source and record route (RFC 791) */ +# define IPOPT_TYPE_OPTION_EXPMEAS (10 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental measurement */ +# define IPOPT_TYPE_OPTION_MTUPROBE (11 << IPOPT_TYPE_OPTION_SHIFT) /* MTU Probe (RFC 1063) */ +# define IPOPT_TYPE_OPTION_MTUREPLY (12 << IPOPT_TYPE_OPTION_SHIFT) /* MTU Reply (RFC 1063) */ +# define IPOPT_TYPE_OPTION_EXPFC (13 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental flow control */ +# define IPOPT_TYPE_OPTION_EXPAC (14 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental access control */ +# define IPOPT_TYPE_OPTION_ENCODE (15 << IPOPT_TYPE_OPTION_SHIFT) /* ENCODE */ +# define IPOPT_TYPE_OPTION_IMITD (16 << IPOPT_TYPE_OPTION_SHIFT) /* IMI traffic descriptor */ +# define IPOPT_TYPE_OPTION_EXTIP (17 << IPOPT_TYPE_OPTION_SHIFT) /* Extended IP (RFC 1385) */ +# define IPOPT_TYPE_OPTION_TR (18 << IPOPT_TYPE_OPTION_SHIFT) /* Traceroute (RFC 1393) */ +# define IPOPT_TYPE_OPTION_ADDREXT (19 << IPOPT_TYPE_OPTION_SHIFT) /* Address extension (RFC 1475) */ +# define IPOPT_TYPE_OPTION_RA (20 << IPOPT_TYPE_OPTION_SHIFT) /* Router alert (RFC 2113) */ +# define IPOPT_TYPE_OPTION_SDBM (21 << IPOPT_TYPE_OPTION_SHIFT) /* Selective direct broadcast mode (RFC 1770) */ +# define IPOPT_TYPE_OPTION_DPS (23 << IPOPT_TYPE_OPTION_SHIFT) /* Dynamic packet state */ +# define IPOPT_TYPE_OPTION_UMP (24 << IPOPT_TYPE_OPTION_SHIFT) /* Upstream multicast packet */ +# define IPOPT_TYPE_OPTION_QS (25 << IPOPT_TYPE_OPTION_SHIFT) /* Quick start (RFC 4782) */ +# define IPOPT_TYPE_OPTION_EXP3692 (30 << IPOPT_TYPE_OPTION_SHIFT) /* RFC 3692-style experiment (RFC 4782) */ +#define IPOPT_TYPE_CLASS_SHIFT (5) /* Bits 5-6: Class */ +#define IPOPT_TYPE_CLASS_MASK (3 << IPOPT_TYPE_CLASS_SHIFT) +# define IPOPT_TYPE_CLASS_CTRL (0 << IPOPT_TYPE_CLASS_SHIFT) /* Control */ +# define IPOPT_TYPE_CLASS_MEASURE (2 << IPOPT_TYPE_CLASS_SHIFT) /* Debugging and measurement */ +#define IPOPT_TYPE_COPIED (1 << 7) /* Bit 7: IP layer must copy option to each fragment */ +#define IPOPT_TYPE_NOTCOPIED (0) + +/* IP Option encoding macros */ + +#define IPOPT_MKTYPE(copied,class,option) (copied|class|option) + +#define IPOPT_MKOPTION8(copied,class,option) \ + ((uint8_t)IPOPT_MKTYPE(copied,class,option)) +#define IPOPT_MKOPTION32(type,len,ptr,data) \ + ((uint32_t)(type) << 24 | (uint32_t)(len) << 16 | \ + (uint32_t)(ptr) << 8 | (uint32_t)(data)) + +/* Option Copy Class Length Description References + * ------ ---- ----- --------- ------------------------------------------------ + * 0 0 0 1 End of options list (RFC 791) + * 1 0 0 1 NOP (RFC 791 + * 2 1 0 11 Security (RFC 791, RFC 1108) + * 3 1 0 variable Loose Source Route (RFC 791) + * 4 0 2 variable Time stamp (RFC 781, RFC 791) + * 5 1 0 3-31 Extended Security (RFC 1108) + * 6 1 0 Commercial Security + * 7 0 0 variable Record Route (RFC 791) + * 8 1 0 4 Stream Identifier (RFC 791, RFC 1122) + * 9 1 0 variable Strict Source Route (RFC 791) + * 10 0 0 Experimental Measurement + * 11 0 0 4 MTU Probe (obsolete) (RFC 1063) + * 12 0 0 4 MTU Reply (obsolete) (RFC 1063) + * 13 1 2 Experimental Flow Control + * 14 1 0 Experimental Access Control + * 15 0 0 ENCODE + * 16 1 0 IMI Traffic Descriptor + * 17 1 0 variable Extended Internet Protocol (RFC 1385) + * 18 0 2 12 Traceroute (RFC 1393) + * 19 1 0 10 Address Extension (RFC 1475) + * 20 1 0 4 Router Alert (RFC 2113) + * 21 1 0 6-38 Selective Directed Broadcast Mode (RFC 1770) + * 22 1 0 + * 23 1 0 Dynamic Packet State + * 24 1 0 Upstream Multicast Packet + * 25 0 0 QS, Quick-Start (RFC 4782) + * 26 + * - + * 29 + * 30 0 0 EXP - RFC3692-style Experiment (RFC 4727) + * 30 0 2 EXP - RFC3692-style Experiment (RFC 4727) + * 30 1 0 EXP - RFC3692-style Experiment RFC 4727) + * 30 1 2 EXP - RFC3692-style Experiment (RFC 4727) + * 31 + */ + +#define IPOTR_END_LEN 1 +#define IPOPT_END_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_END) + +#define IPOTR_NOOP_LEN 1 +#define IPOPT_NOOP_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_NOOP) + +#define IPOPT_SEC_LEN 11 +#define IPOPT_SEC_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SEC) + +#define IPOPT_LSRR_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_LSRR) + +#define IPOPT_TIMESTAMP_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_TIMESTAMP) + +#define IPOPT_EXTSEC_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXTSEC) + +#define IPOPT_COMMSEC_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_COMMSEC) + +#define IPOPT_RR_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_RR) + +#define IPOPT_SSID_LEN 4 +#define IPOPT_SSID_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SSID) + +#define IPOPT_SSRR_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SSRR) +#define IPOPT_EXPMEAS_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXPMEAS) + +#define IPOPT_MTUPROBE_LEN 4 +#define IPOPT_MTUPROBE_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_MTUPROBE) + +#define IPOPT_MTUREPLY_LEN 4 +#define IPOPT_MTUREPLY_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_MTUREPLY) + +#define IPOPT_EXPFC_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_EXPFC) + +#define IPOPT_EXPAC_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXPAC) + +#define IPOPT_ENCODE_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_ENCODE) + +#define IPOPT_IMITD_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_IMITD) + +#define IPOPT_EXTIP_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXTIP) + +#define IPOPT_TR_LEN 12 +#define IPOPT_TR_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_TR) + +#define IPOPT_ADDREXT_LEN 10 +#define IPOPT_ADDREXT_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_ADDREXT) + +#define IPOPT_RA_LEN 4 +#define IPOPT_RA_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_RA) +#define IPOPT_RA \ + IPOPT_MKOPTION32(IPOPT_RA_TYPE, 4, 0, 0) + +#define IPOPT_SDBM_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SDBM) + +#define IPOPT_DPS_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_DPS) + +#define IPOPT_UMP_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_UMP) + +#define IPOPT_QS_TYPE \ + IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_QS) + +/************************************************************************************************************ + * Public Type Definitions + ************************************************************************************************************/ + +/************************************************************************************************************ + * Public Data + ************************************************************************************************************/ + +/************************************************************************************************************ + * Public Function Prototypes + ************************************************************************************************************/ + +#endif /* __INCLUDE_NUTTX_NET_IP_H */ diff --git a/nuttx/include/nuttx/net/net.h b/nuttx/include/nuttx/net/net.h index c433d25b9..d8b6b1f39 100644 --- a/nuttx/include/nuttx/net/net.h +++ b/nuttx/include/nuttx/net/net.h @@ -48,7 +48,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/include/nuttx/net/netdev.h b/nuttx/include/nuttx/net/netdev.h index 7f7733d2a..9c6cbd441 100644 --- a/nuttx/include/nuttx/net/netdev.h +++ b/nuttx/include/nuttx/net/netdev.h @@ -52,9 +52,9 @@ #include #include -#include +#include #ifdef CONFIG_NET_IGMP -# include +# include #endif #include diff --git a/nuttx/include/nuttx/net/pkt.h b/nuttx/include/nuttx/net/pkt.h new file mode 100644 index 000000000..8db02e923 --- /dev/null +++ b/nuttx/include/nuttx/net/pkt.h @@ -0,0 +1,106 @@ +/**************************************************************************** + * include/nuttx/net/pkt.h + * Definitions for use with AF_PACKET sockets + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Daniel Laszlo Sitzer + * + * Includes some definitions that a compatible with the LGPL GNU C Library + * header file of the same name. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_NET_PKT_H +#define __INCLUDE_NUTTX_NET_PKT_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +/* Representation of a uIP packet socket connection */ + +struct uip_pkt_conn +{ + 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 uip_callback_s *list; +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * 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 + */ + +struct uip_pkt_conn *uip_pktalloc(void); + +/* Allocate a new packet socket data callback */ + +#define uip_pktcallbackalloc(conn) uip_callbackalloc(&conn->list) +#define uip_pktcallbackfree(conn,cb) uip_callbackfree(cb, &conn->list) + +/* Free a connection structure that is no longer in use. This should + * be done by the implementation of close() + */ + +void uip_pktfree(struct uip_pkt_conn *conn); + +void uip_pktpoll(struct uip_driver_s *dev, struct uip_pkt_conn *conn); + +int uip_pktinput(struct uip_driver_s *dev); + +#endif /* __INCLUDE_NUTTX_NET_PKT_H */ diff --git a/nuttx/include/nuttx/net/tcp.h b/nuttx/include/nuttx/net/tcp.h new file mode 100644 index 000000000..05ccf4c4a --- /dev/null +++ b/nuttx/include/nuttx/net/tcp.h @@ -0,0 +1,529 @@ +/**************************************************************************** + * include/nuttx/net/tcp.h + * Header file for the uIP TCP/IP stack. + * + * The uIP TCP/IP stack header file contains definitions for a number + * of C macros that are used by uIP programs as well as internal uIP + * structures, TCP/IP header structures and function declarations. + * + * Copyright (C) 2007, 2009-2010, 2012-2014 Gregory Nutt. All rights + * reserved. + * Author: Gregory Nutt + * + * This logic was leveraged from uIP which also has a BSD-style license: + * + * Author Adam Dunkels + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_NET_TCP_H +#define __INCLUDE_NUTTX_NET_TCP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#ifdef CONFIG_NET_TCP + +#include +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* TCP definitions */ + +#define TCP_FIN 0x01 +#define TCP_SYN 0x02 +#define TCP_RST 0x04 +#define TCP_PSH 0x08 +#define TCP_ACK 0x10 +#define TCP_URG 0x20 +#define TCP_CTL 0x3f + +#define TCP_OPT_END 0 /* End of TCP options list */ +#define TCP_OPT_NOOP 1 /* "No-operation" TCP option */ +#define TCP_OPT_MSS 2 /* Maximum segment size TCP option */ + +#define TCP_OPT_MSS_LEN 4 /* Length of TCP MSS option. */ + +/* The TCP states used in the struct uip_conn tcpstateflags field */ + +#define UIP_TS_MASK 0x0f /* Bits 0-3: TCP state */ +#define UIP_CLOSED 0x00 /* The connection is not in use and available */ +#define UIP_ALLOCATED 0x01 /* The connection is allocated, but not yet initialized */ +#define UIP_SYN_RCVD 0x02 +#define UIP_SYN_SENT 0x03 +#define UIP_ESTABLISHED 0x04 +#define UIP_FIN_WAIT_1 0x05 +#define UIP_FIN_WAIT_2 0x06 +#define UIP_CLOSING 0x07 +#define UIP_TIME_WAIT 0x08 +#define UIP_LAST_ACK 0x09 +#define UIP_STOPPED 0x10 /* Bit 4: stopped */ + /* Bit 5-7: Unused, but not available */ + +/* Flag bits in 16-bit flags+ipoffset IPv4 TCP header field */ + +#define UIP_TCPFLAG_RESERVED 0x8000 +#define UIP_TCPFLAG_DONTFRAG 0x4000 +#define UIP_TCPFLAG_MOREFRAGS 0x2000 + +/* TCP header sizes */ + +#define UIP_TCPH_LEN 20 /* Size of TCP header */ +#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP + TCP header */ +#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN + +/* Initial minimum MSS according to RFC 879 + * + * There have been some assumptions made about using other than the + * default size for datagrams with some unfortunate results. + * + * HOSTS MUST NOT SEND DATAGRAMS LARGER THAN 576 OCTETS UNLESS THEY + * HAVE SPECIFIC KNOWLEDGE THAT THE DESTINATION HOST IS PREPARED TO + * ACCEPT LARGER DATAGRAMS. + * + * This is a long established rule. + */ + +#if UIP_TCP_MSS > 576 +# define UIP_TCP_INITIAL_MSS 576 +#else +# define UIP_TCP_INITIAL_MSS UIP_TCP_MSS +#endif + +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS +/* TCP write buffer access macros */ + +# define WRB_SEQNO(wrb) ((wrb)->wb_seqno) +# define WRB_PKTLEN(wrb) ((wrb)->wb_iob->io_pktlen) +# define WRB_SENT(wrb) ((wrb)->wb_sent) +# define WRB_NRTX(wrb) ((wrb)->wb_nrtx) +# define WRB_IOB(wrb) ((wrb)->wb_iob) +# define WRB_COPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0)) +# define WRB_COPYIN(wrb,src,n) (iob_copyin((wrb)->wb_iob,src,(n),0)) + +# define WRB_TRIM(wrb,n) \ + do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0) + +#ifdef CONFIG_DEBUG +# define WRB_DUMP(msg,wrb,len,offset) \ + tcp_wrbuffer_dump(msg,wrb,len,offset) +#else +# define WRB_DUMP(msg,wrb,len,offset) +#endif +#endif + +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +/* Representation of a uIP TCP connection. + * + * The uip_conn structure is used for identifying a connection. All + * but one field in the structure are to be considered read-only by an + * application. The only exception is the 'private' fields whose purpose + * is to let the application store application-specific state (e.g., + * file pointers) for the connection. + */ + +struct uip_driver_s; /* Forward reference */ +struct uip_callback_s; /* Forward reference */ +struct uip_backlog_s; /* Forward reference */ + +struct uip_conn +{ + dq_entry_t node; /* Implements a doubly linked list */ + uip_ipaddr_t ripaddr; /* The IP address of the remote host */ + uint8_t rcvseq[4]; /* The sequence number that we expect to + * receive next */ + uint8_t sndseq[4]; /* The sequence number that was last sent by us */ + uint8_t crefs; /* Reference counts on this instance */ + uint8_t sa; /* Retransmission time-out calculation state + * variable */ + uint8_t sv; /* Retransmission time-out calculation state + * variable */ + uint8_t rto; /* Retransmission time-out */ + uint8_t tcpstateflags; /* TCP state and flags */ + uint8_t timer; /* The retransmission timer (units: half-seconds) */ + uint8_t nrtx; /* The number of retransmissions for the last + * segment sent */ + uint16_t lport; /* The local TCP port, in network byte order */ + uint16_t rport; /* The remoteTCP port, in network byte order */ + uint16_t mss; /* Current maximum segment size for the + * connection */ + uint16_t winsize; /* Current window size of the connection */ +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS + uint32_t unacked; /* Number bytes sent but not yet ACKed */ +#else + uint16_t unacked; /* Number bytes sent but not yet ACKed */ +#endif + + /* Read-ahead buffering. + * + * readahead - A singly linked list of type struct uip_readahead_s + * where the TCP/IP read-ahead data is retained. + */ + +#ifdef CONFIG_NET_TCP_READAHEAD + sq_queue_t readahead; /* Read-ahead buffering */ +#endif + + /* Write buffering + * + * write_q - The queue of unsent I/O buffers. The head of this + * list may be partially sent. FIFO ordering. + * unacked_q - A queue of completely sent, but unacked I/O buffer + * chains. Sequence number ordering. + */ + +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS + sq_queue_t write_q; /* Write buffering for segments */ + sq_queue_t unacked_q; /* Write buffering for un-ACKed segments */ + uint16_t expired; /* Number segments retransmitted but not yet ACKed, + * it can only be updated at UIP_ESTABLISHED state */ + uint16_t sent; /* The number of bytes sent (ACKed and un-ACKed) */ + uint32_t isn; /* Initial sequence number */ +#endif + + /* Listen backlog support + * + * blparent - The backlog parent. If this connection is backlogged, + * this field will be non-null and will refer to the TCP connection + * structure in which this connection is backlogged. + * backlog - The pending connection backlog. If this connection is + * configured as a listener with backlog, then this refers to the + * struct uip_backlog_s tear-off structure that manages that backlog. + */ + +#ifdef CONFIG_NET_TCPBACKLOG + FAR struct uip_conn *blparent; + FAR struct uip_backlog_s *backlog; +#endif + + /* Application callbacks: + * + * Data transfer events are retained in 'list'. Event handlers in 'list' + * are called for events specified in the flags set within struct + * uip_callback_s + * + * When an callback is executed from 'list', the input flags are normally + * returned, however, the implementation may set one of the following: + * + * UIP_CLOSE - Gracefully close the current connection + * UIP_ABORT - Abort (reset) the current connection on an error that + * prevents UIP_CLOSE from working. + * + * And/Or set/clear the following: + * + * UIP_NEWDATA - May be cleared to indicate that the data was consumed + * and that no further process of the new data should be + * attempted. + * UIP_SNDACK - If UIP_NEWDATA is cleared, then UIP_SNDACK may be set + * to indicate that an ACK should be included in the response. + * (In UIP_NEWDATA is cleared bu UIP_SNDACK is not set, then + * dev->d_len should also be cleared). + */ + + FAR struct uip_callback_s *list; + + /* accept() is called when the TCP logic has created a connection */ + + FAR void *accept_private; + int (*accept)(FAR struct uip_conn *listener, struct uip_conn *conn); + + /* connection_event() is called on any of the subset of connection-related + * events. + */ + + FAR void *connection_private; + void (*connection_event)(FAR struct uip_conn *conn, uint16_t flags); +}; + +/* The following structure is used to handle read-ahead buffering for TCP + * connection. When incoming TCP data is received while no application is + * listening for the data, that data will be retained in these read-ahead + * buffers so that no data is lost. + */ + +#ifdef CONFIG_NET_TCP_READAHEAD +struct uip_readahead_s +{ + sq_entry_t rh_node; /* Supports a singly linked list */ + uint16_t rh_nbytes; /* Number of bytes available in this buffer */ + uint8_t rh_buffer[CONFIG_NET_TCP_READAHEAD_BUFSIZE]; +}; +#endif + +/* This structure supports TCP write buffering */ + +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS +struct iob_s; /* Forward reference */ +struct tcp_wrbuffer_s +{ + sq_entry_t wb_node; /* Supports a singly linked list */ + uint32_t wb_seqno; /* Sequence number of the write segment */ + uint16_t wb_sent; /* Number of bytes sent from the I/O buffer chain */ + uint8_t wb_nrtx; /* The number of retransmissions for the last + * segment sent */ + struct iob_s *wb_iob; /* Head of the I/O buffer chain */ +}; +#endif + +/* Support for listen backlog: + * + * struct uip_blcontainer_s describes one backlogged connection + * struct uip_backlog_s is a "tear-off" describing all backlog for a + * listener connection + */ + +#ifdef CONFIG_NET_TCPBACKLOG +struct uip_blcontainer_s +{ + sq_entry_t bc_node; /* Implements a singly linked list */ + FAR struct uip_conn *bc_conn; /* Holds reference to the new connection structure */ +}; + +struct uip_backlog_s +{ + sq_queue_t bl_free; /* Implements a singly-linked list of free containers */ + sq_queue_t bl_pending; /* Implements a singly-linked list of pending connections */ +}; +#endif + +/* The structure holding the TCP/IP statistics that are gathered if + * CONFIG_NET_STATISTICS is defined. + */ + +#ifdef CONFIG_NET_STATISTICS +struct uip_tcp_stats_s +{ + uip_stats_t drop; /* Number of dropped TCP segments */ + uip_stats_t recv; /* Number of received TCP segments */ + uip_stats_t sent; /* Number of sent TCP segments */ + uip_stats_t chkerr; /* Number of TCP segments with a bad checksum */ + uip_stats_t ackerr; /* Number of TCP segments with a bad ACK number */ + uip_stats_t rst; /* Number of received TCP RST (reset) segments */ + uip_stats_t rexmit; /* Number of retransmitted TCP segments */ + uip_stats_t syndrop; /* Number of dropped SYNs due to too few + available connections */ + uip_stats_t synrst; /* Number of SYNs for closed ports triggering a RST */ +}; +#endif + +/* The TCP and IP headers */ + +struct uip_tcpip_hdr +{ +#ifdef CONFIG_NET_IPv6 + + /* IPv6 Ip header */ + + uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ + uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */ + uint16_t flow; /* 16-bit flow label (LS) */ + uint8_t len[2]; /* 16-bit Payload length */ + uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ + uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ + uip_ip6addr_t srcipaddr; /* 128-bit Source address */ + uip_ip6addr_t destipaddr; /* 128-bit Destination address */ + +#else /* CONFIG_NET_IPv6 */ + + /* IPv4 IP header */ + + uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ + uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ + uint8_t len[2]; /* 16-bit Total length */ + uint8_t ipid[2]; /* 16-bit Identification */ + uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ + uint8_t ttl; /* 8-bit Time to Live */ + uint8_t proto; /* 8-bit Protocol */ + uint16_t ipchksum; /* 16-bit Header checksum */ + uint16_t srcipaddr[2]; /* 32-bit Source IP address */ + uint16_t destipaddr[2]; /* 32-bit Destination IP address */ + +#endif /* CONFIG_NET_IPv6 */ + + /* TCP header */ + + uint16_t srcport; + uint16_t destport; + uint8_t seqno[4]; + uint8_t ackno[4]; + uint8_t tcpoffset; + uint8_t flags; + uint8_t wnd[2]; + uint16_t tcpchksum; + uint8_t urgp[2]; + uint8_t optdata[4]; +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * 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 + */ + +struct uip_conn *uip_tcpalloc(void); + +/* Allocate a new TCP data callback */ + +#define uip_tcpcallbackalloc(conn) uip_callbackalloc(&conn->list) +#define uip_tcpcallbackfree(conn,cb) uip_callbackfree(cb, &conn->list) + +/* Free a connection structure that is no longer in use. This should + * be done by the implementation of close() + */ + +void uip_tcpfree(struct uip_conn *conn); + +/* Bind a TCP connection to a local address */ + +#ifdef CONFIG_NET_IPv6 +int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in6 *addr); +#else +int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in *addr); +#endif + +/* This function implements the UIP specific parts of the standard + * TCP connect() operation: It connects to a remote host using TCP. + * + * This function is used to start a new connection to the specified + * port on the specied host. It uses the connection structure that was + * allocated by a preceding socket() call. It sets the connection to + * the SYN_SENT state and sets the retransmission timer to 0. This will + * cause a TCP SYN segment to be sent out the next time this connection + * is periodically processed, which usually is done within 0.5 seconds + * after the call to uip_tcpconnect(). + * + * This function is called from normal user level code. + */ + +#ifdef CONFIG_NET_IPv6 +int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in6 *addr); +#else +int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr); +#endif + +/* Start listening to the port bound to the specified TCP connection */ + +int uip_listen(struct uip_conn *conn); + +/* Stop listening to the port bound to the specified TCP connection */ + +int uip_unlisten(struct uip_conn *conn); + +/* Access to TCP read-ahead buffers */ + +#ifdef CONFIG_NET_TCP_READAHEAD +FAR struct uip_readahead_s *uip_tcpreadahead_alloc(void); +void uip_tcpreadahead_release(FAR struct uip_readahead_s *readahead); +#endif /* CONFIG_NET_TCP_READAHEAD */ + +/* Backlog support */ + +#ifdef CONFIG_NET_TCPBACKLOG +/* APIs to create and terminate TCP backlog support */ + +int uip_backlogcreate(FAR struct uip_conn *conn, int nblg); +int uip_backlogdestroy(FAR struct uip_conn *conn); + +/* APIs to manage individual backlog actions */ + +int uip_backlogadd(FAR struct uip_conn *conn, FAR struct uip_conn *blconn); +#ifndef CONFIG_DISABLE_POLL +bool uip_backlogavailable(FAR struct uip_conn *conn); +#else +# define uip_backlogavailable(conn) (false); +#endif +FAR struct uip_conn *uip_backlogremove(FAR struct uip_conn *conn); +int uip_backlogdelete(FAR struct uip_conn *conn, FAR struct uip_conn *blconn); + +#else +# define uip_backlogcreate(conn,nblg) (-ENOSYS) +# define uip_backlogdestroy(conn) (-ENOSYS) +# define uip_backlogadd(conn,blconn) (-ENOSYS) +# define uip_backlogavailable(conn) (false); +# define uip_backlogremove(conn) (NULL) +#endif + +/* Tell the sending host to stop sending data. + * + * This function will close our receiver's window so that we stop + * receiving data for the current connection. + */ + +#define uip_stop(conn) ((conn)->tcpstateflags |= UIP_STOPPED) + +/* Find out if the current connection has been previously stopped with + * uip_stop(). + */ + +#define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED) + +/* Restart the current connection, if is has previously been stopped + * with uip_stop(). + * + * This function will open the receiver's window again so that we start + * receiving data for the current connection. + */ + +#define uip_restart(conn,f) \ + do { \ + (f) |= UIP_NEWDATA; \ + (conn)->tcpstateflags &= ~UIP_STOPPED; \ + } while (0) + +/* Get the current maximum segment size that can be sent on the current + * connection. + */ + +#define uip_mss(conn) ((conn)->mss) + +#endif /* CONFIG_NET_TCP */ +#endif /* __INCLUDE_NUTTX_NET_TCP_H */ diff --git a/nuttx/include/nuttx/net/udp.h b/nuttx/include/nuttx/net/udp.h new file mode 100644 index 000000000..2b90dce79 --- /dev/null +++ b/nuttx/include/nuttx/net/udp.h @@ -0,0 +1,206 @@ +/**************************************************************************** + * include/nuttx/net/udp.h + * Header file for the uIP UDP stack. + * + * The uIP UDP stack header file contains definitions for a number + * of C macros that are used by uIP programs as well as internal uIP + * structures, UDP header structures and function declarations. + * + * Copyright (C) 2007, 2009, 2012, 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * This logic was leveraged from uIP which also has a BSD-style license: + * + * Author Adam Dunkels + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_NET_UDP_H +#define __INCLUDE_NUTTX_NET_UDP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Header sizes */ + +#define UIP_UDPH_LEN 8 /* Size of UDP header */ +#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + UDP header */ + +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +/* Representation of a uIP UDP connection */ + +struct uip_driver_s; /* Forward reference */ +struct uip_callback_s; /* Forward reference */ +struct uip_udp_conn +{ + dq_entry_t node; /* Supports a doubly linked list */ + uip_ipaddr_t ripaddr; /* The IP address of the remote peer */ + uint16_t lport; /* The local port number in network byte order */ + uint16_t rport; /* The remote port number in network byte order */ + uint8_t ttl; /* Default time-to-live */ + uint8_t crefs; /* Reference counts on this instance */ + + /* Defines the list of UDP callbacks */ + + struct uip_callback_s *list; +}; + +/* The UDP and IP headers */ + +struct uip_udpip_hdr +{ +#ifdef CONFIG_NET_IPv6 + + /* IPv6 Ip header */ + + uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ + uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */ + uint16_t flow; /* 16-bit flow label (LS) */ + uint8_t len[2]; /* 16-bit Payload length */ + uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ + uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ + uip_ip6addr_t srcipaddr; /* 128-bit Source address */ + uip_ip6addr_t destipaddr; /* 128-bit Destination address */ + +#else /* CONFIG_NET_IPv6 */ + + /* IPv4 header */ + + uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ + uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ + uint8_t len[2]; /* 16-bit Total length */ + uint8_t ipid[2]; /* 16-bit Identification */ + uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ + uint8_t ttl; /* 8-bit Time to Live */ + uint8_t proto; /* 8-bit Protocol */ + uint16_t ipchksum; /* 16-bit Header checksum */ + uint16_t srcipaddr[2]; /* 32-bit Source IP address */ + uint16_t destipaddr[2]; /* 32-bit Destination IP address */ + +#endif /* CONFIG_NET_IPv6 */ + + /* UDP header */ + + uint16_t srcport; + uint16_t destport; + uint16_t udplen; + uint16_t udpchksum; +}; + +/* The structure holding the UDP statistics that are gathered if + * CONFIG_NET_STATISTICS is defined. + */ + +#ifdef CONFIG_NET_STATISTICS +struct uip_udp_stats_s +{ + uip_stats_t drop; /* Number of dropped UDP segments */ + uip_stats_t recv; /* Number of recived UDP segments */ + uip_stats_t sent; /* Number of sent UDP segments */ + uip_stats_t chkerr; /* Number of UDP segments with a bad checksum */ +}; +#endif + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * 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 + */ + +extern struct uip_udp_conn *uip_udpalloc(void); + +/* Allocate a new TCP data callback */ + +#define uip_udpcallbackalloc(conn) uip_callbackalloc(&conn->list) +#define uip_udpcallbackfree(conn,cb) uip_callbackfree(cb, &conn->list) + +/* Free a connection structure that is no longer in use. This should + * be done by the implementation of close() + */ + +extern void uip_udpfree(struct uip_udp_conn *conn); + +/* Bind a UDP connection to a local address */ + +#ifdef CONFIG_NET_IPv6 +extern int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in6 *addr); +#else +extern int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in *addr); +#endif + +/* This function sets up a new UDP connection. The function will + * automatically allocate an unused local port for the new + * connection. However, another port can be chosen by using the + * uip_udpbind() call, after the uip_udpconnect() function has been + * called. + * + * This function is called as part of the implementation of sendto + * and recvfrom. + * + * addr The address of the remote host. + */ + +#ifdef CONFIG_NET_IPv6 +extern int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in6 *addr); +#else +extern int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in *addr); +#endif + +/* Enable/disable UDP callbacks on a connection */ + +extern void uip_udpenable(struct uip_udp_conn *conn); +extern void uip_udpdisable(struct uip_udp_conn *conn); + +#endif /* __INCLUDE_NUTTX_NET_UDP_H */ diff --git a/nuttx/include/nuttx/net/uip.h b/nuttx/include/nuttx/net/uip.h new file mode 100644 index 000000000..3725f423f --- /dev/null +++ b/nuttx/include/nuttx/net/uip.h @@ -0,0 +1,584 @@ +/**************************************************************************** + * include/nuttx/net/uip.h + * + * The uIP header file contains definitions for a number of C macros that + * are used by uIP programs as well as internal uIP structures and function + * declarations. + * + * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * This logic was leveraged from uIP which also has a BSD-style license: + * + * Author Adam Dunkels + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_NET_UIP_H +#define __INCLUDE_NUTTX_NET_UIP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#ifdef CONFIG_NET_NOINTS +# include +#endif + +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The following flags may be set in the set of flags before calling the + * application callback. The UIP_ACKDATA, UIP_NEWDATA, and UIP_CLOSE flags + * may be set at the same time, whereas the others are mutualy exclusive. + * + * UIP_ACKDATA IN: Signifies that the outstanding data was acked and + * the application should send out new data instead + * of retransmitting the last data (TCP only) + * OUT: Input state must be preserved on output. + * UIP_NEWDATA IN: Set to indicate that the peer has sent us new data. + * OUT: Cleared (only) by the application logic to indicate + * that the new data was consumed, suppressing further + * attempts to process the new data. + * UIP_SNDACK IN: Not used; always zero + * OUT: Set by the application if the new data was consumed + * and an ACK should be sent in the response. (TCP only) + * UIP_REXMIT IN: Tells the application to retransmit the data that + * was last sent. (TCP only) + * OUT: Not used + * UIP_POLL IN: Used for polling the application. This is provided + * periodically from the drivers to support (1) timed + * operations, and (2) to check if the application has + * data that it wants to send + * OUT: Not used + * UIP_BACKLOG IN: There is a new connection in the backlog list set + * up by the listen() command. (TCP only) + * OUT: Not used + * UIP_CLOSE IN: The remote host has closed the connection, thus the + * connection has gone away. (TCP only) + * OUT: The application signals that it wants to close the + * connection. (TCP only) + * UIP_ABORT IN: The remote host has aborted the connection, thus the + * connection has gone away. (TCP only) + * OUT: The application signals that it wants to abort the + * connection. (TCP only) + * UIP_CONNECTED IN: We have got a connection from a remote host and have + * set up a new connection for it, or an active connection + * has been successfully established. (TCP only) + * OUT: Not used + * UIP_TIMEDOUT IN: The connection has been aborted due to too many + * retransmissions. (TCP only) + * OUT: Not used + * UIP_ECHOREPLY IN: An ICMP Echo Reply has been received. Used to support + * ICMP ping from applications. (ICMP only) + * OUT: Cleared (only) by the application logic to indicate + * that the reply was processed, suppressing further + * attempts to process the reply. + */ + +#define UIP_ACKDATA (1 << 0) +#define UIP_NEWDATA (1 << 1) +#define UIP_SNDACK (1 << 2) +#define UIP_REXMIT (1 << 3) +#define UIP_POLL (1 << 4) +#define UIP_BACKLOG (1 << 5) +#define UIP_CLOSE (1 << 6) +#define UIP_ABORT (1 << 7) +#define UIP_CONNECTED (1 << 8) +#define UIP_TIMEDOUT (1 << 9) +#define UIP_ECHOREPLY (1 << 10) + +#define UIP_CONN_EVENTS (UIP_CLOSE|UIP_ABORT|UIP_CONNECTED|UIP_TIMEDOUT) + +/* The buffer size available for user data in the d_buf buffer. + * + * This macro holds the available size for user data in the + * d_buf buffer. The macro is intended to be used for checking + * bounds of available user data. + * + * Example: + * + * snprintf(dev->d_appdata, UIP_APPDATA_SIZE, "%u\n", i); + */ + +#define UIP_APPDATA_SIZE (CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) + +#define UIP_PROTO_ICMP 1 +#define UIP_PROTO_IGMP 2 +#define UIP_PROTO_TCP 6 +#define UIP_PROTO_UDP 17 +#define UIP_PROTO_ICMP6 58 + +/* Header sizes */ + +#ifdef CONFIG_NET_IPv6 +# define UIP_IPH_LEN 40 /* Size of IP header */ +#else +# define UIP_IPH_LEN 20 /* Size of IP header */ +#endif + +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +/* Representation of an IP address */ + +typedef in_addr_t uip_ip4addr_t; +typedef uint16_t uip_ip6addr_t[8]; + +#ifdef CONFIG_NET_IPv6 +typedef uip_ip6addr_t uip_ipaddr_t; +#else +typedef uip_ip4addr_t uip_ipaddr_t; +#endif + +/* The IP header */ + +struct uip_ip_hdr +{ +#ifdef CONFIG_NET_IPv6 + + /* IPv6 Ip header */ + + uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ + uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */ + uint16_t flow; /* 16-bit flow label (LS) */ + uint8_t len[2]; /* 16-bit Payload length */ + uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ + uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ + uip_ip6addr_t srcipaddr; /* 128-bit Source address */ + uip_ip6addr_t destipaddr; /* 128-bit Destination address */ + +#else /* CONFIG_NET_IPv6 */ + + /* IPv4 IP header */ + + uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ + uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ + uint8_t len[2]; /* 16-bit Total length */ + uint8_t ipid[2]; /* 16-bit Identification */ + uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ + uint8_t ttl; /* 8-bit Time to Live */ + uint8_t proto; /* 8-bit Protocol */ + uint16_t ipchksum; /* 16-bit Header checksum */ + uint16_t srcipaddr[2]; /* 32-bit Source IP address */ + uint16_t destipaddr[2]; /* 32-bit Destination IP address */ + +#endif /* CONFIG_NET_IPv6 */ +}; + +/* Describes a uIP callback + * + * flink - Supports a singly linked list + * event - Provides the address of the callback function entry point. + * pvconn is a pointer to one of struct uip_conn or struct uip_udp_conn. + * priv - Holds a reference to application specific data that will + * provided + * flags - Set by the application to inform the uIP layer which flags + * are and are not handled by the callback. + */ + +struct uip_driver_s; /* Forward reference */ +struct uip_callback_s +{ + FAR struct uip_callback_s *flink; + uint16_t (*event)(struct uip_driver_s *dev, void *pvconn, void *pvpriv, uint16_t flags); + void *priv; + uint16_t flags; +}; + +/* Protocol-specific support */ + +#ifdef CONFIG_NET_PKT +# include +#endif +#ifdef CONFIG_NET_TCP +# include +#endif +#ifdef CONFIG_NET_UDP +# include +#endif +#ifdef CONFIG_NET_ICMP +# include +#endif +#ifdef CONFIG_NET_IGMP +# include +#endif + +/* The structure holding the uIP statistics that are gathered if + * CONFIG_NET_STATISTICS is defined. + */ + +#ifdef CONFIG_NET_STATISTICS +struct uip_ip_stats_s +{ + uip_stats_t drop; /* Number of dropped packets at the IP layer */ + uip_stats_t recv; /* Number of received packets at the IP layer */ + uip_stats_t sent; /* Number of sent packets at the IP layer */ + uip_stats_t vhlerr; /* Number of packets dropped due to wrong + IP version or header length */ + uip_stats_t hblenerr; /* Number of packets dropped due to wrong + IP length, high byte */ + uip_stats_t lblenerr; /* Number of packets dropped due to wrong + IP length, low byte */ + uip_stats_t fragerr; /* Number of packets dropped since they + were IP fragments */ + uip_stats_t chkerr; /* Number of packets dropped due to IP + checksum errors */ + uip_stats_t protoerr; /* Number of packets dropped since they + were neither ICMP, UDP nor TCP */ +}; + +struct uip_stats +{ + struct uip_ip_stats_s ip; /* IP statistics */ + +#ifdef CONFIG_NET_ICMP + struct uip_icmp_stats_s icmp; /* ICMP statistics */ +#endif + +#ifdef CONFIG_NET_IGMP + struct uip_igmp_stats_s igmp; /* IGMP statistics */ +#endif + +#ifdef CONFIG_NET_TCP + struct uip_tcp_stats_s tcp; /* TCP statistics */ +#endif + +#ifdef CONFIG_NET_UDP + struct uip_udp_stats_s udp; /* UDP statistics */ +#endif +}; +#endif /* CONFIG_NET_STATISTICS */ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* This is the structure in which the statistics are gathered. */ + +#ifdef CONFIG_NET_STATISTICS +extern struct uip_stats uip_stat; +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* uIP initialization functions + * + * The uIP initialization functions are used for booting uIP. + * + * This function should be called at boot up to initilize the uIP + * TCP/IP stack. + */ + +void uip_initialize(void); + +/* This function may be used at boot time to set the initial ip_id.*/ + +void uip_setipid(uint16_t id); + +/* Critical section management. The NuttX configuration setting + * CONFIG_NET_NOINT indicates that uIP not called from the interrupt level. + * If CONFIG_NET_NOINTS is defined, then these will map to semaphore + * controls. Otherwise, it assumed that uIP will be called from interrupt + * level handling and these will map to interrupt enable/disable controls. + */ + +#ifdef CONFIG_NET_NOINTS + +/* Semaphore based locking for non-interrupt based logic. + * + * uip_lock_t -- Not used. Only for compatibility + * uip_lockinit() -- Initializes an underlying semaphore/mutex + * uip_lock() -- Takes the semaphore(). Implements a re-entrant mutex. + * uip_unlock() -- Gives the semaphore(). + * uip_lockedwait() -- Like pthread_cond_wait(); releases the semaphore + * momemtarily to wait on another semaphore() + */ + +typedef uint8_t uip_lock_t; /* Not really used */ + +void uip_lockinit(void); +uip_lock_t uip_lock(void); +void uip_unlock(uip_lock_t flags); +int uip_lockedwait(sem_t *sem); + +#else + +/* Enable/disable locking for interrupt based logic: + * + * uip_lock_t -- The processor specific representation of interrupt state. + * uip_lockinit() -- (Does not exist). + * uip_lock() -- Disables interrupts. + * uip_unlock() -- Conditionally restores interrupts. + * uip_lockedwait() -- Just wait for the semaphore. + */ + +# define uip_lock_t irqstate_t +# define uip_lockinit() +# define uip_lock() irqsave() +# define uip_unlock(f) irqrestore(f) +# define uip_lockedwait(s) sem_wait(s) + +#endif + +/* 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. + */ + +/* Send data on the current connection. + * + * This function is used to send out a single segment of TCP + * data. Only applications that have been invoked by uIP for event + * processing can send data. + * + * The amount of data that actually is sent out after a call to this + * funcion is determined by the maximum amount of data TCP allows. uIP + * will automatically crop the data so that only the appropriate + * amount of data is sent. The function uip_mss() can be used to query + * uIP for the amount of data that actually will be sent. + * + * Note: This function does not guarantee that the sent data will + * arrive at the destination. If the data is lost in the network, the + * application will be invoked with the UIP_REXMIT flag set. The + * application will then have to resend the data using this function. + * + * data A pointer to the data which is to be sent. + * + * len The maximum amount of data bytes to be sent. + */ + +void uip_send(FAR struct uip_driver_s *dev, FAR const void *buf, int len); + +#ifdef CONFIG_NET_IOB +struct iob_s; +void uip_iobsend(FAR struct uip_driver_s *dev, FAR struct iob_s *buf, + unsigned int len, unsigned int offset); +#endif + +#ifdef CONFIG_NET_PKT +void uip_pktsend(FAR struct uip_driver_s *dev, FAR const void *buf, + unsigned int len); +#endif + +/* uIP convenience and converting functions. + * + * These functions can be used for converting between different data + * formats used by uIP. + * + * Construct an IP address from four bytes. + * + * This function constructs an IPv4 address in network byte order. + * + * addr A pointer to a uip_ipaddr_t variable that will be + * filled in with the IPv4 address. + * addr0 The first octet of the IPv4 address. + * addr1 The second octet of the IPv4 address. + * addr2 The third octet of the IPv4 address. + * addr3 The forth octet of the IPv4 address. + */ + +#define uip_ipaddr(addr, addr0, addr1, addr2, addr3) \ + do { \ + addr = HTONL((uint32_t)(addr0) << 24 | (uint32_t)(addr1) << 16 | \ + (uint32_t)(addr2) << 8 | (uint32_t)(addr3)); \ + } while (0) + +/* Convert an IPv4 address of the form uint16_t[2] to an in_addr_t */ + +#ifdef CONFIG_ENDIAN_BIG +# define uip_ip4addr_conv(addr) (((in_addr_t)((uint16_t*)addr)[0] << 16) | (in_addr_t)((uint16_t*)addr)[1]) +#else +# define uip_ip4addr_conv(addr) (((in_addr_t)((uint16_t*)addr)[1] << 16) | (in_addr_t)((uint16_t*)addr)[0]) +#endif + +/* Extract individual bytes from a 32-bit IPv4 IP address that is in network byte order */ + +#ifdef CONFIG_ENDIAN_BIG + /* Big-endian byte order: 11223344 */ + +# define ip4_addr1(ipaddr) (((ipaddr) >> 24) & 0xff) +# define ip4_addr2(ipaddr) (((ipaddr) >> 16) & 0xff) +# define ip4_addr3(ipaddr) (((ipaddr) >> 8) & 0xff) +# define ip4_addr4(ipaddr) ((ipaddr) & 0xff) +#else + /* Little endian byte order: 44223311 */ + +# define ip4_addr1(ipaddr) ((ipaddr) & 0xff) +# define ip4_addr2(ipaddr) (((ipaddr) >> 8) & 0xff) +# define ip4_addr3(ipaddr) (((ipaddr) >> 16) & 0xff) +# define ip4_addr4(ipaddr) (((ipaddr) >> 24) & 0xff) +#endif + +/* Construct an IPv6 address from eight 16-bit words. + * + * This function constructs an IPv6 address. + */ + +#define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) \ + do { \ + ((uint16_t*)(addr))[0] = HTONS((addr0)); \ + ((uint16_t*)(addr))[1] = HTONS((addr1)); \ + ((uint16_t*)(addr))[2] = HTONS((addr2)); \ + ((uint16_t*)(addr))[3] = HTONS((addr3)); \ + ((uint16_t*)(addr))[4] = HTONS((addr4)); \ + ((uint16_t*)(addr))[5] = HTONS((addr5)); \ + ((uint16_t*)(addr))[6] = HTONS((addr6)); \ + ((uint16_t*)(addr))[7] = HTONS((addr7)); \ + } while (0) + +/* Copy an IP address to another IP address. + * + * Copies an IP address from one place to another. + * + * Example: + * + * uip_ipaddr_t ipaddr1, ipaddr2; + * + * uip_ipaddr(&ipaddr1, 192,16,1,2); + * uip_ipaddr_copy(&ipaddr2, &ipaddr1); + * + * dest The destination for the copy. + * src The source from where to copy. + */ + +#ifndef CONFIG_NET_IPv6 +# define uip_ipaddr_copy(dest, src) \ + do { \ + (dest) = (in_addr_t)(src); \ + } while (0) +# define uiphdr_ipaddr_copy(dest, src) \ + do { \ + ((uint16_t*)(dest))[0] = ((uint16_t*)(src))[0]; \ + ((uint16_t*)(dest))[1] = ((uint16_t*)(src))[1]; \ + } while (0) +#else /* !CONFIG_NET_IPv6 */ +# define uip_ipaddr_copy(dest, src) memcpy(&dest, &src, sizeof(uip_ip6addr_t)) +# define uiphdr_ipaddr_copy(dest, src) uip_ipaddr_copy(dest, src) +#endif /* !CONFIG_NET_IPv6 */ + +/* Compare two IP addresses + * + * Example: + * + * uip_ipaddr_t ipaddr1, ipaddr2; + * + * uip_ipaddr(&ipaddr1, 192,16,1,2); + * if (uip_ipaddr_cmp(ipaddr2, ipaddr1)) + * { + * printf("They are the same"); + * } + * + * addr1 The first IP address. + * addr2 The second IP address. + */ + +#ifndef CONFIG_NET_IPv6 +# define uip_ipaddr_cmp(addr1, addr2) (addr1 == addr2) +# define uiphdr_ipaddr_cmp(addr1, addr2) uip_ipaddr_cmp(uip_ip4addr_conv(addr1), uip_ip4addr_conv(addr2)) +#else /* !CONFIG_NET_IPv6 */ +# define uip_ipaddr_cmp(addr1, addr2) (memcmp(&addr1, &addr2, sizeof(uip_ip6addr_t)) == 0) +# define uiphdr_ipaddr_cmp(addr1, addr2) uip_ipaddr_cmp(addr, addr2) +#endif /* !CONFIG_NET_IPv6 */ + +/* Compare two IP addresses with netmasks + * + * Compares two IP addresses with netmasks. The masks are used to mask + * out the bits that are to be compared. + * + * Example: + * + * uip_ipaddr_t ipaddr1, ipaddr2, mask; + * + * uip_ipaddr(&mask, 255,255,255,0); + * uip_ipaddr(&ipaddr1, 192,16,1,2); + * uip_ipaddr(&ipaddr2, 192,16,1,3); + * if (uip_ipaddr_maskcmp(ipaddr1, ipaddr2, &mask)) + * { + * printf("They are the same"); + * } + * + * addr1 The first IP address. + * addr2 The second IP address. + * mask The netmask. + */ + +#ifndef CONFIG_NET_IPv6 +# define uip_ipaddr_maskcmp(addr1, addr2, mask) \ + (((in_addr_t)(addr1) & (in_addr_t)(mask)) == \ + ((in_addr_t)(addr2) & (in_addr_t)(mask))) +#else +bool uip_ipaddr_maskcmp(uip_ipaddr_t addr1, uip_ipaddr_t addr2, + uip_ipaddr_t mask); +#endif + +/* Mask out the network part of an IP address. + * + * Masks out the network part of an IP address, given the address and + * the netmask. + * + * Example: + * + * uip_ipaddr_t ipaddr1, ipaddr2, netmask; + * + * uip_ipaddr(&ipaddr1, 192,16,1,2); + * uip_ipaddr(&netmask, 255,255,255,0); + * uip_ipaddr_mask(&ipaddr2, &ipaddr1, &netmask); + * + * In the example above, the variable "ipaddr2" will contain the IP + * address 192.168.1.0. + * + * dest Where the result is to be placed. + * src The IP address. + * mask The netmask. + */ + +#define uip_ipaddr_mask(dest, src, mask) \ + do { \ + (in_addr_t)(dest) = (in_addr_t)(src) & (in_addr_t)(mask); \ + } while (0) + +#endif /* __INCLUDE_NUTTX_NET_UIP_H */ diff --git a/nuttx/include/nuttx/net/uip/uip-icmp.h b/nuttx/include/nuttx/net/uip/uip-icmp.h deleted file mode 100644 index 849d62af0..000000000 --- a/nuttx/include/nuttx/net/uip/uip-icmp.h +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** - * include/nuttx/net/uip/uip-icmp.h - * Header file for the uIP ICMP stack. - * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * This logic was leveraged from uIP which also has a BSD-style license: - * - * Author Adam Dunkels - * Copyright (c) 2001-2003, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __INCLUDE_NUTTX_NET_UIP_UIP_ICMP_H -#define __INCLUDE_NUTTX_NET_UIP_UIP_ICMP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* ICMP/ICMP6 definitions */ - -/* ICMP/ICMP6 Message Types */ - -#define ICMP_ECHO_REPLY 0 /* RFC 792 */ -#define ICMP_DEST_UNREACHABLE 3 /* RFC 792 */ -#define ICMP_SRC_QUENCH 4 /* RFC 792 */ -#define ICMP_REDIRECT 5 /* RFC 792 */ -#define ICMP_ALT_HOST_ADDRESS 6 -#define ICMP_ECHO_REQUEST 8 /* RFC 792 */ -#define ICMP_ROUTER_ADVERTISEMENT 9 /* RFC 1256 */ -#define ICMP_ROUTER_SOLICITATION 10 /* RFC 1256 */ -#define ICMP_TIME_EXCEEDED 11 /* RFC 792 */ -#define ICMP_PARAMETER_PROBLEM 12 -#define ICMP_TIMESTAMP_REQUEST 13 -#define ICMP_TIMESTAMP_REPLY 14 -#define ICMP_INFORMATION_REQUEST 15 -#define ICMP_INFORMATION_REPLY 16 -#define ICMP_ADDRESS_MASK_REQUEST 17 -#define ICMP_ADDRESS_MASK_REPLY 18 -#define ICMP_TRACEROUTE 30 -#define ICMP_CONVERSION_ERROR 31 -#define ICMP_MOBILE_HOST_REDIRECT 32 -#define ICMP_IPV6_WHEREAREYOU 33 -#define ICMP_IPV6_IAMHERE 34 -#define ICMP_MOBILE_REGIS_REQUEST 35 -#define ICMP_MOBILE_REGIS_REPLY 36 -#define ICMP_DOMAIN_NAME_REQUEST 37 -#define ICMP_DOMAIN_NAME_REPLY 38 -#define ICMP_SKIP_DISCOVERY_PROTO 39 -#define ICMP_PHOTURIS_SECURITY_FAIL 40 -#define ICMP_EXP_MOBILE_PROTO 41 /* RFC 4065 */ - -/* ICMP6 Message Types */ - -#define ICMP6_ECHO_REPLY 129 -#define ICMP6_ECHO_REQUEST 128 -#define ICMP6_NEIGHBOR_SOLICITATION 135 -#define ICMP6_NEIGHBOR_ADVERTISEMENT 136 - -#define ICMP6_FLAG_S (1 << 6) - -#define ICMP6_OPTION_SOURCE_LINK_ADDRESS 1 -#define ICMP6_OPTION_TARGET_LINK_ADDRESS 2 - -/* Header sizes */ - -#define UIP_ICMPH_LEN 4 /* Size of ICMP header */ -#define UIP_IPICMPH_LEN (UIP_ICMPH_LEN + UIP_IPH_LEN) /* Size of IP + ICMP header */ - -/**************************************************************************** - * Public Type Definitions - ****************************************************************************/ - -/* The ICMP and IP headers */ - -struct uip_icmpip_hdr -{ -#ifdef CONFIG_NET_IPv6 - - /* IPv6 Ip header */ - - uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ - uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */ - uint16_t flow; /* 16-bit flow label (LS) */ - uint8_t len[2]; /* 16-bit Payload length */ - uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ - uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ - uip_ip6addr_t srcipaddr; /* 128-bit Source address */ - uip_ip6addr_t destipaddr; /* 128-bit Destination address */ - -#else /* CONFIG_NET_IPv6 */ - - /* IPv4 IP header */ - - uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ - uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ - uint8_t len[2]; /* 16-bit Total length */ - uint8_t ipid[2]; /* 16-bit Identification */ - uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ - uint8_t ttl; /* 8-bit Time to Live */ - uint8_t proto; /* 8-bit Protocol */ - uint16_t ipchksum; /* 16-bit Header checksum */ - uint16_t srcipaddr[2]; /* 32-bit Source IP address */ - uint16_t destipaddr[2]; /* 32-bit Destination IP address */ - -#endif /* CONFIG_NET_IPv6 */ - - /* ICMP header */ - - uint8_t type; /* Defines the format of the ICMP message */ - uint8_t icode; /* Further qualifies the ICMP messsage */ - uint16_t icmpchksum; /* Checksum of ICMP header and data */ - - /* Data following the ICMP header contains the data specific to the - * message type indicated by the Type and Code fields. - */ - -#ifndef CONFIG_NET_IPv6 - - /* ICMP_ECHO_REQUEST and ICMP_ECHO_REPLY data */ - - uint16_t id; /* Used to match requests with replies */ - uint16_t seqno; /* " " "" " " " " " " " " */ - -#else /* !CONFIG_NET_IPv6 */ - - /* ICMP6_ECHO_REQUEST and ICMP6_ECHO_REPLY data */ - - uint8_t flags; - uint8_t reserved1; - uint8_t reserved2; - uint8_t reserved3; - uint8_t icmp6data[16]; - uint8_t options[1]; - -#endif /* !CONFIG_NET_IPv6 */ -}; - -/* The structure holding the ICMP statistics that are gathered if - * CONFIG_NET_STATISTICS is defined. - */ - -#ifdef CONFIG_NET_STATISTICS -struct uip_icmp_stats_s -{ - uip_stats_t drop; /* Number of dropped ICMP packets */ - uip_stats_t recv; /* Number of received ICMP packets */ - uip_stats_t sent; /* Number of sent ICMP packets */ - uip_stats_t typeerr; /* Number of ICMP packets with a wrong type */ -}; -#endif - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -EXTERN int uip_ping(uip_ipaddr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen, int dsecs); - -#undef EXTERN -#ifdef __cplusplus -} -#endif -#endif /* __INCLUDE_NUTTX_NET_UIP_UIP_ICMP_H */ diff --git a/nuttx/include/nuttx/net/uip/uip-igmp.h b/nuttx/include/nuttx/net/uip/uip-igmp.h deleted file mode 100644 index d3c021b66..000000000 --- a/nuttx/include/nuttx/net/uip/uip-igmp.h +++ /dev/null @@ -1,258 +0,0 @@ -/**************************************************************************** - * include/nuttx/net/uip/uip-igmp.h - * The definitions in this header file are intended only for internal use - * by the NuttX port of the uIP stack. - * - * Copyright (C) 2010, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * The NuttX implementation of IGMP was inspired by the IGMP add-on for the - * lwIP TCP/IP stack by Steve Reynolds: - * - * Copyright (c) 2002 CITEL Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __INCLUDE_NUTTX_NET_UIP_UIP_IGMP_H -#define __INCLUDE_NUTTX_NET_UIP_UIP_IGMP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include - -#include -#include - -#ifdef CONFIG_NET_IGMP - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifdef CONFIG_NET_IPv6 -# error "IGMP for IPv6 not supported" -#endif - -/* IGMP packet types */ - -#define IGMP_MEMBERSHIP_QUERY 0x11 /* Membership Query */ -#define IGMPv1_MEMBERSHIP_REPORT 0x12 /* IGMP Ver. 1 Membership Report */ -#define IGMPv2_MEMBERSHIP_REPORT 0x16 /* IGMP Ver. 2 Membership Report */ -#define IGMPv3_MEMBERSHIP_REPORT 0x22 /* IGMP Ver. 3 Membership Report */ -#define IGMP_LEAVE_GROUP 0x17 /* Leave Group */ - -/* Header sizes: - * - * UIP_IGMPH_LEN - Size of IGMP header in bytes - * UIP_IPIGMPH_LEN - Size of IP + Size of IGMP header + Size of router alert - */ - -#define UIP_IGMPH_LEN 8 -#define UIP_IPIGMPH_LEN (UIP_IGMPH_LEN + UIP_IPH_LEN + 4) - -/* Group flags */ - -#define IGMP_PREALLOCATED (1 << 0) -#define IGMP_LASTREPORT (1 << 1) -#define IGMP_IDLEMEMBER (1 << 2) -#define IGMP_SCHEDMSG (1 << 3) -#define IGMP_WAITMSG (1 << 4) - -#define SET_PREALLOCATED(f) do { (f) |= IGMP_PREALLOCATED; } while (0) -#define SET_LASTREPORT(f) do { (f) |= IGMP_LASTREPORT; } while (0) -#define SET_IDLEMEMBER(f) do { (f) |= IGMP_IDLEMEMBER; } while (0) -#define SET_SCHEDMSG(f) do { (f) |= IGMP_SCHEDMSG; } while (0) -#define SET_WAITMSG(f) do { (f) |= IGMP_WAITMSG; } while (0) - -#define CLR_PREALLOCATED(f) do { (f) &= ~IGMP_PREALLOCATED; } while (0) -#define CLR_LASTREPORT(f) do { (f) &= ~IGMP_LASTREPORT; } while (0) -#define CLR_IDLEMEMBER(f) do { (f) &= ~IGMP_IDLEMEMBER; } while (0) -#define CLR_SCHEDMSG(f) do { (f) &= ~IGMP_SCHEDMSG; } while (0) -#define CLR_WAITMSG(f) do { (f) &= ~IGMP_WAITMSG; } while (0) - -#define IS_PREALLOCATED(f) (((f) & IGMP_PREALLOCATED) != 0) -#define IS_LASTREPORT(f) (((f) & IGMP_LASTREPORT) != 0) -#define IS_IDLEMEMBER(f) (((f) & IGMP_IDLEMEMBER) != 0) -#define IS_SCHEDMSG(f) (((f) & IGMP_SCHEDMSG) != 0) -#define IS_WAITMSG(f) (((f) & IGMP_WAITMSG) != 0) - -#define IGMP_TTL 1 - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/* IGMPv2 packet structure as defined by RFC 2236. - * - * The Max Respone Time (maxresp) specifies the time limit for the - * corresponding report. The field has a resolution of 100 miliseconds, the - * value is taken directly. This field is meaningful only in Membership Query - * (0x11); in other messages it is set to 0 and ignored by the receiver. - */ - -struct uip_igmphdr_s -{ -#ifdef CONFIG_NET_IPv6 - - /* IPv6 Ip header */ - - uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ - uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */ - uint16_t flow; /* 16-bit flow label (LS) */ - uint8_t len[2]; /* 16-bit Payload length */ - uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ - uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ - uip_ip6addr_t srcipaddr; /* 128-bit Source address */ - uip_ip6addr_t destipaddr; /* 128-bit Destination address */ - -#else /* CONFIG_NET_IPv6 */ - - /* IPv4 IP header */ - - uint8_t vhl; /* 8-bit Version (4) and header length (6 with Router Alert) */ - uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ - uint8_t len[2]; /* 16-bit Total length */ - uint8_t ipid[2]; /* 16-bit Identification */ - uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ - uint8_t ttl; /* 8-bit Time to Live */ - uint8_t proto; /* 8-bit Protocol */ - uint16_t ipchksum; /* 16-bit Header checksum */ - uint16_t srcipaddr[2]; /* 32-bit Source IP address */ - uint16_t destipaddr[2]; /* 32-bit Destination IP address */ - -#endif /* CONFIG_NET_IPv6 */ - - /* Router Alert IP header option */ - - uint16_t ra[2]; - - /* IGMPv2 header: - * - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Type | Max Resp Time | Checksum | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Group Address | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - uint8_t type; /* 8-bit IGMP packet type */ - uint8_t maxresp; /* 8-bit Max response time */ - uint16_t chksum; /* 16-bit Checksum */ - uint16_t grpaddr[2]; /* 32-bit Group address */ -}; - -#ifdef CONFIG_NET_STATISTICS -struct uip_igmp_stats_s -{ - uint32_t length_errors; - uint32_t chksum_errors; - uint32_t v1_received; - uint32_t joins; - uint32_t leaves; - uint32_t leave_sched; - uint32_t report_sched; - uint32_t poll_send; - uint32_t ucast_query; - uint32_t query_received; - uint32_t report_received; -}; - -# define IGMP_STATINCR(p) ((p)++) -#else -# define IGMP_STATINCR(p) -#endif - -/* This structure represents one group member. There is a list of groups - * for each device interface structure. - * - * There will be a group for the all systems group address but this - * will not run the state machine as it is used to kick off reports - * from all the other groups - */ - -typedef FAR struct wdog_s *WDOG_ID; -struct igmp_group_s -{ - struct igmp_group_s *next; /* Implements a singly-linked list */ - uip_ipaddr_t grpaddr; /* Group IP address */ - WDOG_ID wdog; /* WDOG used to detect timeouts */ - sem_t sem; /* Used to wait for message transmission */ - volatile uint8_t flags; /* See IGMP_ flags definitions */ - uint8_t msgid; /* Pending message ID (if non-zero) */ -}; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -EXTERN uip_ipaddr_t g_allsystems; -EXTERN uip_ipaddr_t g_allrouters; - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: uip_igmpdevinit - * - * Description: - * Called when a new network device is registered to configure that device - * for IGMP support. - * - ****************************************************************************/ - -EXTERN void uip_igmpdevinit(struct uip_driver_s *dev); -EXTERN int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr); -EXTERN int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr); - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - -#endif /* CONFIG_NET_IGMP */ -#endif /* __INCLUDE_NUTTX_NET_UIP_UIP_IGMP_H */ diff --git a/nuttx/include/nuttx/net/uip/uip-ipopt.h b/nuttx/include/nuttx/net/uip/uip-ipopt.h deleted file mode 100644 index 7aa4114db..000000000 --- a/nuttx/include/nuttx/net/uip/uip-ipopt.h +++ /dev/null @@ -1,251 +0,0 @@ -/************************************************************************************************************ - * include/nuttx/net/uip/uip-ipopt.h - * - * Defines values for the IP header options - * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ************************************************************************************************************/ - -#ifndef __INCLUDE_NUTTX_NET_UIP_UIP_IPOPT_H -#define __INCLUDE_NUTTX_NET_UIP_UIP_IPOPT_H - -/************************************************************************************************************ - * Included Files - ************************************************************************************************************/ - -#include - -/************************************************************************************************************ - * Pre-processor Definitions - ************************************************************************************************************/ - -/* IP Header Options: - * - * The basic 20-byte IP header can be extended by up to another 40 bytes - * (in units of 4 bytes) to provide IP options. The format of a single IP - * option is as follows: - * - * Single byte options: - * - * Type: 8-bits - * - * Multi-byte options: - * - * Type: 8-bits - * Length: 8-bits - * Pointer: 8-bits: - * Option Data: (depends on Length) - * - * The IP Option Type byte consists of the following subfields: - */ - -#define IPOPT_TYPE_OPTION_SHIFT (0) /* Bits 0-5: Option number*/ -#define IPOPT_TYPE_OPTION_MASK (0x1f << IPOPT_TYPE_OPTION_SHIFT) -# define IPOPT_TYPE_OPTION_END (0 << IPOPT_TYPE_OPTION_SHIFT) /* End of options list (RFC 791) */ -# define IPOPT_TYPE_OPTION_NOOP (1 << IPOPT_TYPE_OPTION_SHIFT) /* No operation (RFC 791) */ -# define IPOPT_TYPE_OPTION_SEC (2 << IPOPT_TYPE_OPTION_SHIFT) /* Security (RFC 791, 1108) */ -# define IPOPT_TYPE_OPTION_LSRR (3 << IPOPT_TYPE_OPTION_SHIFT) /* Loose source and record route (RFC 791) */ -# define IPOPT_TYPE_OPTION_TIMESTAMP (4 << IPOPT_TYPE_OPTION_SHIFT) /* Timestamp (RFC 781, 791) */ -# define IPOPT_TYPE_OPTION_EXTSEC (5 << IPOPT_TYPE_OPTION_SHIFT) /* Extended security (RFC 1108) */ -# define IPOPT_TYPE_OPTION_COMMSEC (6 << IPOPT_TYPE_OPTION_SHIFT) /* Commercial security */ -# define IPOPT_TYPE_OPTION_RR (7 << IPOPT_TYPE_OPTION_SHIFT) /* Record route (RFC 791) */ -# define IPOPT_TYPE_OPTION_SSID (8 << IPOPT_TYPE_OPTION_SHIFT) /* Stream ID (RFC 791, 1122) */ -# define IPOPT_TYPE_OPTION_SSRR (9 << IPOPT_TYPE_OPTION_SHIFT) /* Strict source and record route (RFC 791) */ -# define IPOPT_TYPE_OPTION_EXPMEAS (10 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental measurement */ -# define IPOPT_TYPE_OPTION_MTUPROBE (11 << IPOPT_TYPE_OPTION_SHIFT) /* MTU Probe (RFC 1063) */ -# define IPOPT_TYPE_OPTION_MTUREPLY (12 << IPOPT_TYPE_OPTION_SHIFT) /* MTU Reply (RFC 1063) */ -# define IPOPT_TYPE_OPTION_EXPFC (13 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental flow control */ -# define IPOPT_TYPE_OPTION_EXPAC (14 << IPOPT_TYPE_OPTION_SHIFT) /* Experimental access control */ -# define IPOPT_TYPE_OPTION_ENCODE (15 << IPOPT_TYPE_OPTION_SHIFT) /* ENCODE */ -# define IPOPT_TYPE_OPTION_IMITD (16 << IPOPT_TYPE_OPTION_SHIFT) /* IMI traffic descriptor */ -# define IPOPT_TYPE_OPTION_EXTIP (17 << IPOPT_TYPE_OPTION_SHIFT) /* Extended IP (RFC 1385) */ -# define IPOPT_TYPE_OPTION_TR (18 << IPOPT_TYPE_OPTION_SHIFT) /* Traceroute (RFC 1393) */ -# define IPOPT_TYPE_OPTION_ADDREXT (19 << IPOPT_TYPE_OPTION_SHIFT) /* Address extension (RFC 1475) */ -# define IPOPT_TYPE_OPTION_RA (20 << IPOPT_TYPE_OPTION_SHIFT) /* Router alert (RFC 2113) */ -# define IPOPT_TYPE_OPTION_SDBM (21 << IPOPT_TYPE_OPTION_SHIFT) /* Selective direct broadcast mode (RFC 1770) */ -# define IPOPT_TYPE_OPTION_DPS (23 << IPOPT_TYPE_OPTION_SHIFT) /* Dynamic packet state */ -# define IPOPT_TYPE_OPTION_UMP (24 << IPOPT_TYPE_OPTION_SHIFT) /* Upstream multicast packet */ -# define IPOPT_TYPE_OPTION_QS (25 << IPOPT_TYPE_OPTION_SHIFT) /* Quick start (RFC 4782) */ -# define IPOPT_TYPE_OPTION_EXP3692 (30 << IPOPT_TYPE_OPTION_SHIFT) /* RFC 3692-style experiment (RFC 4782) */ -#define IPOPT_TYPE_CLASS_SHIFT (5) /* Bits 5-6: Class */ -#define IPOPT_TYPE_CLASS_MASK (3 << IPOPT_TYPE_CLASS_SHIFT) -# define IPOPT_TYPE_CLASS_CTRL (0 << IPOPT_TYPE_CLASS_SHIFT) /* Control */ -# define IPOPT_TYPE_CLASS_MEASURE (2 << IPOPT_TYPE_CLASS_SHIFT) /* Debugging and measurement */ -#define IPOPT_TYPE_COPIED (1 << 7) /* Bit 7: IP layer must copy option to each fragment */ -#define IPOPT_TYPE_NOTCOPIED (0) - -/* IP Option encoding macros */ - -#define IPOPT_MKTYPE(copied,class,option) (copied|class|option) - -#define IPOPT_MKOPTION8(copied,class,option) \ - ((uint8_t)IPOPT_MKTYPE(copied,class,option)) -#define IPOPT_MKOPTION32(type,len,ptr,data) \ - ((uint32_t)(type) << 24 | (uint32_t)(len) << 16 | \ - (uint32_t)(ptr) << 8 | (uint32_t)(data)) - -/* Option Copy Class Length Description References - * ------ ---- ----- --------- ------------------------------------------------ - * 0 0 0 1 End of options list (RFC 791) - * 1 0 0 1 NOP (RFC 791 - * 2 1 0 11 Security (RFC 791, RFC 1108) - * 3 1 0 variable Loose Source Route (RFC 791) - * 4 0 2 variable Time stamp (RFC 781, RFC 791) - * 5 1 0 3-31 Extended Security (RFC 1108) - * 6 1 0 Commercial Security - * 7 0 0 variable Record Route (RFC 791) - * 8 1 0 4 Stream Identifier (RFC 791, RFC 1122) - * 9 1 0 variable Strict Source Route (RFC 791) - * 10 0 0 Experimental Measurement - * 11 0 0 4 MTU Probe (obsolete) (RFC 1063) - * 12 0 0 4 MTU Reply (obsolete) (RFC 1063) - * 13 1 2 Experimental Flow Control - * 14 1 0 Experimental Access Control - * 15 0 0 ENCODE - * 16 1 0 IMI Traffic Descriptor - * 17 1 0 variable Extended Internet Protocol (RFC 1385) - * 18 0 2 12 Traceroute (RFC 1393) - * 19 1 0 10 Address Extension (RFC 1475) - * 20 1 0 4 Router Alert (RFC 2113) - * 21 1 0 6-38 Selective Directed Broadcast Mode (RFC 1770) - * 22 1 0 - * 23 1 0 Dynamic Packet State - * 24 1 0 Upstream Multicast Packet - * 25 0 0 QS, Quick-Start (RFC 4782) - * 26 - * - - * 29 - * 30 0 0 EXP - RFC3692-style Experiment (RFC 4727) - * 30 0 2 EXP - RFC3692-style Experiment (RFC 4727) - * 30 1 0 EXP - RFC3692-style Experiment RFC 4727) - * 30 1 2 EXP - RFC3692-style Experiment (RFC 4727) - * 31 - */ - -#define IPOTR_END_LEN 1 -#define IPOPT_END_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_END) - -#define IPOTR_NOOP_LEN 1 -#define IPOPT_NOOP_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_NOOP) - -#define IPOPT_SEC_LEN 11 -#define IPOPT_SEC_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SEC) - -#define IPOPT_LSRR_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_LSRR) - -#define IPOPT_TIMESTAMP_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_TIMESTAMP) - -#define IPOPT_EXTSEC_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXTSEC) - -#define IPOPT_COMMSEC_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_COMMSEC) - -#define IPOPT_RR_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_RR) - -#define IPOPT_SSID_LEN 4 -#define IPOPT_SSID_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SSID) - -#define IPOPT_SSRR_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SSRR) -#define IPOPT_EXPMEAS_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXPMEAS) - -#define IPOPT_MTUPROBE_LEN 4 -#define IPOPT_MTUPROBE_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_MTUPROBE) - -#define IPOPT_MTUREPLY_LEN 4 -#define IPOPT_MTUREPLY_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_MTUREPLY) - -#define IPOPT_EXPFC_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_EXPFC) - -#define IPOPT_EXPAC_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXPAC) - -#define IPOPT_ENCODE_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_ENCODE) - -#define IPOPT_IMITD_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_IMITD) - -#define IPOPT_EXTIP_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_EXTIP) - -#define IPOPT_TR_LEN 12 -#define IPOPT_TR_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_MEASURE, IPOPT_TYPE_OPTION_TR) - -#define IPOPT_ADDREXT_LEN 10 -#define IPOPT_ADDREXT_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_ADDREXT) - -#define IPOPT_RA_LEN 4 -#define IPOPT_RA_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_RA) -#define IPOPT_RA \ - IPOPT_MKOPTION32(IPOPT_RA_TYPE, 4, 0, 0) - -#define IPOPT_SDBM_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_SDBM) - -#define IPOPT_DPS_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_DPS) - -#define IPOPT_UMP_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_UMP) - -#define IPOPT_QS_TYPE \ - IPOPT_MKTYPE(IPOPT_TYPE_NOTCOPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_QS) - -/************************************************************************************************************ - * Public Type Definitions - ************************************************************************************************************/ - -/************************************************************************************************************ - * Public Data - ************************************************************************************************************/ - -/************************************************************************************************************ - * Public Function Prototypes - ************************************************************************************************************/ - -#endif /* __INCLUDE_NUTTX_NET_UIP_UIP_IPOPT_H */ diff --git a/nuttx/include/nuttx/net/uip/uip-pkt.h b/nuttx/include/nuttx/net/uip/uip-pkt.h deleted file mode 100644 index 1a5f2db4a..000000000 --- a/nuttx/include/nuttx/net/uip/uip-pkt.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** - * include/netpacket/netpacket.h - * Definitions for use with AF_PACKET sockets - * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. - * Author: Daniel Laszlo Sitzer - * - * Includes some definitions that a compatible with the LGPL GNU C Library - * header file of the same name. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __INCLUDE_NUTTX_NET_UIP_UIP_PKT_H -#define __INCLUDE_NUTTX_NET_UIP_UIP_PKT_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -/**************************************************************************** - * Public Type Definitions - ****************************************************************************/ - -/* Representation of a uIP packet socket connection */ - -struct uip_pkt_conn -{ - 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 uip_callback_s *list; -}; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * 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 - */ - -struct uip_pkt_conn *uip_pktalloc(void); - -/* Allocate a new packet socket data callback */ - -#define uip_pktcallbackalloc(conn) uip_callbackalloc(&conn->list) -#define uip_pktcallbackfree(conn,cb) uip_callbackfree(cb, &conn->list) - -/* Free a connection structure that is no longer in use. This should - * be done by the implementation of close() - */ - -void uip_pktfree(struct uip_pkt_conn *conn); - -void uip_pktpoll(struct uip_driver_s *dev, struct uip_pkt_conn *conn); - -int uip_pktinput(struct uip_driver_s *dev); - -#endif /* __INCLUDE_NUTTX_NET_UIP_UIP_PKT_H */ diff --git a/nuttx/include/nuttx/net/uip/uip-tcp.h b/nuttx/include/nuttx/net/uip/uip-tcp.h deleted file mode 100644 index a019f70b0..000000000 --- a/nuttx/include/nuttx/net/uip/uip-tcp.h +++ /dev/null @@ -1,529 +0,0 @@ -/**************************************************************************** - * include/nuttx/net/uip/uip-tcp.h - * Header file for the uIP TCP/IP stack. - * - * The uIP TCP/IP stack header file contains definitions for a number - * of C macros that are used by uIP programs as well as internal uIP - * structures, TCP/IP header structures and function declarations. - * - * Copyright (C) 2007, 2009-2010, 2012-2014 Gregory Nutt. All rights - * reserved. - * Author: Gregory Nutt - * - * This logic was leveraged from uIP which also has a BSD-style license: - * - * Author Adam Dunkels - * Copyright (c) 2001-2003, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __INCLUDE_NUTTX_NET_UIP_UIP_TCP_H -#define __INCLUDE_NUTTX_NET_UIP_UIP_TCP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#ifdef CONFIG_NET_TCP - -#include -#include -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* TCP definitions */ - -#define TCP_FIN 0x01 -#define TCP_SYN 0x02 -#define TCP_RST 0x04 -#define TCP_PSH 0x08 -#define TCP_ACK 0x10 -#define TCP_URG 0x20 -#define TCP_CTL 0x3f - -#define TCP_OPT_END 0 /* End of TCP options list */ -#define TCP_OPT_NOOP 1 /* "No-operation" TCP option */ -#define TCP_OPT_MSS 2 /* Maximum segment size TCP option */ - -#define TCP_OPT_MSS_LEN 4 /* Length of TCP MSS option. */ - -/* The TCP states used in the struct uip_conn tcpstateflags field */ - -#define UIP_TS_MASK 0x0f /* Bits 0-3: TCP state */ -#define UIP_CLOSED 0x00 /* The connection is not in use and available */ -#define UIP_ALLOCATED 0x01 /* The connection is allocated, but not yet initialized */ -#define UIP_SYN_RCVD 0x02 -#define UIP_SYN_SENT 0x03 -#define UIP_ESTABLISHED 0x04 -#define UIP_FIN_WAIT_1 0x05 -#define UIP_FIN_WAIT_2 0x06 -#define UIP_CLOSING 0x07 -#define UIP_TIME_WAIT 0x08 -#define UIP_LAST_ACK 0x09 -#define UIP_STOPPED 0x10 /* Bit 4: stopped */ - /* Bit 5-7: Unused, but not available */ - -/* Flag bits in 16-bit flags+ipoffset IPv4 TCP header field */ - -#define UIP_TCPFLAG_RESERVED 0x8000 -#define UIP_TCPFLAG_DONTFRAG 0x4000 -#define UIP_TCPFLAG_MOREFRAGS 0x2000 - -/* TCP header sizes */ - -#define UIP_TCPH_LEN 20 /* Size of TCP header */ -#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP + TCP header */ -#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN - -/* Initial minimum MSS according to RFC 879 - * - * There have been some assumptions made about using other than the - * default size for datagrams with some unfortunate results. - * - * HOSTS MUST NOT SEND DATAGRAMS LARGER THAN 576 OCTETS UNLESS THEY - * HAVE SPECIFIC KNOWLEDGE THAT THE DESTINATION HOST IS PREPARED TO - * ACCEPT LARGER DATAGRAMS. - * - * This is a long established rule. - */ - -#if UIP_TCP_MSS > 576 -# define UIP_TCP_INITIAL_MSS 576 -#else -# define UIP_TCP_INITIAL_MSS UIP_TCP_MSS -#endif - -#ifdef CONFIG_NET_TCP_WRITE_BUFFERS -/* TCP write buffer access macros */ - -# define WRB_SEQNO(wrb) ((wrb)->wb_seqno) -# define WRB_PKTLEN(wrb) ((wrb)->wb_iob->io_pktlen) -# define WRB_SENT(wrb) ((wrb)->wb_sent) -# define WRB_NRTX(wrb) ((wrb)->wb_nrtx) -# define WRB_IOB(wrb) ((wrb)->wb_iob) -# define WRB_COPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0)) -# define WRB_COPYIN(wrb,src,n) (iob_copyin((wrb)->wb_iob,src,(n),0)) - -# define WRB_TRIM(wrb,n) \ - do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0) - -#ifdef CONFIG_DEBUG -# define WRB_DUMP(msg,wrb,len,offset) \ - tcp_wrbuffer_dump(msg,wrb,len,offset) -#else -# define WRB_DUMP(msg,wrb,len,offset) -#endif -#endif - -/**************************************************************************** - * Public Type Definitions - ****************************************************************************/ - -/* Representation of a uIP TCP connection. - * - * The uip_conn structure is used for identifying a connection. All - * but one field in the structure are to be considered read-only by an - * application. The only exception is the 'private' fields whose purpose - * is to let the application store application-specific state (e.g., - * file pointers) for the connection. - */ - -struct uip_driver_s; /* Forward reference */ -struct uip_callback_s; /* Forward reference */ -struct uip_backlog_s; /* Forward reference */ - -struct uip_conn -{ - dq_entry_t node; /* Implements a doubly linked list */ - uip_ipaddr_t ripaddr; /* The IP address of the remote host */ - uint8_t rcvseq[4]; /* The sequence number that we expect to - * receive next */ - uint8_t sndseq[4]; /* The sequence number that was last sent by us */ - uint8_t crefs; /* Reference counts on this instance */ - uint8_t sa; /* Retransmission time-out calculation state - * variable */ - uint8_t sv; /* Retransmission time-out calculation state - * variable */ - uint8_t rto; /* Retransmission time-out */ - uint8_t tcpstateflags; /* TCP state and flags */ - uint8_t timer; /* The retransmission timer (units: half-seconds) */ - uint8_t nrtx; /* The number of retransmissions for the last - * segment sent */ - uint16_t lport; /* The local TCP port, in network byte order */ - uint16_t rport; /* The remoteTCP port, in network byte order */ - uint16_t mss; /* Current maximum segment size for the - * connection */ - uint16_t winsize; /* Current window size of the connection */ -#ifdef CONFIG_NET_TCP_WRITE_BUFFERS - uint32_t unacked; /* Number bytes sent but not yet ACKed */ -#else - uint16_t unacked; /* Number bytes sent but not yet ACKed */ -#endif - - /* Read-ahead buffering. - * - * readahead - A singly linked list of type struct uip_readahead_s - * where the TCP/IP read-ahead data is retained. - */ - -#ifdef CONFIG_NET_TCP_READAHEAD - sq_queue_t readahead; /* Read-ahead buffering */ -#endif - - /* Write buffering - * - * write_q - The queue of unsent I/O buffers. The head of this - * list may be partially sent. FIFO ordering. - * unacked_q - A queue of completely sent, but unacked I/O buffer - * chains. Sequence number ordering. - */ - -#ifdef CONFIG_NET_TCP_WRITE_BUFFERS - sq_queue_t write_q; /* Write buffering for segments */ - sq_queue_t unacked_q; /* Write buffering for un-ACKed segments */ - uint16_t expired; /* Number segments retransmitted but not yet ACKed, - * it can only be updated at UIP_ESTABLISHED state */ - uint16_t sent; /* The number of bytes sent (ACKed and un-ACKed) */ - uint32_t isn; /* Initial sequence number */ -#endif - - /* Listen backlog support - * - * blparent - The backlog parent. If this connection is backlogged, - * this field will be non-null and will refer to the TCP connection - * structure in which this connection is backlogged. - * backlog - The pending connection backlog. If this connection is - * configured as a listener with backlog, then this refers to the - * struct uip_backlog_s tear-off structure that manages that backlog. - */ - -#ifdef CONFIG_NET_TCPBACKLOG - FAR struct uip_conn *blparent; - FAR struct uip_backlog_s *backlog; -#endif - - /* Application callbacks: - * - * Data transfer events are retained in 'list'. Event handlers in 'list' - * are called for events specified in the flags set within struct - * uip_callback_s - * - * When an callback is executed from 'list', the input flags are normally - * returned, however, the implementation may set one of the following: - * - * UIP_CLOSE - Gracefully close the current connection - * UIP_ABORT - Abort (reset) the current connection on an error that - * prevents UIP_CLOSE from working. - * - * And/Or set/clear the following: - * - * UIP_NEWDATA - May be cleared to indicate that the data was consumed - * and that no further process of the new data should be - * attempted. - * UIP_SNDACK - If UIP_NEWDATA is cleared, then UIP_SNDACK may be set - * to indicate that an ACK should be included in the response. - * (In UIP_NEWDATA is cleared bu UIP_SNDACK is not set, then - * dev->d_len should also be cleared). - */ - - FAR struct uip_callback_s *list; - - /* accept() is called when the TCP logic has created a connection */ - - FAR void *accept_private; - int (*accept)(FAR struct uip_conn *listener, struct uip_conn *conn); - - /* connection_event() is called on any of the subset of connection-related - * events. - */ - - FAR void *connection_private; - void (*connection_event)(FAR struct uip_conn *conn, uint16_t flags); -}; - -/* The following structure is used to handle read-ahead buffering for TCP - * connection. When incoming TCP data is received while no application is - * listening for the data, that data will be retained in these read-ahead - * buffers so that no data is lost. - */ - -#ifdef CONFIG_NET_TCP_READAHEAD -struct uip_readahead_s -{ - sq_entry_t rh_node; /* Supports a singly linked list */ - uint16_t rh_nbytes; /* Number of bytes available in this buffer */ - uint8_t rh_buffer[CONFIG_NET_TCP_READAHEAD_BUFSIZE]; -}; -#endif - -/* This structure supports TCP write buffering */ - -#ifdef CONFIG_NET_TCP_WRITE_BUFFERS -struct iob_s; /* Forward reference */ -struct tcp_wrbuffer_s -{ - sq_entry_t wb_node; /* Supports a singly linked list */ - uint32_t wb_seqno; /* Sequence number of the write segment */ - uint16_t wb_sent; /* Number of bytes sent from the I/O buffer chain */ - uint8_t wb_nrtx; /* The number of retransmissions for the last - * segment sent */ - struct iob_s *wb_iob; /* Head of the I/O buffer chain */ -}; -#endif - -/* Support for listen backlog: - * - * struct uip_blcontainer_s describes one backlogged connection - * struct uip_backlog_s is a "tear-off" describing all backlog for a - * listener connection - */ - -#ifdef CONFIG_NET_TCPBACKLOG -struct uip_blcontainer_s -{ - sq_entry_t bc_node; /* Implements a singly linked list */ - FAR struct uip_conn *bc_conn; /* Holds reference to the new connection structure */ -}; - -struct uip_backlog_s -{ - sq_queue_t bl_free; /* Implements a singly-linked list of free containers */ - sq_queue_t bl_pending; /* Implements a singly-linked list of pending connections */ -}; -#endif - -/* The structure holding the TCP/IP statistics that are gathered if - * CONFIG_NET_STATISTICS is defined. - */ - -#ifdef CONFIG_NET_STATISTICS -struct uip_tcp_stats_s -{ - uip_stats_t drop; /* Number of dropped TCP segments */ - uip_stats_t recv; /* Number of received TCP segments */ - uip_stats_t sent; /* Number of sent TCP segments */ - uip_stats_t chkerr; /* Number of TCP segments with a bad checksum */ - uip_stats_t ackerr; /* Number of TCP segments with a bad ACK number */ - uip_stats_t rst; /* Number of received TCP RST (reset) segments */ - uip_stats_t rexmit; /* Number of retransmitted TCP segments */ - uip_stats_t syndrop; /* Number of dropped SYNs due to too few - available connections */ - uip_stats_t synrst; /* Number of SYNs for closed ports triggering a RST */ -}; -#endif - -/* The TCP and IP headers */ - -struct uip_tcpip_hdr -{ -#ifdef CONFIG_NET_IPv6 - - /* IPv6 Ip header */ - - uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ - uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */ - uint16_t flow; /* 16-bit flow label (LS) */ - uint8_t len[2]; /* 16-bit Payload length */ - uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ - uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ - uip_ip6addr_t srcipaddr; /* 128-bit Source address */ - uip_ip6addr_t destipaddr; /* 128-bit Destination address */ - -#else /* CONFIG_NET_IPv6 */ - - /* IPv4 IP header */ - - uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ - uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ - uint8_t len[2]; /* 16-bit Total length */ - uint8_t ipid[2]; /* 16-bit Identification */ - uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ - uint8_t ttl; /* 8-bit Time to Live */ - uint8_t proto; /* 8-bit Protocol */ - uint16_t ipchksum; /* 16-bit Header checksum */ - uint16_t srcipaddr[2]; /* 32-bit Source IP address */ - uint16_t destipaddr[2]; /* 32-bit Destination IP address */ - -#endif /* CONFIG_NET_IPv6 */ - - /* TCP header */ - - uint16_t srcport; - uint16_t destport; - uint8_t seqno[4]; - uint8_t ackno[4]; - uint8_t tcpoffset; - uint8_t flags; - uint8_t wnd[2]; - uint16_t tcpchksum; - uint8_t urgp[2]; - uint8_t optdata[4]; -}; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * 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 - */ - -struct uip_conn *uip_tcpalloc(void); - -/* Allocate a new TCP data callback */ - -#define uip_tcpcallbackalloc(conn) uip_callbackalloc(&conn->list) -#define uip_tcpcallbackfree(conn,cb) uip_callbackfree(cb, &conn->list) - -/* Free a connection structure that is no longer in use. This should - * be done by the implementation of close() - */ - -void uip_tcpfree(struct uip_conn *conn); - -/* Bind a TCP connection to a local address */ - -#ifdef CONFIG_NET_IPv6 -int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in6 *addr); -#else -int uip_tcpbind(struct uip_conn *conn, const struct sockaddr_in *addr); -#endif - -/* This function implements the UIP specific parts of the standard - * TCP connect() operation: It connects to a remote host using TCP. - * - * This function is used to start a new connection to the specified - * port on the specied host. It uses the connection structure that was - * allocated by a preceding socket() call. It sets the connection to - * the SYN_SENT state and sets the retransmission timer to 0. This will - * cause a TCP SYN segment to be sent out the next time this connection - * is periodically processed, which usually is done within 0.5 seconds - * after the call to uip_tcpconnect(). - * - * This function is called from normal user level code. - */ - -#ifdef CONFIG_NET_IPv6 -int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in6 *addr); -#else -int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr); -#endif - -/* Start listening to the port bound to the specified TCP connection */ - -int uip_listen(struct uip_conn *conn); - -/* Stop listening to the port bound to the specified TCP connection */ - -int uip_unlisten(struct uip_conn *conn); - -/* Access to TCP read-ahead buffers */ - -#ifdef CONFIG_NET_TCP_READAHEAD -FAR struct uip_readahead_s *uip_tcpreadahead_alloc(void); -void uip_tcpreadahead_release(FAR struct uip_readahead_s *readahead); -#endif /* CONFIG_NET_TCP_READAHEAD */ - -/* Backlog support */ - -#ifdef CONFIG_NET_TCPBACKLOG -/* APIs to create and terminate TCP backlog support */ - -int uip_backlogcreate(FAR struct uip_conn *conn, int nblg); -int uip_backlogdestroy(FAR struct uip_conn *conn); - -/* APIs to manage individual backlog actions */ - -int uip_backlogadd(FAR struct uip_conn *conn, FAR struct uip_conn *blconn); -#ifndef CONFIG_DISABLE_POLL -bool uip_backlogavailable(FAR struct uip_conn *conn); -#else -# define uip_backlogavailable(conn) (false); -#endif -FAR struct uip_conn *uip_backlogremove(FAR struct uip_conn *conn); -int uip_backlogdelete(FAR struct uip_conn *conn, FAR struct uip_conn *blconn); - -#else -# define uip_backlogcreate(conn,nblg) (-ENOSYS) -# define uip_backlogdestroy(conn) (-ENOSYS) -# define uip_backlogadd(conn,blconn) (-ENOSYS) -# define uip_backlogavailable(conn) (false); -# define uip_backlogremove(conn) (NULL) -#endif - -/* Tell the sending host to stop sending data. - * - * This function will close our receiver's window so that we stop - * receiving data for the current connection. - */ - -#define uip_stop(conn) ((conn)->tcpstateflags |= UIP_STOPPED) - -/* Find out if the current connection has been previously stopped with - * uip_stop(). - */ - -#define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED) - -/* Restart the current connection, if is has previously been stopped - * with uip_stop(). - * - * This function will open the receiver's window again so that we start - * receiving data for the current connection. - */ - -#define uip_restart(conn,f) \ - do { \ - (f) |= UIP_NEWDATA; \ - (conn)->tcpstateflags &= ~UIP_STOPPED; \ - } while (0) - -/* Get the current maximum segment size that can be sent on the current - * connection. - */ - -#define uip_mss(conn) ((conn)->mss) - -#endif /* CONFIG_NET_TCP */ -#endif /* __INCLUDE_NUTTX_NET_UIP_UIP_TCP_H */ diff --git a/nuttx/include/nuttx/net/uip/uip-udp.h b/nuttx/include/nuttx/net/uip/uip-udp.h deleted file mode 100644 index 9cdfb3fe7..000000000 --- a/nuttx/include/nuttx/net/uip/uip-udp.h +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** - * include/nuttx/net/uip/uip-udp.h - * Header file for the uIP UDP stack. - * - * The uIP UDP stack header file contains definitions for a number - * of C macros that are used by uIP programs as well as internal uIP - * structures, UDP header structures and function declarations. - * - * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * This logic was leveraged from uIP which also has a BSD-style license: - * - * Author Adam Dunkels - * Copyright (c) 2001-2003, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __INCLUDE_NUTTX_NET_UIP_UIP_UDP_H -#define __INCLUDE_NUTTX_NET_UIP_UIP_UDP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Header sizes */ - -#define UIP_UDPH_LEN 8 /* Size of UDP header */ -#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + UDP header */ - -/**************************************************************************** - * Public Type Definitions - ****************************************************************************/ - -/* Representation of a uIP UDP connection */ - -struct uip_driver_s; /* Forward reference */ -struct uip_callback_s; /* Forward reference */ -struct uip_udp_conn -{ - dq_entry_t node; /* Supports a doubly linked list */ - uip_ipaddr_t ripaddr; /* The IP address of the remote peer */ - uint16_t lport; /* The local port number in network byte order */ - uint16_t rport; /* The remote port number in network byte order */ - uint8_t ttl; /* Default time-to-live */ - uint8_t crefs; /* Reference counts on this instance */ - - /* Defines the list of UDP callbacks */ - - struct uip_callback_s *list; -}; - -/* The UDP and IP headers */ - -struct uip_udpip_hdr -{ -#ifdef CONFIG_NET_IPv6 - - /* IPv6 Ip header */ - - uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ - uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */ - uint16_t flow; /* 16-bit flow label (LS) */ - uint8_t len[2]; /* 16-bit Payload length */ - uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ - uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ - uip_ip6addr_t srcipaddr; /* 128-bit Source address */ - uip_ip6addr_t destipaddr; /* 128-bit Destination address */ - -#else /* CONFIG_NET_IPv6 */ - - /* IPv4 header */ - - uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ - uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ - uint8_t len[2]; /* 16-bit Total length */ - uint8_t ipid[2]; /* 16-bit Identification */ - uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ - uint8_t ttl; /* 8-bit Time to Live */ - uint8_t proto; /* 8-bit Protocol */ - uint16_t ipchksum; /* 16-bit Header checksum */ - uint16_t srcipaddr[2]; /* 32-bit Source IP address */ - uint16_t destipaddr[2]; /* 32-bit Destination IP address */ - -#endif /* CONFIG_NET_IPv6 */ - - /* UDP header */ - - uint16_t srcport; - uint16_t destport; - uint16_t udplen; - uint16_t udpchksum; -}; - -/* The structure holding the UDP statistics that are gathered if - * CONFIG_NET_STATISTICS is defined. - */ - -#ifdef CONFIG_NET_STATISTICS -struct uip_udp_stats_s -{ - uip_stats_t drop; /* Number of dropped UDP segments */ - uip_stats_t recv; /* Number of recived UDP segments */ - uip_stats_t sent; /* Number of sent UDP segments */ - uip_stats_t chkerr; /* Number of UDP segments with a bad checksum */ -}; -#endif - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * 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 - */ - -extern struct uip_udp_conn *uip_udpalloc(void); - -/* Allocate a new TCP data callback */ - -#define uip_udpcallbackalloc(conn) uip_callbackalloc(&conn->list) -#define uip_udpcallbackfree(conn,cb) uip_callbackfree(cb, &conn->list) - -/* Free a connection structure that is no longer in use. This should - * be done by the implementation of close() - */ - -extern void uip_udpfree(struct uip_udp_conn *conn); - -/* Bind a UDP connection to a local address */ - -#ifdef CONFIG_NET_IPv6 -extern int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in6 *addr); -#else -extern int uip_udpbind(struct uip_udp_conn *conn, const struct sockaddr_in *addr); -#endif - -/* This function sets up a new UDP connection. The function will - * automatically allocate an unused local port for the new - * connection. However, another port can be chosen by using the - * uip_udpbind() call, after the uip_udpconnect() function has been - * called. - * - * This function is called as part of the implementation of sendto - * and recvfrom. - * - * addr The address of the remote host. - */ - -#ifdef CONFIG_NET_IPv6 -extern int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in6 *addr); -#else -extern int uip_udpconnect(struct uip_udp_conn *conn, const struct sockaddr_in *addr); -#endif - -/* Enable/disable UDP callbacks on a connection */ - -extern void uip_udpenable(struct uip_udp_conn *conn); -extern void uip_udpdisable(struct uip_udp_conn *conn); - -#endif /* __INCLUDE_NUTTX_NET_UIP_UIP_UDP_H */ diff --git a/nuttx/include/nuttx/net/uip/uip.h b/nuttx/include/nuttx/net/uip/uip.h deleted file mode 100644 index 260082795..000000000 --- a/nuttx/include/nuttx/net/uip/uip.h +++ /dev/null @@ -1,584 +0,0 @@ -/**************************************************************************** - * include/nuttx/net/uip/uip.h - * - * The uIP header file contains definitions for a number of C macros that - * are used by uIP programs as well as internal uIP structures and function - * declarations. - * - * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * This logic was leveraged from uIP which also has a BSD-style license: - * - * Author Adam Dunkels - * Copyright (c) 2001-2003, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __INCLUDE_NUTTX_NET_UIP_UIP_H -#define __INCLUDE_NUTTX_NET_UIP_UIP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* The following flags may be set in the set of flags before calling the - * application callback. The UIP_ACKDATA, UIP_NEWDATA, and UIP_CLOSE flags - * may be set at the same time, whereas the others are mutualy exclusive. - * - * UIP_ACKDATA IN: Signifies that the outstanding data was acked and - * the application should send out new data instead - * of retransmitting the last data (TCP only) - * OUT: Input state must be preserved on output. - * UIP_NEWDATA IN: Set to indicate that the peer has sent us new data. - * OUT: Cleared (only) by the application logic to indicate - * that the new data was consumed, suppressing further - * attempts to process the new data. - * UIP_SNDACK IN: Not used; always zero - * OUT: Set by the application if the new data was consumed - * and an ACK should be sent in the response. (TCP only) - * UIP_REXMIT IN: Tells the application to retransmit the data that - * was last sent. (TCP only) - * OUT: Not used - * UIP_POLL IN: Used for polling the application. This is provided - * periodically from the drivers to support (1) timed - * operations, and (2) to check if the application has - * data that it wants to send - * OUT: Not used - * UIP_BACKLOG IN: There is a new connection in the backlog list set - * up by the listen() command. (TCP only) - * OUT: Not used - * UIP_CLOSE IN: The remote host has closed the connection, thus the - * connection has gone away. (TCP only) - * OUT: The application signals that it wants to close the - * connection. (TCP only) - * UIP_ABORT IN: The remote host has aborted the connection, thus the - * connection has gone away. (TCP only) - * OUT: The application signals that it wants to abort the - * connection. (TCP only) - * UIP_CONNECTED IN: We have got a connection from a remote host and have - * set up a new connection for it, or an active connection - * has been successfully established. (TCP only) - * OUT: Not used - * UIP_TIMEDOUT IN: The connection has been aborted due to too many - * retransmissions. (TCP only) - * OUT: Not used - * UIP_ECHOREPLY IN: An ICMP Echo Reply has been received. Used to support - * ICMP ping from applications. (ICMP only) - * OUT: Cleared (only) by the application logic to indicate - * that the reply was processed, suppressing further - * attempts to process the reply. - */ - -#define UIP_ACKDATA (1 << 0) -#define UIP_NEWDATA (1 << 1) -#define UIP_SNDACK (1 << 2) -#define UIP_REXMIT (1 << 3) -#define UIP_POLL (1 << 4) -#define UIP_BACKLOG (1 << 5) -#define UIP_CLOSE (1 << 6) -#define UIP_ABORT (1 << 7) -#define UIP_CONNECTED (1 << 8) -#define UIP_TIMEDOUT (1 << 9) -#define UIP_ECHOREPLY (1 << 10) - -#define UIP_CONN_EVENTS (UIP_CLOSE|UIP_ABORT|UIP_CONNECTED|UIP_TIMEDOUT) - -/* The buffer size available for user data in the d_buf buffer. - * - * This macro holds the available size for user data in the - * d_buf buffer. The macro is intended to be used for checking - * bounds of available user data. - * - * Example: - * - * snprintf(dev->d_appdata, UIP_APPDATA_SIZE, "%u\n", i); - */ - -#define UIP_APPDATA_SIZE (CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) - -#define UIP_PROTO_ICMP 1 -#define UIP_PROTO_IGMP 2 -#define UIP_PROTO_TCP 6 -#define UIP_PROTO_UDP 17 -#define UIP_PROTO_ICMP6 58 - -/* Header sizes */ - -#ifdef CONFIG_NET_IPv6 -# define UIP_IPH_LEN 40 /* Size of IP header */ -#else -# define UIP_IPH_LEN 20 /* Size of IP header */ -#endif - -/**************************************************************************** - * Public Type Definitions - ****************************************************************************/ - -/* Representation of an IP address */ - -typedef in_addr_t uip_ip4addr_t; -typedef uint16_t uip_ip6addr_t[8]; - -#ifdef CONFIG_NET_IPv6 -typedef uip_ip6addr_t uip_ipaddr_t; -#else -typedef uip_ip4addr_t uip_ipaddr_t; -#endif - -/* The IP header */ - -struct uip_ip_hdr -{ -#ifdef CONFIG_NET_IPv6 - - /* IPv6 Ip header */ - - uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ - uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */ - uint16_t flow; /* 16-bit flow label (LS) */ - uint8_t len[2]; /* 16-bit Payload length */ - uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ - uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ - uip_ip6addr_t srcipaddr; /* 128-bit Source address */ - uip_ip6addr_t destipaddr; /* 128-bit Destination address */ - -#else /* CONFIG_NET_IPv6 */ - - /* IPv4 IP header */ - - uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ - uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ - uint8_t len[2]; /* 16-bit Total length */ - uint8_t ipid[2]; /* 16-bit Identification */ - uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ - uint8_t ttl; /* 8-bit Time to Live */ - uint8_t proto; /* 8-bit Protocol */ - uint16_t ipchksum; /* 16-bit Header checksum */ - uint16_t srcipaddr[2]; /* 32-bit Source IP address */ - uint16_t destipaddr[2]; /* 32-bit Destination IP address */ - -#endif /* CONFIG_NET_IPv6 */ -}; - -/* Describes a uIP callback - * - * flink - Supports a singly linked list - * event - Provides the address of the callback function entry point. - * pvconn is a pointer to one of struct uip_conn or struct uip_udp_conn. - * priv - Holds a reference to application specific data that will - * provided - * flags - Set by the application to inform the uIP layer which flags - * are and are not handled by the callback. - */ - -struct uip_driver_s; /* Forward reference */ -struct uip_callback_s -{ - FAR struct uip_callback_s *flink; - uint16_t (*event)(struct uip_driver_s *dev, void *pvconn, void *pvpriv, uint16_t flags); - void *priv; - uint16_t flags; -}; - -/* Protocol-specific support */ - -#ifdef CONFIG_NET_PKT -# include -#endif -#ifdef CONFIG_NET_TCP -# include -#endif -#ifdef CONFIG_NET_UDP -# include -#endif -#ifdef CONFIG_NET_ICMP -# include -#endif -#ifdef CONFIG_NET_IGMP -# include -#endif - -/* The structure holding the uIP statistics that are gathered if - * CONFIG_NET_STATISTICS is defined. - */ - -#ifdef CONFIG_NET_STATISTICS -struct uip_ip_stats_s -{ - uip_stats_t drop; /* Number of dropped packets at the IP layer */ - uip_stats_t recv; /* Number of received packets at the IP layer */ - uip_stats_t sent; /* Number of sent packets at the IP layer */ - uip_stats_t vhlerr; /* Number of packets dropped due to wrong - IP version or header length */ - uip_stats_t hblenerr; /* Number of packets dropped due to wrong - IP length, high byte */ - uip_stats_t lblenerr; /* Number of packets dropped due to wrong - IP length, low byte */ - uip_stats_t fragerr; /* Number of packets dropped since they - were IP fragments */ - uip_stats_t chkerr; /* Number of packets dropped due to IP - checksum errors */ - uip_stats_t protoerr; /* Number of packets dropped since they - were neither ICMP, UDP nor TCP */ -}; - -struct uip_stats -{ - struct uip_ip_stats_s ip; /* IP statistics */ - -#ifdef CONFIG_NET_ICMP - struct uip_icmp_stats_s icmp; /* ICMP statistics */ -#endif - -#ifdef CONFIG_NET_IGMP - struct uip_igmp_stats_s igmp; /* IGMP statistics */ -#endif - -#ifdef CONFIG_NET_TCP - struct uip_tcp_stats_s tcp; /* TCP statistics */ -#endif - -#ifdef CONFIG_NET_UDP - struct uip_udp_stats_s udp; /* UDP statistics */ -#endif -}; -#endif /* CONFIG_NET_STATISTICS */ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/* This is the structure in which the statistics are gathered. */ - -#ifdef CONFIG_NET_STATISTICS -extern struct uip_stats uip_stat; -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/* uIP initialization functions - * - * The uIP initialization functions are used for booting uIP. - * - * This function should be called at boot up to initilize the uIP - * TCP/IP stack. - */ - -void uip_initialize(void); - -/* This function may be used at boot time to set the initial ip_id.*/ - -void uip_setipid(uint16_t id); - -/* Critical section management. The NuttX configuration setting - * CONFIG_NET_NOINT indicates that uIP not called from the interrupt level. - * If CONFIG_NET_NOINTS is defined, then these will map to semaphore - * controls. Otherwise, it assumed that uIP will be called from interrupt - * level handling and these will map to interrupt enable/disable controls. - */ - -#ifdef CONFIG_NET_NOINTS - -/* Semaphore based locking for non-interrupt based logic. - * - * uip_lock_t -- Not used. Only for compatibility - * uip_lockinit() -- Initializes an underlying semaphore/mutex - * uip_lock() -- Takes the semaphore(). Implements a re-entrant mutex. - * uip_unlock() -- Gives the semaphore(). - * uip_lockedwait() -- Like pthread_cond_wait(); releases the semaphore - * momemtarily to wait on another semaphore() - */ - -typedef uint8_t uip_lock_t; /* Not really used */ - -void uip_lockinit(void); -uip_lock_t uip_lock(void); -void uip_unlock(uip_lock_t flags); -int uip_lockedwait(sem_t *sem); - -#else - -/* Enable/disable locking for interrupt based logic: - * - * uip_lock_t -- The processor specific representation of interrupt state. - * uip_lockinit() -- (Does not exist). - * uip_lock() -- Disables interrupts. - * uip_unlock() -- Conditionally restores interrupts. - * uip_lockedwait() -- Just wait for the semaphore. - */ - -# define uip_lock_t irqstate_t -# define uip_lockinit() -# define uip_lock() irqsave() -# define uip_unlock(f) irqrestore(f) -# define uip_lockedwait(s) sem_wait(s) - -#endif - -/* 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. - */ - -/* Send data on the current connection. - * - * This function is used to send out a single segment of TCP - * data. Only applications that have been invoked by uIP for event - * processing can send data. - * - * The amount of data that actually is sent out after a call to this - * funcion is determined by the maximum amount of data TCP allows. uIP - * will automatically crop the data so that only the appropriate - * amount of data is sent. The function uip_mss() can be used to query - * uIP for the amount of data that actually will be sent. - * - * Note: This function does not guarantee that the sent data will - * arrive at the destination. If the data is lost in the network, the - * application will be invoked with the UIP_REXMIT flag set. The - * application will then have to resend the data using this function. - * - * data A pointer to the data which is to be sent. - * - * len The maximum amount of data bytes to be sent. - */ - -void uip_send(FAR struct uip_driver_s *dev, FAR const void *buf, int len); - -#ifdef CONFIG_NET_IOB -struct iob_s; -void uip_iobsend(FAR struct uip_driver_s *dev, FAR struct iob_s *buf, - unsigned int len, unsigned int offset); -#endif - -#ifdef CONFIG_NET_PKT -void uip_pktsend(FAR struct uip_driver_s *dev, FAR const void *buf, - unsigned int len); -#endif - -/* uIP convenience and converting functions. - * - * These functions can be used for converting between different data - * formats used by uIP. - * - * Construct an IP address from four bytes. - * - * This function constructs an IPv4 address in network byte order. - * - * addr A pointer to a uip_ipaddr_t variable that will be - * filled in with the IPv4 address. - * addr0 The first octet of the IPv4 address. - * addr1 The second octet of the IPv4 address. - * addr2 The third octet of the IPv4 address. - * addr3 The forth octet of the IPv4 address. - */ - -#define uip_ipaddr(addr, addr0, addr1, addr2, addr3) \ - do { \ - addr = HTONL((uint32_t)(addr0) << 24 | (uint32_t)(addr1) << 16 | \ - (uint32_t)(addr2) << 8 | (uint32_t)(addr3)); \ - } while (0) - -/* Convert an IPv4 address of the form uint16_t[2] to an in_addr_t */ - -#ifdef CONFIG_ENDIAN_BIG -# define uip_ip4addr_conv(addr) (((in_addr_t)((uint16_t*)addr)[0] << 16) | (in_addr_t)((uint16_t*)addr)[1]) -#else -# define uip_ip4addr_conv(addr) (((in_addr_t)((uint16_t*)addr)[1] << 16) | (in_addr_t)((uint16_t*)addr)[0]) -#endif - -/* Extract individual bytes from a 32-bit IPv4 IP address that is in network byte order */ - -#ifdef CONFIG_ENDIAN_BIG - /* Big-endian byte order: 11223344 */ - -# define ip4_addr1(ipaddr) (((ipaddr) >> 24) & 0xff) -# define ip4_addr2(ipaddr) (((ipaddr) >> 16) & 0xff) -# define ip4_addr3(ipaddr) (((ipaddr) >> 8) & 0xff) -# define ip4_addr4(ipaddr) ((ipaddr) & 0xff) -#else - /* Little endian byte order: 44223311 */ - -# define ip4_addr1(ipaddr) ((ipaddr) & 0xff) -# define ip4_addr2(ipaddr) (((ipaddr) >> 8) & 0xff) -# define ip4_addr3(ipaddr) (((ipaddr) >> 16) & 0xff) -# define ip4_addr4(ipaddr) (((ipaddr) >> 24) & 0xff) -#endif - -/* Construct an IPv6 address from eight 16-bit words. - * - * This function constructs an IPv6 address. - */ - -#define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) \ - do { \ - ((uint16_t*)(addr))[0] = HTONS((addr0)); \ - ((uint16_t*)(addr))[1] = HTONS((addr1)); \ - ((uint16_t*)(addr))[2] = HTONS((addr2)); \ - ((uint16_t*)(addr))[3] = HTONS((addr3)); \ - ((uint16_t*)(addr))[4] = HTONS((addr4)); \ - ((uint16_t*)(addr))[5] = HTONS((addr5)); \ - ((uint16_t*)(addr))[6] = HTONS((addr6)); \ - ((uint16_t*)(addr))[7] = HTONS((addr7)); \ - } while (0) - -/* Copy an IP address to another IP address. - * - * Copies an IP address from one place to another. - * - * Example: - * - * uip_ipaddr_t ipaddr1, ipaddr2; - * - * uip_ipaddr(&ipaddr1, 192,16,1,2); - * uip_ipaddr_copy(&ipaddr2, &ipaddr1); - * - * dest The destination for the copy. - * src The source from where to copy. - */ - -#ifndef CONFIG_NET_IPv6 -# define uip_ipaddr_copy(dest, src) \ - do { \ - (dest) = (in_addr_t)(src); \ - } while (0) -# define uiphdr_ipaddr_copy(dest, src) \ - do { \ - ((uint16_t*)(dest))[0] = ((uint16_t*)(src))[0]; \ - ((uint16_t*)(dest))[1] = ((uint16_t*)(src))[1]; \ - } while (0) -#else /* !CONFIG_NET_IPv6 */ -# define uip_ipaddr_copy(dest, src) memcpy(&dest, &src, sizeof(uip_ip6addr_t)) -# define uiphdr_ipaddr_copy(dest, src) uip_ipaddr_copy(dest, src) -#endif /* !CONFIG_NET_IPv6 */ - -/* Compare two IP addresses - * - * Example: - * - * uip_ipaddr_t ipaddr1, ipaddr2; - * - * uip_ipaddr(&ipaddr1, 192,16,1,2); - * if (uip_ipaddr_cmp(ipaddr2, ipaddr1)) - * { - * printf("They are the same"); - * } - * - * addr1 The first IP address. - * addr2 The second IP address. - */ - -#ifndef CONFIG_NET_IPv6 -# define uip_ipaddr_cmp(addr1, addr2) (addr1 == addr2) -# define uiphdr_ipaddr_cmp(addr1, addr2) uip_ipaddr_cmp(uip_ip4addr_conv(addr1), uip_ip4addr_conv(addr2)) -#else /* !CONFIG_NET_IPv6 */ -# define uip_ipaddr_cmp(addr1, addr2) (memcmp(&addr1, &addr2, sizeof(uip_ip6addr_t)) == 0) -# define uiphdr_ipaddr_cmp(addr1, addr2) uip_ipaddr_cmp(addr, addr2) -#endif /* !CONFIG_NET_IPv6 */ - -/* Compare two IP addresses with netmasks - * - * Compares two IP addresses with netmasks. The masks are used to mask - * out the bits that are to be compared. - * - * Example: - * - * uip_ipaddr_t ipaddr1, ipaddr2, mask; - * - * uip_ipaddr(&mask, 255,255,255,0); - * uip_ipaddr(&ipaddr1, 192,16,1,2); - * uip_ipaddr(&ipaddr2, 192,16,1,3); - * if (uip_ipaddr_maskcmp(ipaddr1, ipaddr2, &mask)) - * { - * printf("They are the same"); - * } - * - * addr1 The first IP address. - * addr2 The second IP address. - * mask The netmask. - */ - -#ifndef CONFIG_NET_IPv6 -# define uip_ipaddr_maskcmp(addr1, addr2, mask) \ - (((in_addr_t)(addr1) & (in_addr_t)(mask)) == \ - ((in_addr_t)(addr2) & (in_addr_t)(mask))) -#else -bool uip_ipaddr_maskcmp(uip_ipaddr_t addr1, uip_ipaddr_t addr2, - uip_ipaddr_t mask); -#endif - -/* Mask out the network part of an IP address. - * - * Masks out the network part of an IP address, given the address and - * the netmask. - * - * Example: - * - * uip_ipaddr_t ipaddr1, ipaddr2, netmask; - * - * uip_ipaddr(&ipaddr1, 192,16,1,2); - * uip_ipaddr(&netmask, 255,255,255,0); - * uip_ipaddr_mask(&ipaddr2, &ipaddr1, &netmask); - * - * In the example above, the variable "ipaddr2" will contain the IP - * address 192.168.1.0. - * - * dest Where the result is to be placed. - * src The IP address. - * mask The netmask. - */ - -#define uip_ipaddr_mask(dest, src, mask) \ - do { \ - (in_addr_t)(dest) = (in_addr_t)(src) & (in_addr_t)(mask); \ - } while (0) - -#endif /* __INCLUDE_NUTTX_NET_UIP_UIP_H */ diff --git a/nuttx/net/accept.c b/nuttx/net/accept.c index 07e3f983e..d6a4ed84e 100644 --- a/nuttx/net/accept.c +++ b/nuttx/net/accept.c @@ -51,7 +51,7 @@ #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/arp/arp_timer.c b/nuttx/net/arp/arp_timer.c index 6331bda19..059f1577a 100644 --- a/nuttx/net/arp/arp_timer.c +++ b/nuttx/net/arp/arp_timer.c @@ -48,7 +48,7 @@ #include #include -#include "net_internal.h" +#include "net.h" #ifdef CONFIG_NET_ARP diff --git a/nuttx/net/bind.c b/nuttx/net/bind.c index 48e0ad3af..0d1a35cfe 100644 --- a/nuttx/net/bind.c +++ b/nuttx/net/bind.c @@ -49,7 +49,7 @@ # include #endif -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Private Functions diff --git a/nuttx/net/connect.c b/nuttx/net/connect.c index 9ffd4a15c..0e28d91c5 100644 --- a/nuttx/net/connect.c +++ b/nuttx/net/connect.c @@ -50,8 +50,8 @@ #include #include -#include "net_internal.h" -#include "uip/uip_internal.h" +#include "net.h" +#include "uip/uip.h" /**************************************************************************** * Private Types diff --git a/nuttx/net/getsockname.c b/nuttx/net/getsockname.c index fd5121308..ba15055e1 100644 --- a/nuttx/net/getsockname.c +++ b/nuttx/net/getsockname.c @@ -48,7 +48,7 @@ #include #include -#include "net_internal.h" +#include "net.h" #ifdef CONFIG_NET diff --git a/nuttx/net/getsockopt.c b/nuttx/net/getsockopt.c index 405823fb4..d1b8578c4 100644 --- a/nuttx/net/getsockopt.c +++ b/nuttx/net/getsockopt.c @@ -44,7 +44,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/icmp/icmp_input.c b/nuttx/net/icmp/icmp_input.c index 83fe252a9..94087b9ae 100644 --- a/nuttx/net/icmp/icmp_input.c +++ b/nuttx/net/icmp/icmp_input.c @@ -50,10 +50,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_ICMP diff --git a/nuttx/net/icmp/icmp_ping.c b/nuttx/net/icmp/icmp_ping.c index 9394a49ce..adcc3626c 100644 --- a/nuttx/net/icmp/icmp_ping.c +++ b/nuttx/net/icmp/icmp_ping.c @@ -50,11 +50,11 @@ #include #include #include -#include +#include #include -#include "uip/uip_internal.h" -#include "../net_internal.h" /* Should not include this! */ +#include "uip/uip.h" +#include "../net.h" /* Should not include this! */ /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/icmp/icmp_poll.c b/nuttx/net/icmp/icmp_poll.c index d3b6014c7..2d79255e7 100644 --- a/nuttx/net/icmp/icmp_poll.c +++ b/nuttx/net/icmp/icmp_poll.c @@ -43,10 +43,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/icmp/icmp_send.c b/nuttx/net/icmp/icmp_send.c index 603a477f9..96df208ea 100644 --- a/nuttx/net/icmp/icmp_send.c +++ b/nuttx/net/icmp/icmp_send.c @@ -43,10 +43,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/igmp/igmp_group.c b/nuttx/net/igmp/igmp_group.c index fb38cc1cb..1fbcaa08a 100644 --- a/nuttx/net/igmp/igmp_group.c +++ b/nuttx/net/igmp/igmp_group.c @@ -55,10 +55,10 @@ #include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_init.c b/nuttx/net/igmp/igmp_init.c index f0f94198a..36f48b547 100644 --- a/nuttx/net/igmp/igmp_init.c +++ b/nuttx/net/igmp/igmp_init.c @@ -47,10 +47,10 @@ #include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_input.c b/nuttx/net/igmp/igmp_input.c index 660d9f0b0..b1c39399b 100644 --- a/nuttx/net/igmp/igmp_input.c +++ b/nuttx/net/igmp/igmp_input.c @@ -48,10 +48,10 @@ #include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_join.c b/nuttx/net/igmp/igmp_join.c index 33e5b5140..5dafb0dd6 100644 --- a/nuttx/net/igmp/igmp_join.c +++ b/nuttx/net/igmp/igmp_join.c @@ -47,10 +47,10 @@ #include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_leave.c b/nuttx/net/igmp/igmp_leave.c index 1b80272ee..f3bfe9f4d 100644 --- a/nuttx/net/igmp/igmp_leave.c +++ b/nuttx/net/igmp/igmp_leave.c @@ -48,10 +48,10 @@ #include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_mcastmac.c b/nuttx/net/igmp/igmp_mcastmac.c index 937810935..163ad0db5 100644 --- a/nuttx/net/igmp/igmp_mcastmac.c +++ b/nuttx/net/igmp/igmp_mcastmac.c @@ -47,9 +47,9 @@ #include #include -#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_msg.c b/nuttx/net/igmp/igmp_msg.c index ae0155e70..ba4151209 100644 --- a/nuttx/net/igmp/igmp_msg.c +++ b/nuttx/net/igmp/igmp_msg.c @@ -47,10 +47,10 @@ #include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_poll.c b/nuttx/net/igmp/igmp_poll.c index 522826e29..9f6f8f0a5 100644 --- a/nuttx/net/igmp/igmp_poll.c +++ b/nuttx/net/igmp/igmp_poll.c @@ -47,10 +47,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_send.c b/nuttx/net/igmp/igmp_send.c index af7da4cfb..64e609827 100644 --- a/nuttx/net/igmp/igmp_send.c +++ b/nuttx/net/igmp/igmp_send.c @@ -43,12 +43,12 @@ #include #include -#include +#include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/igmp/igmp_timer.c b/nuttx/net/igmp/igmp_timer.c index bf7007998..bdcc846b5 100644 --- a/nuttx/net/igmp/igmp_timer.c +++ b/nuttx/net/igmp/igmp_timer.c @@ -49,10 +49,10 @@ #include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" #ifdef CONFIG_NET_IGMP diff --git a/nuttx/net/listen.c b/nuttx/net/listen.c index 5e3c62f69..c8a1260bd 100644 --- a/nuttx/net/listen.c +++ b/nuttx/net/listen.c @@ -44,7 +44,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/net.h b/nuttx/net/net.h new file mode 100644 index 000000000..96eddb8b2 --- /dev/null +++ b/nuttx/net/net.h @@ -0,0 +1,239 @@ +/**************************************************************************** + * net/net.h + * + * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef _NET_NET_H +#define _NET_NET_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#ifdef CONFIG_NET + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Definitions of 8-bit socket flags */ + + /* Bits 0-2: Socket state */ +#define _SF_IDLE 0x00 /* - There is no socket activity */ +#define _SF_ACCEPT 0x01 /* - Socket is waiting to accept a connection */ +#define _SF_RECV 0x02 /* - Waiting for recv action to complete */ +#define _SF_SEND 0x03 /* - Waiting for send action to complete */ +#define _SF_MASK 0x03 /* - Mask to isolate the above actions */ + +#define _SF_NONBLOCK 0x08 /* Bit 3: Don't block if no data (TCP/READ only) */ +#define _SF_LISTENING 0x10 /* Bit 4: SOCK_STREAM is listening */ +#define _SF_BOUND 0x20 /* Bit 5: SOCK_STREAM is bound to an address */ + /* Bits 6-7: Connection state */ +#define _SF_CONNECTED 0x40 /* Bit 6: SOCK_STREAM is connected */ +#define _SF_CLOSED 0x80 /* Bit 7: SOCK_STREAM was gracefully disconnected */ + +/* Connection state encoding: + * + * _SF_CONNECTED==1 && _SF_CLOSED==0 - the socket is connected + * _SF_CONNECTED==0 && _SF_CLOSED==1 - the socket was gracefully disconnected + * _SF_CONNECTED==0 && _SF_CLOSED==0 - the socket was rudely disconnected + */ + +/* Macro to manage the socket state and flags */ + +#define _SS_SETSTATE(s,f) (((s) & ~_SF_MASK) | (f)) +#define _SS_GETSTATE(s) ((s) & _SF_MASK) +#define _SS_ISBUSY(s) (_SS_GETSTATE(s) != _SF_IDLE) + +#define _SS_ISNONBLOCK(s) (((s) & _SF_NONBLOCK) != 0) +#define _SS_ISLISTENING(s) (((s) & _SF_LISTENING) != 0) +#define _SS_ISBOUND(s) (((s) & _SF_CONNECTED) != 0) +#define _SS_ISCONNECTED(s) (((s) & _SF_CONNECTED) != 0) +#define _SS_ISCLOSED(s) (((s) & _SF_CLOSED) != 0) + +/* This macro converts a socket option value into a bit setting */ + +#define _SO_BIT(o) (1 << (o)) + +/* These define bit positions for each socket option (see sys/socket.h) */ + +#define _SO_DEBUG _SO_BIT(SO_DEBUG) +#define _SO_ACCEPTCONN _SO_BIT(SO_ACCEPTCONN) +#define _SO_BROADCAST _SO_BIT(SO_BROADCAST) +#define _SO_REUSEADDR _SO_BIT(SO_REUSEADDR) +#define _SO_KEEPALIVE _SO_BIT(SO_KEEPALIVE) +#define _SO_LINGER _SO_BIT(SO_LINGER) +#define _SO_OOBINLINE _SO_BIT(SO_OOBINLINE) +#define _SO_SNDBUF _SO_BIT(SO_SNDBUF) +#define _SO_RCVBUF _SO_BIT(SO_RCVBUF) +#define _SO_ERROR _SO_BIT(SO_ERROR) +#define _SO_TYPE _SO_BIT(SO_TYPE) +#define _SO_DONTROUTE _SO_BIT(SO_DONTROUTE) +#define _SO_RCVLOWAT _SO_BIT(SO_RCVLOWAT) +#define _SO_RCVTIMEO _SO_BIT(SO_RCVTIMEO) +#define _SO_SNDLOWAT _SO_BIT(SO_SNDLOWAT) +#define _SO_SNDTIMEO _SO_BIT(SO_SNDTIMEO) + +/* This is the larget option value */ + +#define _SO_MAXOPT (15) + +/* Macros to set, test, clear options */ + +#define _SO_SETOPT(s,o) ((s) |= _SO_BIT(o)) +#define _SO_CLROPT(s,o) ((s) &= ~_SO_BIT(o)) +#define _SO_GETOPT(s,o) (((s) & _SO_BIT(o)) != 0) + +/* These are macros that can be used to determine if socket option code is + * valid (in range) and supported by API. + */ + +#define _SO_GETONLYSET (_SO_ACCEPTCONN|_SO_ERROR|_SO_TYPE) +#define _SO_GETONLY(o) ((_SO_BIT(o) & _SO_GETONLYSET) != 0) +#define _SO_GETVALID(o) (((unsigned int)(o)) <= _SO_MAXOPT) +#define _SO_SETVALID(o) ((((unsigned int)(o)) <= _SO_MAXOPT) && !_SO_GETONLY(o)) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/* List of registered ethernet device drivers */ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 +EXTERN struct uip_driver_s *g_netdevices; +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* net_sockets.c *************************************************************/ + +int sockfd_allocate(int minsd); +void sock_release(FAR struct socket *psock); +void sockfd_release(int sockfd); +FAR struct socket *sockfd_socket(int sockfd); + +/* net_connect.c *************************************************************/ + +#ifdef CONFIG_NET_TCP +int net_startmonitor(FAR struct socket *psock); +void net_stopmonitor(FAR struct uip_conn *conn); +void net_lostconnection(FAR struct socket *psock, uint16_t flags); +#endif + +/* net_close.c ***************************************************************/ + +int psock_close(FAR struct socket *psock); + +/* sockopt support ***********************************************************/ + +#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) +int net_timeo(uint32_t start_time, socktimeo_t timeo); +socktimeo_t net_timeval2dsec(FAR struct timeval *tv); +void net_dsec2timeval(uint16_t dsec, FAR struct timeval *tv); +#endif + +/* net_register.c ************************************************************/ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 +void netdev_seminit(void); +void netdev_semtake(void); +void netdev_semgive(void); +#endif + +/* net_findbyname.c **********************************************************/ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 +FAR struct uip_driver_s *netdev_findbyname(FAR const char *ifname); +#endif + +/* net_findbyaddr.c **********************************************************/ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 +FAR struct uip_driver_s *netdev_findbyaddr(const uip_ipaddr_t addr); +#endif + +/* net_txnotify.c ************************************************************/ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 +void netdev_txnotify(const uip_ipaddr_t addr); +#endif + +/* net_rxnotify.c ************************************************************/ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL) +void netdev_rxnotify(const uip_ipaddr_t addr); +#else +# define netdev_rxnotify(addr) +#endif + +/* net_count.c ***************************************************************/ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 +int netdev_count(void); +#endif + +/* send.c ********************************************************************/ + +ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len, + int flags); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* CONFIG_NET */ +#endif /* _NET_NET_H */ diff --git a/nuttx/net/net_addroute.c b/nuttx/net/net_addroute.c index b93a84071..7db5504d8 100644 --- a/nuttx/net/net_addroute.c +++ b/nuttx/net/net_addroute.c @@ -46,7 +46,7 @@ #include -#include "net_internal.h" +#include "net.h" #include "net_route.h" #if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE) diff --git a/nuttx/net/net_allocroute.c b/nuttx/net/net_allocroute.c index 8ae0938e8..69fdd56b9 100644 --- a/nuttx/net/net_allocroute.c +++ b/nuttx/net/net_allocroute.c @@ -45,7 +45,7 @@ #include -#include "net_internal.h" +#include "net.h" #include "net_route.h" #if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE) diff --git a/nuttx/net/net_checksd.c b/nuttx/net/net_checksd.c index 0a6975cad..77feab68a 100644 --- a/nuttx/net/net_checksd.c +++ b/nuttx/net/net_checksd.c @@ -45,7 +45,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/net_clone.c b/nuttx/net/net_clone.c index 5efed0944..4f5bfe668 100644 --- a/nuttx/net/net_clone.c +++ b/nuttx/net/net_clone.c @@ -46,7 +46,7 @@ #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/net_close.c b/nuttx/net/net_close.c index f96724f0e..d5a72f59d 100644 --- a/nuttx/net/net_close.c +++ b/nuttx/net/net_close.c @@ -54,8 +54,8 @@ # include #endif -#include "net_internal.h" -#include "uip/uip_internal.h" +#include "net.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/net_delroute.c b/nuttx/net/net_delroute.c index 50c978a88..1d4571c52 100644 --- a/nuttx/net/net_delroute.c +++ b/nuttx/net/net_delroute.c @@ -43,7 +43,7 @@ #include #include -#include "net_internal.h" +#include "net.h" #include "net_route.h" #if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE) diff --git a/nuttx/net/net_dsec2timeval.c b/nuttx/net/net_dsec2timeval.c index 0f570cb39..cad43ae03 100644 --- a/nuttx/net/net_dsec2timeval.c +++ b/nuttx/net/net_dsec2timeval.c @@ -45,7 +45,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/net_dup.c b/nuttx/net/net_dup.c index 9ab36b920..5f0185a12 100644 --- a/nuttx/net/net_dup.c +++ b/nuttx/net/net_dup.c @@ -44,7 +44,7 @@ #include #include -#include "net_internal.h" +#include "net.h" #if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 diff --git a/nuttx/net/net_dup2.c b/nuttx/net/net_dup2.c index 3403a70c3..3223fcf78 100644 --- a/nuttx/net/net_dup2.c +++ b/nuttx/net/net_dup2.c @@ -44,7 +44,7 @@ #include #include -#include "net_internal.h" +#include "net.h" #if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 diff --git a/nuttx/net/net_foreachroute.c b/nuttx/net/net_foreachroute.c index f8343618d..2b22abc90 100644 --- a/nuttx/net/net_foreachroute.c +++ b/nuttx/net/net_foreachroute.c @@ -44,7 +44,7 @@ #include -#include "net_internal.h" +#include "net.h" #include "net_route.h" #if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE) diff --git a/nuttx/net/net_internal.h b/nuttx/net/net_internal.h deleted file mode 100644 index 9577d2ea3..000000000 --- a/nuttx/net/net_internal.h +++ /dev/null @@ -1,239 +0,0 @@ -/**************************************************************************** - * net/net_internal.h - * - * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __NET_INTERNAL_H -#define __NET_INTERNAL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#ifdef CONFIG_NET - -#include -#include -#include - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Definitions of 8-bit socket flags */ - - /* Bits 0-2: Socket state */ -#define _SF_IDLE 0x00 /* - There is no socket activity */ -#define _SF_ACCEPT 0x01 /* - Socket is waiting to accept a connection */ -#define _SF_RECV 0x02 /* - Waiting for recv action to complete */ -#define _SF_SEND 0x03 /* - Waiting for send action to complete */ -#define _SF_MASK 0x03 /* - Mask to isolate the above actions */ - -#define _SF_NONBLOCK 0x08 /* Bit 3: Don't block if no data (TCP/READ only) */ -#define _SF_LISTENING 0x10 /* Bit 4: SOCK_STREAM is listening */ -#define _SF_BOUND 0x20 /* Bit 5: SOCK_STREAM is bound to an address */ - /* Bits 6-7: Connection state */ -#define _SF_CONNECTED 0x40 /* Bit 6: SOCK_STREAM is connected */ -#define _SF_CLOSED 0x80 /* Bit 7: SOCK_STREAM was gracefully disconnected */ - -/* Connection state encoding: - * - * _SF_CONNECTED==1 && _SF_CLOSED==0 - the socket is connected - * _SF_CONNECTED==0 && _SF_CLOSED==1 - the socket was gracefully disconnected - * _SF_CONNECTED==0 && _SF_CLOSED==0 - the socket was rudely disconnected - */ - -/* Macro to manage the socket state and flags */ - -#define _SS_SETSTATE(s,f) (((s) & ~_SF_MASK) | (f)) -#define _SS_GETSTATE(s) ((s) & _SF_MASK) -#define _SS_ISBUSY(s) (_SS_GETSTATE(s) != _SF_IDLE) - -#define _SS_ISNONBLOCK(s) (((s) & _SF_NONBLOCK) != 0) -#define _SS_ISLISTENING(s) (((s) & _SF_LISTENING) != 0) -#define _SS_ISBOUND(s) (((s) & _SF_CONNECTED) != 0) -#define _SS_ISCONNECTED(s) (((s) & _SF_CONNECTED) != 0) -#define _SS_ISCLOSED(s) (((s) & _SF_CLOSED) != 0) - -/* This macro converts a socket option value into a bit setting */ - -#define _SO_BIT(o) (1 << (o)) - -/* These define bit positions for each socket option (see sys/socket.h) */ - -#define _SO_DEBUG _SO_BIT(SO_DEBUG) -#define _SO_ACCEPTCONN _SO_BIT(SO_ACCEPTCONN) -#define _SO_BROADCAST _SO_BIT(SO_BROADCAST) -#define _SO_REUSEADDR _SO_BIT(SO_REUSEADDR) -#define _SO_KEEPALIVE _SO_BIT(SO_KEEPALIVE) -#define _SO_LINGER _SO_BIT(SO_LINGER) -#define _SO_OOBINLINE _SO_BIT(SO_OOBINLINE) -#define _SO_SNDBUF _SO_BIT(SO_SNDBUF) -#define _SO_RCVBUF _SO_BIT(SO_RCVBUF) -#define _SO_ERROR _SO_BIT(SO_ERROR) -#define _SO_TYPE _SO_BIT(SO_TYPE) -#define _SO_DONTROUTE _SO_BIT(SO_DONTROUTE) -#define _SO_RCVLOWAT _SO_BIT(SO_RCVLOWAT) -#define _SO_RCVTIMEO _SO_BIT(SO_RCVTIMEO) -#define _SO_SNDLOWAT _SO_BIT(SO_SNDLOWAT) -#define _SO_SNDTIMEO _SO_BIT(SO_SNDTIMEO) - -/* This is the larget option value */ - -#define _SO_MAXOPT (15) - -/* Macros to set, test, clear options */ - -#define _SO_SETOPT(s,o) ((s) |= _SO_BIT(o)) -#define _SO_CLROPT(s,o) ((s) &= ~_SO_BIT(o)) -#define _SO_GETOPT(s,o) (((s) & _SO_BIT(o)) != 0) - -/* These are macros that can be used to determine if socket option code is - * valid (in range) and supported by API. - */ - -#define _SO_GETONLYSET (_SO_ACCEPTCONN|_SO_ERROR|_SO_TYPE) -#define _SO_GETONLY(o) ((_SO_BIT(o) & _SO_GETONLYSET) != 0) -#define _SO_GETVALID(o) (((unsigned int)(o)) <= _SO_MAXOPT) -#define _SO_SETVALID(o) ((((unsigned int)(o)) <= _SO_MAXOPT) && !_SO_GETONLY(o)) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Variables - ****************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/* List of registered ethernet device drivers */ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 -EXTERN struct uip_driver_s *g_netdevices; -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/* net_sockets.c *************************************************************/ - -int sockfd_allocate(int minsd); -void sock_release(FAR struct socket *psock); -void sockfd_release(int sockfd); -FAR struct socket *sockfd_socket(int sockfd); - -/* net_connect.c *************************************************************/ - -#ifdef CONFIG_NET_TCP -int net_startmonitor(FAR struct socket *psock); -void net_stopmonitor(FAR struct uip_conn *conn); -void net_lostconnection(FAR struct socket *psock, uint16_t flags); -#endif - -/* net_close.c ***************************************************************/ - -int psock_close(FAR struct socket *psock); - -/* sockopt support ***********************************************************/ - -#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) -int net_timeo(uint32_t start_time, socktimeo_t timeo); -socktimeo_t net_timeval2dsec(FAR struct timeval *tv); -void net_dsec2timeval(uint16_t dsec, FAR struct timeval *tv); -#endif - -/* net_register.c ************************************************************/ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 -void netdev_seminit(void); -void netdev_semtake(void); -void netdev_semgive(void); -#endif - -/* net_findbyname.c **********************************************************/ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 -FAR struct uip_driver_s *netdev_findbyname(FAR const char *ifname); -#endif - -/* net_findbyaddr.c **********************************************************/ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 -FAR struct uip_driver_s *netdev_findbyaddr(const uip_ipaddr_t addr); -#endif - -/* net_txnotify.c ************************************************************/ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 -void netdev_txnotify(const uip_ipaddr_t addr); -#endif - -/* net_rxnotify.c ************************************************************/ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL) -void netdev_rxnotify(const uip_ipaddr_t addr); -#else -# define netdev_rxnotify(addr) -#endif - -/* net_count.c ***************************************************************/ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 -int netdev_count(void); -#endif - -/* send.c ********************************************************************/ - -ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len, - int flags); - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - -#endif /* CONFIG_NET */ -#endif /* __NET_INTERNAL_H */ diff --git a/nuttx/net/net_monitor.c b/nuttx/net/net_monitor.c index 3ce092220..cc1289da3 100644 --- a/nuttx/net/net_monitor.c +++ b/nuttx/net/net_monitor.c @@ -44,8 +44,8 @@ #include #include -#include "net_internal.h" -#include "uip/uip_internal.h" +#include "net.h" +#include "uip/uip.h" /**************************************************************************** * Private Types diff --git a/nuttx/net/net_poll.c b/nuttx/net/net_poll.c index 49c0a2b74..00900919a 100644 --- a/nuttx/net/net_poll.c +++ b/nuttx/net/net_poll.c @@ -51,12 +51,12 @@ #include #include -#include +#include #include -#include +#include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/net_route.h b/nuttx/net/net_route.h index 08039fe01..e6484ce93 100644 --- a/nuttx/net/net_route.h +++ b/nuttx/net/net_route.h @@ -45,7 +45,7 @@ #include #include -#include +#include #ifdef CONFIG_NET_ROUTE diff --git a/nuttx/net/net_router.c b/nuttx/net/net_router.c index e56b2c550..4851c08ec 100644 --- a/nuttx/net/net_router.c +++ b/nuttx/net/net_router.c @@ -43,7 +43,7 @@ #include #include -#include "net_internal.h" +#include "net.h" #include "net_route.h" #if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE) diff --git a/nuttx/net/net_sendfile.c b/nuttx/net/net_sendfile.c index aaaefcce0..23d8cd1b5 100644 --- a/nuttx/net/net_sendfile.c +++ b/nuttx/net/net_sendfile.c @@ -61,8 +61,8 @@ #include #include -#include "net_internal.h" -#include "uip/uip_internal.h" +#include "net.h" +#include "uip/uip.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/net_sockets.c b/nuttx/net/net_sockets.c index c6962915d..66800f382 100644 --- a/nuttx/net/net_sockets.c +++ b/nuttx/net/net_sockets.c @@ -49,12 +49,12 @@ #include #include -#include +#include #include #include #include "net_route.h" -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/net_timeo.c b/nuttx/net/net_timeo.c index c593c45c7..551aa188f 100644 --- a/nuttx/net/net_timeo.c +++ b/nuttx/net/net_timeo.c @@ -45,7 +45,7 @@ #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/net_timeval2dsec.c b/nuttx/net/net_timeval2dsec.c index e0b25db98..f61f1a179 100644 --- a/nuttx/net/net_timeval2dsec.c +++ b/nuttx/net/net_timeval2dsec.c @@ -45,7 +45,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/net_vfcntl.c b/nuttx/net/net_vfcntl.c index 5fa6177f1..7db7fdb77 100644 --- a/nuttx/net/net_vfcntl.c +++ b/nuttx/net/net_vfcntl.c @@ -47,7 +47,7 @@ #include #include -#include "net_internal.h" +#include "net.h" #if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 diff --git a/nuttx/net/netdev_carrier.c b/nuttx/net/netdev_carrier.c index d0e59d996..d74ce46c2 100644 --- a/nuttx/net/netdev_carrier.c +++ b/nuttx/net/netdev_carrier.c @@ -52,7 +52,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/netdev_count.c b/nuttx/net/netdev_count.c index 4ee0612a5..c185c1428 100644 --- a/nuttx/net/netdev_count.c +++ b/nuttx/net/netdev_count.c @@ -45,7 +45,7 @@ #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/netdev_findbyaddr.c b/nuttx/net/netdev_findbyaddr.c index 77bef5aaf..99bdc9d9f 100644 --- a/nuttx/net/netdev_findbyaddr.c +++ b/nuttx/net/netdev_findbyaddr.c @@ -48,7 +48,7 @@ #include #include "net_route.h" -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/netdev_findbyname.c b/nuttx/net/netdev_findbyname.c index c56971e2b..281fadcb7 100644 --- a/nuttx/net/netdev_findbyname.c +++ b/nuttx/net/netdev_findbyname.c @@ -45,7 +45,7 @@ #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/netdev_foreach.c b/nuttx/net/netdev_foreach.c index b3c4975f9..47597d522 100644 --- a/nuttx/net/netdev_foreach.c +++ b/nuttx/net/netdev_foreach.c @@ -44,7 +44,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/netdev_ioctl.c b/nuttx/net/netdev_ioctl.c index eb0c6e523..3c7e4eeda 100644 --- a/nuttx/net/netdev_ioctl.c +++ b/nuttx/net/netdev_ioctl.c @@ -56,14 +56,14 @@ #include #include -#include +#include #ifdef CONFIG_NET_IGMP # include "sys/sockio.h" -# include "nuttx/net/uip/uip-igmp.h" +# include "nuttx/net/igmp.h" #endif -#include "net_internal.h" +#include "net.h" #include "net_route.h" /**************************************************************************** diff --git a/nuttx/net/netdev_register.c b/nuttx/net/netdev_register.c index e34f79232..58c928c33 100644 --- a/nuttx/net/netdev_register.c +++ b/nuttx/net/netdev_register.c @@ -52,7 +52,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/netdev_router.c b/nuttx/net/netdev_router.c index c0e32056d..bcb47b3ab 100644 --- a/nuttx/net/netdev_router.c +++ b/nuttx/net/netdev_router.c @@ -45,7 +45,7 @@ #include -#include "net_internal.h" +#include "net.h" #include "net_route.h" #if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE) diff --git a/nuttx/net/netdev_rxnotify.c b/nuttx/net/netdev_rxnotify.c index ffacf061d..67830258d 100644 --- a/nuttx/net/netdev_rxnotify.c +++ b/nuttx/net/netdev_rxnotify.c @@ -47,7 +47,7 @@ #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/netdev_sem.c b/nuttx/net/netdev_sem.c index ba6299c62..b56f7cba2 100644 --- a/nuttx/net/netdev_sem.c +++ b/nuttx/net/netdev_sem.c @@ -48,7 +48,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/netdev_txnotify.c b/nuttx/net/netdev_txnotify.c index 9d8c69f9a..760fe3291 100644 --- a/nuttx/net/netdev_txnotify.c +++ b/nuttx/net/netdev_txnotify.c @@ -47,7 +47,7 @@ #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/netdev_unregister.c b/nuttx/net/netdev_unregister.c index 7ce9af17a..e8dd76238 100644 --- a/nuttx/net/netdev_unregister.c +++ b/nuttx/net/netdev_unregister.c @@ -52,7 +52,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/pkt/pkt_callback.c b/nuttx/net/pkt/pkt_callback.c index 679f46ef3..a00360f7e 100644 --- a/nuttx/net/pkt/pkt_callback.c +++ b/nuttx/net/pkt/pkt_callback.c @@ -44,10 +44,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/pkt/pkt_conn.c b/nuttx/net/pkt/pkt_conn.c index 30a20655d..bbaae63b3 100644 --- a/nuttx/net/pkt/pkt_conn.c +++ b/nuttx/net/pkt/pkt_conn.c @@ -51,11 +51,11 @@ #include #include -#include +#include #include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/pkt/pkt_input.c b/nuttx/net/pkt/pkt_input.c index 227c388fb..916deb564 100644 --- a/nuttx/net/pkt/pkt_input.c +++ b/nuttx/net/pkt/pkt_input.c @@ -47,12 +47,12 @@ #include -#include +#include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/pkt/pkt_poll.c b/nuttx/net/pkt/pkt_poll.c index 58ca8f3b7..36ee03c58 100644 --- a/nuttx/net/pkt/pkt_poll.c +++ b/nuttx/net/pkt/pkt_poll.c @@ -48,11 +48,11 @@ #include #include -#include +#include #include -#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/pkt/pkt_send.c b/nuttx/net/pkt/pkt_send.c index e8449eb6b..3712c3e29 100644 --- a/nuttx/net/pkt/pkt_send.c +++ b/nuttx/net/pkt/pkt_send.c @@ -53,10 +53,10 @@ #include #include #include -#include +#include -#include "net_internal.h" -#include "uip/uip_internal.h" +#include "net.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/recv.c b/nuttx/net/recv.c index 1571a7377..8ddb4bce6 100644 --- a/nuttx/net/recv.c +++ b/nuttx/net/recv.c @@ -44,7 +44,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index d7f479309..79e1e339b 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -56,8 +56,8 @@ #include #include -#include "net_internal.h" -#include "uip/uip_internal.h" +#include "net.h" +#include "uip/uip.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/send.c b/nuttx/net/send.c index cbec0f7de..6ff0d9f98 100644 --- a/nuttx/net/send.c +++ b/nuttx/net/send.c @@ -45,7 +45,7 @@ #include "tcp/tcp.h" #include "pkt/pkt.h" -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Definitions diff --git a/nuttx/net/sendto.c b/nuttx/net/sendto.c index e34afc9dc..512bdf62c 100644 --- a/nuttx/net/sendto.c +++ b/nuttx/net/sendto.c @@ -51,8 +51,8 @@ #include #include -#include "net_internal.h" -#include "uip/uip_internal.h" +#include "net.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/setsockopt.c b/nuttx/net/setsockopt.c index 7700775bf..40e12c7a0 100644 --- a/nuttx/net/setsockopt.c +++ b/nuttx/net/setsockopt.c @@ -46,7 +46,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/socket.c b/nuttx/net/socket.c index bd63a6584..d7352c04a 100644 --- a/nuttx/net/socket.c +++ b/nuttx/net/socket.c @@ -45,7 +45,7 @@ #include #include -#include "net_internal.h" +#include "net.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/tcp/tcp_appsend.c b/nuttx/net/tcp/tcp_appsend.c index 9f95906f5..50eaf0352 100644 --- a/nuttx/net/tcp/tcp_appsend.c +++ b/nuttx/net/tcp/tcp_appsend.c @@ -49,10 +49,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/tcp/tcp_backlog.c b/nuttx/net/tcp/tcp_backlog.c index 8fa707223..e76af4e25 100644 --- a/nuttx/net/tcp/tcp_backlog.c +++ b/nuttx/net/tcp/tcp_backlog.c @@ -47,10 +47,10 @@ #include #include -#include -#include +#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/tcp/tcp_callback.c b/nuttx/net/tcp/tcp_callback.c index 63b2d5199..b05027c5b 100644 --- a/nuttx/net/tcp/tcp_callback.c +++ b/nuttx/net/tcp/tcp_callback.c @@ -46,10 +46,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/tcp/tcp_conn.c b/nuttx/net/tcp/tcp_conn.c index b95cd7e7b..893c95642 100644 --- a/nuttx/net/tcp/tcp_conn.c +++ b/nuttx/net/tcp/tcp_conn.c @@ -52,11 +52,11 @@ #include #include -#include +#include #include #include "tcp/tcp.h" -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Public Data diff --git a/nuttx/net/tcp/tcp_input.c b/nuttx/net/tcp/tcp_input.c index e373e466e..60a7151fc 100644 --- a/nuttx/net/tcp/tcp_input.c +++ b/nuttx/net/tcp/tcp_input.c @@ -51,10 +51,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/tcp/tcp_listen.c b/nuttx/net/tcp/tcp_listen.c index f974d3f6f..daff52996 100644 --- a/nuttx/net/tcp/tcp_listen.c +++ b/nuttx/net/tcp/tcp_listen.c @@ -50,7 +50,7 @@ #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/tcp/tcp_poll.c b/nuttx/net/tcp/tcp_poll.c index b0286fd24..e741344e8 100644 --- a/nuttx/net/tcp/tcp_poll.c +++ b/nuttx/net/tcp/tcp_poll.c @@ -49,10 +49,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/tcp/tcp_readahead.c b/nuttx/net/tcp/tcp_readahead.c index 280b5469c..059abbc5c 100644 --- a/nuttx/net/tcp/tcp_readahead.c +++ b/nuttx/net/tcp/tcp_readahead.c @@ -43,9 +43,9 @@ #include #include -#include +#include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Private Types diff --git a/nuttx/net/tcp/tcp_send.c b/nuttx/net/tcp/tcp_send.c index 0b079934f..5aa2ef599 100644 --- a/nuttx/net/tcp/tcp_send.c +++ b/nuttx/net/tcp/tcp_send.c @@ -49,10 +49,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/tcp/tcp_send_buffered.c b/nuttx/net/tcp/tcp_send_buffered.c index 1f0a568f2..05a0e4bfb 100644 --- a/nuttx/net/tcp/tcp_send_buffered.c +++ b/nuttx/net/tcp/tcp_send_buffered.c @@ -67,9 +67,9 @@ #include #include -#include "net_internal.h" +#include "net.h" #include "tcp/tcp.h" -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/tcp/tcp_send_unbuffered.c b/nuttx/net/tcp/tcp_send_unbuffered.c index ad58daf8a..dc0cd0eb9 100644 --- a/nuttx/net/tcp/tcp_send_unbuffered.c +++ b/nuttx/net/tcp/tcp_send_unbuffered.c @@ -55,8 +55,8 @@ #include #include -#include "net_internal.h" -#include "uip/uip_internal.h" +#include "net.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/tcp/tcp_seqno.c b/nuttx/net/tcp/tcp_seqno.c index 754740717..6e5cb0b5c 100644 --- a/nuttx/net/tcp/tcp_seqno.c +++ b/nuttx/net/tcp/tcp_seqno.c @@ -51,10 +51,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Public Data diff --git a/nuttx/net/tcp/tcp_timer.c b/nuttx/net/tcp/tcp_timer.c index 0b159abc4..08614ed73 100644 --- a/nuttx/net/tcp/tcp_timer.c +++ b/nuttx/net/tcp/tcp_timer.c @@ -49,10 +49,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/tcp/tcp_wrbuffer.c b/nuttx/net/tcp/tcp_wrbuffer.c index 0cdd99c97..21da66cb0 100644 --- a/nuttx/net/tcp/tcp_wrbuffer.c +++ b/nuttx/net/tcp/tcp_wrbuffer.c @@ -56,7 +56,7 @@ #include "tcp/tcp.h" #include "nuttx/net/iob.h" -#include "nuttx/net/uip/uip-tcp.h" +#include "nuttx/net/tcp.h" /**************************************************************************** * Private Types diff --git a/nuttx/net/tcp/tcp_wrbuffer_dump.c b/nuttx/net/tcp/tcp_wrbuffer_dump.c index 6ff5bb021..497d7c20e 100644 --- a/nuttx/net/tcp/tcp_wrbuffer_dump.c +++ b/nuttx/net/tcp/tcp_wrbuffer_dump.c @@ -43,7 +43,7 @@ #include #include -#include +#include #ifdef CONFIG_DEBUG diff --git a/nuttx/net/udp/udp_callback.c b/nuttx/net/udp/udp_callback.c index b43a5f4fc..7241d6912 100644 --- a/nuttx/net/udp/udp_callback.c +++ b/nuttx/net/udp/udp_callback.c @@ -44,10 +44,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/udp/udp_conn.c b/nuttx/net/udp/udp_conn.c index 4b8178283..09b1c848d 100644 --- a/nuttx/net/udp/udp_conn.c +++ b/nuttx/net/udp/udp_conn.c @@ -57,10 +57,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/udp/udp_input.c b/nuttx/net/udp/udp_input.c index d5280f432..9097fe077 100644 --- a/nuttx/net/udp/udp_input.c +++ b/nuttx/net/udp/udp_input.c @@ -48,10 +48,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/udp/udp_poll.c b/nuttx/net/udp/udp_poll.c index 46ea6ddce..80a1d1f64 100644 --- a/nuttx/net/udp/udp_poll.c +++ b/nuttx/net/udp/udp_poll.c @@ -48,10 +48,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/udp/udp_send.c b/nuttx/net/udp/udp_send.c index 5f43eafd4..722ef5302 100644 --- a/nuttx/net/udp/udp_send.c +++ b/nuttx/net/udp/udp_send.c @@ -47,10 +47,10 @@ #include #include -#include +#include #include -#include "uip/uip_internal.h" +#include "uip/uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/uip/uip.h b/nuttx/net/uip/uip.h new file mode 100644 index 000000000..91e804d0f --- /dev/null +++ b/nuttx/net/uip/uip.h @@ -0,0 +1,296 @@ +/**************************************************************************** + * net/uip/uip.h + * + * Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * This logic was leveraged from uIP which also has a BSD-style license: + * + * Author Adam Dunkels + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef _NET_UIP_UIP_H +#define _NET_UIP_UIP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#ifdef CONFIG_NET + +#include +#include +#include +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +extern const uip_ipaddr_t g_alloneaddr; +extern const uip_ipaddr_t g_allzeroaddr; + +/* Increasing number used for the IP ID field. */ + +extern uint16_t g_ipid; + +/* Reassembly timer (units: deci-seconds) */ + +#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6) +extern uint8_t uip_reasstmr; +#endif + +/* List of applications waiting for ICMP ECHO REPLY */ + +#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) +extern struct uip_callback_s *g_echocallback; +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/* Defined in uip_callback.c ************************************************/ + +void uip_callbackinit(void); +FAR struct uip_callback_s *uip_callbackalloc(struct uip_callback_s **list); +void uip_callbackfree(FAR struct uip_callback_s *cb, struct uip_callback_s **list); +uint16_t uip_callbackexecute(FAR struct uip_driver_s *dev, void *pvconn, + uint16_t flags, FAR struct uip_callback_s *list); + +#ifdef CONFIG_NET_PKT +/* Defined in uip_pktconn.c *************************************************/ + +void uip_pktinit(void); +struct uip_pkt_conn *uip_pktalloc(void); +void uip_pktfree(struct uip_pkt_conn *conn); +struct uip_pkt_conn *uip_pktactive(struct uip_eth_hdr *buf); +struct uip_pkt_conn *uip_nextpktconn(struct uip_pkt_conn *conn); + +/* Defined in uip_pktcallback.c *********************************************/ + +uint16_t uip_pktcallback(struct uip_driver_s *dev, struct uip_pkt_conn *conn, + uint16_t flags); + +/* Defined in uip_pktinput.c ************************************************/ + +/* Defined in uip_pktpoll.c *************************************************/ + +void uip_pktpoll(struct uip_driver_s *dev, struct uip_pkt_conn *conn); + +#endif /* CONFIG_NET_PKT */ + +#ifdef CONFIG_NET_TCP +/* Defined in tcp_conn.c ****************************************************/ + +void uip_tcpinit(void); +struct uip_conn *uip_tcpactive(struct uip_tcpip_hdr *buf); +struct uip_conn *uip_nexttcpconn(struct uip_conn *conn); +struct uip_conn *uip_tcplistener(uint16_t portno); +struct uip_conn *uip_tcpaccept(struct uip_tcpip_hdr *buf); + +/* Defined in tcp_seqno.c ***************************************************/ + +void uip_tcpsetsequence(FAR uint8_t *seqno, uint32_t value); +uint32_t uip_tcpgetsequence(FAR uint8_t *seqno); +uint32_t uip_tcpaddsequence(FAR uint8_t *seqno, uint16_t len); +void uip_tcpinitsequence(FAR uint8_t *seqno); +void uip_tcpnextsequence(void); + +/* Defined in tcp_poll.c ****************************************************/ + +void uip_tcppoll(struct uip_driver_s *dev, struct uip_conn *conn); + +/* Defined in tcp_timer.c ***************************************************/ + +void uip_tcptimer(struct uip_driver_s *dev, struct uip_conn *conn, int hsec); + +/* Defined in tcp_listen.c **************************************************/ + +void uip_listeninit(void); +bool uip_islistener(uint16_t port); +int uip_accept(struct uip_driver_s *dev, struct uip_conn *conn, uint16_t portno); + +/* Defined in tcp_send.c ****************************************************/ + +void uip_tcpsend(struct uip_driver_s *dev, struct uip_conn *conn, + uint16_t flags, uint16_t len); +void uip_tcpreset(struct uip_driver_s *dev); +void uip_tcpack(struct uip_driver_s *dev, struct uip_conn *conn, + uint8_t ack); + +/* Defined in tcp_appsend.c *************************************************/ + +void uip_tcpappsend(struct uip_driver_s *dev, struct uip_conn *conn, + uint16_t result); +void uip_tcprexmit(struct uip_driver_s *dev, struct uip_conn *conn, + uint16_t result); + +/* Defined in tcp_input.c ***************************************************/ + +void uip_tcpinput(struct uip_driver_s *dev); + +/* Defined in tcp_callback.c ************************************************/ + +uint16_t uip_tcpcallback(FAR struct uip_driver_s *dev, + FAR struct uip_conn *conn, uint16_t flags); +#ifdef CONFIG_NET_TCP_READAHEAD +uint16_t uip_datahandler(FAR struct uip_conn *conn, + FAR uint8_t *buffer, uint16_t nbytes); +#endif + +/* Defined in tcp_readahead.c ***********************************************/ + +#ifdef CONFIG_NET_TCP_READAHEAD +void uip_tcpreadahead_init(void); + +struct uip_readahead_s; +FAR struct uip_readahead_s *uip_tcpreadahead_alloc(void); +void uip_tcpreadahead_release(FAR struct uip_readahead_s *readahead); +#endif /* CONFIG_NET_TCP_READAHEAD */ + +#endif /* CONFIG_NET_TCP */ + +#ifdef CONFIG_NET_UDP +/* Defined in udp_conn.c ****************************************************/ + +void uip_udpinit(void); +struct uip_udp_conn *uip_udpactive(struct uip_udpip_hdr *buf); +struct uip_udp_conn *uip_nextudpconn(struct uip_udp_conn *conn); + +/* Defined in udp_poll.c ****************************************************/ + +void uip_udppoll(struct uip_driver_s *dev, struct uip_udp_conn *conn); + +/* Defined in udp_send.c ****************************************************/ + +void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn); + +/* Defined in udp_input.c ***************************************************/ + +int uip_udpinput(struct uip_driver_s *dev); + +/* Defined in udp_callback.c ************************************************/ + +uint16_t uip_udpcallback(struct uip_driver_s *dev, + struct uip_udp_conn *conn, uint16_t flags); +#endif /* CONFIG_NET_UDP */ + +#ifdef CONFIG_NET_ICMP +/* Defined in icmp_input.c **************************************************/ + +void uip_icmpinput(struct uip_driver_s *dev); + +#ifdef CONFIG_NET_ICMP_PING +/* Defined in icmp_poll.c ***************************************************/ + +void uip_icmppoll(struct uip_driver_s *dev); + +/* Defined in icmp_send.c ***************************************************/ + +void uip_icmpsend(struct uip_driver_s *dev, uip_ipaddr_t *destaddr); + +#endif /* CONFIG_NET_ICMP_PING */ +#endif /* CONFIG_NET_ICMP */ + +#ifdef CONFIG_NET_IGMP +/* Defined in igmp_init.c ***************************************************/ + +void uip_igmpinit(void); + +/* Defined in igmp_input.c **************************************************/ + +void uip_igmpinput(struct uip_driver_s *dev); + +/* Defined in igmp_group.c **************************************************/ + +void uip_grpinit(void); +FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev, + FAR const uip_ipaddr_t *addr); +FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev, + FAR const uip_ipaddr_t *addr); +FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev, + FAR const uip_ipaddr_t *addr); +void uip_grpfree(FAR struct uip_driver_s *dev, + FAR struct igmp_group_s *group); + +/* Defined in igmp_msg.c ****************************************************/ + +void uip_igmpschedmsg(FAR struct igmp_group_s *group, uint8_t msgid); +void uip_igmpwaitmsg(FAR struct igmp_group_s *group, uint8_t msgid); + +/* Defined in igmp_poll.c ***************************************************/ + +void uip_igmppoll(FAR struct uip_driver_s *dev); + +/* Defined in igmp_send.c ***************************************************/ + +void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group, + FAR uip_ipaddr_t *dest); + +/* Defined in igmp_timer.c **************************************************/ + +int uip_decisec2tick(int decisecs); +void uip_igmpstartticks(FAR struct igmp_group_s *group, int ticks); +void uip_igmpstarttimer(FAR struct igmp_group_s *group, uint8_t decisecs); +bool uip_igmpcmptimer(FAR struct igmp_group_s *group, int maxticks); + +/* Defined in igmp_mcastmac *****************************************************/ + +void uip_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip); +void uip_removemcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip); + +#endif /* CONFIG_NET_IGMP */ + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_NET */ +#endif /* _NET_UIP_UIP_H */ diff --git a/nuttx/net/uip/uip_callback.c b/nuttx/net/uip/uip_callback.c index 6caf28c10..3a0847bac 100644 --- a/nuttx/net/uip/uip_callback.c +++ b/nuttx/net/uip/uip_callback.c @@ -45,10 +45,10 @@ #include #include -#include +#include #include -#include "uip_internal.h" +#include "uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/uip/uip_chksum.c b/nuttx/net/uip/uip_chksum.c index 1f28eeaf0..f8ad769a8 100644 --- a/nuttx/net/uip/uip_chksum.c +++ b/nuttx/net/uip/uip_chksum.c @@ -44,10 +44,10 @@ #include #include -#include +#include #include -#include "uip_internal.h" +#include "uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/uip/uip_initialize.c b/nuttx/net/uip/uip_initialize.c index 03266fc91..a76f0a1bd 100644 --- a/nuttx/net/uip/uip_initialize.c +++ b/nuttx/net/uip/uip_initialize.c @@ -45,10 +45,10 @@ #ifdef CONFIG_NET #include -#include +#include #include "tcp/tcp.h" -#include "uip_internal.h" +#include "uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/uip/uip_input.c b/nuttx/net/uip/uip_input.c index b9b94f193..f5ee06b53 100644 --- a/nuttx/net/uip/uip_input.c +++ b/nuttx/net/uip/uip_input.c @@ -86,14 +86,14 @@ #include #include -#include +#include #include #ifdef CONFIG_NET_IPv6 # include "uip_neighbor.h" #endif /* CONFIG_NET_IPv6 */ -#include "uip_internal.h" +#include "uip.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/net/uip/uip_internal.h b/nuttx/net/uip/uip_internal.h deleted file mode 100644 index a5ebc56ec..000000000 --- a/nuttx/net/uip/uip_internal.h +++ /dev/null @@ -1,296 +0,0 @@ -/**************************************************************************** - * net/uip/uip_internal.h - * - * Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * This logic was leveraged from uIP which also has a BSD-style license: - * - * Author Adam Dunkels - * Copyright (c) 2001-2003, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef _NET_UIP_UIP_INTERNAL_H -#define _NET_UIP_UIP_INTERNAL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#ifdef CONFIG_NET - -#include -#include -#include -#include -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Type Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -extern const uip_ipaddr_t g_alloneaddr; -extern const uip_ipaddr_t g_allzeroaddr; - -/* Increasing number used for the IP ID field. */ - -extern uint16_t g_ipid; - -/* Reassembly timer (units: deci-seconds) */ - -#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6) -extern uint8_t uip_reasstmr; -#endif - -/* List of applications waiting for ICMP ECHO REPLY */ - -#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) -extern struct uip_callback_s *g_echocallback; -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -/* Defined in uip_callback.c ************************************************/ - -void uip_callbackinit(void); -FAR struct uip_callback_s *uip_callbackalloc(struct uip_callback_s **list); -void uip_callbackfree(FAR struct uip_callback_s *cb, struct uip_callback_s **list); -uint16_t uip_callbackexecute(FAR struct uip_driver_s *dev, void *pvconn, - uint16_t flags, FAR struct uip_callback_s *list); - -#ifdef CONFIG_NET_PKT -/* Defined in uip_pktconn.c *************************************************/ - -void uip_pktinit(void); -struct uip_pkt_conn *uip_pktalloc(void); -void uip_pktfree(struct uip_pkt_conn *conn); -struct uip_pkt_conn *uip_pktactive(struct uip_eth_hdr *buf); -struct uip_pkt_conn *uip_nextpktconn(struct uip_pkt_conn *conn); - -/* Defined in uip_pktcallback.c *********************************************/ - -uint16_t uip_pktcallback(struct uip_driver_s *dev, struct uip_pkt_conn *conn, - uint16_t flags); - -/* Defined in uip_pktinput.c ************************************************/ - -/* Defined in uip_pktpoll.c *************************************************/ - -void uip_pktpoll(struct uip_driver_s *dev, struct uip_pkt_conn *conn); - -#endif /* CONFIG_NET_PKT */ - -#ifdef CONFIG_NET_TCP -/* Defined in tcp_conn.c ****************************************************/ - -void uip_tcpinit(void); -struct uip_conn *uip_tcpactive(struct uip_tcpip_hdr *buf); -struct uip_conn *uip_nexttcpconn(struct uip_conn *conn); -struct uip_conn *uip_tcplistener(uint16_t portno); -struct uip_conn *uip_tcpaccept(struct uip_tcpip_hdr *buf); - -/* Defined in tcp_seqno.c ***************************************************/ - -void uip_tcpsetsequence(FAR uint8_t *seqno, uint32_t value); -uint32_t uip_tcpgetsequence(FAR uint8_t *seqno); -uint32_t uip_tcpaddsequence(FAR uint8_t *seqno, uint16_t len); -void uip_tcpinitsequence(FAR uint8_t *seqno); -void uip_tcpnextsequence(void); - -/* Defined in tcp_poll.c ****************************************************/ - -void uip_tcppoll(struct uip_driver_s *dev, struct uip_conn *conn); - -/* Defined in tcp_timer.c ***************************************************/ - -void uip_tcptimer(struct uip_driver_s *dev, struct uip_conn *conn, int hsec); - -/* Defined in tcp_listen.c **************************************************/ - -void uip_listeninit(void); -bool uip_islistener(uint16_t port); -int uip_accept(struct uip_driver_s *dev, struct uip_conn *conn, uint16_t portno); - -/* Defined in tcp_send.c ****************************************************/ - -void uip_tcpsend(struct uip_driver_s *dev, struct uip_conn *conn, - uint16_t flags, uint16_t len); -void uip_tcpreset(struct uip_driver_s *dev); -void uip_tcpack(struct uip_driver_s *dev, struct uip_conn *conn, - uint8_t ack); - -/* Defined in tcp_appsend.c *************************************************/ - -void uip_tcpappsend(struct uip_driver_s *dev, struct uip_conn *conn, - uint16_t result); -void uip_tcprexmit(struct uip_driver_s *dev, struct uip_conn *conn, - uint16_t result); - -/* Defined in tcp_input.c ***************************************************/ - -void uip_tcpinput(struct uip_driver_s *dev); - -/* Defined in tcp_callback.c ************************************************/ - -uint16_t uip_tcpcallback(FAR struct uip_driver_s *dev, - FAR struct uip_conn *conn, uint16_t flags); -#ifdef CONFIG_NET_TCP_READAHEAD -uint16_t uip_datahandler(FAR struct uip_conn *conn, - FAR uint8_t *buffer, uint16_t nbytes); -#endif - -/* Defined in tcp_readahead.c ***********************************************/ - -#ifdef CONFIG_NET_TCP_READAHEAD -void uip_tcpreadahead_init(void); - -struct uip_readahead_s; -FAR struct uip_readahead_s *uip_tcpreadahead_alloc(void); -void uip_tcpreadahead_release(FAR struct uip_readahead_s *readahead); -#endif /* CONFIG_NET_TCP_READAHEAD */ - -#endif /* CONFIG_NET_TCP */ - -#ifdef CONFIG_NET_UDP -/* Defined in udp_conn.c ****************************************************/ - -void uip_udpinit(void); -struct uip_udp_conn *uip_udpactive(struct uip_udpip_hdr *buf); -struct uip_udp_conn *uip_nextudpconn(struct uip_udp_conn *conn); - -/* Defined in udp_poll.c ****************************************************/ - -void uip_udppoll(struct uip_driver_s *dev, struct uip_udp_conn *conn); - -/* Defined in udp_send.c ****************************************************/ - -void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn); - -/* Defined in udp_input.c ***************************************************/ - -int uip_udpinput(struct uip_driver_s *dev); - -/* Defined in udp_callback.c ************************************************/ - -uint16_t uip_udpcallback(struct uip_driver_s *dev, - struct uip_udp_conn *conn, uint16_t flags); -#endif /* CONFIG_NET_UDP */ - -#ifdef CONFIG_NET_ICMP -/* Defined in icmp_input.c **************************************************/ - -void uip_icmpinput(struct uip_driver_s *dev); - -#ifdef CONFIG_NET_ICMP_PING -/* Defined in icmp_poll.c ***************************************************/ - -void uip_icmppoll(struct uip_driver_s *dev); - -/* Defined in icmp_send.c ***************************************************/ - -void uip_icmpsend(struct uip_driver_s *dev, uip_ipaddr_t *destaddr); - -#endif /* CONFIG_NET_ICMP_PING */ -#endif /* CONFIG_NET_ICMP */ - -#ifdef CONFIG_NET_IGMP -/* Defined in igmp_init.c ***************************************************/ - -void uip_igmpinit(void); - -/* Defined in igmp_input.c **************************************************/ - -void uip_igmpinput(struct uip_driver_s *dev); - -/* Defined in igmp_group.c **************************************************/ - -void uip_grpinit(void); -FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev, - FAR const uip_ipaddr_t *addr); -FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev, - FAR const uip_ipaddr_t *addr); -FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev, - FAR const uip_ipaddr_t *addr); -void uip_grpfree(FAR struct uip_driver_s *dev, - FAR struct igmp_group_s *group); - -/* Defined in igmp_msg.c ****************************************************/ - -void uip_igmpschedmsg(FAR struct igmp_group_s *group, uint8_t msgid); -void uip_igmpwaitmsg(FAR struct igmp_group_s *group, uint8_t msgid); - -/* Defined in igmp_poll.c ***************************************************/ - -void uip_igmppoll(FAR struct uip_driver_s *dev); - -/* Defined in igmp_send.c ***************************************************/ - -void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group, - FAR uip_ipaddr_t *dest); - -/* Defined in igmp_timer.c **************************************************/ - -int uip_decisec2tick(int decisecs); -void uip_igmpstartticks(FAR struct igmp_group_s *group, int ticks); -void uip_igmpstarttimer(FAR struct igmp_group_s *group, uint8_t decisecs); -bool uip_igmpcmptimer(FAR struct igmp_group_s *group, int maxticks); - -/* Defined in igmp_mcastmac *****************************************************/ - -void uip_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip); -void uip_removemcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip); - -#endif /* CONFIG_NET_IGMP */ - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* CONFIG_NET */ -#endif /* _NET_UIP_UIP_INTERNAL_H */ diff --git a/nuttx/net/uip/uip_iobsend.c b/nuttx/net/uip/uip_iobsend.c index 2fda3bd47..874e78e7f 100644 --- a/nuttx/net/uip/uip_iobsend.c +++ b/nuttx/net/uip/uip_iobsend.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include #ifdef CONFIG_NET_IOB diff --git a/nuttx/net/uip/uip_lock.c b/nuttx/net/uip/uip_lock.c index 594390a44..0bb17b941 100644 --- a/nuttx/net/uip/uip_lock.c +++ b/nuttx/net/uip/uip_lock.c @@ -46,7 +46,7 @@ #include #include -#include +#include #if defined(CONFIG_NET) && defined(CONFIG_NET_NOINTS) diff --git a/nuttx/net/uip/uip_neighbor.h b/nuttx/net/uip/uip_neighbor.h index b55835b74..455610d02 100644 --- a/nuttx/net/uip/uip_neighbor.h +++ b/nuttx/net/uip/uip_neighbor.h @@ -40,7 +40,7 @@ #define __UIP_NEIGHBOR_H__ #include -#include +#include #include struct uip_neighbor_addr diff --git a/nuttx/net/uip/uip_pktsend.c b/nuttx/net/uip/uip_pktsend.c index 1a53c93cd..379845922 100644 --- a/nuttx/net/uip/uip_pktsend.c +++ b/nuttx/net/uip/uip_pktsend.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #ifdef CONFIG_NET_PKT diff --git a/nuttx/net/uip/uip_poll.c b/nuttx/net/uip/uip_poll.c index adab74520..a4100e576 100644 --- a/nuttx/net/uip/uip_poll.c +++ b/nuttx/net/uip/uip_poll.c @@ -43,10 +43,10 @@ #include #include -#include +#include #include -#include "uip_internal.h" +#include "uip.h" /**************************************************************************** * Private Data diff --git a/nuttx/net/uip/uip_send.c b/nuttx/net/uip/uip_send.c index 1eaf97414..f426166b8 100644 --- a/nuttx/net/uip/uip_send.c +++ b/nuttx/net/uip/uip_send.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include /**************************************************************************** diff --git a/nuttx/net/uip/uip_setipid.c b/nuttx/net/uip/uip_setipid.c index 9aaea482a..eb859cce3 100644 --- a/nuttx/net/uip/uip_setipid.c +++ b/nuttx/net/uip/uip_setipid.c @@ -43,9 +43,9 @@ #include #include -#include +#include -#include "uip_internal.h" +#include "uip.h" /**************************************************************************** * Private Data -- cgit v1.2.3