From 835ae2999d2164a17b48b62c0b243adcbceafb51 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 7 Aug 2017 13:03:23 -0600 Subject: [PATCH] networking: Move a little more to the inet/ subdirectory. --- net/devif/Make.defs | 7 ++-- net/devif/devif.h | 34 +++++++++---------- net/devif/devif_initialize.c | 3 -- net/devif/ipv4_input.c | 1 + net/icmp/icmp_send.c | 1 + net/igmp/igmp_send.c | 1 + net/inet/Make.defs | 6 ++-- net/inet/inet.h | 22 ++++++++++-- .../net_setipid.c => inet/inet_setipid.c} | 18 +++------- net/tcp/tcp_send.c | 1 + net/udp/udp_conn.c | 8 ++--- net/udp/udp_send.c | 1 + 12 files changed, 57 insertions(+), 46 deletions(-) rename net/{devif/net_setipid.c => inet/inet_setipid.c} (82%) diff --git a/net/devif/Make.defs b/net/devif/Make.defs index 22d2ad05ab..cb1e16e433 100644 --- a/net/devif/Make.defs +++ b/net/devif/Make.defs @@ -1,7 +1,7 @@ ############################################################################ -# net/devif/Make.defs +# net/inet/Make.defs # -# Copyright (C) 2007, 2009-2010, 2014-2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2007, 2009-2010, 2014-2015, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,8 +35,7 @@ # Network device interface source files -NET_CSRCS += devif_initialize.c net_setipid.c devif_send.c devif_poll.c -NET_CSRCS += devif_callback.c +NET_CSRCS += devif_initialize.c devif_send.c devif_poll.c devif_callback.c # Device driver IP packet receipt interfaces diff --git a/net/devif/devif.h b/net/devif/devif.h index 3a2215bf94..411f2a4cbd 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -274,25 +274,9 @@ struct devif_callback_s /**************************************************************************** * Public Data ****************************************************************************/ -/* Increasing number used for the IP ID field. */ -extern uint16_t g_ipid; - -#if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6) -/* Reassembly timer (units: deci-seconds) */ - -extern uint8_t g_reassembly_timer; -#endif - -/* Time of last poll */ - -extern systime_t g_polltime; - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus +#undef EXTERN +#if defined(__cplusplus) #define EXTERN extern "C" extern "C" { @@ -300,6 +284,20 @@ extern "C" #define EXTERN extern #endif +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_TCP_REASSEMBLY) +/* Reassembly timer (units: deci-seconds) */ + +EXTERN uint8_t g_reassembly_timer; +#endif + +/* Time of last poll */ + +EXTERN systime_t g_polltime; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + /**************************************************************************** * Name: devif_initialize * diff --git a/net/devif/devif_initialize.c b/net/devif/devif_initialize.c index 5d1761d088..244d7a1b6c 100644 --- a/net/devif/devif_initialize.c +++ b/net/devif/devif_initialize.c @@ -65,9 +65,6 @@ struct net_stats_s g_netstats; #endif -/* Increasing number used for the IP ID field. */ - -uint16_t g_ipid; #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_TCP_REASSEMBLY) /* Reassembly timer (units: deci-seconds) */ diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c index 033e82b97f..f9dc601ec6 100644 --- a/net/devif/ipv4_input.c +++ b/net/devif/ipv4_input.c @@ -93,6 +93,7 @@ #include #include +#include "inet/inet.h" #include "tcp/tcp.h" #include "udp/udp.h" #include "pkt/pkt.h" diff --git a/net/icmp/icmp_send.c b/net/icmp/icmp_send.c index 768451c9d7..d8216378eb 100644 --- a/net/icmp/icmp_send.c +++ b/net/icmp/icmp_send.c @@ -50,6 +50,7 @@ #include #include "devif/devif.h" +#include "inet/inet.h" #include "utils/utils.h" #include "icmp/icmp.h" diff --git a/net/igmp/igmp_send.c b/net/igmp/igmp_send.c index 7e51068ab2..fb91636f46 100644 --- a/net/igmp/igmp_send.c +++ b/net/igmp/igmp_send.c @@ -51,6 +51,7 @@ #include #include "devif/devif.h" +#include "inet/inet.h" #include "igmp/igmp.h" #ifdef CONFIG_NET_IGMP diff --git a/net/inet/Make.defs b/net/inet/Make.defs index 7eaedc783f..2ce0674ef3 100644 --- a/net/inet/Make.defs +++ b/net/inet/Make.defs @@ -37,16 +37,18 @@ ifeq ($(CONFIG_NET_IPv4),y) SOCK_CSRCS += inet_sockif.c inet_recvfrom.c inet_connect.c inet_close.c +SOCK_CSRCS += inet_globals.c else ifeq ($(CONFIG_NET_IPv6),y) SOCK_CSRCS += inet_sockif.c inet_recvfrom.c inet_connect.c inet_close.c +SOCK_CSRCS += inet_globals.c endif ifeq ($(CONFIG_NET_IPv4),y) -SOCK_CSRCS += ipv4_getsockname.c +SOCK_CSRCS += ipv4_getsockname.c inet_setipid.c endif ifeq ($(CONFIG_NET_IPv6),y) -SOCK_CSRCS += ipv6_getsockname.c inet_globals.c +SOCK_CSRCS += ipv6_getsockname.c endif ifeq ($(CONFIG_NET_SENDFILE),y) diff --git a/net/inet/inet.h b/net/inet/inet.h index 1b79daa501..4a4f97b833 100644 --- a/net/inet/inet.h +++ b/net/inet/inet.h @@ -82,7 +82,13 @@ extern "C" #define EXTERN extern #endif -/* Well-known IP addresses */ +#ifdef CONFIG_NET_IPv4 +/* Increasing number used for the IP ID field. */ + +EXTERN uint16_t g_ipid; +#endif /* CONFIG_NET_IPv4 */ + +/* Well-known IPv6 addresses */ #ifdef CONFIG_NET_IPv6 EXTERN const net_ipv6addr_t g_ipv6_allzeroaddr; /* An address of all zeroes */ @@ -93,7 +99,7 @@ EXTERN const net_ipv6addr_t g_ipv6_allrouters; /* All link local routers */ EXTERN const net_ipv6addr_t g_ipv6_llnetmask; /* Netmask for local link address */ #endif #endif -#endif +#endif /* CONFIG_NET_IPv6 */ /* PF_INET/PF_INET6 socket address family interface */ @@ -110,6 +116,18 @@ struct tcp_conn_s; /* Forward reference */ #endif struct socket; /* Forward reference */ +/**************************************************************************** + * Name: inet_setipid + * + * Description: + * This function may be used at boot time to set the initial ip_id. + * + * Assumptions: + * + ****************************************************************************/ + +void inet_setipid(uint16_t id); + /**************************************************************************** * Name: net_startmonitor * diff --git a/net/devif/net_setipid.c b/net/inet/inet_setipid.c similarity index 82% rename from net/devif/net_setipid.c rename to net/inet/inet_setipid.c index b3cbf4ea8f..16ce2c111f 100644 --- a/net/devif/net_setipid.c +++ b/net/inet/inet_setipid.c @@ -1,7 +1,7 @@ /**************************************************************************** - * net/devif/net_setipid.c + * net/inet/net_setipid.c * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,22 +43,14 @@ #include #include -#include "devif/devif.h" - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ +#include "inet/inet.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: net_setipid + * Name: inet_setipid * * Description: * This function may be used at boot time to set the initial ip_id. @@ -67,7 +59,7 @@ * ****************************************************************************/ -void net_setipid(uint16_t id) +void inet_setipid(uint16_t id) { g_ipid = id; } diff --git a/net/tcp/tcp_send.c b/net/tcp/tcp_send.c index efe8be243f..6797c9d279 100644 --- a/net/tcp/tcp_send.c +++ b/net/tcp/tcp_send.c @@ -55,6 +55,7 @@ #include #include "devif/devif.h" +#include "inet/inet.h" #include "tcp/tcp.h" #include "utils/utils.h" diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index e282c72141..11913f8581 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -378,11 +378,11 @@ static inline FAR struct udp_conn_s * * If all of the above are true then the newly received UDP packet * is destined for this UDP connection. * - * To send and receive broadcast packets, the application should: + * To send and receive multicast packets, the application should: * - * - Bind socket to INADDR6_ANY - * - setsockopt to SO_BROADCAST - * - call sendto with sendaddr.sin_addr.s_addr = + * - Bind socket to INADDR6_ANY or to a specific + * - setsockopt to SO_BROADCAST (for all-nodes address) + * - call sendto with sendaddr.sin_addr.s_addr = * - call recvfrom. * * REVIST: SO_BROADCAST flag is currently ignored. diff --git a/net/udp/udp_send.c b/net/udp/udp_send.c index f58bdf5a13..a29b1b239b 100644 --- a/net/udp/udp_send.c +++ b/net/udp/udp_send.c @@ -57,6 +57,7 @@ #include #include "devif/devif.h" +#include "inet/inet.h" #include "utils/utils.h" #include "udp/udp.h"