Send connman mailing list submissions to connman@lists.01.org To subscribe or unsubscribe via the World Wide Web, visit https://lists.01.org/mailman/listinfo/connman or, via email, send a message with subject or body 'help' to connman-requ...@lists.01.org
You can reach the person managing the list at connman-ow...@lists.01.org When replying, please edit your Subject line so it is more specific than "Re: Contents of connman digest..." Today's Topics: 1. [PATCH 15/27] acd: add acd_defend_timeout and acd_announce_timeout (Christian Spielberger) 2. [PATCH 19/27] network: add content of acd callback functions (Christian Spielberger) 3. [PATCH 17/27] acd: add callback registration (Christian Spielberger) 4. [PATCH 18/27] network: init and start of acd (Christian Spielberger) 5. [PATCH 24/27] acd: add acdhost_get_conflicts_count (Christian Spielberger) 6. [PATCH 27/27] network: also send DHCP DECLINE after second DHCP try (Christian Spielberger) ---------------------------------------------------------------------- Message: 1 Date: Wed, 11 Apr 2018 16:00:35 +0200 From: Christian Spielberger <christian.spielber...@gmail.com> To: Daniel Wagner <w...@monom.org> Cc: connman@lists.01.org, Christian Spielberger <christian.spielber...@gmail.com> Subject: [PATCH 15/27] acd: add acd_defend_timeout and acd_announce_timeout Message-ID: <1523455247-5877-16-git-send-email-christian.spielber...@gmail.com> Adds the content of acd_defend_timeout which switches from state DEFEND back to MONITOR. Also adds content of acd_announce_timeout which sends repeated announce packets until ANNOUNCE_NUM is reached, then switches back to state MONITOR. --- src/acd.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/acd.c b/src/acd.c index fcc955c..76dbc77 100644 --- a/src/acd.c +++ b/src/acd.c @@ -27,6 +27,9 @@ #include <unistd.h> #include <stdarg.h> #include <stdio.h> +#include <netinet/if_ether.h> +#include <net/if_arp.h> +#include <string.h> typedef enum _acd_state { ACD_PROBE, @@ -35,6 +38,13 @@ typedef enum _acd_state { ACD_DEFEND, } ACDState; +static const char* acd_state_texts[] = { + "PROBE", + "ANNOUNCE", + "MONITOR", + "DEFEND" +}; + struct _acd_host { ACDState state; int ifindex; @@ -326,10 +336,38 @@ void acdhost_stop(acd_host *acd) static gboolean acd_defend_timeout(gpointer acd_data) { + acd_host *acd = acd_data; + + debug(acd, "back to MONITOR mode"); + acd->timeout = 0; + acd->conflicts = 0; + acd->state = ACD_MONITOR; + + return FALSE; } static gboolean acd_announce_timeout(gpointer acd_data) { + acd_host *acd = acd_data; + + acd->timeout = 0; + + debug(acd, "acd announce timeout (retries %d)", acd->retry_times); + if (acd->retry_times != ANNOUNCE_NUM) { + acd->retry_times++; + send_announce_packet(acd); + return FALSE; + } + + debug(acd, "switching to monitor mode"); + acd->state = ACD_MONITOR; + + if (acd->ipv4_available_cb) + acd->ipv4_available_cb(acd, + acd->ipv4_available_data); + acd->conflicts = 0; + + return FALSE; } static int acd_recv_arp_packet(acd_host *acd) { -- 2.7.4 ------------------------------ Message: 2 Date: Wed, 11 Apr 2018 16:00:39 +0200 From: Christian Spielberger <christian.spielber...@gmail.com> To: Daniel Wagner <w...@monom.org> Cc: connman@lists.01.org, Christian Spielberger <christian.spielber...@gmail.com> Subject: [PATCH 19/27] network: add content of acd callback functions Message-ID: <1523455247-5877-20-git-send-email-christian.spielber...@gmail.com> Adds content for acdhost_ipv4_available and acdhost_ipv4_lost which is basically applying (adding) and removing an IPv4 address to ipconfig. --- src/network.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/network.c b/src/network.c index e3207da..5b79a2a 100644 --- a/src/network.c +++ b/src/network.c @@ -157,20 +157,98 @@ static void set_configuration(struct connman_network *network, type); } +static int start_acd(struct connman_network *network); + static void acdhost_ipv4_available(acd_host *acd, gpointer user_data) { + struct connman_network *network = user_data; + struct connman_service *service; + struct connman_ipconfig *ipconfig_ipv4; + int err; + + if (!network) + return; + + service = connman_service_lookup_from_network(network); + if (!service) + return; + + ipconfig_ipv4 = __connman_service_get_ip4config(service); + if (!ipconfig_ipv4) { + connman_error("Service has no IPv4 configuration"); + return; + } + + err = __connman_ipconfig_address_add(ipconfig_ipv4); + if (err < 0) + goto err; + + err = __connman_ipconfig_gateway_add(ipconfig_ipv4); + if (err < 0) + goto err; + + __connman_service_save(service); + + return; + +err: + connman_network_set_error(__connman_service_get_network(service), + CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL); } static void acdhost_ipv4_lost(acd_host *acd, gpointer user_data) { + struct connman_network *network = user_data; + struct connman_service *service; + struct connman_ipconfig *ipconfig_ipv4; + enum connman_ipconfig_type type; + enum connman_ipconfig_method method; + + if (!network) + return; + + service = connman_service_lookup_from_network(network); + if (!service) + return; + + ipconfig_ipv4 = __connman_service_get_ip4config(service); + if (!ipconfig_ipv4) { + connman_error("Service has no IPv4 configuration"); + return; + } + + type = __connman_ipconfig_get_config_type(ipconfig_ipv4); + if (type != CONNMAN_IPCONFIG_TYPE_IPV4) + return; + + __connman_ipconfig_address_remove(ipconfig_ipv4); + + method = __connman_ipconfig_get_method(ipconfig_ipv4); + if (method == CONNMAN_IPCONFIG_METHOD_DHCP) { + /* We have one more chance for DHCP. If this fails + * acdhost_ipv4_conflict will be called. */ + network = __connman_service_get_network(service); + if (network) + __connman_network_enable_ipconfig(network, ipconfig_ipv4); + } else { + /* Start IPv4LL ACD. */ + } } static void acdhost_ipv4_conflict(acd_host *acd, gpointer user_data) { + struct connman_network *network = user_data; + + /* Start IPv4LL ACD. */ } static void acdhost_ipv4_maxconflict(acd_host *acd, gpointer user_data) { + struct connman_network *network = user_data; + + connman_info("Had maximum number of conflicts. Next IPv4LL address will be " + "tried in %d seconds", RATE_LIMIT_INTERVAL); + /* Wait, then start IPv4LL ACD. */ } static int start_acd(struct connman_network *network) -- 2.7.4 ------------------------------ Message: 3 Date: Wed, 11 Apr 2018 16:00:37 +0200 From: Christian Spielberger <christian.spielber...@gmail.com> To: Daniel Wagner <w...@monom.org> Cc: connman@lists.01.org, Christian Spielberger <christian.spielber...@gmail.com> Subject: [PATCH 17/27] acd: add callback registration Message-ID: <1523455247-5877-18-git-send-email-christian.spielber...@gmail.com> Adds function acdhost_register_event for registration of higher level address conflict callback functions. --- include/acd.h | 12 ++++++++++++ src/acd.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/acd.h b/include/acd.h index 24b4707..dc7e570 100644 --- a/include/acd.h +++ b/include/acd.h @@ -40,6 +40,18 @@ void acdhost_stop(acd_host *acd); typedef void (*ACDHostEventFunc) (acd_host *acd, gpointer user_data); +typedef enum { + ACDHOST_EVENT_IPV4_AVAILABLE, + ACDHOST_EVENT_IPV4_LOST, + ACDHOST_EVENT_IPV4_CONFLICT, + ACDHOST_EVENT_IPV4_MAXCONFLICT, +} ACDHostEvent; + +void acdhost_register_event(acd_host *acd, + ACDHostEvent event, + ACDHostEventFunc func, + gpointer user_data); + #ifdef __cplusplus } #endif diff --git a/src/acd.c b/src/acd.c index c796f2f..cdd2569 100644 --- a/src/acd.c +++ b/src/acd.c @@ -454,3 +454,32 @@ static int acd_recv_arp_packet(acd_host *acd) { return 0; } + +void acdhost_register_event(acd_host *acd, + ACDHostEvent event, + ACDHostEventFunc func, + gpointer user_data) +{ + switch (event) { + case ACDHOST_EVENT_IPV4_AVAILABLE: + acd->ipv4_available_cb = func; + acd->ipv4_available_data = user_data; + break; + case ACDHOST_EVENT_IPV4_LOST: + acd->ipv4_lost_cb = func; + acd->ipv4_lost_data = user_data; + break; + case ACDHOST_EVENT_IPV4_CONFLICT: + acd->ipv4_conflict_cb = func; + acd->ipv4_conflict_data = user_data; + break; + case ACDHOST_EVENT_IPV4_MAXCONFLICT: + acd->ipv4_max_conflicts_cb = func; + acd->ipv4_max_conflicts_data = user_data; + break; + default: + connman_warn("%s unknown event %d.", __FUNCTION__, event); + break; + } +} + -- 2.7.4 ------------------------------ Message: 4 Date: Wed, 11 Apr 2018 16:00:38 +0200 From: Christian Spielberger <christian.spielber...@gmail.com> To: Daniel Wagner <w...@monom.org> Cc: connman@lists.01.org, Christian Spielberger <christian.spielber...@gmail.com> Subject: [PATCH 18/27] network: init and start of acd Message-ID: <1523455247-5877-19-git-send-email-christian.spielber...@gmail.com> Adds empty higher level ACD callback functions. Also adds content of function start_acd which is allocation of ACD structure, registration of callback functions and invoke ACD with a pre-defined IPv4 address. --- src/network.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/network.c b/src/network.c index acf4179..e3207da 100644 --- a/src/network.c +++ b/src/network.c @@ -27,6 +27,7 @@ #include <string.h> #include <connman/acd.h> +#include "src/shared/arp.h" #include "connman.h" /* @@ -156,10 +157,28 @@ static void set_configuration(struct connman_network *network, type); } +static void acdhost_ipv4_available(acd_host *acd, gpointer user_data) +{ +} + +static void acdhost_ipv4_lost(acd_host *acd, gpointer user_data) +{ +} + +static void acdhost_ipv4_conflict(acd_host *acd, gpointer user_data) +{ +} + +static void acdhost_ipv4_maxconflict(acd_host *acd, gpointer user_data) +{ +} + static int start_acd(struct connman_network *network) { struct connman_service *service; struct connman_ipconfig *ipconfig_ipv4; + const char* address; + struct in_addr addr; service = connman_service_lookup_from_network(network); if (!service) @@ -171,6 +190,40 @@ static int start_acd(struct connman_network *network) return -EINVAL; } + if (!network->acdhost) { + int index; + + index = __connman_ipconfig_get_index(ipconfig_ipv4); + network->acdhost = acdhost_new(index); + if (!network->acdhost) { + connman_error("Could not create ACD data structure"); + return -EINVAL; + } + + acdhost_register_event(network->acdhost, + ACDHOST_EVENT_IPV4_AVAILABLE, + acdhost_ipv4_available, network); + acdhost_register_event(network->acdhost, + ACDHOST_EVENT_IPV4_LOST, + acdhost_ipv4_lost, network); + acdhost_register_event(network->acdhost, + ACDHOST_EVENT_IPV4_CONFLICT, + acdhost_ipv4_conflict, network); + acdhost_register_event(network->acdhost, + ACDHOST_EVENT_IPV4_MAXCONFLICT, + acdhost_ipv4_maxconflict, network); + } + + address = __connman_ipconfig_get_local(ipconfig_ipv4); + if (!address) + return -EINVAL; + + connman_info("Starting ACD for address %s", address); + if (inet_pton(AF_INET, address, &addr) != 1) + connman_error("Could not convert address %s", address); + + acdhost_start(network->acdhost, htonl(addr.s_addr)); + return 0; } -- 2.7.4 ------------------------------ Message: 5 Date: Wed, 11 Apr 2018 16:00:44 +0200 From: Christian Spielberger <christian.spielber...@gmail.com> To: Daniel Wagner <w...@monom.org> Cc: connman@lists.01.org, Christian Spielberger <christian.spielber...@gmail.com> Subject: [PATCH 24/27] acd: add acdhost_get_conflicts_count Message-ID: <1523455247-5877-25-git-send-email-christian.spielber...@gmail.com> This is necessary to decide if DHCP can be tried again. --- include/acd.h | 2 ++ src/acd.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/acd.h b/include/acd.h index 69d740d..b4ecfc5 100644 --- a/include/acd.h +++ b/include/acd.h @@ -55,6 +55,8 @@ void acdhost_register_event(acd_host *acd, void acdhost_append_dbus_property(acd_host *acd, DBusMessageIter *dict); +unsigned int acdhost_get_conflicts_count(acd_host *acd); + #ifdef __cplusplus } #endif diff --git a/src/acd.c b/src/acd.c index f10e3d7..9c8ed8f 100644 --- a/src/acd.c +++ b/src/acd.c @@ -565,3 +565,8 @@ static void report_conflict(acd_host *acd) connman_dbus_property_changed_dict(acd->path, CONNMAN_SERVICE_INTERFACE, "LastAddressConflict", append_ac_property, acd); } + +unsigned int acdhost_get_conflicts_count(acd_host *acd) +{ + return acd->conflicts; +} -- 2.7.4 ------------------------------ Message: 6 Date: Wed, 11 Apr 2018 16:00:47 +0200 From: Christian Spielberger <christian.spielber...@gmail.com> To: Daniel Wagner <w...@monom.org> Cc: connman@lists.01.org, Christian Spielberger <christian.spielber...@gmail.com> Subject: [PATCH 27/27] network: also send DHCP DECLINE after second DHCP try Message-ID: <1523455247-5877-28-git-send-email-christian.spielber...@gmail.com> DHCP is tried two times. We want to send also a DECLINE after second try fails with an address conflict. --- src/network.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network.c b/src/network.c index 777966f..8611daf 100644 --- a/src/network.c +++ b/src/network.c @@ -336,6 +336,7 @@ static void acdhost_ipv4_conflict(acd_host *acd, gpointer user_data) if (method == CONNMAN_IPCONFIG_METHOD_DHCP) { __connman_ipconfig_set_method(ipconfig_ipv4, CONNMAN_IPCONFIG_METHOD_AUTO); + __connman_dhcp_decline(ipconfig_ipv4); } /* Start IPv4LL ACD. */ if (start_ipv4ll(network) < 0) -- 2.7.4 ------------------------------ Subject: Digest Footer _______________________________________________ connman mailing list connman@lists.01.org https://lists.01.org/mailman/listinfo/connman ------------------------------ End of connman Digest, Vol 30, Issue 8 **************************************