2003-03-25 12:59:42 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* lwIP network interface abstraction
|
2017-09-17 18:38:38 +00:00
|
|
|
*
|
2016-08-07 08:05:34 +00:00
|
|
|
* @defgroup netif Network interface (NETIF)
|
|
|
|
* @ingroup callbackstyle_api
|
2017-09-17 18:38:38 +00:00
|
|
|
*
|
2016-08-25 20:04:04 +00:00
|
|
|
* @defgroup netif_ip4 IPv4 address handling
|
|
|
|
* @ingroup netif
|
2017-09-17 18:38:38 +00:00
|
|
|
*
|
2016-08-25 20:04:04 +00:00
|
|
|
* @defgroup netif_ip6 IPv6 address handling
|
|
|
|
* @ingroup netif
|
2017-09-17 18:38:38 +00:00
|
|
|
*
|
2016-08-26 09:21:49 +00:00
|
|
|
* @defgroup netif_cd Client data handling
|
|
|
|
* Store data (void*) on a netif for application usage.
|
|
|
|
* @see @ref LWIP_NUM_NETIF_CLIENT_DATA
|
|
|
|
* @ingroup netif
|
2003-03-25 12:59:42 +00:00
|
|
|
*/
|
|
|
|
|
2002-10-19 12:59:30 +00:00
|
|
|
/*
|
2004-02-07 00:30:03 +00:00
|
|
|
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
2003-06-09 21:08:55 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
2002-10-19 12:59:30 +00:00
|
|
|
* 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
|
2003-06-09 21:08:55 +00:00
|
|
|
* derived from this software without specific prior written permission.
|
2002-10-19 12:59:30 +00:00
|
|
|
*
|
2003-06-09 21:08:55 +00:00
|
|
|
* 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
|
2002-10-19 12:59:30 +00:00
|
|
|
* OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This file is part of the lwIP TCP/IP stack.
|
2003-06-09 21:08:55 +00:00
|
|
|
*
|
2002-10-19 12:59:30 +00:00
|
|
|
* Author: Adam Dunkels <adam@sics.se>
|
2016-07-26 14:53:27 +00:00
|
|
|
*/
|
|
|
|
|
2003-02-21 16:43:46 +00:00
|
|
|
#include "lwip/opt.h"
|
2002-10-19 12:59:30 +00:00
|
|
|
|
2017-02-14 12:54:14 +00:00
|
|
|
#include <string.h> /* memset */
|
2017-02-13 12:35:30 +00:00
|
|
|
#include <stdlib.h> /* atoi */
|
2016-08-17 14:37:15 +00:00
|
|
|
|
2002-10-19 12:59:30 +00:00
|
|
|
#include "lwip/def.h"
|
2003-04-01 15:00:26 +00:00
|
|
|
#include "lwip/ip_addr.h"
|
2011-05-17 19:35:14 +00:00
|
|
|
#include "lwip/ip6_addr.h"
|
2004-03-12 00:10:07 +00:00
|
|
|
#include "lwip/netif.h"
|
2015-10-09 19:58:58 +00:00
|
|
|
#include "lwip/priv/tcp_priv.h"
|
2015-02-26 21:45:37 +00:00
|
|
|
#include "lwip/udp.h"
|
2018-01-25 11:51:46 +00:00
|
|
|
#include "lwip/priv/raw_priv.h"
|
2015-11-12 20:25:42 +00:00
|
|
|
#include "lwip/snmp.h"
|
2007-08-29 21:12:32 +00:00
|
|
|
#include "lwip/igmp.h"
|
2016-07-19 07:29:51 +00:00
|
|
|
#include "lwip/etharp.h"
|
2010-02-09 17:00:57 +00:00
|
|
|
#include "lwip/stats.h"
|
2015-09-08 07:47:30 +00:00
|
|
|
#include "lwip/sys.h"
|
2016-09-07 06:11:30 +00:00
|
|
|
#include "lwip/ip.h"
|
2008-06-19 16:27:18 +00:00
|
|
|
#if ENABLE_LOOPBACK
|
|
|
|
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
|
2008-06-17 19:39:22 +00:00
|
|
|
#include "lwip/tcpip.h"
|
2008-06-19 16:27:18 +00:00
|
|
|
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
|
|
|
#endif /* ENABLE_LOOPBACK */
|
2007-03-28 09:23:35 +00:00
|
|
|
|
2016-08-19 06:36:00 +00:00
|
|
|
#include "netif/ethernet.h"
|
|
|
|
|
2009-08-24 13:11:35 +00:00
|
|
|
#if LWIP_AUTOIP
|
|
|
|
#include "lwip/autoip.h"
|
|
|
|
#endif /* LWIP_AUTOIP */
|
2009-08-24 13:12:37 +00:00
|
|
|
#if LWIP_DHCP
|
|
|
|
#include "lwip/dhcp.h"
|
|
|
|
#endif /* LWIP_DHCP */
|
ACD module added + update and improve DHCP + AUTOIP behavior
Squashed commit of the following:
commit 2d98d8e2ef1941c3824ffb874f1e529d284667fc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:15:06 2018 +0200
AUTOIP: correct functionality autoip_supplied_address
It does not mean that if autoip is bound, it also supplied the
netif address. A check is added.
commit 2ca0a2183991ef73860c4207d95799b37acc64cc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:06:49 2018 +0200
AUTOIP: keep using the same link local address as much as possible
Only calculate a new link local address at start up or when a
conflict occured. On link up or down -> keep same address.
TODO: in the future a function for persistent storage should be
added.
commit aa70a693351e4c898aa28d8521308794614838f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 14:43:14 2018 +0200
ACD, AUTOIP & DHCP: make link up & down functions where needed
When the link goes down or up the approriate functions should be
stopped or started again. To accomodate this, network_changed is
adjusted to network_changed_link_up and network_changed_link_down.
DHCP does not need to control AUTOIP. AUTOIP can take care of
itself. The only thing DHCP needs to do is starting it when
discovering is failing. The AUTOIP state variable is removed from
DHCP.
commit ad469eb006b47f8a8c37f7c0de0216f47a8c19c7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 11:25:58 2018 +0200
ACD: add address change listener + passive conflict detection mode
In the case their previously was a LL address on a netif that
is now configured with a routable address, we want the LL
address to be able to keep receiving packets.
for as long as the LL address is available on the interface it
should do ongoing conflict detection. But we cannot defend when
the LL address is not the netif address any more.
An address change listener is added to detect when an ACD module
needs to go from active ongoing conflict detection to passive.
When a conflict is detected autoip is stopped and will not be able
to receive packets any more. Because we have a valid routable
address on the netif, autoip is not restarted.
commit 07c4ec20cea78e2b4a6f5599569abaf075619c62
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Sep 11 16:25:37 2018 +0200
ACD: make module reusable within a netif
DHCP and AUTOIP both have ACD running simultaniously. The ACD
struct is added to the DHCP and AUTOIP structs. In the netif a list
of ACD modules is kept to loop over if functions need to perform
some action on all ACD modules (for example tmr function). With
acd_add a module can be added to the list. ACD_FOREACH loops over
the list similar to NETIF_FOREACH.
commit ee3b4585b7768f5353dd80190a2929bad45f7ff4
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 10 16:36:18 2018 +0200
etharp & acd: add probe and announce functions to etharp.
The new probe and announce functions are independent of
netif->ip_addr. This means we can keep the LL address working
while we start to probe for the newly received routable address.
The netif->ip_addr does not need to be any for probing to work
with this patch.
commit 7d3032bae8f1b8081368a807682388eb642729e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 3 13:35:51 2018 +0200
autoip -> unused random function removed + small comment update
commit be749ba4eb26ddc69233c85d532dc035741275c5
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 16:37:36 2018 +0200
ACD: update comment in header
commit 4491842991c90b3a58fa327f70aa42f04174546b
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 15:44:45 2018 +0200
ACD: subscribe to link down messages to stop the acd process
When the link goes down the acd process should be stopped
independent of the acd client. Otherwise the acd will keep probing
or announcing while their simply is no connection.
commit 71f668aa7583354e132c20b3b50ba2c86bf08738
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 13:59:44 2018 +0200
DHCP coop autoip bug fix: wait after last discovery before starting autoip
After the last dhcp discovery we need to give the dhcp server the
time to respond. Currently the discovery message is send and autoip
is started simultaniously. This is changed. Autoip will now be started
after the next discovery timeout.
commit 0da16604ec079195533f2591f0d0f04bdf212a72
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 11:23:31 2018 +0200
ACD: rate limit interval bug solved -> first decline then wait then restart.
According the the ACD RFC we need to limit the rate of acquiring
and probing addresses after MAX_CONFLICTS. It is important to first
decline the address and stop the netif from using the address before
the time is started. After this rate limit time, the address acquiring
process can be started again.
To make this possible we had to change the callback function and
the location in the process were the rate limiting is done.
commit a89a0601a251acb14abe270116f38c6d25c2d7a9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:27:10 2018 +0200
DHCP: after a succesful dhcp_reboot, the address should be probed.
Reboot means that the connection was gone for some amount of time.
This is seen as a new connection for the ACD module so should be
the address should be probed before use.
commit 853afb448ba35c6e2b35e8238c9c367c599dece7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:19:12 2018 +0200
DHCP_DOES_ARP_CHECK changed to DHCP_DOES_ACD_CHECK
small update in opt.h to add the correct dependencies.
commit e28b4766bdef69e76f6170c470c93f5b251c579a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:05:43 2018 +0200
DHCP check code replaced by ACD module.
when DHCP_DOES_ARP_CHECK is enabled, the ACD module will take care
of address conflict detection. Via a call back function the DHCP
state machine will continue and bind to an address if no conflicts
are found.
dhcp_arp_reply is obsolete because the ACD module replaces its
function.
commit 52193a0f5d13e8786a4db2fff1f1a8f1367a4eba
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 16:05:22 2018 +0200
Issue 2 + 3 from Comment #5, task #13508 solved
Removed C++ comments and // ----... marks as requested.
commit 7faaf61275d67ccfb88ea7e26c249428c3088536
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 15:55:24 2018 +0200
Issue 1 from Comment #5, task #13508 solved
Comments added to clarify how arp messages are handled.
commit 9348aea22623b705759fd30b873f06a50a104d16
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:45:35 2018 +0200
acd: add comment for callback function
commit 49fdd1177c05b74d49fa179564dcaa5e650adbcc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:42:59 2018 +0200
autoip: Add debugging output and complete comments
commit 591856b82c029687a657a1b1ccc674522e6f4be0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:25:18 2018 +0200
Removed autoip from timeouts.c
We do not need a timer anymore. All timing is part of acd.
commit 3b3272fdd14015cfca0b3b6d149505b1cf0e36b6
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:22:32 2018 +0200
autoip_network_changed -> first bring down the netif and then acd
Make it do what it says in the comment
commit 77b0ccf96efd22774279c6f9b5bade18c5e42c59
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:21:23 2018 +0200
Simplified the autoIP states + update autoip_start()
commit 96e0581d36857f8b70c4b4cce4fb323fd3dd51ab
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:10:48 2018 +0200
Deleted unused variables, functions and defines from autoip module
The functionality is now embedded in the acd module so can be
removed from autoip.
commit 9296e2ebb4b51019aaccfc47e8b9f51b265d37cd
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:07:34 2018 +0200
Bug fix acd -> rate limiting needs to be after MAX conflicts
It was only after MAX conflicts + 1.
commit c55e16903c045d0ea84336b50eccbf24d3d097e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:52:45 2018 +0200
Small intruduction to module added
commit d1498a37293bd9f97f6b938b48e5980ab0a01bd1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:49:58 2018 +0200
Copyright information added
I based the copyright text on the other files. I'm not sure this
is how its done. I kept Dominik in their because I copied quite
some code from the autoip module.
commit 359a845ef5e73061832069f364b370634ee0b071
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:08:44 2018 +0200
Fixing comments in acd.c
commit 100d72549d0ef44157143d031848a727f5dfbe69
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 15:43:40 2018 +0200
Probe wait time and Probe interval time made random via lwip_rand
According to the RFC a random amount of time needs to be waited
before probing can be started also a random amount of time
needs to be waited between the probes.
The random time is calculated via the LWIP_RAND function (see
lwipopts and sys_arch).
commit f7f037c32e9416f8b803c3c7af617b871b55ee35
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:56:48 2018 +0200
autoip will start probing again when the network has changed
commit 1f40f6274195f24aa1b05caf82b79285ad189c2a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:55:47 2018 +0200
Duplicate code removed -> already present in autoip_start
commit be59431271da862a8ca330dbca638842c87765bc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:52:49 2018 +0200
add rate limiting to acd when too many conflicts are detected.
When more then max conflicts are detected during device on time,
the rate at which probing for a new address starts is limited.
For clarity we combined the conflict counting and the callback into
a new function acd_restart.
commit 91448455e95edb24c1f418c341b6fb306391f4f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:50:01 2018 +0200
ARP packet conflict detection added.
If a conflict is detected between the begin until after announce
wait, a new address needs to be chosen immediatly.
This can occur in two situations:
1) another host already has this ip address
2) another host is also probing for the same address.
If a conflict is detected during announcing or during the ongoing
conflict detection, we defend our ip address once. If a second
conflict occurs during defend interval, we take another ip address.
If not we can keep our address and connections.
When a conflict occurs and it's decided we need a new address,
autoip is simply restarted. To do: test if a acd stop is needed.
This will become more important when DHCP is added I believe.
commit 65f47ba9444d8b9f767dc908319579323eeb8664
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:33:44 2018 +0200
Update ACD state machine with PROBE_WAIT and and ANNOUNCE_WAIT
By adding the ANNOUNCE_WAIT state, we could remove duplicate code
that was present in the original autoip state implementation.
But because we cannot directly go to ANNOUNCING we needed this
extra state during the wait period. It also makes the different
states clearer.
Their is no need to number the enum because the compiler takes
care of this standard numbering.
Also a indent issue on the state machine code is solved here.
commit 2d9f4414c7b1f2ed35c0b5cea78dabb9c9afee77
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:28:33 2018 +0200
Added an extra check for etharp responses.
Their is no need to answer a request that is initiated by ourselves.
In my test case, a conflicting request would be seen here as a
request needing a reply. Which off course isn't needed at all.
The acd module will let the requester know that it is using our
ip address.
I could not think of a reason not to add this extra check but please
check if this doesn't break other functionality.
commit f84cc1dba4061219bd1aadb97bd340278db07cd7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:27:13 2018 +0200
Redirect all incoming ARP messages to the ACD module.
The ACD module will scan the packets and react on conflicts.
autoip does not need the arp packets any more.
commit 9faf266993cc2df0b9434720b59b5922f17d7d33
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:08:39 2018 +0200
Initiate acd from autoip implementation.
The state machine in autoip is now replaced by the acd module.
commit 40a5a40d911c98e6ee8566c0adce7716f26f20e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:05:59 2018 +0200
Add simple acd state machine to timer function.
This state machine will be started from acd_start and will go
through the probing and the announcing state. At this moment the
timings are made fixed for easy debugging. Will be made variable
afterwards.
commit 0a2629bf1f7942e80ec11bcc3e163ac1a2b9a580
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:44:19 2018 +0200
Disable gratuitous ARP send from netif_issue_report when acd is enabled
The acd module needs to be fully under control on what arp messages are
send. It wouldn't be a clean solution if we kept this announce as one
of the announce messages.
So when ACD is enabled, this message will not be send.
commit a7b9a4d5039168723c2043677176c5c8fc69f8df
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:42:46 2018 +0200
ARP probe and announce functions added.
Both use etharp_requests to send out an arp message.
commit e2f1ce3fa84e2ce01bc944d8049412e156cd7cc7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:26:07 2018 +0200
Add conflict callback mechanism to acd module
When starting the acd with acd_start, a conflict callback has to be
provided. After probing when no conflict is detected, the callback
is called with the conflict variable on 0. From the moment a conflict
is detected, it will be called set to 1.
By not making a fixed link between acd, autoip and dhcp but working
with callback functions the user (caller) can easily use it for
fixed ip too. This keeps the acd module completely independent from
the other application layer protocols.
commit 21e7995888d2941601e99873ee129d1ea927e3f7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:41:52 2018 +0200
acd_stop function added.
When calling this function the acd state machine will be put in
ACD_STATE_OFF. This will disable the acd functionality until
acd_start is called.
commit 503037fb462504e46a14ce7486bc763dbc6a8690
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:35:48 2018 +0200
acd_start function added
This function will allocate a struct for the acd module if one wasn't
added with acd_set_struct. It will then initialize the acd struct
and start the probe wait timer (for now fixed).
commit e439f6dffc44e93078a2976783bdebfe17304d8c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:22:39 2018 +0200
ACD_DEBUG define added for enabling / disabling debug messages.
commit 80d33e1eaf092934ace1045fac096464cd5be5e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:39:37 2018 +0200
ACD struct added together with set struct function
ACD needs some variables: state, timing, probe counter etc.
We added the struct as netif data. For now one ACD module per netif
is enough. We found some unclarities about ACD with multiple IP
address on one interface. For now, ACD will only be implemented for
the IP address that is going to be used / is being used on the netif.
commit 2c4cca36744973318c3efe7cbae6384b52dc71a8
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:35:06 2018 +0200
Add acd timer to timeouts.c with interval of 100ms.
This timer will be used for time to wait counting etc.
Very similar to the auto ip timer.
commit e2ed447e00c4df790df21509acb4ab09b5b79e66
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:56:39 2018 +0200
Add ACD protocol definitions
commit 445733214460eae18817556439bed979e9b3747c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:07:58 2018 +0200
Add c++ option (to use C code module in c++)
commit 63d78bc1f77ac6698c3d663a1c67b40a0c297125
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:57:34 2018 +0200
Added on off option for ACD module
commit d5ec4b69eb4175d4dd569bcfc80ae0e192780015
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:09:40 2018 +0200
ACD IPv4 module files added
The files for IPv4 ACD or Address Conflict Detection are added
to the lwip source.
2018-09-13 15:02:21 +00:00
|
|
|
#if LWIP_ACD
|
|
|
|
#include "lwip/acd.h"
|
|
|
|
#endif /* LWIP_ACD */
|
2011-05-17 19:35:14 +00:00
|
|
|
#if LWIP_IPV6_DHCP6
|
|
|
|
#include "lwip/dhcp6.h"
|
|
|
|
#endif /* LWIP_IPV6_DHCP6 */
|
|
|
|
#if LWIP_IPV6_MLD
|
|
|
|
#include "lwip/mld6.h"
|
|
|
|
#endif /* LWIP_IPV6_MLD */
|
2016-05-06 14:15:20 +00:00
|
|
|
#if LWIP_IPV6
|
|
|
|
#include "lwip/nd6.h"
|
|
|
|
#endif
|
2009-08-24 13:11:35 +00:00
|
|
|
|
2007-08-22 11:26:01 +00:00
|
|
|
#if LWIP_NETIF_STATUS_CALLBACK
|
2010-02-15 19:53:46 +00:00
|
|
|
#define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0)
|
2007-07-13 15:00:40 +00:00
|
|
|
#else
|
2010-02-15 19:53:46 +00:00
|
|
|
#define NETIF_STATUS_CALLBACK(n)
|
2015-10-06 19:08:28 +00:00
|
|
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
2007-07-13 15:00:40 +00:00
|
|
|
|
|
|
|
#if LWIP_NETIF_LINK_CALLBACK
|
2010-02-15 19:53:46 +00:00
|
|
|
#define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0)
|
2007-07-13 15:00:40 +00:00
|
|
|
#else
|
2010-02-15 19:53:46 +00:00
|
|
|
#define NETIF_LINK_CALLBACK(n)
|
2015-10-06 19:08:28 +00:00
|
|
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
2007-03-28 09:23:35 +00:00
|
|
|
|
2017-02-13 20:40:08 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
2017-09-17 18:38:38 +00:00
|
|
|
static netif_ext_callback_t *ext_callback;
|
2017-02-13 20:40:08 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-01 15:10:50 +00:00
|
|
|
#if !LWIP_SINGLE_NETIF
|
2007-10-09 20:00:55 +00:00
|
|
|
struct netif *netif_list;
|
2017-03-01 15:10:50 +00:00
|
|
|
#endif /* !LWIP_SINGLE_NETIF */
|
2007-10-09 20:00:55 +00:00
|
|
|
struct netif *netif_default;
|
2002-10-19 12:59:30 +00:00
|
|
|
|
2017-02-13 12:21:45 +00:00
|
|
|
#define netif_index_to_num(index) ((index) - 1)
|
2011-06-07 19:10:55 +00:00
|
|
|
static u8_t netif_num;
|
|
|
|
|
2016-08-18 09:44:19 +00:00
|
|
|
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
|
2016-08-18 10:37:21 +00:00
|
|
|
static u8_t netif_client_id;
|
2016-08-18 09:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-05 19:57:43 +00:00
|
|
|
#define NETIF_REPORT_TYPE_IPV4 0x01
|
|
|
|
#define NETIF_REPORT_TYPE_IPV6 0x02
|
2017-09-17 18:38:38 +00:00
|
|
|
static void netif_issue_reports(struct netif *netif, u8_t report_type);
|
2015-03-05 19:57:43 +00:00
|
|
|
|
2012-08-17 16:56:14 +00:00
|
|
|
#if LWIP_IPV6
|
2015-02-22 20:46:35 +00:00
|
|
|
static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr);
|
2012-08-17 16:56:14 +00:00
|
|
|
#endif /* LWIP_IPV6 */
|
2018-03-13 19:29:37 +00:00
|
|
|
#if LWIP_IPV4
|
|
|
|
static err_t netif_null_output_ip4(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr);
|
|
|
|
#endif /* LWIP_IPV4 */
|
2012-08-17 16:56:14 +00:00
|
|
|
|
2010-02-09 16:01:24 +00:00
|
|
|
#if LWIP_HAVE_LOOPIF
|
2015-04-12 08:43:46 +00:00
|
|
|
#if LWIP_IPV4
|
2017-09-17 18:38:38 +00:00
|
|
|
static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t *addr);
|
2015-04-12 08:43:46 +00:00
|
|
|
#endif
|
2014-01-17 20:57:40 +00:00
|
|
|
#if LWIP_IPV6
|
2017-09-17 18:38:38 +00:00
|
|
|
static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t *addr);
|
2014-01-17 20:57:40 +00:00
|
|
|
#endif
|
2014-01-17 20:55:46 +00:00
|
|
|
|
|
|
|
|
2010-02-09 16:01:24 +00:00
|
|
|
static struct netif loop_netif;
|
|
|
|
|
2018-11-01 20:35:06 +00:00
|
|
|
#if LWIP_TESTMODE
|
|
|
|
struct netif* netif_get_loopif(void)
|
|
|
|
{
|
|
|
|
return &loop_netif;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-02-09 16:01:24 +00:00
|
|
|
/**
|
|
|
|
* Initialize a lwip network interface structure for a loopback interface
|
|
|
|
*
|
|
|
|
* @param netif the lwip network interface structure for this loopif
|
|
|
|
* @return ERR_OK if the loopif is initialized
|
|
|
|
* ERR_MEM if private data couldn't be allocated
|
|
|
|
*/
|
|
|
|
static err_t
|
|
|
|
netif_loopif_init(struct netif *netif)
|
|
|
|
{
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_loopif_init: invalid netif", netif != NULL);
|
|
|
|
|
2010-02-09 16:01:24 +00:00
|
|
|
/* initialize the snmp variables and counters inside the struct netif
|
|
|
|
* ifSpeed: no assumption can be made!
|
|
|
|
*/
|
2015-09-08 07:47:30 +00:00
|
|
|
MIB2_INIT_NETIF(netif, snmp_ifType_softwareLoopback, 0);
|
2010-02-09 16:01:24 +00:00
|
|
|
|
|
|
|
netif->name[0] = 'l';
|
|
|
|
netif->name[1] = 'o';
|
2015-04-12 08:43:46 +00:00
|
|
|
#if LWIP_IPV4
|
2014-01-17 20:55:46 +00:00
|
|
|
netif->output = netif_loop_output_ipv4;
|
2015-04-12 08:43:46 +00:00
|
|
|
#endif
|
2014-01-17 20:57:40 +00:00
|
|
|
#if LWIP_IPV6
|
2014-01-17 20:55:46 +00:00
|
|
|
netif->output_ip6 = netif_loop_output_ipv6;
|
2015-08-24 16:28:13 +00:00
|
|
|
#endif
|
2015-08-26 18:55:51 +00:00
|
|
|
#if LWIP_LOOPIF_MULTICAST
|
2017-06-25 21:01:57 +00:00
|
|
|
netif_set_flags(netif, NETIF_FLAG_IGMP);
|
2014-01-17 20:57:40 +00:00
|
|
|
#endif
|
2018-04-27 21:54:01 +00:00
|
|
|
NETIF_SET_CHECKSUM_CTRL(netif, NETIF_CHECKSUM_DISABLE_ALL);
|
2010-02-09 16:01:24 +00:00
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
#endif /* LWIP_HAVE_LOOPIF */
|
|
|
|
|
|
|
|
void
|
|
|
|
netif_init(void)
|
|
|
|
{
|
|
|
|
#if LWIP_HAVE_LOOPIF
|
2015-04-12 08:43:46 +00:00
|
|
|
#if LWIP_IPV4
|
|
|
|
#define LOOPIF_ADDRINIT &loop_ipaddr, &loop_netmask, &loop_gw,
|
2015-04-09 20:21:15 +00:00
|
|
|
ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
|
2017-09-17 18:38:38 +00:00
|
|
|
IP4_ADDR(&loop_gw, 127, 0, 0, 1);
|
|
|
|
IP4_ADDR(&loop_ipaddr, 127, 0, 0, 1);
|
|
|
|
IP4_ADDR(&loop_netmask, 255, 0, 0, 0);
|
2015-04-12 08:43:46 +00:00
|
|
|
#else /* LWIP_IPV4 */
|
|
|
|
#define LOOPIF_ADDRINIT
|
|
|
|
#endif /* LWIP_IPV4 */
|
2010-02-09 16:01:24 +00:00
|
|
|
|
|
|
|
#if NO_SYS
|
2015-04-12 08:43:46 +00:00
|
|
|
netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, ip_input);
|
2010-02-09 16:01:24 +00:00
|
|
|
#else /* NO_SYS */
|
2015-04-12 08:43:46 +00:00
|
|
|
netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, tcpip_input);
|
2010-02-09 16:01:24 +00:00
|
|
|
#endif /* NO_SYS */
|
2014-01-17 20:55:46 +00:00
|
|
|
|
|
|
|
#if LWIP_IPV6
|
2016-12-07 21:19:37 +00:00
|
|
|
IP_ADDR6_HOST(loop_netif.ip6_addr, 0, 0, 0, 0x00000001UL);
|
2014-01-17 20:55:46 +00:00
|
|
|
loop_netif.ip6_addr_state[0] = IP6_ADDR_VALID;
|
|
|
|
#endif /* LWIP_IPV6 */
|
|
|
|
|
2015-07-26 22:22:30 +00:00
|
|
|
netif_set_link_up(&loop_netif);
|
2010-02-09 16:01:24 +00:00
|
|
|
netif_set_up(&loop_netif);
|
|
|
|
|
|
|
|
#endif /* LWIP_HAVE_LOOPIF */
|
|
|
|
}
|
|
|
|
|
2016-07-30 08:19:16 +00:00
|
|
|
/**
|
2016-07-30 08:40:36 +00:00
|
|
|
* @ingroup lwip_nosys
|
|
|
|
* Forwards a received packet for input processing with
|
|
|
|
* ethernet_input() or ip_input() depending on netif flags.
|
|
|
|
* Don't call directly, pass to netif_add() and call
|
|
|
|
* netif->input().
|
2017-09-17 18:38:38 +00:00
|
|
|
* Only works if the netif driver correctly sets
|
2016-07-30 08:40:36 +00:00
|
|
|
* NETIF_FLAG_ETHARP and/or NETIF_FLAG_ETHERNET flag!
|
2016-07-30 08:19:16 +00:00
|
|
|
*/
|
2016-07-30 08:29:14 +00:00
|
|
|
err_t
|
2016-07-30 08:19:16 +00:00
|
|
|
netif_input(struct pbuf *p, struct netif *inp)
|
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_input: invalid pbuf", p != NULL);
|
|
|
|
LWIP_ASSERT("netif_input: invalid netif", inp != NULL);
|
|
|
|
|
2016-07-30 08:19:16 +00:00
|
|
|
#if LWIP_ETHERNET
|
|
|
|
if (inp->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) {
|
|
|
|
return ethernet_input(p, inp);
|
|
|
|
} else
|
|
|
|
#endif /* LWIP_ETHERNET */
|
2017-09-17 18:38:38 +00:00
|
|
|
return ip_input(p, inp);
|
2016-07-30 08:19:16 +00:00
|
|
|
}
|
|
|
|
|
2017-04-25 10:05:05 +00:00
|
|
|
/**
|
|
|
|
* @ingroup netif
|
|
|
|
* Add a network interface to the list of lwIP netifs.
|
|
|
|
*
|
|
|
|
* Same as @ref netif_add but without IPv4 addresses
|
|
|
|
*/
|
|
|
|
struct netif *
|
|
|
|
netif_add_noaddr(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
|
|
|
|
{
|
|
|
|
return netif_add(netif,
|
|
|
|
#if LWIP_IPV4
|
2017-09-17 18:38:38 +00:00
|
|
|
NULL, NULL, NULL,
|
2017-04-25 10:05:05 +00:00
|
|
|
#endif /* LWIP_IPV4*/
|
2017-09-17 18:38:38 +00:00
|
|
|
state, init, input);
|
2017-04-25 10:05:05 +00:00
|
|
|
}
|
|
|
|
|
2003-02-10 13:47:47 +00:00
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2003-02-10 13:47:47 +00:00
|
|
|
* Add a network interface to the list of lwIP netifs.
|
|
|
|
*
|
2004-03-04 16:19:53 +00:00
|
|
|
* @param netif a pre-allocated netif structure
|
2003-02-10 13:47:47 +00:00
|
|
|
* @param ipaddr IP address for the new netif
|
|
|
|
* @param netmask network mask for the new netif
|
|
|
|
* @param gw default gateway IP address for the new netif
|
2003-02-11 09:51:22 +00:00
|
|
|
* @param state opaque data passed to the new netif
|
|
|
|
* @param init callback function that initializes the interface
|
2004-03-04 16:19:53 +00:00
|
|
|
* @param input callback function that is called to pass
|
2019-03-26 16:34:01 +00:00
|
|
|
* ingress packets up in the protocol layer stack.<br>
|
2016-08-01 07:32:54 +00:00
|
|
|
* It is recommended to use a function that passes the input directly
|
|
|
|
* to the stack (netif_input(), NO_SYS=1 mode) or via sending a
|
2019-03-26 16:34:01 +00:00
|
|
|
* message to TCPIP thread (tcpip_input(), NO_SYS=0 mode).<br>
|
2016-08-01 07:32:54 +00:00
|
|
|
* These functions use netif flags NETIF_FLAG_ETHARP and NETIF_FLAG_ETHERNET
|
|
|
|
* to decide whether to forward to ethernet_input() or ip_input().
|
|
|
|
* In other words, the functions only work when the netif
|
2019-03-26 16:34:01 +00:00
|
|
|
* driver is implemented correctly!<br>
|
2017-09-17 18:38:38 +00:00
|
|
|
* Most members of struct netif should be be initialized by the
|
2019-03-26 16:34:01 +00:00
|
|
|
* netif init function = netif driver (init parameter of this function).<br>
|
2016-09-29 10:02:50 +00:00
|
|
|
* IPv6: Don't forget to call netif_create_ip6_linklocal_address() after
|
|
|
|
* setting the MAC address in struct netif.hwaddr
|
|
|
|
* (IPv6 requires a link-local address).
|
2017-09-17 18:38:38 +00:00
|
|
|
*
|
2003-02-10 13:47:47 +00:00
|
|
|
* @return netif, or NULL if failed.
|
|
|
|
*/
|
2002-10-19 12:59:30 +00:00
|
|
|
struct netif *
|
2015-04-09 20:21:15 +00:00
|
|
|
netif_add(struct netif *netif,
|
|
|
|
#if LWIP_IPV4
|
|
|
|
const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
|
|
|
|
#endif /* LWIP_IPV4 */
|
|
|
|
void *state, netif_init_fn init, netif_input_fn input)
|
2002-10-19 12:59:30 +00:00
|
|
|
{
|
2011-05-17 19:35:14 +00:00
|
|
|
#if LWIP_IPV6
|
2016-08-24 07:19:53 +00:00
|
|
|
s8_t i;
|
2011-05-17 19:35:14 +00:00
|
|
|
#endif
|
2006-11-28 13:12:15 +00:00
|
|
|
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2017-03-01 15:10:50 +00:00
|
|
|
#if LWIP_SINGLE_NETIF
|
|
|
|
if (netif_default != NULL) {
|
|
|
|
LWIP_ASSERT("single netif already set", 0);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ERROR("netif_add: invalid netif", netif != NULL, return NULL);
|
|
|
|
LWIP_ERROR("netif_add: No init function given", init != NULL, return NULL);
|
2010-01-10 13:32:36 +00:00
|
|
|
|
2017-05-05 08:02:44 +00:00
|
|
|
#if LWIP_IPV4
|
2017-05-05 07:07:40 +00:00
|
|
|
if (ipaddr == NULL) {
|
|
|
|
ipaddr = ip_2_ip4(IP4_ADDR_ANY);
|
|
|
|
}
|
|
|
|
if (netmask == NULL) {
|
|
|
|
netmask = ip_2_ip4(IP4_ADDR_ANY);
|
|
|
|
}
|
|
|
|
if (gw == NULL) {
|
|
|
|
gw = ip_2_ip4(IP4_ADDR_ANY);
|
|
|
|
}
|
|
|
|
|
2006-11-28 13:12:15 +00:00
|
|
|
/* reset new interface configuration state */
|
2015-09-23 20:09:37 +00:00
|
|
|
ip_addr_set_zero_ip4(&netif->ip_addr);
|
|
|
|
ip_addr_set_zero_ip4(&netif->netmask);
|
|
|
|
ip_addr_set_zero_ip4(&netif->gw);
|
2018-03-13 19:29:37 +00:00
|
|
|
netif->output = netif_null_output_ip4;
|
2015-04-09 20:21:15 +00:00
|
|
|
#endif /* LWIP_IPV4 */
|
2011-05-17 19:35:14 +00:00
|
|
|
#if LWIP_IPV6
|
|
|
|
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
2015-09-23 20:09:37 +00:00
|
|
|
ip_addr_set_zero_ip6(&netif->ip6_addr[i]);
|
2016-10-28 21:28:48 +00:00
|
|
|
netif->ip6_addr_state[i] = IP6_ADDR_INVALID;
|
nd6: improve address autoconfiguration support
In summary, this patch aims to resolve bugs #47923 and #48162, by
decoupling address autoconfiguration from the on-link prefix list,
since those are not related. Important necessary changes are needed
to meet this goal, ultimately bringing the lwIP ND6 implementation
closer to compliance with RFC 4862. The main changes are:
1. support for address lifetimes, and,
2. addition of a new DUPLICATED address state.
The decoupling implies that the prefix list can no longer be used to
maintain state for address autoconfiguration. Most importantly, the
lifetime of each address, which was previously derived from the
prefix slot's lifetime, must now be associated with the address
itself. This patch implements address lifetime tracking, maintaining
both a valid and a preferred lifetime for each address, along with
the corresponding address state changes (e.g., between PREFERRED and
DEPRECATED), all as required by RFC 4862.
The support for address lifetimes can be enabled with a new
LWIP_IPV6_ADDRESS_LIFETIMES setting in lwipopts.h. It is required for
autoconfiguration and enabled by default if autoconfiguration is
enabled as well, but it may also be enabled separately, so as to allow
application-controlled lifetime management (e.g., if autoconfiguration
is implemented in a separate application). A special valid-lifetime of
zero is used to denote a static address--that is, an address that was
configured manually, that does not have lifetimes, and that should be
left alone by the autoconfiguration functionality. Addresses assigned
without setting a lifetime are deemed static, thus preserving
compatibility with existing lwIP-based applications in this respect.
Similarly, the decoupling implies that the prefix list can no longer
be used to remember cases of address duplication. Previously, the
detection of a duplicated address would simply result in removal of
the address altogether. Instead, this patch introduces a new state
"DUPLICATED", indicating that the address, while technically still
present, has been found to conflict with other node addresses, and no
attempt should be made to produce an autoconfiguration address for
that prefix.
Manually added addresses, including the link-local address, once set
to DUPLICATED, will remain in that state until manual intervention.
Autoconfigured DUPLICATED addresses will expire according to their
valid-lifetime, essentially preserving the current behavior but
without the use of the prefix list. As a first attempt to approach
compliance with RFC 4862 Sec. 5.4.5, if the link-local address is
detected to be duplicated, all derived addresses are marked duplicated
as well, and no new addresses will be autoconfigured. More work is to
be done for full compliance with that section, however.
Together, those two main changes indeed do fully decouple address
autoconfiguration from the on-link prefix list. Changes to the latter
thus no longer affect the former, resolving bug #47923. Moreover, as a
result, autoconfiguration can, and does, now also take place on
advertised prefixes that do not have the on-link flag set, resolving
bug #48162. The routing changes mentioned in the discussion of that
bug are left to a separate patch, though.
2016-12-29 21:03:41 +00:00
|
|
|
#if LWIP_IPV6_ADDRESS_LIFETIMES
|
|
|
|
netif->ip6_addr_valid_life[i] = IP6_ADDR_LIFE_STATIC;
|
|
|
|
netif->ip6_addr_pref_life[i] = IP6_ADDR_LIFE_STATIC;
|
|
|
|
#endif /* LWIP_IPV6_ADDRESS_LIFETIMES */
|
2011-05-17 19:35:14 +00:00
|
|
|
}
|
2012-08-17 16:56:14 +00:00
|
|
|
netif->output_ip6 = netif_null_output_ip6;
|
2011-05-17 19:35:14 +00:00
|
|
|
#endif /* LWIP_IPV6 */
|
2015-09-01 20:04:15 +00:00
|
|
|
NETIF_SET_CHECKSUM_CTRL(netif, NETIF_CHECKSUM_ENABLE_ALL);
|
2018-06-14 10:55:18 +00:00
|
|
|
netif->mtu = 0;
|
2006-11-28 13:12:15 +00:00
|
|
|
netif->flags = 0;
|
2016-09-21 11:33:33 +00:00
|
|
|
#ifdef netif_get_client_data
|
2016-08-17 14:37:15 +00:00
|
|
|
memset(netif->client_data, 0, sizeof(netif->client_data));
|
|
|
|
#endif /* LWIP_NUM_NETIF_CLIENT_DATA */
|
2018-06-08 20:18:50 +00:00
|
|
|
#if LWIP_IPV6
|
2011-05-17 19:35:14 +00:00
|
|
|
#if LWIP_IPV6_AUTOCONFIG
|
|
|
|
/* IPv6 address autoconfiguration not enabled by default */
|
|
|
|
netif->ip6_autoconfig_enabled = 0;
|
|
|
|
#endif /* LWIP_IPV6_AUTOCONFIG */
|
2018-06-08 20:18:50 +00:00
|
|
|
nd6_restart_netif(netif);
|
|
|
|
#endif /* LWIP_IPV6 */
|
2007-08-22 11:26:01 +00:00
|
|
|
#if LWIP_NETIF_STATUS_CALLBACK
|
2007-03-21 13:24:20 +00:00
|
|
|
netif->status_callback = NULL;
|
2007-08-22 11:26:01 +00:00
|
|
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
2007-07-13 15:00:40 +00:00
|
|
|
#if LWIP_NETIF_LINK_CALLBACK
|
|
|
|
netif->link_callback = NULL;
|
|
|
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
2007-09-03 14:53:18 +00:00
|
|
|
#if LWIP_IGMP
|
|
|
|
netif->igmp_mac_filter = NULL;
|
|
|
|
#endif /* LWIP_IGMP */
|
2011-05-17 19:35:14 +00:00
|
|
|
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
|
|
|
netif->mld_mac_filter = NULL;
|
|
|
|
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
2008-06-17 19:39:22 +00:00
|
|
|
#if ENABLE_LOOPBACK
|
2008-06-12 20:10:08 +00:00
|
|
|
netif->loop_first = NULL;
|
|
|
|
netif->loop_last = NULL;
|
2008-06-17 19:39:22 +00:00
|
|
|
#endif /* ENABLE_LOOPBACK */
|
2007-03-21 13:24:20 +00:00
|
|
|
|
2003-03-13 08:50:04 +00:00
|
|
|
/* remember netif specific state information data */
|
2003-02-06 22:18:56 +00:00
|
|
|
netif->state = state;
|
2017-02-23 19:41:54 +00:00
|
|
|
netif->num = netif_num;
|
2016-08-01 07:32:54 +00:00
|
|
|
netif->input = input;
|
|
|
|
|
2017-04-27 10:38:53 +00:00
|
|
|
NETIF_RESET_HINTS(netif);
|
2008-06-17 19:39:22 +00:00
|
|
|
#if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS
|
|
|
|
netif->loop_cnt_current = 0;
|
|
|
|
#endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */
|
2002-10-19 12:59:30 +00:00
|
|
|
|
2015-04-09 20:21:15 +00:00
|
|
|
#if LWIP_IPV4
|
2003-03-07 10:55:58 +00:00
|
|
|
netif_set_addr(netif, ipaddr, netmask, gw);
|
2015-04-09 20:21:15 +00:00
|
|
|
#endif /* LWIP_IPV4 */
|
2003-06-09 21:08:55 +00:00
|
|
|
|
2003-03-13 08:50:04 +00:00
|
|
|
/* call user specified initialization function for netif */
|
2003-02-20 11:51:53 +00:00
|
|
|
if (init(netif) != ERR_OK) {
|
2003-04-15 14:32:13 +00:00
|
|
|
return NULL;
|
2003-02-20 11:51:53 +00:00
|
|
|
}
|
2018-06-14 10:55:18 +00:00
|
|
|
#if LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES
|
|
|
|
/* Initialize the MTU for IPv6 to the one set by the netif driver.
|
|
|
|
This can be updated later by RA. */
|
|
|
|
netif->mtu6 = netif->mtu;
|
|
|
|
#endif /* LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES */
|
2003-06-09 21:08:55 +00:00
|
|
|
|
2017-03-01 15:10:50 +00:00
|
|
|
#if !LWIP_SINGLE_NETIF
|
2017-02-23 19:41:54 +00:00
|
|
|
/* Assign a unique netif number in the range [0..254], so that (num+1) can
|
|
|
|
serve as an interface index that fits in a u8_t.
|
|
|
|
We assume that the new netif has not yet been added to the list here.
|
|
|
|
This algorithm is O(n^2), but that should be OK for lwIP.
|
|
|
|
*/
|
2017-03-01 15:10:50 +00:00
|
|
|
{
|
|
|
|
struct netif *netif2;
|
|
|
|
int num_netifs;
|
|
|
|
do {
|
|
|
|
if (netif->num == 255) {
|
|
|
|
netif->num = 0;
|
2017-02-23 19:41:54 +00:00
|
|
|
}
|
2017-03-01 15:10:50 +00:00
|
|
|
num_netifs = 0;
|
|
|
|
for (netif2 = netif_list; netif2 != NULL; netif2 = netif2->next) {
|
2018-03-21 08:32:39 +00:00
|
|
|
LWIP_ASSERT("netif already added", netif2 != netif);
|
2017-03-01 15:10:50 +00:00
|
|
|
num_netifs++;
|
|
|
|
LWIP_ASSERT("too many netifs, max. supported number is 255", num_netifs <= 255);
|
|
|
|
if (netif2->num == netif->num) {
|
|
|
|
netif->num++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (netif2 != NULL);
|
|
|
|
}
|
2017-06-25 21:01:57 +00:00
|
|
|
if (netif->num == 254) {
|
|
|
|
netif_num = 0;
|
|
|
|
} else {
|
|
|
|
netif_num = (u8_t)(netif->num + 1);
|
|
|
|
}
|
2017-01-20 20:49:11 +00:00
|
|
|
|
2003-03-13 08:50:04 +00:00
|
|
|
/* add this netif to the list */
|
2002-10-19 12:59:30 +00:00
|
|
|
netif->next = netif_list;
|
|
|
|
netif_list = netif;
|
2017-03-01 15:10:50 +00:00
|
|
|
#endif /* "LWIP_SINGLE_NETIF */
|
2015-09-08 07:47:30 +00:00
|
|
|
mib2_netif_added(netif);
|
2006-09-01 07:14:50 +00:00
|
|
|
|
2007-08-29 21:12:32 +00:00
|
|
|
#if LWIP_IGMP
|
|
|
|
/* start IGMP processing */
|
2007-09-09 20:46:33 +00:00
|
|
|
if (netif->flags & NETIF_FLAG_IGMP) {
|
2010-02-09 16:01:24 +00:00
|
|
|
igmp_start(netif);
|
2007-09-09 20:46:33 +00:00
|
|
|
}
|
2007-08-29 21:12:32 +00:00
|
|
|
#endif /* LWIP_IGMP */
|
|
|
|
|
2015-04-09 20:21:15 +00:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP",
|
2017-09-17 18:38:38 +00:00
|
|
|
netif->name[0], netif->name[1]));
|
2015-04-09 20:21:15 +00:00
|
|
|
#if LWIP_IPV4
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, (" addr "));
|
|
|
|
ip4_addr_debug_print(NETIF_DEBUG, ipaddr);
|
2003-06-10 10:45:29 +00:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, (" netmask "));
|
2015-04-09 20:21:15 +00:00
|
|
|
ip4_addr_debug_print(NETIF_DEBUG, netmask);
|
2003-06-11 22:11:42 +00:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, (" gw "));
|
2015-04-09 20:21:15 +00:00
|
|
|
ip4_addr_debug_print(NETIF_DEBUG, gw);
|
|
|
|
#endif /* LWIP_IPV4 */
|
2003-06-10 10:45:29 +00:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("\n"));
|
2017-04-25 10:07:28 +00:00
|
|
|
|
2017-02-15 09:14:06 +00:00
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_NETIF_ADDED, NULL);
|
2017-04-25 10:07:28 +00:00
|
|
|
|
2002-10-19 12:59:30 +00:00
|
|
|
return netif;
|
|
|
|
}
|
2003-03-07 10:55:58 +00:00
|
|
|
|
2018-03-14 14:59:17 +00:00
|
|
|
static void
|
|
|
|
netif_do_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_addr)
|
|
|
|
{
|
|
|
|
#if LWIP_TCP
|
|
|
|
tcp_netif_ip_addr_changed(old_addr, new_addr);
|
|
|
|
#endif /* LWIP_TCP */
|
|
|
|
#if LWIP_UDP
|
|
|
|
udp_netif_ip_addr_changed(old_addr, new_addr);
|
|
|
|
#endif /* LWIP_UDP */
|
|
|
|
#if LWIP_RAW
|
|
|
|
raw_netif_ip_addr_changed(old_addr, new_addr);
|
|
|
|
#endif /* LWIP_RAW */
|
|
|
|
}
|
|
|
|
|
2015-04-09 20:21:15 +00:00
|
|
|
#if LWIP_IPV4
|
2018-01-12 22:11:38 +00:00
|
|
|
static int
|
|
|
|
netif_do_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr, ip_addr_t *old_addr)
|
2018-01-03 06:47:49 +00:00
|
|
|
{
|
2018-01-12 22:11:38 +00:00
|
|
|
LWIP_ASSERT("invalid pointer", ipaddr != NULL);
|
|
|
|
LWIP_ASSERT("invalid pointer", old_addr != NULL);
|
2018-01-03 06:47:49 +00:00
|
|
|
|
|
|
|
/* address is actually being changed? */
|
2018-01-12 22:11:38 +00:00
|
|
|
if (ip4_addr_cmp(ipaddr, netif_ip4_addr(netif)) == 0) {
|
|
|
|
ip_addr_t new_addr;
|
|
|
|
*ip_2_ip4(&new_addr) = *ipaddr;
|
|
|
|
IP_SET_TYPE_VAL(new_addr, IPADDR_TYPE_V4);
|
|
|
|
|
|
|
|
ip_addr_copy(*old_addr, *netif_ip_addr4(netif));
|
2018-01-03 06:47:49 +00:00
|
|
|
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
|
2018-03-14 14:59:17 +00:00
|
|
|
netif_do_ip_addr_changed(old_addr, &new_addr);
|
2018-01-03 06:47:49 +00:00
|
|
|
|
ACD module added + update and improve DHCP + AUTOIP behavior
Squashed commit of the following:
commit 2d98d8e2ef1941c3824ffb874f1e529d284667fc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:15:06 2018 +0200
AUTOIP: correct functionality autoip_supplied_address
It does not mean that if autoip is bound, it also supplied the
netif address. A check is added.
commit 2ca0a2183991ef73860c4207d95799b37acc64cc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:06:49 2018 +0200
AUTOIP: keep using the same link local address as much as possible
Only calculate a new link local address at start up or when a
conflict occured. On link up or down -> keep same address.
TODO: in the future a function for persistent storage should be
added.
commit aa70a693351e4c898aa28d8521308794614838f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 14:43:14 2018 +0200
ACD, AUTOIP & DHCP: make link up & down functions where needed
When the link goes down or up the approriate functions should be
stopped or started again. To accomodate this, network_changed is
adjusted to network_changed_link_up and network_changed_link_down.
DHCP does not need to control AUTOIP. AUTOIP can take care of
itself. The only thing DHCP needs to do is starting it when
discovering is failing. The AUTOIP state variable is removed from
DHCP.
commit ad469eb006b47f8a8c37f7c0de0216f47a8c19c7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 11:25:58 2018 +0200
ACD: add address change listener + passive conflict detection mode
In the case their previously was a LL address on a netif that
is now configured with a routable address, we want the LL
address to be able to keep receiving packets.
for as long as the LL address is available on the interface it
should do ongoing conflict detection. But we cannot defend when
the LL address is not the netif address any more.
An address change listener is added to detect when an ACD module
needs to go from active ongoing conflict detection to passive.
When a conflict is detected autoip is stopped and will not be able
to receive packets any more. Because we have a valid routable
address on the netif, autoip is not restarted.
commit 07c4ec20cea78e2b4a6f5599569abaf075619c62
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Sep 11 16:25:37 2018 +0200
ACD: make module reusable within a netif
DHCP and AUTOIP both have ACD running simultaniously. The ACD
struct is added to the DHCP and AUTOIP structs. In the netif a list
of ACD modules is kept to loop over if functions need to perform
some action on all ACD modules (for example tmr function). With
acd_add a module can be added to the list. ACD_FOREACH loops over
the list similar to NETIF_FOREACH.
commit ee3b4585b7768f5353dd80190a2929bad45f7ff4
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 10 16:36:18 2018 +0200
etharp & acd: add probe and announce functions to etharp.
The new probe and announce functions are independent of
netif->ip_addr. This means we can keep the LL address working
while we start to probe for the newly received routable address.
The netif->ip_addr does not need to be any for probing to work
with this patch.
commit 7d3032bae8f1b8081368a807682388eb642729e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 3 13:35:51 2018 +0200
autoip -> unused random function removed + small comment update
commit be749ba4eb26ddc69233c85d532dc035741275c5
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 16:37:36 2018 +0200
ACD: update comment in header
commit 4491842991c90b3a58fa327f70aa42f04174546b
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 15:44:45 2018 +0200
ACD: subscribe to link down messages to stop the acd process
When the link goes down the acd process should be stopped
independent of the acd client. Otherwise the acd will keep probing
or announcing while their simply is no connection.
commit 71f668aa7583354e132c20b3b50ba2c86bf08738
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 13:59:44 2018 +0200
DHCP coop autoip bug fix: wait after last discovery before starting autoip
After the last dhcp discovery we need to give the dhcp server the
time to respond. Currently the discovery message is send and autoip
is started simultaniously. This is changed. Autoip will now be started
after the next discovery timeout.
commit 0da16604ec079195533f2591f0d0f04bdf212a72
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 11:23:31 2018 +0200
ACD: rate limit interval bug solved -> first decline then wait then restart.
According the the ACD RFC we need to limit the rate of acquiring
and probing addresses after MAX_CONFLICTS. It is important to first
decline the address and stop the netif from using the address before
the time is started. After this rate limit time, the address acquiring
process can be started again.
To make this possible we had to change the callback function and
the location in the process were the rate limiting is done.
commit a89a0601a251acb14abe270116f38c6d25c2d7a9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:27:10 2018 +0200
DHCP: after a succesful dhcp_reboot, the address should be probed.
Reboot means that the connection was gone for some amount of time.
This is seen as a new connection for the ACD module so should be
the address should be probed before use.
commit 853afb448ba35c6e2b35e8238c9c367c599dece7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:19:12 2018 +0200
DHCP_DOES_ARP_CHECK changed to DHCP_DOES_ACD_CHECK
small update in opt.h to add the correct dependencies.
commit e28b4766bdef69e76f6170c470c93f5b251c579a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:05:43 2018 +0200
DHCP check code replaced by ACD module.
when DHCP_DOES_ARP_CHECK is enabled, the ACD module will take care
of address conflict detection. Via a call back function the DHCP
state machine will continue and bind to an address if no conflicts
are found.
dhcp_arp_reply is obsolete because the ACD module replaces its
function.
commit 52193a0f5d13e8786a4db2fff1f1a8f1367a4eba
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 16:05:22 2018 +0200
Issue 2 + 3 from Comment #5, task #13508 solved
Removed C++ comments and // ----... marks as requested.
commit 7faaf61275d67ccfb88ea7e26c249428c3088536
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 15:55:24 2018 +0200
Issue 1 from Comment #5, task #13508 solved
Comments added to clarify how arp messages are handled.
commit 9348aea22623b705759fd30b873f06a50a104d16
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:45:35 2018 +0200
acd: add comment for callback function
commit 49fdd1177c05b74d49fa179564dcaa5e650adbcc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:42:59 2018 +0200
autoip: Add debugging output and complete comments
commit 591856b82c029687a657a1b1ccc674522e6f4be0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:25:18 2018 +0200
Removed autoip from timeouts.c
We do not need a timer anymore. All timing is part of acd.
commit 3b3272fdd14015cfca0b3b6d149505b1cf0e36b6
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:22:32 2018 +0200
autoip_network_changed -> first bring down the netif and then acd
Make it do what it says in the comment
commit 77b0ccf96efd22774279c6f9b5bade18c5e42c59
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:21:23 2018 +0200
Simplified the autoIP states + update autoip_start()
commit 96e0581d36857f8b70c4b4cce4fb323fd3dd51ab
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:10:48 2018 +0200
Deleted unused variables, functions and defines from autoip module
The functionality is now embedded in the acd module so can be
removed from autoip.
commit 9296e2ebb4b51019aaccfc47e8b9f51b265d37cd
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:07:34 2018 +0200
Bug fix acd -> rate limiting needs to be after MAX conflicts
It was only after MAX conflicts + 1.
commit c55e16903c045d0ea84336b50eccbf24d3d097e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:52:45 2018 +0200
Small intruduction to module added
commit d1498a37293bd9f97f6b938b48e5980ab0a01bd1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:49:58 2018 +0200
Copyright information added
I based the copyright text on the other files. I'm not sure this
is how its done. I kept Dominik in their because I copied quite
some code from the autoip module.
commit 359a845ef5e73061832069f364b370634ee0b071
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:08:44 2018 +0200
Fixing comments in acd.c
commit 100d72549d0ef44157143d031848a727f5dfbe69
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 15:43:40 2018 +0200
Probe wait time and Probe interval time made random via lwip_rand
According to the RFC a random amount of time needs to be waited
before probing can be started also a random amount of time
needs to be waited between the probes.
The random time is calculated via the LWIP_RAND function (see
lwipopts and sys_arch).
commit f7f037c32e9416f8b803c3c7af617b871b55ee35
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:56:48 2018 +0200
autoip will start probing again when the network has changed
commit 1f40f6274195f24aa1b05caf82b79285ad189c2a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:55:47 2018 +0200
Duplicate code removed -> already present in autoip_start
commit be59431271da862a8ca330dbca638842c87765bc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:52:49 2018 +0200
add rate limiting to acd when too many conflicts are detected.
When more then max conflicts are detected during device on time,
the rate at which probing for a new address starts is limited.
For clarity we combined the conflict counting and the callback into
a new function acd_restart.
commit 91448455e95edb24c1f418c341b6fb306391f4f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:50:01 2018 +0200
ARP packet conflict detection added.
If a conflict is detected between the begin until after announce
wait, a new address needs to be chosen immediatly.
This can occur in two situations:
1) another host already has this ip address
2) another host is also probing for the same address.
If a conflict is detected during announcing or during the ongoing
conflict detection, we defend our ip address once. If a second
conflict occurs during defend interval, we take another ip address.
If not we can keep our address and connections.
When a conflict occurs and it's decided we need a new address,
autoip is simply restarted. To do: test if a acd stop is needed.
This will become more important when DHCP is added I believe.
commit 65f47ba9444d8b9f767dc908319579323eeb8664
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:33:44 2018 +0200
Update ACD state machine with PROBE_WAIT and and ANNOUNCE_WAIT
By adding the ANNOUNCE_WAIT state, we could remove duplicate code
that was present in the original autoip state implementation.
But because we cannot directly go to ANNOUNCING we needed this
extra state during the wait period. It also makes the different
states clearer.
Their is no need to number the enum because the compiler takes
care of this standard numbering.
Also a indent issue on the state machine code is solved here.
commit 2d9f4414c7b1f2ed35c0b5cea78dabb9c9afee77
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:28:33 2018 +0200
Added an extra check for etharp responses.
Their is no need to answer a request that is initiated by ourselves.
In my test case, a conflicting request would be seen here as a
request needing a reply. Which off course isn't needed at all.
The acd module will let the requester know that it is using our
ip address.
I could not think of a reason not to add this extra check but please
check if this doesn't break other functionality.
commit f84cc1dba4061219bd1aadb97bd340278db07cd7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:27:13 2018 +0200
Redirect all incoming ARP messages to the ACD module.
The ACD module will scan the packets and react on conflicts.
autoip does not need the arp packets any more.
commit 9faf266993cc2df0b9434720b59b5922f17d7d33
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:08:39 2018 +0200
Initiate acd from autoip implementation.
The state machine in autoip is now replaced by the acd module.
commit 40a5a40d911c98e6ee8566c0adce7716f26f20e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:05:59 2018 +0200
Add simple acd state machine to timer function.
This state machine will be started from acd_start and will go
through the probing and the announcing state. At this moment the
timings are made fixed for easy debugging. Will be made variable
afterwards.
commit 0a2629bf1f7942e80ec11bcc3e163ac1a2b9a580
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:44:19 2018 +0200
Disable gratuitous ARP send from netif_issue_report when acd is enabled
The acd module needs to be fully under control on what arp messages are
send. It wouldn't be a clean solution if we kept this announce as one
of the announce messages.
So when ACD is enabled, this message will not be send.
commit a7b9a4d5039168723c2043677176c5c8fc69f8df
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:42:46 2018 +0200
ARP probe and announce functions added.
Both use etharp_requests to send out an arp message.
commit e2f1ce3fa84e2ce01bc944d8049412e156cd7cc7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:26:07 2018 +0200
Add conflict callback mechanism to acd module
When starting the acd with acd_start, a conflict callback has to be
provided. After probing when no conflict is detected, the callback
is called with the conflict variable on 0. From the moment a conflict
is detected, it will be called set to 1.
By not making a fixed link between acd, autoip and dhcp but working
with callback functions the user (caller) can easily use it for
fixed ip too. This keeps the acd module completely independent from
the other application layer protocols.
commit 21e7995888d2941601e99873ee129d1ea927e3f7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:41:52 2018 +0200
acd_stop function added.
When calling this function the acd state machine will be put in
ACD_STATE_OFF. This will disable the acd functionality until
acd_start is called.
commit 503037fb462504e46a14ce7486bc763dbc6a8690
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:35:48 2018 +0200
acd_start function added
This function will allocate a struct for the acd module if one wasn't
added with acd_set_struct. It will then initialize the acd struct
and start the probe wait timer (for now fixed).
commit e439f6dffc44e93078a2976783bdebfe17304d8c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:22:39 2018 +0200
ACD_DEBUG define added for enabling / disabling debug messages.
commit 80d33e1eaf092934ace1045fac096464cd5be5e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:39:37 2018 +0200
ACD struct added together with set struct function
ACD needs some variables: state, timing, probe counter etc.
We added the struct as netif data. For now one ACD module per netif
is enough. We found some unclarities about ACD with multiple IP
address on one interface. For now, ACD will only be implemented for
the IP address that is going to be used / is being used on the netif.
commit 2c4cca36744973318c3efe7cbae6384b52dc71a8
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:35:06 2018 +0200
Add acd timer to timeouts.c with interval of 100ms.
This timer will be used for time to wait counting etc.
Very similar to the auto ip timer.
commit e2ed447e00c4df790df21509acb4ab09b5b79e66
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:56:39 2018 +0200
Add ACD protocol definitions
commit 445733214460eae18817556439bed979e9b3747c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:07:58 2018 +0200
Add c++ option (to use C code module in c++)
commit 63d78bc1f77ac6698c3d663a1c67b40a0c297125
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:57:34 2018 +0200
Added on off option for ACD module
commit d5ec4b69eb4175d4dd569bcfc80ae0e192780015
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:09:40 2018 +0200
ACD IPv4 module files added
The files for IPv4 ACD or Address Conflict Detection are added
to the lwip source.
2018-09-13 15:02:21 +00:00
|
|
|
#if LWIP_ACD
|
|
|
|
acd_netif_ip_addr_changed(netif, old_addr, &new_addr);
|
|
|
|
#endif /* LWIP_ACD */
|
|
|
|
|
2018-01-03 06:47:49 +00:00
|
|
|
mib2_remove_ip4(netif);
|
|
|
|
mib2_remove_route_ip4(0, netif);
|
|
|
|
/* set new IP address to netif */
|
|
|
|
ip4_addr_set(ip_2_ip4(&netif->ip_addr), ipaddr);
|
|
|
|
IP_SET_TYPE_VAL(netif->ip_addr, IPADDR_TYPE_V4);
|
|
|
|
mib2_add_ip4(netif);
|
|
|
|
mib2_add_route_ip4(0, netif);
|
|
|
|
|
|
|
|
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4);
|
|
|
|
|
|
|
|
NETIF_STATUS_CALLBACK(netif);
|
2018-01-12 22:11:38 +00:00
|
|
|
return 1; /* address changed */
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
2018-01-12 22:11:38 +00:00
|
|
|
return 0; /* address unchanged */
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup netif_ip4
|
|
|
|
* Change the IP address of a network interface
|
|
|
|
*
|
|
|
|
* @param netif the network interface to change
|
|
|
|
* @param ipaddr the new IP address
|
|
|
|
*
|
|
|
|
* @note call netif_set_addr() if you also want to change netmask and
|
|
|
|
* default gateway
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
|
|
|
{
|
2018-01-12 22:11:38 +00:00
|
|
|
ip_addr_t old_addr;
|
2018-06-14 11:41:27 +00:00
|
|
|
|
|
|
|
LWIP_ERROR("netif_set_ipaddr: invalid netif", netif != NULL, return);
|
|
|
|
|
2018-01-09 06:51:09 +00:00
|
|
|
/* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */
|
|
|
|
if (ipaddr == NULL) {
|
|
|
|
ipaddr = IP4_ADDR_ANY4;
|
|
|
|
}
|
|
|
|
|
2018-01-03 09:36:03 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-01-12 22:11:38 +00:00
|
|
|
if (netif_do_set_ipaddr(netif, ipaddr, &old_addr)) {
|
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.ipv4_changed.old_address = &old_addr;
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_IPV4_ADDRESS_CHANGED, &args);
|
|
|
|
#endif
|
|
|
|
}
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
|
|
|
|
2018-01-12 22:11:38 +00:00
|
|
|
static int
|
|
|
|
netif_do_set_netmask(struct netif *netif, const ip4_addr_t *netmask, ip_addr_t *old_nm)
|
2018-01-03 06:47:49 +00:00
|
|
|
{
|
2018-01-09 07:08:22 +00:00
|
|
|
/* address is actually being changed? */
|
|
|
|
if (ip4_addr_cmp(netmask, netif_ip4_netmask(netif)) == 0) {
|
2018-01-03 06:47:49 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
2018-01-12 22:11:38 +00:00
|
|
|
LWIP_ASSERT("invalid pointer", old_nm != NULL);
|
|
|
|
ip_addr_copy(*old_nm, *netif_ip_netmask4(netif));
|
|
|
|
#else
|
|
|
|
LWIP_UNUSED_ARG(old_nm);
|
2018-01-03 06:47:49 +00:00
|
|
|
#endif
|
|
|
|
mib2_remove_route_ip4(0, netif);
|
|
|
|
/* set new netmask to netif */
|
|
|
|
ip4_addr_set(ip_2_ip4(&netif->netmask), netmask);
|
|
|
|
IP_SET_TYPE_VAL(netif->netmask, IPADDR_TYPE_V4);
|
|
|
|
mib2_add_route_ip4(0, netif);
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
|
|
|
netif->name[0], netif->name[1],
|
|
|
|
ip4_addr1_16(netif_ip4_netmask(netif)),
|
|
|
|
ip4_addr2_16(netif_ip4_netmask(netif)),
|
|
|
|
ip4_addr3_16(netif_ip4_netmask(netif)),
|
|
|
|
ip4_addr4_16(netif_ip4_netmask(netif))));
|
2018-01-12 22:11:38 +00:00
|
|
|
return 1; /* netmask changed */
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
2018-01-12 22:11:38 +00:00
|
|
|
return 0; /* netmask unchanged */
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup netif_ip4
|
|
|
|
* Change the netmask of a network interface
|
|
|
|
*
|
|
|
|
* @param netif the network interface to change
|
|
|
|
* @param netmask the new netmask
|
|
|
|
*
|
|
|
|
* @note call netif_set_addr() if you also want to change ip address and
|
|
|
|
* default gateway
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask)
|
|
|
|
{
|
2018-01-12 22:11:38 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
ip_addr_t old_nm_val;
|
|
|
|
ip_addr_t *old_nm = &old_nm_val;
|
|
|
|
#else
|
|
|
|
ip_addr_t *old_nm = NULL;
|
|
|
|
#endif
|
2018-01-03 09:36:03 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-14 11:41:27 +00:00
|
|
|
LWIP_ERROR("netif_set_netmask: invalid netif", netif != NULL, return);
|
|
|
|
|
2018-01-09 06:51:09 +00:00
|
|
|
/* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */
|
|
|
|
if (netmask == NULL) {
|
|
|
|
netmask = IP4_ADDR_ANY4;
|
|
|
|
}
|
|
|
|
|
2018-01-12 22:11:38 +00:00
|
|
|
if (netif_do_set_netmask(netif, netmask, old_nm)) {
|
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.ipv4_changed.old_netmask = old_nm;
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_IPV4_NETMASK_CHANGED, &args);
|
|
|
|
#endif
|
|
|
|
}
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
|
|
|
|
2018-01-12 22:11:38 +00:00
|
|
|
static int
|
|
|
|
netif_do_set_gw(struct netif *netif, const ip4_addr_t *gw, ip_addr_t *old_gw)
|
2018-01-03 06:47:49 +00:00
|
|
|
{
|
2018-01-09 07:08:22 +00:00
|
|
|
/* address is actually being changed? */
|
|
|
|
if (ip4_addr_cmp(gw, netif_ip4_gw(netif)) == 0) {
|
2018-01-03 06:47:49 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
2018-01-12 22:11:38 +00:00
|
|
|
LWIP_ASSERT("invalid pointer", old_gw != NULL);
|
|
|
|
ip_addr_copy(*old_gw, *netif_ip_gw4(netif));
|
|
|
|
#else
|
|
|
|
LWIP_UNUSED_ARG(old_gw);
|
2018-01-03 06:47:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
ip4_addr_set(ip_2_ip4(&netif->gw), gw);
|
|
|
|
IP_SET_TYPE_VAL(netif->gw, IPADDR_TYPE_V4);
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
|
|
|
netif->name[0], netif->name[1],
|
|
|
|
ip4_addr1_16(netif_ip4_gw(netif)),
|
|
|
|
ip4_addr2_16(netif_ip4_gw(netif)),
|
|
|
|
ip4_addr3_16(netif_ip4_gw(netif)),
|
|
|
|
ip4_addr4_16(netif_ip4_gw(netif))));
|
2018-01-12 22:11:38 +00:00
|
|
|
return 1; /* gateway changed */
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
2018-01-12 22:11:38 +00:00
|
|
|
return 0; /* gateway unchanged */
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup netif_ip4
|
|
|
|
* Change the default gateway for a network interface
|
|
|
|
*
|
|
|
|
* @param netif the network interface to change
|
|
|
|
* @param gw the new default gateway
|
|
|
|
*
|
|
|
|
* @note call netif_set_addr() if you also want to change ip address and netmask
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netif_set_gw(struct netif *netif, const ip4_addr_t *gw)
|
|
|
|
{
|
2018-01-12 22:11:38 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
ip_addr_t old_gw_val;
|
|
|
|
ip_addr_t *old_gw = &old_gw_val;
|
|
|
|
#else
|
|
|
|
ip_addr_t *old_gw = NULL;
|
|
|
|
#endif
|
2018-01-03 09:36:03 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-14 11:41:27 +00:00
|
|
|
LWIP_ERROR("netif_set_gw: invalid netif", netif != NULL, return);
|
|
|
|
|
2018-01-09 06:51:09 +00:00
|
|
|
/* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */
|
|
|
|
if (gw == NULL) {
|
|
|
|
gw = IP4_ADDR_ANY4;
|
|
|
|
}
|
|
|
|
|
2018-01-12 22:11:38 +00:00
|
|
|
if (netif_do_set_gw(netif, gw, old_gw)) {
|
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.ipv4_changed.old_gw = old_gw;
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_IPV4_GATEWAY_CHANGED, &args);
|
|
|
|
#endif
|
|
|
|
}
|
2018-01-03 06:47:49 +00:00
|
|
|
}
|
|
|
|
|
2007-06-07 21:29:44 +00:00
|
|
|
/**
|
2016-08-25 20:04:04 +00:00
|
|
|
* @ingroup netif_ip4
|
2007-06-07 21:29:44 +00:00
|
|
|
* Change IP address configuration for a network interface (including netmask
|
|
|
|
* and default gateway).
|
|
|
|
*
|
|
|
|
* @param netif the network interface to change
|
|
|
|
* @param ipaddr the new IP address
|
|
|
|
* @param netmask the new netmask
|
|
|
|
* @param gw the new default gateway
|
|
|
|
*/
|
2003-03-07 10:55:58 +00:00
|
|
|
void
|
2015-04-09 20:21:15 +00:00
|
|
|
netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask,
|
2017-09-17 18:38:38 +00:00
|
|
|
const ip4_addr_t *gw)
|
2003-03-07 10:55:58 +00:00
|
|
|
{
|
2017-03-18 14:30:20 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
2018-02-07 19:37:29 +00:00
|
|
|
netif_nsc_reason_t change_reason = LWIP_NSC_NONE;
|
2018-01-12 22:11:38 +00:00
|
|
|
netif_ext_callback_args_t cb_args;
|
|
|
|
ip_addr_t old_nm_val;
|
|
|
|
ip_addr_t old_gw_val;
|
|
|
|
ip_addr_t *old_nm = &old_nm_val;
|
|
|
|
ip_addr_t *old_gw = &old_gw_val;
|
|
|
|
#else
|
|
|
|
ip_addr_t *old_nm = NULL;
|
|
|
|
ip_addr_t *old_gw = NULL;
|
2018-01-09 06:51:09 +00:00
|
|
|
#endif
|
2018-01-12 22:11:38 +00:00
|
|
|
ip_addr_t old_addr;
|
|
|
|
int remove;
|
2018-01-09 06:51:09 +00:00
|
|
|
|
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
2017-09-17 18:38:38 +00:00
|
|
|
|
2018-01-09 06:51:09 +00:00
|
|
|
/* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */
|
|
|
|
if (ipaddr == NULL) {
|
|
|
|
ipaddr = IP4_ADDR_ANY4;
|
|
|
|
}
|
|
|
|
if (netmask == NULL) {
|
|
|
|
netmask = IP4_ADDR_ANY4;
|
|
|
|
}
|
|
|
|
if (gw == NULL) {
|
|
|
|
gw = IP4_ADDR_ANY4;
|
|
|
|
}
|
|
|
|
|
2018-01-12 22:11:38 +00:00
|
|
|
remove = ip4_addr_isany(ipaddr);
|
|
|
|
if (remove) {
|
|
|
|
/* when removing an address, we have to remove it *before* changing netmask/gw
|
|
|
|
to ensure that tcp RST segment can be sent correctly */
|
|
|
|
if (netif_do_set_ipaddr(netif, ipaddr, &old_addr)) {
|
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
change_reason |= LWIP_NSC_IPV4_ADDRESS_CHANGED;
|
|
|
|
cb_args.ipv4_changed.old_address = &old_addr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (netif_do_set_netmask(netif, netmask, old_nm)) {
|
2018-01-09 06:51:09 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
2018-01-12 22:11:38 +00:00
|
|
|
change_reason |= LWIP_NSC_IPV4_NETMASK_CHANGED;
|
|
|
|
cb_args.ipv4_changed.old_netmask = old_nm;
|
|
|
|
#endif
|
2017-03-18 14:30:20 +00:00
|
|
|
}
|
2018-01-12 22:11:38 +00:00
|
|
|
if (netif_do_set_gw(netif, gw, old_gw)) {
|
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
change_reason |= LWIP_NSC_IPV4_GATEWAY_CHANGED;
|
|
|
|
cb_args.ipv4_changed.old_gw = old_gw;
|
2017-03-18 14:30:20 +00:00
|
|
|
#endif
|
2018-01-12 22:11:38 +00:00
|
|
|
}
|
|
|
|
if (!remove) {
|
2016-07-19 20:34:22 +00:00
|
|
|
/* set ipaddr last to ensure netmask/gw have been set when status callback is called */
|
2018-01-12 22:11:38 +00:00
|
|
|
if (netif_do_set_ipaddr(netif, ipaddr, &old_addr)) {
|
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
change_reason |= LWIP_NSC_IPV4_ADDRESS_CHANGED;
|
|
|
|
cb_args.ipv4_changed.old_address = &old_addr;
|
|
|
|
#endif
|
|
|
|
}
|
2016-07-19 20:34:22 +00:00
|
|
|
}
|
2017-02-13 20:40:08 +00:00
|
|
|
|
2017-03-18 14:30:20 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
2018-01-12 22:11:38 +00:00
|
|
|
if (change_reason != LWIP_NSC_NONE) {
|
|
|
|
change_reason |= LWIP_NSC_IPV4_SETTINGS_CHANGED;
|
2018-02-07 19:37:29 +00:00
|
|
|
netif_invoke_ext_callback(netif, change_reason, &cb_args);
|
2017-03-18 14:30:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
2003-03-07 10:55:58 +00:00
|
|
|
}
|
2015-04-09 20:21:15 +00:00
|
|
|
#endif /* LWIP_IPV4*/
|
2003-03-07 10:55:58 +00:00
|
|
|
|
2007-06-07 21:29:44 +00:00
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2007-06-07 21:29:44 +00:00
|
|
|
* Remove a network interface from the list of lwIP netifs.
|
|
|
|
*
|
|
|
|
* @param netif the network interface to remove
|
|
|
|
*/
|
2010-01-10 13:32:36 +00:00
|
|
|
void
|
|
|
|
netif_remove(struct netif *netif)
|
2003-02-06 22:18:56 +00:00
|
|
|
{
|
2016-08-24 18:51:05 +00:00
|
|
|
#if LWIP_IPV6
|
|
|
|
int i;
|
|
|
|
#endif
|
|
|
|
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2010-01-10 13:32:36 +00:00
|
|
|
if (netif == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2003-04-15 14:32:13 +00:00
|
|
|
|
2017-02-15 09:14:06 +00:00
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_NETIF_REMOVED, NULL);
|
2017-02-13 20:40:08 +00:00
|
|
|
|
2015-04-09 20:21:15 +00:00
|
|
|
#if LWIP_IPV4
|
2015-08-20 20:39:48 +00:00
|
|
|
if (!ip4_addr_isany_val(*netif_ip4_addr(netif))) {
|
2018-03-14 14:59:17 +00:00
|
|
|
netif_do_ip_addr_changed(netif_ip_addr4(netif), NULL);
|
2015-02-26 21:25:39 +00:00
|
|
|
}
|
|
|
|
|
2007-09-09 20:46:33 +00:00
|
|
|
#if LWIP_IGMP
|
|
|
|
/* stop IGMP processing */
|
|
|
|
if (netif->flags & NETIF_FLAG_IGMP) {
|
2010-01-10 13:32:36 +00:00
|
|
|
igmp_stop(netif);
|
2007-09-09 20:46:33 +00:00
|
|
|
}
|
|
|
|
#endif /* LWIP_IGMP */
|
2015-04-09 20:21:15 +00:00
|
|
|
#endif /* LWIP_IPV4*/
|
|
|
|
|
2016-08-24 18:51:05 +00:00
|
|
|
#if LWIP_IPV6
|
|
|
|
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
|
|
|
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i))) {
|
2018-03-14 14:59:17 +00:00
|
|
|
netif_do_ip_addr_changed(netif_ip_addr6(netif, i), NULL);
|
2016-08-24 18:51:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#if LWIP_IPV6_MLD
|
2011-05-17 19:35:14 +00:00
|
|
|
/* stop MLD processing */
|
|
|
|
mld6_stop(netif);
|
2016-08-24 18:51:05 +00:00
|
|
|
#endif /* LWIP_IPV6_MLD */
|
|
|
|
#endif /* LWIP_IPV6 */
|
2010-01-10 13:34:21 +00:00
|
|
|
if (netif_is_up(netif)) {
|
|
|
|
/* set netif down before removing (call callback function) */
|
|
|
|
netif_set_down(netif);
|
|
|
|
}
|
2007-09-09 20:46:33 +00:00
|
|
|
|
2015-09-08 07:47:30 +00:00
|
|
|
mib2_remove_ip4(netif);
|
2006-09-01 07:14:50 +00:00
|
|
|
|
2015-02-26 21:25:39 +00:00
|
|
|
/* this netif is default? */
|
|
|
|
if (netif_default == netif) {
|
|
|
|
/* reset default netif */
|
|
|
|
netif_set_default(NULL);
|
|
|
|
}
|
2017-03-01 15:10:50 +00:00
|
|
|
#if !LWIP_SINGLE_NETIF
|
2003-04-15 14:32:13 +00:00
|
|
|
/* is it the first netif? */
|
|
|
|
if (netif_list == netif) {
|
|
|
|
netif_list = netif->next;
|
2010-01-10 13:32:36 +00:00
|
|
|
} else {
|
2003-04-15 14:32:13 +00:00
|
|
|
/* look for netif further down the list */
|
2017-09-17 18:38:38 +00:00
|
|
|
struct netif *tmp_netif;
|
2017-11-17 14:19:59 +00:00
|
|
|
NETIF_FOREACH(tmp_netif) {
|
2015-02-26 21:25:39 +00:00
|
|
|
if (tmp_netif->next == netif) {
|
|
|
|
tmp_netif->next = netif->next;
|
2003-04-15 14:32:13 +00:00
|
|
|
break;
|
2006-07-14 09:58:02 +00:00
|
|
|
}
|
2003-06-09 21:14:47 +00:00
|
|
|
}
|
2015-02-26 21:25:39 +00:00
|
|
|
if (tmp_netif == NULL) {
|
|
|
|
return; /* netif is not on the list */
|
|
|
|
}
|
2003-04-15 14:32:13 +00:00
|
|
|
}
|
2017-03-01 15:10:50 +00:00
|
|
|
#endif /* !LWIP_SINGLE_NETIF */
|
2015-09-08 07:47:30 +00:00
|
|
|
mib2_netif_removed(netif);
|
2011-08-24 20:00:10 +00:00
|
|
|
#if LWIP_NETIF_REMOVE_CALLBACK
|
|
|
|
if (netif->remove_callback) {
|
|
|
|
netif->remove_callback(netif);
|
|
|
|
}
|
|
|
|
#endif /* LWIP_NETIF_REMOVE_CALLBACK */
|
2003-06-10 10:45:29 +00:00
|
|
|
LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") );
|
2003-02-06 22:18:56 +00:00
|
|
|
}
|
|
|
|
|
2007-06-07 21:29:44 +00:00
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2007-06-07 21:29:44 +00:00
|
|
|
* Set a network interface as the default network interface
|
|
|
|
* (used to output all packets for which no specific route is found)
|
|
|
|
*
|
|
|
|
* @param netif the default network interface
|
|
|
|
*/
|
2002-10-19 12:59:30 +00:00
|
|
|
void
|
|
|
|
netif_set_default(struct netif *netif)
|
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2010-01-10 13:32:36 +00:00
|
|
|
if (netif == NULL) {
|
2006-09-01 07:14:50 +00:00
|
|
|
/* remove default route */
|
2015-09-08 07:47:30 +00:00
|
|
|
mib2_remove_route_ip4(1, netif);
|
2010-01-10 13:32:36 +00:00
|
|
|
} else {
|
2006-09-01 07:14:50 +00:00
|
|
|
/* install default route */
|
2015-09-08 07:47:30 +00:00
|
|
|
mib2_add_route_ip4(1, netif);
|
2006-09-01 07:14:50 +00:00
|
|
|
}
|
2002-10-19 12:59:30 +00:00
|
|
|
netif_default = netif;
|
2003-06-10 10:45:29 +00:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
|
2017-09-17 18:38:38 +00:00
|
|
|
netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
|
2002-10-19 12:59:30 +00:00
|
|
|
}
|
2003-11-14 13:17:23 +00:00
|
|
|
|
2004-06-30 18:38:07 +00:00
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2004-06-30 18:38:07 +00:00
|
|
|
* Bring an interface up, available for processing
|
|
|
|
* traffic.
|
2015-10-06 19:08:28 +00:00
|
|
|
*/
|
2015-10-06 19:57:40 +00:00
|
|
|
void
|
|
|
|
netif_set_up(struct netif *netif)
|
2004-06-30 18:38:07 +00:00
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ERROR("netif_set_up: invalid netif", netif != NULL, return);
|
|
|
|
|
2010-01-10 13:32:36 +00:00
|
|
|
if (!(netif->flags & NETIF_FLAG_UP)) {
|
2017-06-25 21:01:57 +00:00
|
|
|
netif_set_flags(netif, NETIF_FLAG_UP);
|
2015-03-05 19:57:43 +00:00
|
|
|
|
2015-09-08 07:47:30 +00:00
|
|
|
MIB2_COPY_SYSUPTIME_TO(&netif->ts);
|
2007-03-28 09:23:35 +00:00
|
|
|
|
2007-07-13 15:00:40 +00:00
|
|
|
NETIF_STATUS_CALLBACK(netif);
|
2017-02-15 09:14:06 +00:00
|
|
|
|
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
{
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.status_changed.state = 1;
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_STATUS_CHANGED, &args);
|
|
|
|
}
|
|
|
|
#endif
|
2007-03-28 09:23:35 +00:00
|
|
|
|
2017-11-08 18:55:33 +00:00
|
|
|
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
|
2018-06-08 20:18:50 +00:00
|
|
|
#if LWIP_IPV6
|
|
|
|
nd6_restart_netif(netif);
|
|
|
|
#endif /* LWIP_IPV6 */
|
2015-03-05 19:57:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Send ARP/IGMP/MLD/RS events, e.g. on link-up/netif-up or addr-change
|
|
|
|
*/
|
|
|
|
static void
|
2017-09-17 18:38:38 +00:00
|
|
|
netif_issue_reports(struct netif *netif, u8_t report_type)
|
2015-03-05 19:57:43 +00:00
|
|
|
{
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_issue_reports: invalid netif", netif != NULL);
|
|
|
|
|
2017-11-08 18:55:33 +00:00
|
|
|
/* Only send reports when both link and admin states are up */
|
|
|
|
if (!(netif->flags & NETIF_FLAG_LINK_UP) ||
|
|
|
|
!(netif->flags & NETIF_FLAG_UP)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-09 20:21:15 +00:00
|
|
|
#if LWIP_IPV4
|
2015-03-05 19:57:43 +00:00
|
|
|
if ((report_type & NETIF_REPORT_TYPE_IPV4) &&
|
2015-08-20 20:39:48 +00:00
|
|
|
!ip4_addr_isany_val(*netif_ip4_addr(netif))) {
|
ACD module added + update and improve DHCP + AUTOIP behavior
Squashed commit of the following:
commit 2d98d8e2ef1941c3824ffb874f1e529d284667fc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:15:06 2018 +0200
AUTOIP: correct functionality autoip_supplied_address
It does not mean that if autoip is bound, it also supplied the
netif address. A check is added.
commit 2ca0a2183991ef73860c4207d95799b37acc64cc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:06:49 2018 +0200
AUTOIP: keep using the same link local address as much as possible
Only calculate a new link local address at start up or when a
conflict occured. On link up or down -> keep same address.
TODO: in the future a function for persistent storage should be
added.
commit aa70a693351e4c898aa28d8521308794614838f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 14:43:14 2018 +0200
ACD, AUTOIP & DHCP: make link up & down functions where needed
When the link goes down or up the approriate functions should be
stopped or started again. To accomodate this, network_changed is
adjusted to network_changed_link_up and network_changed_link_down.
DHCP does not need to control AUTOIP. AUTOIP can take care of
itself. The only thing DHCP needs to do is starting it when
discovering is failing. The AUTOIP state variable is removed from
DHCP.
commit ad469eb006b47f8a8c37f7c0de0216f47a8c19c7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 11:25:58 2018 +0200
ACD: add address change listener + passive conflict detection mode
In the case their previously was a LL address on a netif that
is now configured with a routable address, we want the LL
address to be able to keep receiving packets.
for as long as the LL address is available on the interface it
should do ongoing conflict detection. But we cannot defend when
the LL address is not the netif address any more.
An address change listener is added to detect when an ACD module
needs to go from active ongoing conflict detection to passive.
When a conflict is detected autoip is stopped and will not be able
to receive packets any more. Because we have a valid routable
address on the netif, autoip is not restarted.
commit 07c4ec20cea78e2b4a6f5599569abaf075619c62
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Sep 11 16:25:37 2018 +0200
ACD: make module reusable within a netif
DHCP and AUTOIP both have ACD running simultaniously. The ACD
struct is added to the DHCP and AUTOIP structs. In the netif a list
of ACD modules is kept to loop over if functions need to perform
some action on all ACD modules (for example tmr function). With
acd_add a module can be added to the list. ACD_FOREACH loops over
the list similar to NETIF_FOREACH.
commit ee3b4585b7768f5353dd80190a2929bad45f7ff4
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 10 16:36:18 2018 +0200
etharp & acd: add probe and announce functions to etharp.
The new probe and announce functions are independent of
netif->ip_addr. This means we can keep the LL address working
while we start to probe for the newly received routable address.
The netif->ip_addr does not need to be any for probing to work
with this patch.
commit 7d3032bae8f1b8081368a807682388eb642729e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 3 13:35:51 2018 +0200
autoip -> unused random function removed + small comment update
commit be749ba4eb26ddc69233c85d532dc035741275c5
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 16:37:36 2018 +0200
ACD: update comment in header
commit 4491842991c90b3a58fa327f70aa42f04174546b
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 15:44:45 2018 +0200
ACD: subscribe to link down messages to stop the acd process
When the link goes down the acd process should be stopped
independent of the acd client. Otherwise the acd will keep probing
or announcing while their simply is no connection.
commit 71f668aa7583354e132c20b3b50ba2c86bf08738
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 13:59:44 2018 +0200
DHCP coop autoip bug fix: wait after last discovery before starting autoip
After the last dhcp discovery we need to give the dhcp server the
time to respond. Currently the discovery message is send and autoip
is started simultaniously. This is changed. Autoip will now be started
after the next discovery timeout.
commit 0da16604ec079195533f2591f0d0f04bdf212a72
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 11:23:31 2018 +0200
ACD: rate limit interval bug solved -> first decline then wait then restart.
According the the ACD RFC we need to limit the rate of acquiring
and probing addresses after MAX_CONFLICTS. It is important to first
decline the address and stop the netif from using the address before
the time is started. After this rate limit time, the address acquiring
process can be started again.
To make this possible we had to change the callback function and
the location in the process were the rate limiting is done.
commit a89a0601a251acb14abe270116f38c6d25c2d7a9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:27:10 2018 +0200
DHCP: after a succesful dhcp_reboot, the address should be probed.
Reboot means that the connection was gone for some amount of time.
This is seen as a new connection for the ACD module so should be
the address should be probed before use.
commit 853afb448ba35c6e2b35e8238c9c367c599dece7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:19:12 2018 +0200
DHCP_DOES_ARP_CHECK changed to DHCP_DOES_ACD_CHECK
small update in opt.h to add the correct dependencies.
commit e28b4766bdef69e76f6170c470c93f5b251c579a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:05:43 2018 +0200
DHCP check code replaced by ACD module.
when DHCP_DOES_ARP_CHECK is enabled, the ACD module will take care
of address conflict detection. Via a call back function the DHCP
state machine will continue and bind to an address if no conflicts
are found.
dhcp_arp_reply is obsolete because the ACD module replaces its
function.
commit 52193a0f5d13e8786a4db2fff1f1a8f1367a4eba
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 16:05:22 2018 +0200
Issue 2 + 3 from Comment #5, task #13508 solved
Removed C++ comments and // ----... marks as requested.
commit 7faaf61275d67ccfb88ea7e26c249428c3088536
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 15:55:24 2018 +0200
Issue 1 from Comment #5, task #13508 solved
Comments added to clarify how arp messages are handled.
commit 9348aea22623b705759fd30b873f06a50a104d16
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:45:35 2018 +0200
acd: add comment for callback function
commit 49fdd1177c05b74d49fa179564dcaa5e650adbcc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:42:59 2018 +0200
autoip: Add debugging output and complete comments
commit 591856b82c029687a657a1b1ccc674522e6f4be0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:25:18 2018 +0200
Removed autoip from timeouts.c
We do not need a timer anymore. All timing is part of acd.
commit 3b3272fdd14015cfca0b3b6d149505b1cf0e36b6
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:22:32 2018 +0200
autoip_network_changed -> first bring down the netif and then acd
Make it do what it says in the comment
commit 77b0ccf96efd22774279c6f9b5bade18c5e42c59
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:21:23 2018 +0200
Simplified the autoIP states + update autoip_start()
commit 96e0581d36857f8b70c4b4cce4fb323fd3dd51ab
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:10:48 2018 +0200
Deleted unused variables, functions and defines from autoip module
The functionality is now embedded in the acd module so can be
removed from autoip.
commit 9296e2ebb4b51019aaccfc47e8b9f51b265d37cd
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:07:34 2018 +0200
Bug fix acd -> rate limiting needs to be after MAX conflicts
It was only after MAX conflicts + 1.
commit c55e16903c045d0ea84336b50eccbf24d3d097e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:52:45 2018 +0200
Small intruduction to module added
commit d1498a37293bd9f97f6b938b48e5980ab0a01bd1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:49:58 2018 +0200
Copyright information added
I based the copyright text on the other files. I'm not sure this
is how its done. I kept Dominik in their because I copied quite
some code from the autoip module.
commit 359a845ef5e73061832069f364b370634ee0b071
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:08:44 2018 +0200
Fixing comments in acd.c
commit 100d72549d0ef44157143d031848a727f5dfbe69
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 15:43:40 2018 +0200
Probe wait time and Probe interval time made random via lwip_rand
According to the RFC a random amount of time needs to be waited
before probing can be started also a random amount of time
needs to be waited between the probes.
The random time is calculated via the LWIP_RAND function (see
lwipopts and sys_arch).
commit f7f037c32e9416f8b803c3c7af617b871b55ee35
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:56:48 2018 +0200
autoip will start probing again when the network has changed
commit 1f40f6274195f24aa1b05caf82b79285ad189c2a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:55:47 2018 +0200
Duplicate code removed -> already present in autoip_start
commit be59431271da862a8ca330dbca638842c87765bc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:52:49 2018 +0200
add rate limiting to acd when too many conflicts are detected.
When more then max conflicts are detected during device on time,
the rate at which probing for a new address starts is limited.
For clarity we combined the conflict counting and the callback into
a new function acd_restart.
commit 91448455e95edb24c1f418c341b6fb306391f4f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:50:01 2018 +0200
ARP packet conflict detection added.
If a conflict is detected between the begin until after announce
wait, a new address needs to be chosen immediatly.
This can occur in two situations:
1) another host already has this ip address
2) another host is also probing for the same address.
If a conflict is detected during announcing or during the ongoing
conflict detection, we defend our ip address once. If a second
conflict occurs during defend interval, we take another ip address.
If not we can keep our address and connections.
When a conflict occurs and it's decided we need a new address,
autoip is simply restarted. To do: test if a acd stop is needed.
This will become more important when DHCP is added I believe.
commit 65f47ba9444d8b9f767dc908319579323eeb8664
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:33:44 2018 +0200
Update ACD state machine with PROBE_WAIT and and ANNOUNCE_WAIT
By adding the ANNOUNCE_WAIT state, we could remove duplicate code
that was present in the original autoip state implementation.
But because we cannot directly go to ANNOUNCING we needed this
extra state during the wait period. It also makes the different
states clearer.
Their is no need to number the enum because the compiler takes
care of this standard numbering.
Also a indent issue on the state machine code is solved here.
commit 2d9f4414c7b1f2ed35c0b5cea78dabb9c9afee77
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:28:33 2018 +0200
Added an extra check for etharp responses.
Their is no need to answer a request that is initiated by ourselves.
In my test case, a conflicting request would be seen here as a
request needing a reply. Which off course isn't needed at all.
The acd module will let the requester know that it is using our
ip address.
I could not think of a reason not to add this extra check but please
check if this doesn't break other functionality.
commit f84cc1dba4061219bd1aadb97bd340278db07cd7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:27:13 2018 +0200
Redirect all incoming ARP messages to the ACD module.
The ACD module will scan the packets and react on conflicts.
autoip does not need the arp packets any more.
commit 9faf266993cc2df0b9434720b59b5922f17d7d33
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:08:39 2018 +0200
Initiate acd from autoip implementation.
The state machine in autoip is now replaced by the acd module.
commit 40a5a40d911c98e6ee8566c0adce7716f26f20e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:05:59 2018 +0200
Add simple acd state machine to timer function.
This state machine will be started from acd_start and will go
through the probing and the announcing state. At this moment the
timings are made fixed for easy debugging. Will be made variable
afterwards.
commit 0a2629bf1f7942e80ec11bcc3e163ac1a2b9a580
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:44:19 2018 +0200
Disable gratuitous ARP send from netif_issue_report when acd is enabled
The acd module needs to be fully under control on what arp messages are
send. It wouldn't be a clean solution if we kept this announce as one
of the announce messages.
So when ACD is enabled, this message will not be send.
commit a7b9a4d5039168723c2043677176c5c8fc69f8df
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:42:46 2018 +0200
ARP probe and announce functions added.
Both use etharp_requests to send out an arp message.
commit e2f1ce3fa84e2ce01bc944d8049412e156cd7cc7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:26:07 2018 +0200
Add conflict callback mechanism to acd module
When starting the acd with acd_start, a conflict callback has to be
provided. After probing when no conflict is detected, the callback
is called with the conflict variable on 0. From the moment a conflict
is detected, it will be called set to 1.
By not making a fixed link between acd, autoip and dhcp but working
with callback functions the user (caller) can easily use it for
fixed ip too. This keeps the acd module completely independent from
the other application layer protocols.
commit 21e7995888d2941601e99873ee129d1ea927e3f7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:41:52 2018 +0200
acd_stop function added.
When calling this function the acd state machine will be put in
ACD_STATE_OFF. This will disable the acd functionality until
acd_start is called.
commit 503037fb462504e46a14ce7486bc763dbc6a8690
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:35:48 2018 +0200
acd_start function added
This function will allocate a struct for the acd module if one wasn't
added with acd_set_struct. It will then initialize the acd struct
and start the probe wait timer (for now fixed).
commit e439f6dffc44e93078a2976783bdebfe17304d8c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:22:39 2018 +0200
ACD_DEBUG define added for enabling / disabling debug messages.
commit 80d33e1eaf092934ace1045fac096464cd5be5e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:39:37 2018 +0200
ACD struct added together with set struct function
ACD needs some variables: state, timing, probe counter etc.
We added the struct as netif data. For now one ACD module per netif
is enough. We found some unclarities about ACD with multiple IP
address on one interface. For now, ACD will only be implemented for
the IP address that is going to be used / is being used on the netif.
commit 2c4cca36744973318c3efe7cbae6384b52dc71a8
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:35:06 2018 +0200
Add acd timer to timeouts.c with interval of 100ms.
This timer will be used for time to wait counting etc.
Very similar to the auto ip timer.
commit e2ed447e00c4df790df21509acb4ab09b5b79e66
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:56:39 2018 +0200
Add ACD protocol definitions
commit 445733214460eae18817556439bed979e9b3747c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:07:58 2018 +0200
Add c++ option (to use C code module in c++)
commit 63d78bc1f77ac6698c3d663a1c67b40a0c297125
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:57:34 2018 +0200
Added on off option for ACD module
commit d5ec4b69eb4175d4dd569bcfc80ae0e192780015
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:09:40 2018 +0200
ACD IPv4 module files added
The files for IPv4 ACD or Address Conflict Detection are added
to the lwip source.
2018-09-13 15:02:21 +00:00
|
|
|
#if LWIP_ARP && !LWIP_ACD
|
|
|
|
/* For Ethernet network interfaces:
|
|
|
|
* we would like to send a "gratuitous ARP".
|
2018-10-22 18:53:37 +00:00
|
|
|
* Only needs to be done here if ACD isn't configured.
|
ACD module added + update and improve DHCP + AUTOIP behavior
Squashed commit of the following:
commit 2d98d8e2ef1941c3824ffb874f1e529d284667fc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:15:06 2018 +0200
AUTOIP: correct functionality autoip_supplied_address
It does not mean that if autoip is bound, it also supplied the
netif address. A check is added.
commit 2ca0a2183991ef73860c4207d95799b37acc64cc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:06:49 2018 +0200
AUTOIP: keep using the same link local address as much as possible
Only calculate a new link local address at start up or when a
conflict occured. On link up or down -> keep same address.
TODO: in the future a function for persistent storage should be
added.
commit aa70a693351e4c898aa28d8521308794614838f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 14:43:14 2018 +0200
ACD, AUTOIP & DHCP: make link up & down functions where needed
When the link goes down or up the approriate functions should be
stopped or started again. To accomodate this, network_changed is
adjusted to network_changed_link_up and network_changed_link_down.
DHCP does not need to control AUTOIP. AUTOIP can take care of
itself. The only thing DHCP needs to do is starting it when
discovering is failing. The AUTOIP state variable is removed from
DHCP.
commit ad469eb006b47f8a8c37f7c0de0216f47a8c19c7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 11:25:58 2018 +0200
ACD: add address change listener + passive conflict detection mode
In the case their previously was a LL address on a netif that
is now configured with a routable address, we want the LL
address to be able to keep receiving packets.
for as long as the LL address is available on the interface it
should do ongoing conflict detection. But we cannot defend when
the LL address is not the netif address any more.
An address change listener is added to detect when an ACD module
needs to go from active ongoing conflict detection to passive.
When a conflict is detected autoip is stopped and will not be able
to receive packets any more. Because we have a valid routable
address on the netif, autoip is not restarted.
commit 07c4ec20cea78e2b4a6f5599569abaf075619c62
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Sep 11 16:25:37 2018 +0200
ACD: make module reusable within a netif
DHCP and AUTOIP both have ACD running simultaniously. The ACD
struct is added to the DHCP and AUTOIP structs. In the netif a list
of ACD modules is kept to loop over if functions need to perform
some action on all ACD modules (for example tmr function). With
acd_add a module can be added to the list. ACD_FOREACH loops over
the list similar to NETIF_FOREACH.
commit ee3b4585b7768f5353dd80190a2929bad45f7ff4
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 10 16:36:18 2018 +0200
etharp & acd: add probe and announce functions to etharp.
The new probe and announce functions are independent of
netif->ip_addr. This means we can keep the LL address working
while we start to probe for the newly received routable address.
The netif->ip_addr does not need to be any for probing to work
with this patch.
commit 7d3032bae8f1b8081368a807682388eb642729e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 3 13:35:51 2018 +0200
autoip -> unused random function removed + small comment update
commit be749ba4eb26ddc69233c85d532dc035741275c5
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 16:37:36 2018 +0200
ACD: update comment in header
commit 4491842991c90b3a58fa327f70aa42f04174546b
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 15:44:45 2018 +0200
ACD: subscribe to link down messages to stop the acd process
When the link goes down the acd process should be stopped
independent of the acd client. Otherwise the acd will keep probing
or announcing while their simply is no connection.
commit 71f668aa7583354e132c20b3b50ba2c86bf08738
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 13:59:44 2018 +0200
DHCP coop autoip bug fix: wait after last discovery before starting autoip
After the last dhcp discovery we need to give the dhcp server the
time to respond. Currently the discovery message is send and autoip
is started simultaniously. This is changed. Autoip will now be started
after the next discovery timeout.
commit 0da16604ec079195533f2591f0d0f04bdf212a72
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 11:23:31 2018 +0200
ACD: rate limit interval bug solved -> first decline then wait then restart.
According the the ACD RFC we need to limit the rate of acquiring
and probing addresses after MAX_CONFLICTS. It is important to first
decline the address and stop the netif from using the address before
the time is started. After this rate limit time, the address acquiring
process can be started again.
To make this possible we had to change the callback function and
the location in the process were the rate limiting is done.
commit a89a0601a251acb14abe270116f38c6d25c2d7a9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:27:10 2018 +0200
DHCP: after a succesful dhcp_reboot, the address should be probed.
Reboot means that the connection was gone for some amount of time.
This is seen as a new connection for the ACD module so should be
the address should be probed before use.
commit 853afb448ba35c6e2b35e8238c9c367c599dece7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:19:12 2018 +0200
DHCP_DOES_ARP_CHECK changed to DHCP_DOES_ACD_CHECK
small update in opt.h to add the correct dependencies.
commit e28b4766bdef69e76f6170c470c93f5b251c579a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:05:43 2018 +0200
DHCP check code replaced by ACD module.
when DHCP_DOES_ARP_CHECK is enabled, the ACD module will take care
of address conflict detection. Via a call back function the DHCP
state machine will continue and bind to an address if no conflicts
are found.
dhcp_arp_reply is obsolete because the ACD module replaces its
function.
commit 52193a0f5d13e8786a4db2fff1f1a8f1367a4eba
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 16:05:22 2018 +0200
Issue 2 + 3 from Comment #5, task #13508 solved
Removed C++ comments and // ----... marks as requested.
commit 7faaf61275d67ccfb88ea7e26c249428c3088536
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 15:55:24 2018 +0200
Issue 1 from Comment #5, task #13508 solved
Comments added to clarify how arp messages are handled.
commit 9348aea22623b705759fd30b873f06a50a104d16
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:45:35 2018 +0200
acd: add comment for callback function
commit 49fdd1177c05b74d49fa179564dcaa5e650adbcc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:42:59 2018 +0200
autoip: Add debugging output and complete comments
commit 591856b82c029687a657a1b1ccc674522e6f4be0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:25:18 2018 +0200
Removed autoip from timeouts.c
We do not need a timer anymore. All timing is part of acd.
commit 3b3272fdd14015cfca0b3b6d149505b1cf0e36b6
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:22:32 2018 +0200
autoip_network_changed -> first bring down the netif and then acd
Make it do what it says in the comment
commit 77b0ccf96efd22774279c6f9b5bade18c5e42c59
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:21:23 2018 +0200
Simplified the autoIP states + update autoip_start()
commit 96e0581d36857f8b70c4b4cce4fb323fd3dd51ab
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:10:48 2018 +0200
Deleted unused variables, functions and defines from autoip module
The functionality is now embedded in the acd module so can be
removed from autoip.
commit 9296e2ebb4b51019aaccfc47e8b9f51b265d37cd
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:07:34 2018 +0200
Bug fix acd -> rate limiting needs to be after MAX conflicts
It was only after MAX conflicts + 1.
commit c55e16903c045d0ea84336b50eccbf24d3d097e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:52:45 2018 +0200
Small intruduction to module added
commit d1498a37293bd9f97f6b938b48e5980ab0a01bd1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:49:58 2018 +0200
Copyright information added
I based the copyright text on the other files. I'm not sure this
is how its done. I kept Dominik in their because I copied quite
some code from the autoip module.
commit 359a845ef5e73061832069f364b370634ee0b071
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:08:44 2018 +0200
Fixing comments in acd.c
commit 100d72549d0ef44157143d031848a727f5dfbe69
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 15:43:40 2018 +0200
Probe wait time and Probe interval time made random via lwip_rand
According to the RFC a random amount of time needs to be waited
before probing can be started also a random amount of time
needs to be waited between the probes.
The random time is calculated via the LWIP_RAND function (see
lwipopts and sys_arch).
commit f7f037c32e9416f8b803c3c7af617b871b55ee35
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:56:48 2018 +0200
autoip will start probing again when the network has changed
commit 1f40f6274195f24aa1b05caf82b79285ad189c2a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:55:47 2018 +0200
Duplicate code removed -> already present in autoip_start
commit be59431271da862a8ca330dbca638842c87765bc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:52:49 2018 +0200
add rate limiting to acd when too many conflicts are detected.
When more then max conflicts are detected during device on time,
the rate at which probing for a new address starts is limited.
For clarity we combined the conflict counting and the callback into
a new function acd_restart.
commit 91448455e95edb24c1f418c341b6fb306391f4f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:50:01 2018 +0200
ARP packet conflict detection added.
If a conflict is detected between the begin until after announce
wait, a new address needs to be chosen immediatly.
This can occur in two situations:
1) another host already has this ip address
2) another host is also probing for the same address.
If a conflict is detected during announcing or during the ongoing
conflict detection, we defend our ip address once. If a second
conflict occurs during defend interval, we take another ip address.
If not we can keep our address and connections.
When a conflict occurs and it's decided we need a new address,
autoip is simply restarted. To do: test if a acd stop is needed.
This will become more important when DHCP is added I believe.
commit 65f47ba9444d8b9f767dc908319579323eeb8664
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:33:44 2018 +0200
Update ACD state machine with PROBE_WAIT and and ANNOUNCE_WAIT
By adding the ANNOUNCE_WAIT state, we could remove duplicate code
that was present in the original autoip state implementation.
But because we cannot directly go to ANNOUNCING we needed this
extra state during the wait period. It also makes the different
states clearer.
Their is no need to number the enum because the compiler takes
care of this standard numbering.
Also a indent issue on the state machine code is solved here.
commit 2d9f4414c7b1f2ed35c0b5cea78dabb9c9afee77
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:28:33 2018 +0200
Added an extra check for etharp responses.
Their is no need to answer a request that is initiated by ourselves.
In my test case, a conflicting request would be seen here as a
request needing a reply. Which off course isn't needed at all.
The acd module will let the requester know that it is using our
ip address.
I could not think of a reason not to add this extra check but please
check if this doesn't break other functionality.
commit f84cc1dba4061219bd1aadb97bd340278db07cd7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:27:13 2018 +0200
Redirect all incoming ARP messages to the ACD module.
The ACD module will scan the packets and react on conflicts.
autoip does not need the arp packets any more.
commit 9faf266993cc2df0b9434720b59b5922f17d7d33
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:08:39 2018 +0200
Initiate acd from autoip implementation.
The state machine in autoip is now replaced by the acd module.
commit 40a5a40d911c98e6ee8566c0adce7716f26f20e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:05:59 2018 +0200
Add simple acd state machine to timer function.
This state machine will be started from acd_start and will go
through the probing and the announcing state. At this moment the
timings are made fixed for easy debugging. Will be made variable
afterwards.
commit 0a2629bf1f7942e80ec11bcc3e163ac1a2b9a580
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:44:19 2018 +0200
Disable gratuitous ARP send from netif_issue_report when acd is enabled
The acd module needs to be fully under control on what arp messages are
send. It wouldn't be a clean solution if we kept this announce as one
of the announce messages.
So when ACD is enabled, this message will not be send.
commit a7b9a4d5039168723c2043677176c5c8fc69f8df
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:42:46 2018 +0200
ARP probe and announce functions added.
Both use etharp_requests to send out an arp message.
commit e2f1ce3fa84e2ce01bc944d8049412e156cd7cc7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:26:07 2018 +0200
Add conflict callback mechanism to acd module
When starting the acd with acd_start, a conflict callback has to be
provided. After probing when no conflict is detected, the callback
is called with the conflict variable on 0. From the moment a conflict
is detected, it will be called set to 1.
By not making a fixed link between acd, autoip and dhcp but working
with callback functions the user (caller) can easily use it for
fixed ip too. This keeps the acd module completely independent from
the other application layer protocols.
commit 21e7995888d2941601e99873ee129d1ea927e3f7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:41:52 2018 +0200
acd_stop function added.
When calling this function the acd state machine will be put in
ACD_STATE_OFF. This will disable the acd functionality until
acd_start is called.
commit 503037fb462504e46a14ce7486bc763dbc6a8690
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:35:48 2018 +0200
acd_start function added
This function will allocate a struct for the acd module if one wasn't
added with acd_set_struct. It will then initialize the acd struct
and start the probe wait timer (for now fixed).
commit e439f6dffc44e93078a2976783bdebfe17304d8c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:22:39 2018 +0200
ACD_DEBUG define added for enabling / disabling debug messages.
commit 80d33e1eaf092934ace1045fac096464cd5be5e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:39:37 2018 +0200
ACD struct added together with set struct function
ACD needs some variables: state, timing, probe counter etc.
We added the struct as netif data. For now one ACD module per netif
is enough. We found some unclarities about ACD with multiple IP
address on one interface. For now, ACD will only be implemented for
the IP address that is going to be used / is being used on the netif.
commit 2c4cca36744973318c3efe7cbae6384b52dc71a8
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:35:06 2018 +0200
Add acd timer to timeouts.c with interval of 100ms.
This timer will be used for time to wait counting etc.
Very similar to the auto ip timer.
commit e2ed447e00c4df790df21509acb4ab09b5b79e66
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:56:39 2018 +0200
Add ACD protocol definitions
commit 445733214460eae18817556439bed979e9b3747c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:07:58 2018 +0200
Add c++ option (to use C code module in c++)
commit 63d78bc1f77ac6698c3d663a1c67b40a0c297125
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:57:34 2018 +0200
Added on off option for ACD module
commit d5ec4b69eb4175d4dd569bcfc80ae0e192780015
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:09:40 2018 +0200
ACD IPv4 module files added
The files for IPv4 ACD or Address Conflict Detection are added
to the lwip source.
2018-09-13 15:02:21 +00:00
|
|
|
*/
|
2015-03-05 19:57:43 +00:00
|
|
|
if (netif->flags & (NETIF_FLAG_ETHARP)) {
|
|
|
|
etharp_gratuitous(netif);
|
|
|
|
}
|
2007-03-28 09:23:35 +00:00
|
|
|
#endif /* LWIP_ARP */
|
2009-08-24 13:12:37 +00:00
|
|
|
|
|
|
|
#if LWIP_IGMP
|
2015-03-05 19:57:43 +00:00
|
|
|
/* resend IGMP memberships */
|
|
|
|
if (netif->flags & NETIF_FLAG_IGMP) {
|
|
|
|
igmp_report_groups(netif);
|
|
|
|
}
|
2009-08-24 13:12:37 +00:00
|
|
|
#endif /* LWIP_IGMP */
|
2015-03-05 19:57:43 +00:00
|
|
|
}
|
2015-04-09 20:21:15 +00:00
|
|
|
#endif /* LWIP_IPV4 */
|
2011-05-17 19:35:14 +00:00
|
|
|
|
2015-03-05 19:57:43 +00:00
|
|
|
#if LWIP_IPV6
|
|
|
|
if (report_type & NETIF_REPORT_TYPE_IPV6) {
|
|
|
|
#if LWIP_IPV6_MLD
|
|
|
|
/* send mld memberships */
|
|
|
|
mld6_report_groups(netif);
|
|
|
|
#endif /* LWIP_IPV6_MLD */
|
2007-03-21 13:24:20 +00:00
|
|
|
}
|
2015-03-05 19:57:43 +00:00
|
|
|
#endif /* LWIP_IPV6 */
|
2004-06-30 18:38:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2004-06-30 18:38:07 +00:00
|
|
|
* Bring an interface down, disabling any traffic processing.
|
2015-10-06 19:08:28 +00:00
|
|
|
*/
|
2015-10-06 19:57:40 +00:00
|
|
|
void
|
|
|
|
netif_set_down(struct netif *netif)
|
2004-06-30 18:38:07 +00:00
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ERROR("netif_set_down: invalid netif", netif != NULL, return);
|
|
|
|
|
2010-01-10 13:32:36 +00:00
|
|
|
if (netif->flags & NETIF_FLAG_UP) {
|
2017-02-15 09:14:06 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
{
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.status_changed.state = 0;
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_STATUS_CHANGED, &args);
|
|
|
|
}
|
|
|
|
#endif
|
2017-02-14 20:02:38 +00:00
|
|
|
|
2017-06-25 21:01:57 +00:00
|
|
|
netif_clear_flags(netif, NETIF_FLAG_UP);
|
2015-09-08 07:52:22 +00:00
|
|
|
MIB2_COPY_SYSUPTIME_TO(&netif->ts);
|
2010-01-10 13:32:36 +00:00
|
|
|
|
2015-04-09 20:21:15 +00:00
|
|
|
#if LWIP_IPV4 && LWIP_ARP
|
2011-11-22 20:44:28 +00:00
|
|
|
if (netif->flags & NETIF_FLAG_ETHARP) {
|
|
|
|
etharp_cleanup_netif(netif);
|
|
|
|
}
|
2015-04-09 20:21:15 +00:00
|
|
|
#endif /* LWIP_IPV4 && LWIP_ARP */
|
2016-05-06 14:15:20 +00:00
|
|
|
|
|
|
|
#if LWIP_IPV6
|
|
|
|
nd6_cleanup_netif(netif);
|
|
|
|
#endif /* LWIP_IPV6 */
|
|
|
|
|
2010-01-10 13:32:36 +00:00
|
|
|
NETIF_STATUS_CALLBACK(netif);
|
|
|
|
}
|
2004-06-30 18:38:07 +00:00
|
|
|
}
|
|
|
|
|
2007-08-22 11:26:01 +00:00
|
|
|
#if LWIP_NETIF_STATUS_CALLBACK
|
2007-03-21 13:24:20 +00:00
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2015-03-05 19:57:43 +00:00
|
|
|
* Set callback to be called when interface is brought up/down or address is changed while up
|
2007-03-21 13:24:20 +00:00
|
|
|
*/
|
2015-10-06 19:57:40 +00:00
|
|
|
void
|
|
|
|
netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)
|
2007-03-21 13:24:20 +00:00
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2010-01-10 13:32:36 +00:00
|
|
|
if (netif) {
|
|
|
|
netif->status_callback = status_callback;
|
|
|
|
}
|
2007-03-21 13:24:20 +00:00
|
|
|
}
|
2007-08-22 11:26:01 +00:00
|
|
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
2007-07-13 15:00:40 +00:00
|
|
|
|
2011-08-24 20:00:10 +00:00
|
|
|
#if LWIP_NETIF_REMOVE_CALLBACK
|
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2011-08-24 20:00:10 +00:00
|
|
|
* Set callback to be called when the interface has been removed
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback)
|
|
|
|
{
|
2018-01-05 08:05:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2011-08-24 20:00:10 +00:00
|
|
|
if (netif) {
|
|
|
|
netif->remove_callback = remove_callback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* LWIP_NETIF_REMOVE_CALLBACK */
|
|
|
|
|
2007-07-13 15:00:40 +00:00
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2007-07-13 15:00:40 +00:00
|
|
|
* Called by a driver when its link goes up
|
|
|
|
*/
|
2015-10-06 19:08:28 +00:00
|
|
|
void
|
|
|
|
netif_set_link_up(struct netif *netif)
|
2007-07-13 15:00:40 +00:00
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ERROR("netif_set_link_up: invalid netif", netif != NULL, return);
|
|
|
|
|
2010-02-12 16:50:23 +00:00
|
|
|
if (!(netif->flags & NETIF_FLAG_LINK_UP)) {
|
2017-06-25 21:01:57 +00:00
|
|
|
netif_set_flags(netif, NETIF_FLAG_LINK_UP);
|
2007-07-13 15:00:40 +00:00
|
|
|
|
2009-08-24 13:12:37 +00:00
|
|
|
#if LWIP_DHCP
|
ACD module added + update and improve DHCP + AUTOIP behavior
Squashed commit of the following:
commit 2d98d8e2ef1941c3824ffb874f1e529d284667fc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:15:06 2018 +0200
AUTOIP: correct functionality autoip_supplied_address
It does not mean that if autoip is bound, it also supplied the
netif address. A check is added.
commit 2ca0a2183991ef73860c4207d95799b37acc64cc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:06:49 2018 +0200
AUTOIP: keep using the same link local address as much as possible
Only calculate a new link local address at start up or when a
conflict occured. On link up or down -> keep same address.
TODO: in the future a function for persistent storage should be
added.
commit aa70a693351e4c898aa28d8521308794614838f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 14:43:14 2018 +0200
ACD, AUTOIP & DHCP: make link up & down functions where needed
When the link goes down or up the approriate functions should be
stopped or started again. To accomodate this, network_changed is
adjusted to network_changed_link_up and network_changed_link_down.
DHCP does not need to control AUTOIP. AUTOIP can take care of
itself. The only thing DHCP needs to do is starting it when
discovering is failing. The AUTOIP state variable is removed from
DHCP.
commit ad469eb006b47f8a8c37f7c0de0216f47a8c19c7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 11:25:58 2018 +0200
ACD: add address change listener + passive conflict detection mode
In the case their previously was a LL address on a netif that
is now configured with a routable address, we want the LL
address to be able to keep receiving packets.
for as long as the LL address is available on the interface it
should do ongoing conflict detection. But we cannot defend when
the LL address is not the netif address any more.
An address change listener is added to detect when an ACD module
needs to go from active ongoing conflict detection to passive.
When a conflict is detected autoip is stopped and will not be able
to receive packets any more. Because we have a valid routable
address on the netif, autoip is not restarted.
commit 07c4ec20cea78e2b4a6f5599569abaf075619c62
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Sep 11 16:25:37 2018 +0200
ACD: make module reusable within a netif
DHCP and AUTOIP both have ACD running simultaniously. The ACD
struct is added to the DHCP and AUTOIP structs. In the netif a list
of ACD modules is kept to loop over if functions need to perform
some action on all ACD modules (for example tmr function). With
acd_add a module can be added to the list. ACD_FOREACH loops over
the list similar to NETIF_FOREACH.
commit ee3b4585b7768f5353dd80190a2929bad45f7ff4
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 10 16:36:18 2018 +0200
etharp & acd: add probe and announce functions to etharp.
The new probe and announce functions are independent of
netif->ip_addr. This means we can keep the LL address working
while we start to probe for the newly received routable address.
The netif->ip_addr does not need to be any for probing to work
with this patch.
commit 7d3032bae8f1b8081368a807682388eb642729e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 3 13:35:51 2018 +0200
autoip -> unused random function removed + small comment update
commit be749ba4eb26ddc69233c85d532dc035741275c5
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 16:37:36 2018 +0200
ACD: update comment in header
commit 4491842991c90b3a58fa327f70aa42f04174546b
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 15:44:45 2018 +0200
ACD: subscribe to link down messages to stop the acd process
When the link goes down the acd process should be stopped
independent of the acd client. Otherwise the acd will keep probing
or announcing while their simply is no connection.
commit 71f668aa7583354e132c20b3b50ba2c86bf08738
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 13:59:44 2018 +0200
DHCP coop autoip bug fix: wait after last discovery before starting autoip
After the last dhcp discovery we need to give the dhcp server the
time to respond. Currently the discovery message is send and autoip
is started simultaniously. This is changed. Autoip will now be started
after the next discovery timeout.
commit 0da16604ec079195533f2591f0d0f04bdf212a72
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 11:23:31 2018 +0200
ACD: rate limit interval bug solved -> first decline then wait then restart.
According the the ACD RFC we need to limit the rate of acquiring
and probing addresses after MAX_CONFLICTS. It is important to first
decline the address and stop the netif from using the address before
the time is started. After this rate limit time, the address acquiring
process can be started again.
To make this possible we had to change the callback function and
the location in the process were the rate limiting is done.
commit a89a0601a251acb14abe270116f38c6d25c2d7a9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:27:10 2018 +0200
DHCP: after a succesful dhcp_reboot, the address should be probed.
Reboot means that the connection was gone for some amount of time.
This is seen as a new connection for the ACD module so should be
the address should be probed before use.
commit 853afb448ba35c6e2b35e8238c9c367c599dece7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:19:12 2018 +0200
DHCP_DOES_ARP_CHECK changed to DHCP_DOES_ACD_CHECK
small update in opt.h to add the correct dependencies.
commit e28b4766bdef69e76f6170c470c93f5b251c579a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:05:43 2018 +0200
DHCP check code replaced by ACD module.
when DHCP_DOES_ARP_CHECK is enabled, the ACD module will take care
of address conflict detection. Via a call back function the DHCP
state machine will continue and bind to an address if no conflicts
are found.
dhcp_arp_reply is obsolete because the ACD module replaces its
function.
commit 52193a0f5d13e8786a4db2fff1f1a8f1367a4eba
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 16:05:22 2018 +0200
Issue 2 + 3 from Comment #5, task #13508 solved
Removed C++ comments and // ----... marks as requested.
commit 7faaf61275d67ccfb88ea7e26c249428c3088536
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 15:55:24 2018 +0200
Issue 1 from Comment #5, task #13508 solved
Comments added to clarify how arp messages are handled.
commit 9348aea22623b705759fd30b873f06a50a104d16
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:45:35 2018 +0200
acd: add comment for callback function
commit 49fdd1177c05b74d49fa179564dcaa5e650adbcc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:42:59 2018 +0200
autoip: Add debugging output and complete comments
commit 591856b82c029687a657a1b1ccc674522e6f4be0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:25:18 2018 +0200
Removed autoip from timeouts.c
We do not need a timer anymore. All timing is part of acd.
commit 3b3272fdd14015cfca0b3b6d149505b1cf0e36b6
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:22:32 2018 +0200
autoip_network_changed -> first bring down the netif and then acd
Make it do what it says in the comment
commit 77b0ccf96efd22774279c6f9b5bade18c5e42c59
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:21:23 2018 +0200
Simplified the autoIP states + update autoip_start()
commit 96e0581d36857f8b70c4b4cce4fb323fd3dd51ab
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:10:48 2018 +0200
Deleted unused variables, functions and defines from autoip module
The functionality is now embedded in the acd module so can be
removed from autoip.
commit 9296e2ebb4b51019aaccfc47e8b9f51b265d37cd
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:07:34 2018 +0200
Bug fix acd -> rate limiting needs to be after MAX conflicts
It was only after MAX conflicts + 1.
commit c55e16903c045d0ea84336b50eccbf24d3d097e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:52:45 2018 +0200
Small intruduction to module added
commit d1498a37293bd9f97f6b938b48e5980ab0a01bd1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:49:58 2018 +0200
Copyright information added
I based the copyright text on the other files. I'm not sure this
is how its done. I kept Dominik in their because I copied quite
some code from the autoip module.
commit 359a845ef5e73061832069f364b370634ee0b071
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:08:44 2018 +0200
Fixing comments in acd.c
commit 100d72549d0ef44157143d031848a727f5dfbe69
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 15:43:40 2018 +0200
Probe wait time and Probe interval time made random via lwip_rand
According to the RFC a random amount of time needs to be waited
before probing can be started also a random amount of time
needs to be waited between the probes.
The random time is calculated via the LWIP_RAND function (see
lwipopts and sys_arch).
commit f7f037c32e9416f8b803c3c7af617b871b55ee35
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:56:48 2018 +0200
autoip will start probing again when the network has changed
commit 1f40f6274195f24aa1b05caf82b79285ad189c2a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:55:47 2018 +0200
Duplicate code removed -> already present in autoip_start
commit be59431271da862a8ca330dbca638842c87765bc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:52:49 2018 +0200
add rate limiting to acd when too many conflicts are detected.
When more then max conflicts are detected during device on time,
the rate at which probing for a new address starts is limited.
For clarity we combined the conflict counting and the callback into
a new function acd_restart.
commit 91448455e95edb24c1f418c341b6fb306391f4f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:50:01 2018 +0200
ARP packet conflict detection added.
If a conflict is detected between the begin until after announce
wait, a new address needs to be chosen immediatly.
This can occur in two situations:
1) another host already has this ip address
2) another host is also probing for the same address.
If a conflict is detected during announcing or during the ongoing
conflict detection, we defend our ip address once. If a second
conflict occurs during defend interval, we take another ip address.
If not we can keep our address and connections.
When a conflict occurs and it's decided we need a new address,
autoip is simply restarted. To do: test if a acd stop is needed.
This will become more important when DHCP is added I believe.
commit 65f47ba9444d8b9f767dc908319579323eeb8664
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:33:44 2018 +0200
Update ACD state machine with PROBE_WAIT and and ANNOUNCE_WAIT
By adding the ANNOUNCE_WAIT state, we could remove duplicate code
that was present in the original autoip state implementation.
But because we cannot directly go to ANNOUNCING we needed this
extra state during the wait period. It also makes the different
states clearer.
Their is no need to number the enum because the compiler takes
care of this standard numbering.
Also a indent issue on the state machine code is solved here.
commit 2d9f4414c7b1f2ed35c0b5cea78dabb9c9afee77
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:28:33 2018 +0200
Added an extra check for etharp responses.
Their is no need to answer a request that is initiated by ourselves.
In my test case, a conflicting request would be seen here as a
request needing a reply. Which off course isn't needed at all.
The acd module will let the requester know that it is using our
ip address.
I could not think of a reason not to add this extra check but please
check if this doesn't break other functionality.
commit f84cc1dba4061219bd1aadb97bd340278db07cd7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:27:13 2018 +0200
Redirect all incoming ARP messages to the ACD module.
The ACD module will scan the packets and react on conflicts.
autoip does not need the arp packets any more.
commit 9faf266993cc2df0b9434720b59b5922f17d7d33
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:08:39 2018 +0200
Initiate acd from autoip implementation.
The state machine in autoip is now replaced by the acd module.
commit 40a5a40d911c98e6ee8566c0adce7716f26f20e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:05:59 2018 +0200
Add simple acd state machine to timer function.
This state machine will be started from acd_start and will go
through the probing and the announcing state. At this moment the
timings are made fixed for easy debugging. Will be made variable
afterwards.
commit 0a2629bf1f7942e80ec11bcc3e163ac1a2b9a580
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:44:19 2018 +0200
Disable gratuitous ARP send from netif_issue_report when acd is enabled
The acd module needs to be fully under control on what arp messages are
send. It wouldn't be a clean solution if we kept this announce as one
of the announce messages.
So when ACD is enabled, this message will not be send.
commit a7b9a4d5039168723c2043677176c5c8fc69f8df
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:42:46 2018 +0200
ARP probe and announce functions added.
Both use etharp_requests to send out an arp message.
commit e2f1ce3fa84e2ce01bc944d8049412e156cd7cc7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:26:07 2018 +0200
Add conflict callback mechanism to acd module
When starting the acd with acd_start, a conflict callback has to be
provided. After probing when no conflict is detected, the callback
is called with the conflict variable on 0. From the moment a conflict
is detected, it will be called set to 1.
By not making a fixed link between acd, autoip and dhcp but working
with callback functions the user (caller) can easily use it for
fixed ip too. This keeps the acd module completely independent from
the other application layer protocols.
commit 21e7995888d2941601e99873ee129d1ea927e3f7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:41:52 2018 +0200
acd_stop function added.
When calling this function the acd state machine will be put in
ACD_STATE_OFF. This will disable the acd functionality until
acd_start is called.
commit 503037fb462504e46a14ce7486bc763dbc6a8690
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:35:48 2018 +0200
acd_start function added
This function will allocate a struct for the acd module if one wasn't
added with acd_set_struct. It will then initialize the acd struct
and start the probe wait timer (for now fixed).
commit e439f6dffc44e93078a2976783bdebfe17304d8c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:22:39 2018 +0200
ACD_DEBUG define added for enabling / disabling debug messages.
commit 80d33e1eaf092934ace1045fac096464cd5be5e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:39:37 2018 +0200
ACD struct added together with set struct function
ACD needs some variables: state, timing, probe counter etc.
We added the struct as netif data. For now one ACD module per netif
is enough. We found some unclarities about ACD with multiple IP
address on one interface. For now, ACD will only be implemented for
the IP address that is going to be used / is being used on the netif.
commit 2c4cca36744973318c3efe7cbae6384b52dc71a8
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:35:06 2018 +0200
Add acd timer to timeouts.c with interval of 100ms.
This timer will be used for time to wait counting etc.
Very similar to the auto ip timer.
commit e2ed447e00c4df790df21509acb4ab09b5b79e66
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:56:39 2018 +0200
Add ACD protocol definitions
commit 445733214460eae18817556439bed979e9b3747c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:07:58 2018 +0200
Add c++ option (to use C code module in c++)
commit 63d78bc1f77ac6698c3d663a1c67b40a0c297125
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:57:34 2018 +0200
Added on off option for ACD module
commit d5ec4b69eb4175d4dd569bcfc80ae0e192780015
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:09:40 2018 +0200
ACD IPv4 module files added
The files for IPv4 ACD or Address Conflict Detection are added
to the lwip source.
2018-09-13 15:02:21 +00:00
|
|
|
dhcp_network_changed_link_up(netif);
|
2009-08-24 13:12:37 +00:00
|
|
|
#endif /* LWIP_DHCP */
|
|
|
|
|
2009-08-24 13:11:35 +00:00
|
|
|
#if LWIP_AUTOIP
|
ACD module added + update and improve DHCP + AUTOIP behavior
Squashed commit of the following:
commit 2d98d8e2ef1941c3824ffb874f1e529d284667fc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:15:06 2018 +0200
AUTOIP: correct functionality autoip_supplied_address
It does not mean that if autoip is bound, it also supplied the
netif address. A check is added.
commit 2ca0a2183991ef73860c4207d95799b37acc64cc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:06:49 2018 +0200
AUTOIP: keep using the same link local address as much as possible
Only calculate a new link local address at start up or when a
conflict occured. On link up or down -> keep same address.
TODO: in the future a function for persistent storage should be
added.
commit aa70a693351e4c898aa28d8521308794614838f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 14:43:14 2018 +0200
ACD, AUTOIP & DHCP: make link up & down functions where needed
When the link goes down or up the approriate functions should be
stopped or started again. To accomodate this, network_changed is
adjusted to network_changed_link_up and network_changed_link_down.
DHCP does not need to control AUTOIP. AUTOIP can take care of
itself. The only thing DHCP needs to do is starting it when
discovering is failing. The AUTOIP state variable is removed from
DHCP.
commit ad469eb006b47f8a8c37f7c0de0216f47a8c19c7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 11:25:58 2018 +0200
ACD: add address change listener + passive conflict detection mode
In the case their previously was a LL address on a netif that
is now configured with a routable address, we want the LL
address to be able to keep receiving packets.
for as long as the LL address is available on the interface it
should do ongoing conflict detection. But we cannot defend when
the LL address is not the netif address any more.
An address change listener is added to detect when an ACD module
needs to go from active ongoing conflict detection to passive.
When a conflict is detected autoip is stopped and will not be able
to receive packets any more. Because we have a valid routable
address on the netif, autoip is not restarted.
commit 07c4ec20cea78e2b4a6f5599569abaf075619c62
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Sep 11 16:25:37 2018 +0200
ACD: make module reusable within a netif
DHCP and AUTOIP both have ACD running simultaniously. The ACD
struct is added to the DHCP and AUTOIP structs. In the netif a list
of ACD modules is kept to loop over if functions need to perform
some action on all ACD modules (for example tmr function). With
acd_add a module can be added to the list. ACD_FOREACH loops over
the list similar to NETIF_FOREACH.
commit ee3b4585b7768f5353dd80190a2929bad45f7ff4
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 10 16:36:18 2018 +0200
etharp & acd: add probe and announce functions to etharp.
The new probe and announce functions are independent of
netif->ip_addr. This means we can keep the LL address working
while we start to probe for the newly received routable address.
The netif->ip_addr does not need to be any for probing to work
with this patch.
commit 7d3032bae8f1b8081368a807682388eb642729e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 3 13:35:51 2018 +0200
autoip -> unused random function removed + small comment update
commit be749ba4eb26ddc69233c85d532dc035741275c5
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 16:37:36 2018 +0200
ACD: update comment in header
commit 4491842991c90b3a58fa327f70aa42f04174546b
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 15:44:45 2018 +0200
ACD: subscribe to link down messages to stop the acd process
When the link goes down the acd process should be stopped
independent of the acd client. Otherwise the acd will keep probing
or announcing while their simply is no connection.
commit 71f668aa7583354e132c20b3b50ba2c86bf08738
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 13:59:44 2018 +0200
DHCP coop autoip bug fix: wait after last discovery before starting autoip
After the last dhcp discovery we need to give the dhcp server the
time to respond. Currently the discovery message is send and autoip
is started simultaniously. This is changed. Autoip will now be started
after the next discovery timeout.
commit 0da16604ec079195533f2591f0d0f04bdf212a72
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 11:23:31 2018 +0200
ACD: rate limit interval bug solved -> first decline then wait then restart.
According the the ACD RFC we need to limit the rate of acquiring
and probing addresses after MAX_CONFLICTS. It is important to first
decline the address and stop the netif from using the address before
the time is started. After this rate limit time, the address acquiring
process can be started again.
To make this possible we had to change the callback function and
the location in the process were the rate limiting is done.
commit a89a0601a251acb14abe270116f38c6d25c2d7a9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:27:10 2018 +0200
DHCP: after a succesful dhcp_reboot, the address should be probed.
Reboot means that the connection was gone for some amount of time.
This is seen as a new connection for the ACD module so should be
the address should be probed before use.
commit 853afb448ba35c6e2b35e8238c9c367c599dece7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:19:12 2018 +0200
DHCP_DOES_ARP_CHECK changed to DHCP_DOES_ACD_CHECK
small update in opt.h to add the correct dependencies.
commit e28b4766bdef69e76f6170c470c93f5b251c579a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:05:43 2018 +0200
DHCP check code replaced by ACD module.
when DHCP_DOES_ARP_CHECK is enabled, the ACD module will take care
of address conflict detection. Via a call back function the DHCP
state machine will continue and bind to an address if no conflicts
are found.
dhcp_arp_reply is obsolete because the ACD module replaces its
function.
commit 52193a0f5d13e8786a4db2fff1f1a8f1367a4eba
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 16:05:22 2018 +0200
Issue 2 + 3 from Comment #5, task #13508 solved
Removed C++ comments and // ----... marks as requested.
commit 7faaf61275d67ccfb88ea7e26c249428c3088536
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 15:55:24 2018 +0200
Issue 1 from Comment #5, task #13508 solved
Comments added to clarify how arp messages are handled.
commit 9348aea22623b705759fd30b873f06a50a104d16
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:45:35 2018 +0200
acd: add comment for callback function
commit 49fdd1177c05b74d49fa179564dcaa5e650adbcc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:42:59 2018 +0200
autoip: Add debugging output and complete comments
commit 591856b82c029687a657a1b1ccc674522e6f4be0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:25:18 2018 +0200
Removed autoip from timeouts.c
We do not need a timer anymore. All timing is part of acd.
commit 3b3272fdd14015cfca0b3b6d149505b1cf0e36b6
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:22:32 2018 +0200
autoip_network_changed -> first bring down the netif and then acd
Make it do what it says in the comment
commit 77b0ccf96efd22774279c6f9b5bade18c5e42c59
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:21:23 2018 +0200
Simplified the autoIP states + update autoip_start()
commit 96e0581d36857f8b70c4b4cce4fb323fd3dd51ab
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:10:48 2018 +0200
Deleted unused variables, functions and defines from autoip module
The functionality is now embedded in the acd module so can be
removed from autoip.
commit 9296e2ebb4b51019aaccfc47e8b9f51b265d37cd
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:07:34 2018 +0200
Bug fix acd -> rate limiting needs to be after MAX conflicts
It was only after MAX conflicts + 1.
commit c55e16903c045d0ea84336b50eccbf24d3d097e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:52:45 2018 +0200
Small intruduction to module added
commit d1498a37293bd9f97f6b938b48e5980ab0a01bd1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:49:58 2018 +0200
Copyright information added
I based the copyright text on the other files. I'm not sure this
is how its done. I kept Dominik in their because I copied quite
some code from the autoip module.
commit 359a845ef5e73061832069f364b370634ee0b071
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:08:44 2018 +0200
Fixing comments in acd.c
commit 100d72549d0ef44157143d031848a727f5dfbe69
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 15:43:40 2018 +0200
Probe wait time and Probe interval time made random via lwip_rand
According to the RFC a random amount of time needs to be waited
before probing can be started also a random amount of time
needs to be waited between the probes.
The random time is calculated via the LWIP_RAND function (see
lwipopts and sys_arch).
commit f7f037c32e9416f8b803c3c7af617b871b55ee35
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:56:48 2018 +0200
autoip will start probing again when the network has changed
commit 1f40f6274195f24aa1b05caf82b79285ad189c2a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:55:47 2018 +0200
Duplicate code removed -> already present in autoip_start
commit be59431271da862a8ca330dbca638842c87765bc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:52:49 2018 +0200
add rate limiting to acd when too many conflicts are detected.
When more then max conflicts are detected during device on time,
the rate at which probing for a new address starts is limited.
For clarity we combined the conflict counting and the callback into
a new function acd_restart.
commit 91448455e95edb24c1f418c341b6fb306391f4f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:50:01 2018 +0200
ARP packet conflict detection added.
If a conflict is detected between the begin until after announce
wait, a new address needs to be chosen immediatly.
This can occur in two situations:
1) another host already has this ip address
2) another host is also probing for the same address.
If a conflict is detected during announcing or during the ongoing
conflict detection, we defend our ip address once. If a second
conflict occurs during defend interval, we take another ip address.
If not we can keep our address and connections.
When a conflict occurs and it's decided we need a new address,
autoip is simply restarted. To do: test if a acd stop is needed.
This will become more important when DHCP is added I believe.
commit 65f47ba9444d8b9f767dc908319579323eeb8664
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:33:44 2018 +0200
Update ACD state machine with PROBE_WAIT and and ANNOUNCE_WAIT
By adding the ANNOUNCE_WAIT state, we could remove duplicate code
that was present in the original autoip state implementation.
But because we cannot directly go to ANNOUNCING we needed this
extra state during the wait period. It also makes the different
states clearer.
Their is no need to number the enum because the compiler takes
care of this standard numbering.
Also a indent issue on the state machine code is solved here.
commit 2d9f4414c7b1f2ed35c0b5cea78dabb9c9afee77
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:28:33 2018 +0200
Added an extra check for etharp responses.
Their is no need to answer a request that is initiated by ourselves.
In my test case, a conflicting request would be seen here as a
request needing a reply. Which off course isn't needed at all.
The acd module will let the requester know that it is using our
ip address.
I could not think of a reason not to add this extra check but please
check if this doesn't break other functionality.
commit f84cc1dba4061219bd1aadb97bd340278db07cd7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:27:13 2018 +0200
Redirect all incoming ARP messages to the ACD module.
The ACD module will scan the packets and react on conflicts.
autoip does not need the arp packets any more.
commit 9faf266993cc2df0b9434720b59b5922f17d7d33
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:08:39 2018 +0200
Initiate acd from autoip implementation.
The state machine in autoip is now replaced by the acd module.
commit 40a5a40d911c98e6ee8566c0adce7716f26f20e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:05:59 2018 +0200
Add simple acd state machine to timer function.
This state machine will be started from acd_start and will go
through the probing and the announcing state. At this moment the
timings are made fixed for easy debugging. Will be made variable
afterwards.
commit 0a2629bf1f7942e80ec11bcc3e163ac1a2b9a580
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:44:19 2018 +0200
Disable gratuitous ARP send from netif_issue_report when acd is enabled
The acd module needs to be fully under control on what arp messages are
send. It wouldn't be a clean solution if we kept this announce as one
of the announce messages.
So when ACD is enabled, this message will not be send.
commit a7b9a4d5039168723c2043677176c5c8fc69f8df
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:42:46 2018 +0200
ARP probe and announce functions added.
Both use etharp_requests to send out an arp message.
commit e2f1ce3fa84e2ce01bc944d8049412e156cd7cc7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:26:07 2018 +0200
Add conflict callback mechanism to acd module
When starting the acd with acd_start, a conflict callback has to be
provided. After probing when no conflict is detected, the callback
is called with the conflict variable on 0. From the moment a conflict
is detected, it will be called set to 1.
By not making a fixed link between acd, autoip and dhcp but working
with callback functions the user (caller) can easily use it for
fixed ip too. This keeps the acd module completely independent from
the other application layer protocols.
commit 21e7995888d2941601e99873ee129d1ea927e3f7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:41:52 2018 +0200
acd_stop function added.
When calling this function the acd state machine will be put in
ACD_STATE_OFF. This will disable the acd functionality until
acd_start is called.
commit 503037fb462504e46a14ce7486bc763dbc6a8690
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:35:48 2018 +0200
acd_start function added
This function will allocate a struct for the acd module if one wasn't
added with acd_set_struct. It will then initialize the acd struct
and start the probe wait timer (for now fixed).
commit e439f6dffc44e93078a2976783bdebfe17304d8c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:22:39 2018 +0200
ACD_DEBUG define added for enabling / disabling debug messages.
commit 80d33e1eaf092934ace1045fac096464cd5be5e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:39:37 2018 +0200
ACD struct added together with set struct function
ACD needs some variables: state, timing, probe counter etc.
We added the struct as netif data. For now one ACD module per netif
is enough. We found some unclarities about ACD with multiple IP
address on one interface. For now, ACD will only be implemented for
the IP address that is going to be used / is being used on the netif.
commit 2c4cca36744973318c3efe7cbae6384b52dc71a8
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:35:06 2018 +0200
Add acd timer to timeouts.c with interval of 100ms.
This timer will be used for time to wait counting etc.
Very similar to the auto ip timer.
commit e2ed447e00c4df790df21509acb4ab09b5b79e66
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:56:39 2018 +0200
Add ACD protocol definitions
commit 445733214460eae18817556439bed979e9b3747c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:07:58 2018 +0200
Add c++ option (to use C code module in c++)
commit 63d78bc1f77ac6698c3d663a1c67b40a0c297125
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:57:34 2018 +0200
Added on off option for ACD module
commit d5ec4b69eb4175d4dd569bcfc80ae0e192780015
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:09:40 2018 +0200
ACD IPv4 module files added
The files for IPv4 ACD or Address Conflict Detection are added
to the lwip source.
2018-09-13 15:02:21 +00:00
|
|
|
autoip_network_changed_link_up(netif);
|
2009-08-24 13:11:35 +00:00
|
|
|
#endif /* LWIP_AUTOIP */
|
|
|
|
|
2017-11-08 18:55:33 +00:00
|
|
|
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
|
2018-06-08 20:18:50 +00:00
|
|
|
#if LWIP_IPV6
|
|
|
|
nd6_restart_netif(netif);
|
|
|
|
#endif /* LWIP_IPV6 */
|
2017-11-08 18:55:33 +00:00
|
|
|
|
2010-02-12 16:50:23 +00:00
|
|
|
NETIF_LINK_CALLBACK(netif);
|
2017-02-15 09:14:06 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
{
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.link_changed.state = 1;
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_LINK_CHANGED, &args);
|
|
|
|
}
|
|
|
|
#endif
|
2009-08-24 13:11:35 +00:00
|
|
|
}
|
2007-07-13 15:00:40 +00:00
|
|
|
}
|
2007-08-25 10:43:19 +00:00
|
|
|
|
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2007-08-25 10:43:19 +00:00
|
|
|
* Called by a driver when its link goes down
|
|
|
|
*/
|
2015-10-06 19:57:40 +00:00
|
|
|
void
|
2018-06-14 20:10:53 +00:00
|
|
|
netif_set_link_down(struct netif *netif)
|
2007-08-25 10:43:19 +00:00
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ERROR("netif_set_link_down: invalid netif", netif != NULL, return);
|
|
|
|
|
2010-02-12 16:50:23 +00:00
|
|
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
2017-06-25 21:01:57 +00:00
|
|
|
netif_clear_flags(netif, NETIF_FLAG_LINK_UP);
|
ACD module added + update and improve DHCP + AUTOIP behavior
Squashed commit of the following:
commit 2d98d8e2ef1941c3824ffb874f1e529d284667fc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:15:06 2018 +0200
AUTOIP: correct functionality autoip_supplied_address
It does not mean that if autoip is bound, it also supplied the
netif address. A check is added.
commit 2ca0a2183991ef73860c4207d95799b37acc64cc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 16:06:49 2018 +0200
AUTOIP: keep using the same link local address as much as possible
Only calculate a new link local address at start up or when a
conflict occured. On link up or down -> keep same address.
TODO: in the future a function for persistent storage should be
added.
commit aa70a693351e4c898aa28d8521308794614838f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 14:43:14 2018 +0200
ACD, AUTOIP & DHCP: make link up & down functions where needed
When the link goes down or up the approriate functions should be
stopped or started again. To accomodate this, network_changed is
adjusted to network_changed_link_up and network_changed_link_down.
DHCP does not need to control AUTOIP. AUTOIP can take care of
itself. The only thing DHCP needs to do is starting it when
discovering is failing. The AUTOIP state variable is removed from
DHCP.
commit ad469eb006b47f8a8c37f7c0de0216f47a8c19c7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Sep 13 11:25:58 2018 +0200
ACD: add address change listener + passive conflict detection mode
In the case their previously was a LL address on a netif that
is now configured with a routable address, we want the LL
address to be able to keep receiving packets.
for as long as the LL address is available on the interface it
should do ongoing conflict detection. But we cannot defend when
the LL address is not the netif address any more.
An address change listener is added to detect when an ACD module
needs to go from active ongoing conflict detection to passive.
When a conflict is detected autoip is stopped and will not be able
to receive packets any more. Because we have a valid routable
address on the netif, autoip is not restarted.
commit 07c4ec20cea78e2b4a6f5599569abaf075619c62
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Sep 11 16:25:37 2018 +0200
ACD: make module reusable within a netif
DHCP and AUTOIP both have ACD running simultaniously. The ACD
struct is added to the DHCP and AUTOIP structs. In the netif a list
of ACD modules is kept to loop over if functions need to perform
some action on all ACD modules (for example tmr function). With
acd_add a module can be added to the list. ACD_FOREACH loops over
the list similar to NETIF_FOREACH.
commit ee3b4585b7768f5353dd80190a2929bad45f7ff4
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 10 16:36:18 2018 +0200
etharp & acd: add probe and announce functions to etharp.
The new probe and announce functions are independent of
netif->ip_addr. This means we can keep the LL address working
while we start to probe for the newly received routable address.
The netif->ip_addr does not need to be any for probing to work
with this patch.
commit 7d3032bae8f1b8081368a807682388eb642729e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Sep 3 13:35:51 2018 +0200
autoip -> unused random function removed + small comment update
commit be749ba4eb26ddc69233c85d532dc035741275c5
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 16:37:36 2018 +0200
ACD: update comment in header
commit 4491842991c90b3a58fa327f70aa42f04174546b
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 15:44:45 2018 +0200
ACD: subscribe to link down messages to stop the acd process
When the link goes down the acd process should be stopped
independent of the acd client. Otherwise the acd will keep probing
or announcing while their simply is no connection.
commit 71f668aa7583354e132c20b3b50ba2c86bf08738
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 13:59:44 2018 +0200
DHCP coop autoip bug fix: wait after last discovery before starting autoip
After the last dhcp discovery we need to give the dhcp server the
time to respond. Currently the discovery message is send and autoip
is started simultaniously. This is changed. Autoip will now be started
after the next discovery timeout.
commit 0da16604ec079195533f2591f0d0f04bdf212a72
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Aug 31 11:23:31 2018 +0200
ACD: rate limit interval bug solved -> first decline then wait then restart.
According the the ACD RFC we need to limit the rate of acquiring
and probing addresses after MAX_CONFLICTS. It is important to first
decline the address and stop the netif from using the address before
the time is started. After this rate limit time, the address acquiring
process can be started again.
To make this possible we had to change the callback function and
the location in the process were the rate limiting is done.
commit a89a0601a251acb14abe270116f38c6d25c2d7a9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:27:10 2018 +0200
DHCP: after a succesful dhcp_reboot, the address should be probed.
Reboot means that the connection was gone for some amount of time.
This is seen as a new connection for the ACD module so should be
the address should be probed before use.
commit 853afb448ba35c6e2b35e8238c9c367c599dece7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:19:12 2018 +0200
DHCP_DOES_ARP_CHECK changed to DHCP_DOES_ACD_CHECK
small update in opt.h to add the correct dependencies.
commit e28b4766bdef69e76f6170c470c93f5b251c579a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Thu Aug 30 17:05:43 2018 +0200
DHCP check code replaced by ACD module.
when DHCP_DOES_ARP_CHECK is enabled, the ACD module will take care
of address conflict detection. Via a call back function the DHCP
state machine will continue and bind to an address if no conflicts
are found.
dhcp_arp_reply is obsolete because the ACD module replaces its
function.
commit 52193a0f5d13e8786a4db2fff1f1a8f1367a4eba
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 16:05:22 2018 +0200
Issue 2 + 3 from Comment #5, task #13508 solved
Removed C++ comments and // ----... marks as requested.
commit 7faaf61275d67ccfb88ea7e26c249428c3088536
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Aug 27 15:55:24 2018 +0200
Issue 1 from Comment #5, task #13508 solved
Comments added to clarify how arp messages are handled.
commit 9348aea22623b705759fd30b873f06a50a104d16
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:45:35 2018 +0200
acd: add comment for callback function
commit 49fdd1177c05b74d49fa179564dcaa5e650adbcc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:42:59 2018 +0200
autoip: Add debugging output and complete comments
commit 591856b82c029687a657a1b1ccc674522e6f4be0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:25:18 2018 +0200
Removed autoip from timeouts.c
We do not need a timer anymore. All timing is part of acd.
commit 3b3272fdd14015cfca0b3b6d149505b1cf0e36b6
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:22:32 2018 +0200
autoip_network_changed -> first bring down the netif and then acd
Make it do what it says in the comment
commit 77b0ccf96efd22774279c6f9b5bade18c5e42c59
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:21:23 2018 +0200
Simplified the autoIP states + update autoip_start()
commit 96e0581d36857f8b70c4b4cce4fb323fd3dd51ab
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:10:48 2018 +0200
Deleted unused variables, functions and defines from autoip module
The functionality is now embedded in the acd module so can be
removed from autoip.
commit 9296e2ebb4b51019aaccfc47e8b9f51b265d37cd
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 24 11:07:34 2018 +0200
Bug fix acd -> rate limiting needs to be after MAX conflicts
It was only after MAX conflicts + 1.
commit c55e16903c045d0ea84336b50eccbf24d3d097e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:52:45 2018 +0200
Small intruduction to module added
commit d1498a37293bd9f97f6b938b48e5980ab0a01bd1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:49:58 2018 +0200
Copyright information added
I based the copyright text on the other files. I'm not sure this
is how its done. I kept Dominik in their because I copied quite
some code from the autoip module.
commit 359a845ef5e73061832069f364b370634ee0b071
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 17:08:44 2018 +0200
Fixing comments in acd.c
commit 100d72549d0ef44157143d031848a727f5dfbe69
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 23 15:43:40 2018 +0200
Probe wait time and Probe interval time made random via lwip_rand
According to the RFC a random amount of time needs to be waited
before probing can be started also a random amount of time
needs to be waited between the probes.
The random time is calculated via the LWIP_RAND function (see
lwipopts and sys_arch).
commit f7f037c32e9416f8b803c3c7af617b871b55ee35
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:56:48 2018 +0200
autoip will start probing again when the network has changed
commit 1f40f6274195f24aa1b05caf82b79285ad189c2a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:55:47 2018 +0200
Duplicate code removed -> already present in autoip_start
commit be59431271da862a8ca330dbca638842c87765bc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 16:52:49 2018 +0200
add rate limiting to acd when too many conflicts are detected.
When more then max conflicts are detected during device on time,
the rate at which probing for a new address starts is limited.
For clarity we combined the conflict counting and the callback into
a new function acd_restart.
commit 91448455e95edb24c1f418c341b6fb306391f4f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:50:01 2018 +0200
ARP packet conflict detection added.
If a conflict is detected between the begin until after announce
wait, a new address needs to be chosen immediatly.
This can occur in two situations:
1) another host already has this ip address
2) another host is also probing for the same address.
If a conflict is detected during announcing or during the ongoing
conflict detection, we defend our ip address once. If a second
conflict occurs during defend interval, we take another ip address.
If not we can keep our address and connections.
When a conflict occurs and it's decided we need a new address,
autoip is simply restarted. To do: test if a acd stop is needed.
This will become more important when DHCP is added I believe.
commit 65f47ba9444d8b9f767dc908319579323eeb8664
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:33:44 2018 +0200
Update ACD state machine with PROBE_WAIT and and ANNOUNCE_WAIT
By adding the ANNOUNCE_WAIT state, we could remove duplicate code
that was present in the original autoip state implementation.
But because we cannot directly go to ANNOUNCING we needed this
extra state during the wait period. It also makes the different
states clearer.
Their is no need to number the enum because the compiler takes
care of this standard numbering.
Also a indent issue on the state machine code is solved here.
commit 2d9f4414c7b1f2ed35c0b5cea78dabb9c9afee77
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:28:33 2018 +0200
Added an extra check for etharp responses.
Their is no need to answer a request that is initiated by ourselves.
In my test case, a conflicting request would be seen here as a
request needing a reply. Which off course isn't needed at all.
The acd module will let the requester know that it is using our
ip address.
I could not think of a reason not to add this extra check but please
check if this doesn't break other functionality.
commit f84cc1dba4061219bd1aadb97bd340278db07cd7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 15:27:13 2018 +0200
Redirect all incoming ARP messages to the ACD module.
The ACD module will scan the packets and react on conflicts.
autoip does not need the arp packets any more.
commit 9faf266993cc2df0b9434720b59b5922f17d7d33
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:08:39 2018 +0200
Initiate acd from autoip implementation.
The state machine in autoip is now replaced by the acd module.
commit 40a5a40d911c98e6ee8566c0adce7716f26f20e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 10:05:59 2018 +0200
Add simple acd state machine to timer function.
This state machine will be started from acd_start and will go
through the probing and the announcing state. At this moment the
timings are made fixed for easy debugging. Will be made variable
afterwards.
commit 0a2629bf1f7942e80ec11bcc3e163ac1a2b9a580
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:44:19 2018 +0200
Disable gratuitous ARP send from netif_issue_report when acd is enabled
The acd module needs to be fully under control on what arp messages are
send. It wouldn't be a clean solution if we kept this announce as one
of the announce messages.
So when ACD is enabled, this message will not be send.
commit a7b9a4d5039168723c2043677176c5c8fc69f8df
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:42:46 2018 +0200
ARP probe and announce functions added.
Both use etharp_requests to send out an arp message.
commit e2f1ce3fa84e2ce01bc944d8049412e156cd7cc7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Tue Jul 17 09:26:07 2018 +0200
Add conflict callback mechanism to acd module
When starting the acd with acd_start, a conflict callback has to be
provided. After probing when no conflict is detected, the callback
is called with the conflict variable on 0. From the moment a conflict
is detected, it will be called set to 1.
By not making a fixed link between acd, autoip and dhcp but working
with callback functions the user (caller) can easily use it for
fixed ip too. This keeps the acd module completely independent from
the other application layer protocols.
commit 21e7995888d2941601e99873ee129d1ea927e3f7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:41:52 2018 +0200
acd_stop function added.
When calling this function the acd state machine will be put in
ACD_STATE_OFF. This will disable the acd functionality until
acd_start is called.
commit 503037fb462504e46a14ce7486bc763dbc6a8690
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:35:48 2018 +0200
acd_start function added
This function will allocate a struct for the acd module if one wasn't
added with acd_set_struct. It will then initialize the acd struct
and start the probe wait timer (for now fixed).
commit e439f6dffc44e93078a2976783bdebfe17304d8c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 14:22:39 2018 +0200
ACD_DEBUG define added for enabling / disabling debug messages.
commit 80d33e1eaf092934ace1045fac096464cd5be5e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:39:37 2018 +0200
ACD struct added together with set struct function
ACD needs some variables: state, timing, probe counter etc.
We added the struct as netif data. For now one ACD module per netif
is enough. We found some unclarities about ACD with multiple IP
address on one interface. For now, ACD will only be implemented for
the IP address that is going to be used / is being used on the netif.
commit 2c4cca36744973318c3efe7cbae6384b52dc71a8
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Mon Jul 16 11:35:06 2018 +0200
Add acd timer to timeouts.c with interval of 100ms.
This timer will be used for time to wait counting etc.
Very similar to the auto ip timer.
commit e2ed447e00c4df790df21509acb4ab09b5b79e66
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:56:39 2018 +0200
Add ACD protocol definitions
commit 445733214460eae18817556439bed979e9b3747c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 16:07:58 2018 +0200
Add c++ option (to use C code module in c++)
commit 63d78bc1f77ac6698c3d663a1c67b40a0c297125
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:57:34 2018 +0200
Added on off option for ACD module
commit d5ec4b69eb4175d4dd569bcfc80ae0e192780015
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date: Fri Jul 13 15:09:40 2018 +0200
ACD IPv4 module files added
The files for IPv4 ACD or Address Conflict Detection are added
to the lwip source.
2018-09-13 15:02:21 +00:00
|
|
|
|
|
|
|
#if LWIP_AUTOIP
|
|
|
|
autoip_network_changed_link_down(netif);
|
|
|
|
#endif /* LWIP_AUTOIP */
|
|
|
|
|
|
|
|
#if LWIP_ACD
|
|
|
|
acd_network_changed_link_down(netif);
|
|
|
|
#endif /* LWIP_ACD */
|
|
|
|
|
2019-05-06 10:37:19 +00:00
|
|
|
#if LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES
|
|
|
|
netif->mtu6 = netif->mtu;
|
|
|
|
#endif
|
|
|
|
|
2010-02-12 16:50:23 +00:00
|
|
|
NETIF_LINK_CALLBACK(netif);
|
2017-02-15 09:14:06 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
{
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.link_changed.state = 0;
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_LINK_CHANGED, &args);
|
|
|
|
}
|
|
|
|
#endif
|
2010-02-12 16:50:23 +00:00
|
|
|
}
|
2007-08-25 10:43:19 +00:00
|
|
|
}
|
|
|
|
|
2010-02-15 19:53:46 +00:00
|
|
|
#if LWIP_NETIF_LINK_CALLBACK
|
2007-08-25 10:43:19 +00:00
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2007-08-25 10:43:19 +00:00
|
|
|
* Set callback to be called when link is brought up/down
|
|
|
|
*/
|
2015-10-06 19:57:40 +00:00
|
|
|
void
|
|
|
|
netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)
|
2007-08-25 10:43:19 +00:00
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2008-06-17 19:39:22 +00:00
|
|
|
if (netif) {
|
|
|
|
netif->link_callback = link_callback;
|
|
|
|
}
|
2007-08-25 10:43:19 +00:00
|
|
|
}
|
2007-07-13 15:00:40 +00:00
|
|
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
2008-06-12 20:10:08 +00:00
|
|
|
|
|
|
|
#if ENABLE_LOOPBACK
|
|
|
|
/**
|
2016-07-26 14:53:27 +00:00
|
|
|
* @ingroup netif
|
2008-06-12 20:10:08 +00:00
|
|
|
* Send an IP packet to be received on the same netif (loopif-like).
|
|
|
|
* The pbuf is simply copied and handed back to netif->input.
|
|
|
|
* In multithreaded mode, this is done directly since netif->input must put
|
|
|
|
* the packet on a queue.
|
|
|
|
* In callback mode, the packet is put on an internal queue and is fed to
|
|
|
|
* netif->input by netif_poll().
|
|
|
|
*
|
|
|
|
* @param netif the lwip network interface structure
|
|
|
|
* @param p the (IP) packet to 'send'
|
|
|
|
* @return ERR_OK if the packet has been sent
|
|
|
|
* ERR_MEM if the pbuf used to copy the packet couldn't be allocated
|
|
|
|
*/
|
|
|
|
err_t
|
2014-01-17 20:55:46 +00:00
|
|
|
netif_loop_output(struct netif *netif, struct pbuf *p)
|
2008-06-12 20:10:08 +00:00
|
|
|
{
|
|
|
|
struct pbuf *r;
|
|
|
|
err_t err;
|
|
|
|
struct pbuf *last;
|
2008-06-17 19:39:22 +00:00
|
|
|
#if LWIP_LOOPBACK_MAX_PBUFS
|
2016-09-30 07:04:36 +00:00
|
|
|
u16_t clen = 0;
|
2008-06-17 19:39:22 +00:00
|
|
|
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
|
2010-02-09 17:00:57 +00:00
|
|
|
/* If we have a loopif, SNMP counters are adjusted for it,
|
|
|
|
* if not they are adjusted for 'netif'. */
|
2015-09-08 07:47:30 +00:00
|
|
|
#if MIB2_STATS
|
2010-02-09 17:00:57 +00:00
|
|
|
#if LWIP_HAVE_LOOPIF
|
|
|
|
struct netif *stats_if = &loop_netif;
|
|
|
|
#else /* LWIP_HAVE_LOOPIF */
|
|
|
|
struct netif *stats_if = netif;
|
|
|
|
#endif /* LWIP_HAVE_LOOPIF */
|
2015-09-08 07:47:30 +00:00
|
|
|
#endif /* MIB2_STATS */
|
2018-04-27 22:42:30 +00:00
|
|
|
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
|
|
|
|
u8_t schedule_poll = 0;
|
|
|
|
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
2010-02-09 17:41:34 +00:00
|
|
|
SYS_ARCH_DECL_PROTECT(lev);
|
2008-06-12 20:10:08 +00:00
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_loop_output: invalid netif", netif != NULL);
|
|
|
|
LWIP_ASSERT("netif_loop_output: invalid pbuf", p != NULL);
|
|
|
|
|
2008-06-12 20:10:08 +00:00
|
|
|
/* Allocate a new pbuf */
|
|
|
|
r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
|
|
|
|
if (r == NULL) {
|
2010-02-09 17:00:57 +00:00
|
|
|
LINK_STATS_INC(link.memerr);
|
|
|
|
LINK_STATS_INC(link.drop);
|
2015-09-08 07:47:30 +00:00
|
|
|
MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
|
2008-06-12 20:10:08 +00:00
|
|
|
return ERR_MEM;
|
|
|
|
}
|
2008-06-17 19:39:22 +00:00
|
|
|
#if LWIP_LOOPBACK_MAX_PBUFS
|
|
|
|
clen = pbuf_clen(r);
|
|
|
|
/* check for overflow or too many pbuf on queue */
|
2015-10-07 08:36:50 +00:00
|
|
|
if (((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||
|
2017-09-17 18:38:38 +00:00
|
|
|
((netif->loop_cnt_current + clen) > LWIP_MIN(LWIP_LOOPBACK_MAX_PBUFS, 0xFFFF))) {
|
2010-01-10 13:32:36 +00:00
|
|
|
pbuf_free(r);
|
2010-02-09 17:00:57 +00:00
|
|
|
LINK_STATS_INC(link.memerr);
|
|
|
|
LINK_STATS_INC(link.drop);
|
2015-09-08 07:47:30 +00:00
|
|
|
MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
|
2010-01-10 13:32:36 +00:00
|
|
|
return ERR_MEM;
|
2008-06-17 19:39:22 +00:00
|
|
|
}
|
2017-06-25 21:01:57 +00:00
|
|
|
netif->loop_cnt_current = (u16_t)(netif->loop_cnt_current + clen);
|
2008-06-17 19:39:22 +00:00
|
|
|
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
|
2008-06-12 20:10:08 +00:00
|
|
|
|
|
|
|
/* Copy the whole pbuf queue p into the single pbuf r */
|
|
|
|
if ((err = pbuf_copy(r, p)) != ERR_OK) {
|
|
|
|
pbuf_free(r);
|
2010-02-09 17:00:57 +00:00
|
|
|
LINK_STATS_INC(link.memerr);
|
|
|
|
LINK_STATS_INC(link.drop);
|
2015-09-08 07:47:30 +00:00
|
|
|
MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
|
2008-06-12 20:10:08 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-06-17 19:39:22 +00:00
|
|
|
/* Put the packet on a linked list which gets emptied through calling
|
|
|
|
netif_poll(). */
|
2008-06-12 20:10:08 +00:00
|
|
|
|
|
|
|
/* let last point to the last pbuf in chain r */
|
2017-03-17 10:22:30 +00:00
|
|
|
for (last = r; last->next != NULL; last = last->next) {
|
|
|
|
/* nothing to do here, just get to the last pbuf */
|
|
|
|
}
|
2008-06-17 19:39:22 +00:00
|
|
|
|
2008-06-12 20:10:08 +00:00
|
|
|
SYS_ARCH_PROTECT(lev);
|
2013-04-24 19:38:01 +00:00
|
|
|
if (netif->loop_first != NULL) {
|
2008-06-12 20:10:08 +00:00
|
|
|
LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL);
|
|
|
|
netif->loop_last->next = r;
|
|
|
|
netif->loop_last = last;
|
|
|
|
} else {
|
|
|
|
netif->loop_first = r;
|
|
|
|
netif->loop_last = last;
|
2018-04-27 22:42:30 +00:00
|
|
|
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
|
|
|
|
/* No existing packets queued, schedule poll */
|
|
|
|
schedule_poll = 1;
|
|
|
|
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
2008-06-12 20:10:08 +00:00
|
|
|
}
|
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
2008-06-17 19:39:22 +00:00
|
|
|
|
2010-02-09 17:00:57 +00:00
|
|
|
LINK_STATS_INC(link.xmit);
|
2015-09-08 07:47:30 +00:00
|
|
|
MIB2_STATS_NETIF_ADD(stats_if, ifoutoctets, p->tot_len);
|
|
|
|
MIB2_STATS_NETIF_INC(stats_if, ifoutucastpkts);
|
2010-02-09 17:00:57 +00:00
|
|
|
|
2008-06-17 19:39:22 +00:00
|
|
|
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
|
|
|
|
/* For multithreading environment, schedule a call to netif_poll */
|
2018-04-27 22:42:30 +00:00
|
|
|
if (schedule_poll) {
|
|
|
|
tcpip_try_callback((tcpip_callback_fn)netif_poll, netif);
|
|
|
|
}
|
2008-06-12 20:10:08 +00:00
|
|
|
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
|
|
|
|
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-17 20:00:16 +00:00
|
|
|
#if LWIP_HAVE_LOOPIF
|
2015-04-09 20:21:15 +00:00
|
|
|
#if LWIP_IPV4
|
2014-01-17 20:55:46 +00:00
|
|
|
static err_t
|
2017-09-17 18:38:38 +00:00
|
|
|
netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t *addr)
|
2014-01-17 20:55:46 +00:00
|
|
|
{
|
|
|
|
LWIP_UNUSED_ARG(addr);
|
|
|
|
return netif_loop_output(netif, p);
|
|
|
|
}
|
2015-04-09 20:21:15 +00:00
|
|
|
#endif /* LWIP_IPV4 */
|
2014-01-17 20:55:46 +00:00
|
|
|
|
2014-01-17 20:57:40 +00:00
|
|
|
#if LWIP_IPV6
|
2014-01-17 20:55:46 +00:00
|
|
|
static err_t
|
2017-09-17 18:38:38 +00:00
|
|
|
netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t *addr)
|
2014-01-17 20:55:46 +00:00
|
|
|
{
|
|
|
|
LWIP_UNUSED_ARG(addr);
|
|
|
|
return netif_loop_output(netif, p);
|
|
|
|
}
|
2015-09-17 20:00:16 +00:00
|
|
|
#endif /* LWIP_IPV6 */
|
|
|
|
#endif /* LWIP_HAVE_LOOPIF */
|
2014-01-17 20:55:46 +00:00
|
|
|
|
|
|
|
|
2008-06-12 20:10:08 +00:00
|
|
|
/**
|
|
|
|
* Call netif_poll() in the main loop of your application. This is to prevent
|
|
|
|
* reentering non-reentrant functions like tcp_input(). Packets passed to
|
|
|
|
* netif_loop_output() are put on a list that is passed to netif->input() by
|
|
|
|
* netif_poll().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netif_poll(struct netif *netif)
|
|
|
|
{
|
2010-02-09 17:00:57 +00:00
|
|
|
/* If we have a loopif, SNMP counters are adjusted for it,
|
|
|
|
* if not they are adjusted for 'netif'. */
|
2015-09-08 07:47:30 +00:00
|
|
|
#if MIB2_STATS
|
2010-02-09 17:00:57 +00:00
|
|
|
#if LWIP_HAVE_LOOPIF
|
|
|
|
struct netif *stats_if = &loop_netif;
|
|
|
|
#else /* LWIP_HAVE_LOOPIF */
|
|
|
|
struct netif *stats_if = netif;
|
|
|
|
#endif /* LWIP_HAVE_LOOPIF */
|
2015-09-08 07:47:30 +00:00
|
|
|
#endif /* MIB2_STATS */
|
2008-06-12 20:10:08 +00:00
|
|
|
SYS_ARCH_DECL_PROTECT(lev);
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_poll: invalid netif", netif != NULL);
|
|
|
|
|
2016-11-25 11:47:34 +00:00
|
|
|
/* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */
|
|
|
|
SYS_ARCH_PROTECT(lev);
|
|
|
|
while (netif->loop_first != NULL) {
|
|
|
|
struct pbuf *in, *in_end;
|
2008-06-17 19:39:22 +00:00
|
|
|
#if LWIP_LOOPBACK_MAX_PBUFS
|
2016-11-25 11:47:34 +00:00
|
|
|
u8_t clen = 1;
|
2008-06-17 19:39:22 +00:00
|
|
|
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
|
2016-11-25 11:47:34 +00:00
|
|
|
|
|
|
|
in = in_end = netif->loop_first;
|
|
|
|
while (in_end->len != in_end->tot_len) {
|
|
|
|
LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL);
|
|
|
|
in_end = in_end->next;
|
2012-12-12 16:34:09 +00:00
|
|
|
#if LWIP_LOOPBACK_MAX_PBUFS
|
2016-11-25 11:47:34 +00:00
|
|
|
clen++;
|
2012-12-12 16:34:09 +00:00
|
|
|
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
|
2016-11-25 11:47:34 +00:00
|
|
|
}
|
2012-12-12 16:34:09 +00:00
|
|
|
#if LWIP_LOOPBACK_MAX_PBUFS
|
2016-11-25 11:47:34 +00:00
|
|
|
/* adjust the number of pbufs on queue */
|
|
|
|
LWIP_ASSERT("netif->loop_cnt_current underflow",
|
2017-09-17 18:38:38 +00:00
|
|
|
((netif->loop_cnt_current - clen) < netif->loop_cnt_current));
|
2017-06-25 21:01:57 +00:00
|
|
|
netif->loop_cnt_current = (u16_t)(netif->loop_cnt_current - clen);
|
2012-12-12 16:34:09 +00:00
|
|
|
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
|
|
|
|
|
2016-11-25 11:47:34 +00:00
|
|
|
/* 'in_end' now points to the last pbuf from 'in' */
|
|
|
|
if (in_end == netif->loop_last) {
|
|
|
|
/* this was the last pbuf in the list */
|
|
|
|
netif->loop_first = netif->loop_last = NULL;
|
|
|
|
} else {
|
|
|
|
/* pop the pbuf off the list */
|
|
|
|
netif->loop_first = in_end->next;
|
|
|
|
LWIP_ASSERT("should not be null since first != last!", netif->loop_first != NULL);
|
2008-06-12 20:10:08 +00:00
|
|
|
}
|
2016-11-25 11:47:34 +00:00
|
|
|
/* De-queue the pbuf from its successors on the 'loop_' list. */
|
|
|
|
in_end->next = NULL;
|
2008-06-12 20:10:08 +00:00
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
|
|
|
|
2017-04-15 16:27:34 +00:00
|
|
|
in->if_idx = netif_get_index(netif);
|
|
|
|
|
2016-11-25 11:47:34 +00:00
|
|
|
LINK_STATS_INC(link.recv);
|
|
|
|
MIB2_STATS_NETIF_ADD(stats_if, ifinoctets, in->tot_len);
|
|
|
|
MIB2_STATS_NETIF_INC(stats_if, ifinucastpkts);
|
|
|
|
/* loopback packets are always IP packets! */
|
|
|
|
if (ip_input(in, netif) != ERR_OK) {
|
|
|
|
pbuf_free(in);
|
2008-06-12 20:10:08 +00:00
|
|
|
}
|
2016-11-25 11:47:34 +00:00
|
|
|
SYS_ARCH_PROTECT(lev);
|
|
|
|
}
|
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
2008-06-12 20:10:08 +00:00
|
|
|
}
|
2008-06-17 19:39:22 +00:00
|
|
|
|
|
|
|
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
|
|
|
|
/**
|
|
|
|
* Calls netif_poll() for every netif on the netif_list.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netif_poll_all(void)
|
|
|
|
{
|
2017-03-01 15:10:50 +00:00
|
|
|
struct netif *netif;
|
2008-06-17 19:39:22 +00:00
|
|
|
/* loop through netifs */
|
2017-03-01 15:10:50 +00:00
|
|
|
NETIF_FOREACH(netif) {
|
2008-06-17 19:39:22 +00:00
|
|
|
netif_poll(netif);
|
|
|
|
}
|
|
|
|
}
|
2008-06-12 20:10:08 +00:00
|
|
|
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
|
|
|
#endif /* ENABLE_LOOPBACK */
|
2011-05-17 19:35:14 +00:00
|
|
|
|
2016-08-17 14:37:15 +00:00
|
|
|
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
|
|
|
|
/**
|
2016-08-26 09:21:49 +00:00
|
|
|
* @ingroup netif_cd
|
2016-08-17 14:37:15 +00:00
|
|
|
* Allocate an index to store data in client_data member of struct netif.
|
|
|
|
* Returned value is an index in mentioned array.
|
|
|
|
* @see LWIP_NUM_NETIF_CLIENT_DATA
|
|
|
|
*/
|
2016-08-18 09:44:19 +00:00
|
|
|
u8_t
|
|
|
|
netif_alloc_client_data_id(void)
|
2016-08-17 14:37:15 +00:00
|
|
|
{
|
2016-08-18 09:44:19 +00:00
|
|
|
u8_t result = netif_client_id;
|
|
|
|
netif_client_id++;
|
2016-08-18 10:37:21 +00:00
|
|
|
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2017-06-25 21:01:57 +00:00
|
|
|
#if LWIP_NUM_NETIF_CLIENT_DATA > 256
|
|
|
|
#error LWIP_NUM_NETIF_CLIENT_DATA must be <= 256
|
|
|
|
#endif
|
2016-08-24 07:19:53 +00:00
|
|
|
LWIP_ASSERT("Increase LWIP_NUM_NETIF_CLIENT_DATA in lwipopts.h", result < LWIP_NUM_NETIF_CLIENT_DATA);
|
2017-06-25 21:01:57 +00:00
|
|
|
return (u8_t)(result + LWIP_NETIF_CLIENT_DATA_INDEX_MAX);
|
2016-08-17 14:37:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-05-17 19:35:14 +00:00
|
|
|
#if LWIP_IPV6
|
2016-08-24 18:51:05 +00:00
|
|
|
/**
|
2016-08-25 20:04:04 +00:00
|
|
|
* @ingroup netif_ip6
|
2016-08-24 18:51:05 +00:00
|
|
|
* Change an IPv6 address of a network interface
|
|
|
|
*
|
|
|
|
* @param netif the network interface to change
|
|
|
|
* @param addr_idx index of the IPv6 address
|
|
|
|
* @param addr6 the new IPv6 address
|
|
|
|
*
|
|
|
|
* @note call netif_ip6_addr_set_state() to set the address valid/temptative
|
|
|
|
*/
|
2016-08-24 07:19:53 +00:00
|
|
|
void
|
2016-08-24 12:41:48 +00:00
|
|
|
netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, const ip6_addr_t *addr6)
|
2016-08-24 07:19:53 +00:00
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_ip6_addr_set: invalid netif", netif != NULL);
|
|
|
|
LWIP_ASSERT("netif_ip6_addr_set: invalid addr6", addr6 != NULL);
|
|
|
|
|
2016-08-24 07:19:53 +00:00
|
|
|
netif_ip6_addr_set_parts(netif, addr_idx, addr6->addr[0], addr6->addr[1],
|
2017-09-17 18:38:38 +00:00
|
|
|
addr6->addr[2], addr6->addr[3]);
|
2016-08-24 07:19:53 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 18:51:05 +00:00
|
|
|
/*
|
|
|
|
* Change an IPv6 address of a network interface (internal version taking 4 * u32_t)
|
|
|
|
*
|
|
|
|
* @param netif the network interface to change
|
|
|
|
* @param addr_idx index of the IPv6 address
|
|
|
|
* @param i0 word0 of the new IPv6 address
|
|
|
|
* @param i1 word1 of the new IPv6 address
|
|
|
|
* @param i2 word2 of the new IPv6 address
|
|
|
|
* @param i3 word3 of the new IPv6 address
|
|
|
|
*/
|
2016-08-24 07:19:53 +00:00
|
|
|
void
|
|
|
|
netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1, u32_t i2, u32_t i3)
|
|
|
|
{
|
2017-02-14 12:54:14 +00:00
|
|
|
ip_addr_t old_addr;
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
ip_addr_t new_ipaddr;
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
2016-08-24 07:19:53 +00:00
|
|
|
LWIP_ASSERT("netif != NULL", netif != NULL);
|
|
|
|
LWIP_ASSERT("invalid index", addr_idx < LWIP_IPV6_NUM_ADDRESSES);
|
|
|
|
|
2017-02-14 13:20:39 +00:00
|
|
|
ip6_addr_copy(*ip_2_ip6(&old_addr), *netif_ip6_addr(netif, addr_idx));
|
|
|
|
IP_SET_TYPE_VAL(old_addr, IPADDR_TYPE_V6);
|
|
|
|
|
2016-08-24 07:19:53 +00:00
|
|
|
/* address is actually being changed? */
|
2017-02-14 09:59:28 +00:00
|
|
|
if ((ip_2_ip6(&old_addr)->addr[0] != i0) || (ip_2_ip6(&old_addr)->addr[1] != i1) ||
|
|
|
|
(ip_2_ip6(&old_addr)->addr[2] != i2) || (ip_2_ip6(&old_addr)->addr[3] != i3)) {
|
2016-08-24 07:19:53 +00:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_ip6_addr_set: netif address being changed\n"));
|
|
|
|
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
IP_ADDR6(&new_ipaddr, i0, i1, i2, i3);
|
|
|
|
ip6_addr_assign_zone(ip_2_ip6(&new_ipaddr), IP6_UNICAST, netif);
|
|
|
|
|
2017-11-16 12:01:55 +00:00
|
|
|
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, addr_idx))) {
|
2018-03-14 14:59:17 +00:00
|
|
|
netif_do_ip_addr_changed(netif_ip_addr6(netif, addr_idx), &new_ipaddr);
|
2016-08-24 18:51:05 +00:00
|
|
|
}
|
2016-08-24 07:19:53 +00:00
|
|
|
/* @todo: remove/readd mib2 ip6 entries? */
|
|
|
|
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
ip_addr_copy(netif->ip6_addr[addr_idx], new_ipaddr);
|
2016-08-24 07:19:53 +00:00
|
|
|
|
2017-11-16 12:01:55 +00:00
|
|
|
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, addr_idx))) {
|
2016-08-24 07:19:53 +00:00
|
|
|
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV6);
|
|
|
|
NETIF_STATUS_CALLBACK(netif);
|
|
|
|
}
|
2017-02-14 09:59:28 +00:00
|
|
|
|
2017-02-15 09:14:06 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
{
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.ipv6_set.addr_index = addr_idx;
|
|
|
|
args.ipv6_set.old_address = &old_addr;
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_IPV6_SET, &args);
|
|
|
|
}
|
|
|
|
#endif
|
2016-08-24 07:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IPv6 address %d of interface %c%c set to %s/0x%"X8_F"\n",
|
2017-09-17 18:38:38 +00:00
|
|
|
addr_idx, netif->name[0], netif->name[1], ip6addr_ntoa(netif_ip6_addr(netif, addr_idx)),
|
|
|
|
netif_ip6_addr_state(netif, addr_idx)));
|
2016-08-24 07:19:53 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 18:51:05 +00:00
|
|
|
/**
|
2016-08-25 20:04:04 +00:00
|
|
|
* @ingroup netif_ip6
|
2016-08-24 18:51:05 +00:00
|
|
|
* Change the state of an IPv6 address of a network interface
|
|
|
|
* (INVALID, TEMPTATIVE, PREFERRED, DEPRECATED, where TEMPTATIVE
|
|
|
|
* includes the number of checks done, see ip6_addr.h)
|
|
|
|
*
|
|
|
|
* @param netif the network interface to change
|
|
|
|
* @param addr_idx index of the IPv6 address
|
|
|
|
* @param state the new IPv6 address state
|
|
|
|
*/
|
2016-08-24 07:19:53 +00:00
|
|
|
void
|
2017-09-17 18:38:38 +00:00
|
|
|
netif_ip6_addr_set_state(struct netif *netif, s8_t addr_idx, u8_t state)
|
2016-08-24 07:19:53 +00:00
|
|
|
{
|
|
|
|
u8_t old_state;
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
2016-08-24 07:19:53 +00:00
|
|
|
LWIP_ASSERT("netif != NULL", netif != NULL);
|
|
|
|
LWIP_ASSERT("invalid index", addr_idx < LWIP_IPV6_NUM_ADDRESSES);
|
|
|
|
|
|
|
|
old_state = netif_ip6_addr_state(netif, addr_idx);
|
|
|
|
/* state is actually being changed? */
|
|
|
|
if (old_state != state) {
|
|
|
|
u8_t old_valid = old_state & IP6_ADDR_VALID;
|
|
|
|
u8_t new_valid = state & IP6_ADDR_VALID;
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_ip6_addr_set_state: netif address state being changed\n"));
|
|
|
|
|
2016-12-16 21:26:32 +00:00
|
|
|
#if LWIP_IPV6_MLD
|
|
|
|
/* Reevaluate solicited-node multicast group membership. */
|
|
|
|
if (netif->flags & NETIF_FLAG_MLD6) {
|
|
|
|
nd6_adjust_mld_membership(netif, addr_idx, state);
|
|
|
|
}
|
|
|
|
#endif /* LWIP_IPV6_MLD */
|
|
|
|
|
2016-08-24 07:19:53 +00:00
|
|
|
if (old_valid && !new_valid) {
|
|
|
|
/* address about to be removed by setting invalid */
|
2018-03-14 14:59:17 +00:00
|
|
|
netif_do_ip_addr_changed(netif_ip_addr6(netif, addr_idx), NULL);
|
2016-08-24 07:19:53 +00:00
|
|
|
/* @todo: remove mib2 ip6 entries? */
|
|
|
|
}
|
|
|
|
netif->ip6_addr_state[addr_idx] = state;
|
|
|
|
|
|
|
|
if (!old_valid && new_valid) {
|
|
|
|
/* address added by setting valid */
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
/* This is a good moment to check that the address is properly zoned. */
|
|
|
|
IP6_ADDR_ZONECHECK_NETIF(netif_ip6_addr(netif, addr_idx), netif);
|
2016-08-24 07:19:53 +00:00
|
|
|
/* @todo: add mib2 ip6 entries? */
|
|
|
|
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV6);
|
|
|
|
}
|
2016-12-29 22:27:10 +00:00
|
|
|
if ((old_state & ~IP6_ADDR_TENTATIVE_COUNT_MASK) !=
|
|
|
|
(state & ~IP6_ADDR_TENTATIVE_COUNT_MASK)) {
|
|
|
|
/* address state has changed -> call the callback function */
|
2016-08-24 07:19:53 +00:00
|
|
|
NETIF_STATUS_CALLBACK(netif);
|
|
|
|
}
|
|
|
|
|
2017-02-15 09:14:06 +00:00
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
2018-01-25 12:05:33 +00:00
|
|
|
{
|
|
|
|
netif_ext_callback_args_t args;
|
|
|
|
args.ipv6_addr_state_changed.addr_index = addr_idx;
|
|
|
|
args.ipv6_addr_state_changed.old_state = old_state;
|
|
|
|
args.ipv6_addr_state_changed.address = netif_ip_addr6(netif, addr_idx);
|
|
|
|
netif_invoke_ext_callback(netif, LWIP_NSC_IPV6_ADDR_STATE_CHANGED, &args);
|
|
|
|
}
|
2017-02-15 09:14:06 +00:00
|
|
|
#endif
|
2018-01-25 12:05:33 +00:00
|
|
|
}
|
2016-08-24 07:19:53 +00:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IPv6 address %d of interface %c%c set to %s/0x%"X8_F"\n",
|
2017-09-17 18:38:38 +00:00
|
|
|
addr_idx, netif->name[0], netif->name[1], ip6addr_ntoa(netif_ip6_addr(netif, addr_idx)),
|
|
|
|
netif_ip6_addr_state(netif, addr_idx)));
|
2016-08-24 07:19:53 +00:00
|
|
|
}
|
|
|
|
|
2016-07-26 14:53:27 +00:00
|
|
|
/**
|
nd6: improve address autoconfiguration support
In summary, this patch aims to resolve bugs #47923 and #48162, by
decoupling address autoconfiguration from the on-link prefix list,
since those are not related. Important necessary changes are needed
to meet this goal, ultimately bringing the lwIP ND6 implementation
closer to compliance with RFC 4862. The main changes are:
1. support for address lifetimes, and,
2. addition of a new DUPLICATED address state.
The decoupling implies that the prefix list can no longer be used to
maintain state for address autoconfiguration. Most importantly, the
lifetime of each address, which was previously derived from the
prefix slot's lifetime, must now be associated with the address
itself. This patch implements address lifetime tracking, maintaining
both a valid and a preferred lifetime for each address, along with
the corresponding address state changes (e.g., between PREFERRED and
DEPRECATED), all as required by RFC 4862.
The support for address lifetimes can be enabled with a new
LWIP_IPV6_ADDRESS_LIFETIMES setting in lwipopts.h. It is required for
autoconfiguration and enabled by default if autoconfiguration is
enabled as well, but it may also be enabled separately, so as to allow
application-controlled lifetime management (e.g., if autoconfiguration
is implemented in a separate application). A special valid-lifetime of
zero is used to denote a static address--that is, an address that was
configured manually, that does not have lifetimes, and that should be
left alone by the autoconfiguration functionality. Addresses assigned
without setting a lifetime are deemed static, thus preserving
compatibility with existing lwIP-based applications in this respect.
Similarly, the decoupling implies that the prefix list can no longer
be used to remember cases of address duplication. Previously, the
detection of a duplicated address would simply result in removal of
the address altogether. Instead, this patch introduces a new state
"DUPLICATED", indicating that the address, while technically still
present, has been found to conflict with other node addresses, and no
attempt should be made to produce an autoconfiguration address for
that prefix.
Manually added addresses, including the link-local address, once set
to DUPLICATED, will remain in that state until manual intervention.
Autoconfigured DUPLICATED addresses will expire according to their
valid-lifetime, essentially preserving the current behavior but
without the use of the prefix list. As a first attempt to approach
compliance with RFC 4862 Sec. 5.4.5, if the link-local address is
detected to be duplicated, all derived addresses are marked duplicated
as well, and no new addresses will be autoconfigured. More work is to
be done for full compliance with that section, however.
Together, those two main changes indeed do fully decouple address
autoconfiguration from the on-link prefix list. Changes to the latter
thus no longer affect the former, resolving bug #47923. Moreover, as a
result, autoconfiguration can, and does, now also take place on
advertised prefixes that do not have the on-link flag set, resolving
bug #48162. The routing changes mentioned in the discussion of that
bug are left to a separate patch, though.
2016-12-29 21:03:41 +00:00
|
|
|
* Checks if a specific local address is present on the netif and returns its
|
|
|
|
* index. Depending on its state, it may or may not be assigned to the
|
|
|
|
* interface (as per RFC terminology).
|
2015-03-06 20:38:57 +00:00
|
|
|
*
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
* The given address may or may not be zoned (i.e., have a zone index other
|
|
|
|
* than IP6_NO_ZONE). If the address is zoned, it must have the correct zone
|
|
|
|
* for the given netif, or no match will be found.
|
|
|
|
*
|
2015-03-06 20:38:57 +00:00
|
|
|
* @param netif the netif to check
|
|
|
|
* @param ip6addr the IPv6 address to find
|
|
|
|
* @return >= 0: address found, this is its index
|
|
|
|
* -1: address not found on this netif
|
|
|
|
*/
|
2011-05-17 19:35:14 +00:00
|
|
|
s8_t
|
2015-09-30 18:55:08 +00:00
|
|
|
netif_get_ip6_addr_match(struct netif *netif, const ip6_addr_t *ip6addr)
|
2011-05-17 19:35:14 +00:00
|
|
|
{
|
|
|
|
s8_t i;
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_get_ip6_addr_match: invalid netif", netif != NULL);
|
|
|
|
LWIP_ASSERT("netif_get_ip6_addr_match: invalid ip6addr", ip6addr != NULL);
|
|
|
|
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
#if LWIP_IPV6_SCOPES
|
|
|
|
if (ip6_addr_has_zone(ip6addr) && !ip6_addr_test_zone(ip6addr, netif)) {
|
|
|
|
return -1; /* wrong zone, no match */
|
|
|
|
}
|
|
|
|
#endif /* LWIP_IPV6_SCOPES */
|
|
|
|
|
2011-05-17 19:35:14 +00:00
|
|
|
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
2015-03-18 17:56:48 +00:00
|
|
|
if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i)) &&
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
ip6_addr_cmp_zoneless(netif_ip6_addr(netif, i), ip6addr)) {
|
2011-05-17 19:35:14 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-07-26 14:53:27 +00:00
|
|
|
/**
|
2016-08-25 20:04:04 +00:00
|
|
|
* @ingroup netif_ip6
|
2016-07-26 14:53:27 +00:00
|
|
|
* Create a link-local IPv6 address on a netif (stored in slot 0)
|
2015-03-06 20:38:57 +00:00
|
|
|
*
|
|
|
|
* @param netif the netif to create the address on
|
|
|
|
* @param from_mac_48bit if != 0, assume hwadr is a 48-bit MAC address (std conversion)
|
|
|
|
* if == 0, use hwaddr directly as interface ID
|
|
|
|
*/
|
2011-05-17 19:35:14 +00:00
|
|
|
void
|
2015-03-06 20:38:57 +00:00
|
|
|
netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit)
|
2011-05-17 19:35:14 +00:00
|
|
|
{
|
|
|
|
u8_t i, addr_index;
|
|
|
|
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_create_ip6_linklocal_address: invalid netif", netif != NULL);
|
|
|
|
|
2011-05-17 19:35:14 +00:00
|
|
|
/* Link-local prefix. */
|
2015-09-23 20:09:37 +00:00
|
|
|
ip_2_ip6(&netif->ip6_addr[0])->addr[0] = PP_HTONL(0xfe800000ul);
|
|
|
|
ip_2_ip6(&netif->ip6_addr[0])->addr[1] = 0;
|
2011-05-17 19:35:14 +00:00
|
|
|
|
|
|
|
/* Generate interface ID. */
|
|
|
|
if (from_mac_48bit) {
|
|
|
|
/* Assume hwaddr is a 48-bit IEEE 802 MAC. Convert to EUI-64 address. Complement Group bit. */
|
2016-10-06 10:55:57 +00:00
|
|
|
ip_2_ip6(&netif->ip6_addr[0])->addr[2] = lwip_htonl((((u32_t)(netif->hwaddr[0] ^ 0x02)) << 24) |
|
2011-05-17 19:35:14 +00:00
|
|
|
((u32_t)(netif->hwaddr[1]) << 16) |
|
|
|
|
((u32_t)(netif->hwaddr[2]) << 8) |
|
|
|
|
(0xff));
|
2017-07-05 10:20:26 +00:00
|
|
|
ip_2_ip6(&netif->ip6_addr[0])->addr[3] = lwip_htonl((u32_t)(0xfeul << 24) |
|
2011-05-17 19:35:14 +00:00
|
|
|
((u32_t)(netif->hwaddr[3]) << 16) |
|
|
|
|
((u32_t)(netif->hwaddr[4]) << 8) |
|
|
|
|
(netif->hwaddr[5]));
|
2015-03-04 19:58:37 +00:00
|
|
|
} else {
|
2011-05-17 19:35:14 +00:00
|
|
|
/* Use hwaddr directly as interface ID. */
|
2015-09-23 20:09:37 +00:00
|
|
|
ip_2_ip6(&netif->ip6_addr[0])->addr[2] = 0;
|
|
|
|
ip_2_ip6(&netif->ip6_addr[0])->addr[3] = 0;
|
2011-05-17 19:35:14 +00:00
|
|
|
|
|
|
|
addr_index = 3;
|
2015-03-04 19:58:37 +00:00
|
|
|
for (i = 0; (i < 8) && (i < netif->hwaddr_len); i++) {
|
2011-05-17 19:35:14 +00:00
|
|
|
if (i == 4) {
|
|
|
|
addr_index--;
|
|
|
|
}
|
2018-06-13 06:57:17 +00:00
|
|
|
ip_2_ip6(&netif->ip6_addr[0])->addr[addr_index] |= lwip_htonl(((u32_t)(netif->hwaddr[netif->hwaddr_len - i - 1])) << (8 * (i & 0x03)));
|
2011-05-17 19:35:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
/* Set a link-local zone. Even though the zone is implied by the owning
|
|
|
|
* netif, setting the zone anyway has two important conceptual advantages:
|
|
|
|
* 1) it avoids the need for a ton of exceptions in internal code, allowing
|
|
|
|
* e.g. ip6_addr_cmp() to be used on local addresses;
|
|
|
|
* 2) the properly zoned address is visible externally, e.g. when any outside
|
|
|
|
* code enumerates available addresses or uses one to bind a socket.
|
|
|
|
* Any external code unaware of address scoping is likely to just ignore the
|
|
|
|
* zone field, so this should not create any compatibility problems. */
|
|
|
|
ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[0]), IP6_UNICAST, netif);
|
|
|
|
|
2011-05-17 19:35:14 +00:00
|
|
|
/* Set address state. */
|
|
|
|
#if LWIP_IPV6_DUP_DETECT_ATTEMPTS
|
|
|
|
/* Will perform duplicate address detection (DAD). */
|
2016-12-13 20:54:49 +00:00
|
|
|
netif_ip6_addr_set_state(netif, 0, IP6_ADDR_TENTATIVE);
|
2011-05-17 19:35:14 +00:00
|
|
|
#else
|
|
|
|
/* Consider address valid. */
|
2016-12-13 20:54:49 +00:00
|
|
|
netif_ip6_addr_set_state(netif, 0, IP6_ADDR_PREFERRED);
|
2011-05-17 19:35:14 +00:00
|
|
|
#endif /* LWIP_IPV6_AUTOCONFIG */
|
|
|
|
}
|
2012-08-17 16:56:14 +00:00
|
|
|
|
2016-07-26 14:53:27 +00:00
|
|
|
/**
|
2016-08-25 20:04:04 +00:00
|
|
|
* @ingroup netif_ip6
|
2016-07-26 14:53:27 +00:00
|
|
|
* This function allows for the easy addition of a new IPv6 address to an interface.
|
2015-03-06 20:38:57 +00:00
|
|
|
* It takes care of finding an empty slot and then sets the address tentative
|
|
|
|
* (to make sure that all the subsequent processing happens).
|
|
|
|
*
|
|
|
|
* @param netif netif to add the address on
|
|
|
|
* @param ip6addr address to add
|
|
|
|
* @param chosen_idx if != NULL, the chosen IPv6 address index will be stored here
|
|
|
|
*/
|
2015-07-27 09:13:02 +00:00
|
|
|
err_t
|
2015-09-30 18:55:08 +00:00
|
|
|
netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx)
|
2015-03-06 20:30:59 +00:00
|
|
|
{
|
|
|
|
s8_t i;
|
|
|
|
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2018-06-12 08:24:08 +00:00
|
|
|
LWIP_ASSERT("netif_add_ip6_address: invalid netif", netif != NULL);
|
|
|
|
LWIP_ASSERT("netif_add_ip6_address: invalid ip6addr", ip6addr != NULL);
|
|
|
|
|
2015-03-06 20:30:59 +00:00
|
|
|
i = netif_get_ip6_addr_match(netif, ip6addr);
|
|
|
|
if (i >= 0) {
|
|
|
|
/* Address already added */
|
|
|
|
if (chosen_idx != NULL) {
|
|
|
|
*chosen_idx = i;
|
|
|
|
}
|
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
/* Find a free slot. The first one is reserved for link-local addresses. */
|
|
|
|
for (i = ip6_addr_islinklocal(ip6addr) ? 0 : 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
2016-12-13 20:54:49 +00:00
|
|
|
if (ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) {
|
2015-09-23 20:09:37 +00:00
|
|
|
ip_addr_copy_from_ip6(netif->ip6_addr[i], *ip6addr);
|
Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.
The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.
The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.
It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.
This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.
For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-01-23 23:04:39 +00:00
|
|
|
ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[i]), IP6_UNICAST, netif);
|
2015-03-06 20:30:59 +00:00
|
|
|
netif_ip6_addr_set_state(netif, i, IP6_ADDR_TENTATIVE);
|
|
|
|
if (chosen_idx != NULL) {
|
|
|
|
*chosen_idx = i;
|
|
|
|
}
|
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chosen_idx != NULL) {
|
|
|
|
*chosen_idx = -1;
|
|
|
|
}
|
|
|
|
return ERR_VAL;
|
|
|
|
}
|
|
|
|
|
2015-03-06 20:38:57 +00:00
|
|
|
/** Dummy IPv6 output function for netifs not supporting IPv6
|
|
|
|
*/
|
2012-08-17 16:56:14 +00:00
|
|
|
static err_t
|
2015-02-22 20:46:35 +00:00
|
|
|
netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr)
|
2012-08-17 16:56:14 +00:00
|
|
|
{
|
2015-03-06 20:38:57 +00:00
|
|
|
LWIP_UNUSED_ARG(netif);
|
|
|
|
LWIP_UNUSED_ARG(p);
|
|
|
|
LWIP_UNUSED_ARG(ipaddr);
|
2012-08-17 16:56:14 +00:00
|
|
|
|
2015-03-06 20:38:57 +00:00
|
|
|
return ERR_IF;
|
2012-08-17 16:56:14 +00:00
|
|
|
}
|
2011-05-17 19:35:14 +00:00
|
|
|
#endif /* LWIP_IPV6 */
|
2017-01-20 03:38:46 +00:00
|
|
|
|
2018-03-13 19:29:37 +00:00
|
|
|
#if LWIP_IPV4
|
|
|
|
/** Dummy IPv4 output function for netifs not supporting IPv4
|
|
|
|
*/
|
|
|
|
static err_t
|
|
|
|
netif_null_output_ip4(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
|
|
|
|
{
|
|
|
|
LWIP_UNUSED_ARG(netif);
|
|
|
|
LWIP_UNUSED_ARG(p);
|
|
|
|
LWIP_UNUSED_ARG(ipaddr);
|
|
|
|
|
|
|
|
return ERR_IF;
|
|
|
|
}
|
|
|
|
#endif /* LWIP_IPV4 */
|
|
|
|
|
2017-01-20 03:38:46 +00:00
|
|
|
/**
|
2017-02-09 18:39:07 +00:00
|
|
|
* @ingroup netif
|
2017-01-20 03:38:46 +00:00
|
|
|
* Return the interface index for the netif with name
|
2017-05-02 10:51:25 +00:00
|
|
|
* or NETIF_NO_INDEX if not found/on error
|
2017-01-20 03:38:46 +00:00
|
|
|
*
|
|
|
|
* @param name the name of the netif
|
|
|
|
*/
|
|
|
|
u8_t
|
|
|
|
netif_name_to_index(const char *name)
|
|
|
|
{
|
|
|
|
struct netif *netif = netif_find(name);
|
|
|
|
if (netif != NULL) {
|
2017-02-13 12:21:45 +00:00
|
|
|
return netif_get_index(netif);
|
2017-01-20 03:38:46 +00:00
|
|
|
}
|
|
|
|
/* No name found, return invalid index */
|
2017-05-02 10:51:25 +00:00
|
|
|
return NETIF_NO_INDEX;
|
2017-01-20 03:38:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-02-09 18:39:07 +00:00
|
|
|
* @ingroup netif
|
2017-01-20 03:38:46 +00:00
|
|
|
* Return the interface name for the netif matching index
|
|
|
|
* or NULL if not found/on error
|
|
|
|
*
|
2017-01-24 10:39:34 +00:00
|
|
|
* @param idx the interface index of the netif
|
2017-02-03 22:45:29 +00:00
|
|
|
* @param name char buffer of at least NETIF_NAMESIZE bytes
|
2017-01-20 03:38:46 +00:00
|
|
|
*/
|
|
|
|
char *
|
2017-01-23 23:21:43 +00:00
|
|
|
netif_index_to_name(u8_t idx, char *name)
|
2017-01-20 03:38:46 +00:00
|
|
|
{
|
2017-02-13 12:26:54 +00:00
|
|
|
struct netif *netif = netif_get_by_index(idx);
|
|
|
|
|
|
|
|
if (netif != NULL) {
|
|
|
|
name[0] = netif->name[0];
|
|
|
|
name[1] = netif->name[1];
|
|
|
|
lwip_itoa(&name[2], NETIF_NAMESIZE - 2, netif_index_to_num(idx));
|
|
|
|
return name;
|
2017-01-20 03:38:46 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-02-13 12:21:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup netif
|
|
|
|
* Return the interface for the netif index
|
|
|
|
*
|
2017-02-13 12:26:54 +00:00
|
|
|
* @param idx index of netif to find
|
2017-02-13 12:21:45 +00:00
|
|
|
*/
|
2017-09-17 18:38:38 +00:00
|
|
|
struct netif *
|
2017-02-13 12:26:54 +00:00
|
|
|
netif_get_by_index(u8_t idx)
|
2017-02-13 12:21:45 +00:00
|
|
|
{
|
2017-09-17 18:38:38 +00:00
|
|
|
struct netif *netif;
|
2017-02-13 12:21:45 +00:00
|
|
|
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2017-02-13 12:26:54 +00:00
|
|
|
if (idx != NETIF_NO_INDEX) {
|
2017-03-01 15:10:50 +00:00
|
|
|
NETIF_FOREACH(netif) {
|
2017-02-13 12:26:54 +00:00
|
|
|
if (idx == netif_get_index(netif)) {
|
2017-02-13 12:21:45 +00:00
|
|
|
return netif; /* found! */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-25 10:07:28 +00:00
|
|
|
return NULL;
|
2017-02-13 12:21:45 +00:00
|
|
|
}
|
2017-02-13 12:35:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup netif
|
|
|
|
* Find a network interface by searching for its name
|
|
|
|
*
|
|
|
|
* @param name the name of the netif (like netif->name) plus concatenated number
|
|
|
|
* in ascii representation (e.g. 'en0')
|
|
|
|
*/
|
|
|
|
struct netif *
|
|
|
|
netif_find(const char *name)
|
|
|
|
{
|
|
|
|
struct netif *netif;
|
|
|
|
u8_t num;
|
|
|
|
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
|
2017-02-13 12:35:30 +00:00
|
|
|
if (name == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
num = (u8_t)atoi(&name[2]);
|
|
|
|
|
2017-03-01 15:10:50 +00:00
|
|
|
NETIF_FOREACH(netif) {
|
2017-02-13 12:35:30 +00:00
|
|
|
if (num == netif->num &&
|
2017-09-17 18:38:38 +00:00
|
|
|
name[0] == netif->name[0] &&
|
|
|
|
name[1] == netif->name[1]) {
|
2017-02-13 12:35:30 +00:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1]));
|
|
|
|
return netif;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1]));
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-02-13 20:40:08 +00:00
|
|
|
|
|
|
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
|
|
|
/**
|
|
|
|
* @ingroup netif
|
|
|
|
* Add extended netif events listener
|
|
|
|
* @param callback pointer to listener structure
|
2017-02-14 19:28:43 +00:00
|
|
|
* @param fn callback function
|
2017-02-13 20:40:08 +00:00
|
|
|
*/
|
2018-01-12 21:25:34 +00:00
|
|
|
void
|
|
|
|
netif_add_ext_callback(netif_ext_callback_t *callback, netif_ext_callback_fn fn)
|
2017-02-13 20:40:08 +00:00
|
|
|
{
|
2018-01-02 12:44:38 +00:00
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
2017-02-14 19:35:48 +00:00
|
|
|
LWIP_ASSERT("callback must be != NULL", callback != NULL);
|
|
|
|
LWIP_ASSERT("fn must be != NULL", fn != NULL);
|
|
|
|
|
2017-02-13 20:40:08 +00:00
|
|
|
callback->callback_fn = fn;
|
2017-02-15 09:14:06 +00:00
|
|
|
callback->next = ext_callback;
|
|
|
|
ext_callback = callback;
|
2017-02-13 20:40:08 +00:00
|
|
|
}
|
|
|
|
|
2018-01-12 21:25:34 +00:00
|
|
|
/**
|
|
|
|
* @ingroup netif
|
|
|
|
* Remove extended netif events listener
|
|
|
|
* @param callback pointer to listener structure
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netif_remove_ext_callback(netif_ext_callback_t* callback)
|
|
|
|
{
|
|
|
|
netif_ext_callback_t *last, *iter;
|
|
|
|
|
|
|
|
LWIP_ASSERT_CORE_LOCKED();
|
|
|
|
LWIP_ASSERT("callback must be != NULL", callback != NULL);
|
|
|
|
|
|
|
|
if (ext_callback == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (callback == ext_callback) {
|
|
|
|
ext_callback = ext_callback->next;
|
|
|
|
} else {
|
|
|
|
last = ext_callback;
|
|
|
|
for (iter = ext_callback->next; iter != NULL; last = iter, iter = iter->next) {
|
|
|
|
if (iter == callback) {
|
|
|
|
LWIP_ASSERT("last != NULL", last != NULL);
|
|
|
|
last->next = callback->next;
|
|
|
|
callback->next = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-13 20:40:08 +00:00
|
|
|
/**
|
|
|
|
* Invoke extended netif status event
|
|
|
|
* @param netif netif that is affected by change
|
|
|
|
* @param reason change reason
|
2017-02-15 09:14:06 +00:00
|
|
|
* @param args depends on reason, see reason description
|
2017-02-13 20:40:08 +00:00
|
|
|
*/
|
2018-01-12 21:25:34 +00:00
|
|
|
void
|
|
|
|
netif_invoke_ext_callback(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)
|
2017-02-13 20:40:08 +00:00
|
|
|
{
|
2017-09-17 18:38:38 +00:00
|
|
|
netif_ext_callback_t *callback = ext_callback;
|
2017-04-25 10:07:28 +00:00
|
|
|
|
2017-02-15 09:14:06 +00:00
|
|
|
LWIP_ASSERT("netif must be != NULL", netif != NULL);
|
2017-04-25 10:07:28 +00:00
|
|
|
|
|
|
|
while (callback != NULL) {
|
2017-02-15 09:14:06 +00:00
|
|
|
callback->callback_fn(netif, reason, args);
|
2017-02-13 20:40:08 +00:00
|
|
|
callback = callback->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* LWIP_NETIF_EXT_STATUS_CALLBACK */
|