Send connman mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [RFC PATCH 15/27] acd: add callback function pointers
(Peter Meerwald-Stadler)
2. [RFC PATCH 16/27] acd: add acdhost_start and acdhost_stop
(Peter Meerwald-Stadler)
3. [RFC PATCH 11/27] acd: add struct _ACDHost
(Peter Meerwald-Stadler)
4. [RFC PATCH 14/27] acd: add send_announce_packet
(Peter Meerwald-Stadler)
5. [RFC PATCH 17/27] acd: add acd_defend_timeout and
acd_announce_timeout (Peter Meerwald-Stadler)
6. [RFC PATCH 19/27] acd: add callback registration
(Peter Meerwald-Stadler)
7. [RFC PATCH 21/27] service: add acd callback functions
(Peter Meerwald-Stadler)
----------------------------------------------------------------------
Message: 1
Date: Wed, 21 Mar 2018 14:42:25 +0100
From: Peter Meerwald-Stadler <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [RFC PATCH 15/27] acd: add callback function pointers
Message-ID: <[email protected]>
From: Christian Spielberger <[email protected]>
---
include/acd.h | 3 +++
src/acd.c | 15 ++++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/acd.h b/include/acd.h
index 1fb354a9..1f940f2b 100644
--- a/include/acd.h
+++ b/include/acd.h
@@ -22,6 +22,7 @@
#define __CONNMAN_ACD_H
#include <stdint.h>
+#include <glib.h>
#ifdef __cplusplus
extern "C" {
@@ -33,6 +34,8 @@ typedef struct _ACDHost ACDHost;
ACDHost *acdhost_new(int ifindex);
+typedef void (*ACDHostEventFunc) (ACDHost *acd, gpointer user_data);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/acd.c b/src/acd.c
index dcd544c0..bd8901de 100644
--- a/src/acd.c
+++ b/src/acd.c
@@ -19,7 +19,6 @@
#include <connman/inet.h>
#include <shared/arp.h>
#include <shared/random.h>
-#include <glib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
@@ -45,6 +44,15 @@ struct _ACDHost {
unsigned int conflicts;
guint timeout;
guint listener_watch;
+
+ ACDHostEventFunc ipv4_available_cb;
+ gpointer ipv4_available_data;
+ ACDHostEventFunc ipv4_lost_cb;
+ gpointer ipv4_lost_data;
+ ACDHostEventFunc ipv4_conflict_cb;
+ gpointer ipv4_conflict_data;
+ ACDHostEventFunc ipv4_max_conflicts_cb;
+ gpointer ipv4_max_conflicts_data;
};
static int start_listening(ACDHost *acd);
@@ -106,6 +114,11 @@ ACDHost *acdhost_new(int ifindex)
acd->listener_watch = 0;
acd->retry_times = 0;
+ acd->ipv4_available_cb = NULL;
+ acd->ipv4_lost_cb = NULL;
+ acd->ipv4_conflict_cb = NULL;
+ acd->ipv4_max_conflicts_cb = NULL;
+
return acd;
error:
--
2.16.2
------------------------------
Message: 2
Date: Wed, 21 Mar 2018 14:42:26 +0100
From: Peter Meerwald-Stadler <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [RFC PATCH 16/27] acd: add acdhost_start and acdhost_stop
Message-ID: <[email protected]>
From: Christian Spielberger <[email protected]>
---
include/acd.h | 2 ++
src/acd.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/service.c | 3 +++
3 files changed, 59 insertions(+)
diff --git a/include/acd.h b/include/acd.h
index 1f940f2b..aabe9b25 100644
--- a/include/acd.h
+++ b/include/acd.h
@@ -33,6 +33,8 @@ struct _ACDHost;
typedef struct _ACDHost ACDHost;
ACDHost *acdhost_new(int ifindex);
+int acdhost_start(ACDHost *acd, uint32_t ip);
+void acdhost_stop(ACDHost *acd);
typedef void (*ACDHostEventFunc) (ACDHost *acd, gpointer user_data);
diff --git a/src/acd.c b/src/acd.c
index bd8901de..bcb49620 100644
--- a/src/acd.c
+++ b/src/acd.c
@@ -276,3 +276,57 @@ static gboolean send_announce_packet(gpointer acd_data)
NULL);
return TRUE;
}
+
+int acdhost_start(ACDHost *acd, uint32_t ip)
+{
+ guint timeout;
+ int err;
+
+ remove_timeout(acd);
+
+ err = start_listening(acd);
+ if (err)
+ return err;
+
+ acd->retry_times = 0;
+ acd->requested_ip = ip;
+
+ /* First wait a random delay to avoid storm of ARP requests on boot */
+ timeout = random_delay_ms(PROBE_WAIT);
+ acd->state = ACD_PROBE;
+
+ acd->timeout = g_timeout_add_full(G_PRIORITY_HIGH,
+ timeout,
+ acd_probe_timeout,
+ acd,
+ NULL);
+ return 0;
+}
+
+void acdhost_stop(ACDHost *acd)
+{
+
+ stop_listening(acd);
+
+ remove_timeout(acd);
+
+ if (acd->listener_watch > 0) {
+ g_source_remove(acd->listener_watch);
+ acd->listener_watch = 0;
+ }
+
+ acd->state = ACD_PROBE;
+ acd->retry_times = 0;
+ acd->requested_ip = 0;
+}
+
+static gboolean acd_defend_timeout(gpointer acd_data)
+{
+}
+
+static gboolean acd_announce_timeout(gpointer acd_data)
+{
+}
+
+static int acd_recv_arp_packet(ACDHost *acd) {
+}
diff --git a/src/service.c b/src/service.c
index 8abdaea4..459e2534 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6447,6 +6447,9 @@ int __connman_service_disconnect(struct connman_service
*service)
service->connect_reason = CONNMAN_SERVICE_CONNECT_REASON_NONE;
service->proxy = CONNMAN_SERVICE_PROXY_METHOD_UNKNOWN;
+ if (service->acdhost)
+ acdhost_stop(service->acdhost);
+
connman_agent_cancel(service);
reply_pending(service, ECONNABORTED);
--
2.16.2
------------------------------
Message: 3
Date: Wed, 21 Mar 2018 14:42:21 +0100
From: Peter Meerwald-Stadler <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [RFC PATCH 11/27] acd: add struct _ACDHost
Message-ID: <[email protected]>
From: Christian Spielberger <[email protected]>
---
include/acd.h | 4 ++++
src/acd.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
diff --git a/include/acd.h b/include/acd.h
index 6d98c289..1fb354a9 100644
--- a/include/acd.h
+++ b/include/acd.h
@@ -21,6 +21,8 @@
#ifndef __CONNMAN_ACD_H
#define __CONNMAN_ACD_H
+#include <stdint.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -29,6 +31,8 @@ struct _ACDHost;
typedef struct _ACDHost ACDHost;
+ACDHost *acdhost_new(int ifindex);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/acd.c b/src/acd.c
index 6db816f2..19384515 100644
--- a/src/acd.c
+++ b/src/acd.c
@@ -14,3 +14,73 @@
*
*/
+#include <connman/acd.h>
+#include <connman/log.h>
+#include <connman/inet.h>
+#include <shared/arp.h>
+#include <glib.h>
+
+typedef enum _acd_state {
+ ACD_PROBE,
+ ACD_ANNOUNCE,
+ ACD_MONITOR,
+ ACD_DEFEND,
+} ACDState;
+
+struct _ACDHost {
+ ACDState state;
+ int ifindex;
+ char *interface;
+ uint8_t mac_address[6];
+ uint32_t requested_ip; /* host byte order */
+
+ bool listen_on;
+ int listener_sockfd;
+ unsigned int retry_times;
+ unsigned int conflicts;
+ guint timeout;
+ guint listener_watch;
+};
+
+ACDHost *acdhost_new(int ifindex)
+{
+ ACDHost *acd;
+
+ if (ifindex < 0) {
+ connman_error("Invalid interface index %d", ifindex);
+ return NULL;
+ }
+
+ acd = g_try_new0(ACDHost, 1);
+ if (!acd) {
+ connman_error("Could not allocate acd data structure");
+ return NULL;
+ }
+
+ acd->interface = connman_inet_ifname(ifindex);
+ if (!acd->interface) {
+ connman_error("Interface with index %d is not available",
ifindex);
+ goto error;
+ }
+
+ if (!connman_inet_is_ifup(ifindex)) {
+ connman_error("Interface with index %d and name %s is down",
ifindex,
+ acd->interface);
+ goto error;
+ }
+
+ get_interface_mac_address(ifindex, acd->mac_address);
+
+ acd->listener_sockfd = -1;
+ acd->listen_on = FALSE;
+ acd->ifindex = ifindex;
+ acd->listener_watch = 0;
+ acd->retry_times = 0;
+
+ return acd;
+
+error:
+ g_free(acd->interface);
+ g_free(acd);
+ return NULL;
+}
--
2.16.2
------------------------------
Message: 4
Date: Wed, 21 Mar 2018 14:42:24 +0100
From: Peter Meerwald-Stadler <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [RFC PATCH 14/27] acd: add send_announce_packet
Message-ID: <[email protected]>
From: Christian Spielberger <[email protected]>
---
src/acd.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/src/acd.c b/src/acd.c
index 78b8a582..dcd544c0 100644
--- a/src/acd.c
+++ b/src/acd.c
@@ -54,6 +54,9 @@ static gboolean acd_listener_event(GIOChannel *channel,
GIOCondition condition,
static int acd_recv_arp_packet(ACDHost *acd);
static void send_probe_packet(gpointer acd_data);
static gboolean acd_probe_timeout(gpointer acd_data);
+static gboolean send_announce_packet(gpointer acd_data);
+static gboolean acd_announce_timeout(gpointer acd_data);
+static gboolean acd_defend_timeout(gpointer acd_data);
static void debug(ACDHost *acd, const char *format, ...)
{
@@ -111,6 +114,14 @@ error:
return NULL;
}
+static void remove_timeout(ACDHost *acd)
+{
+ if (acd->timeout > 0)
+ g_source_remove(acd->timeout);
+
+ acd->timeout = 0;
+}
+
static int start_listening(ACDHost *acd)
{
GIOChannel *listener_channel;
@@ -182,6 +193,7 @@ static void send_probe_packet(gpointer acd_data)
ACDHost *acd = acd_data;
debug(acd, "sending ARP probe request");
+ remove_timeout(acd);
if (acd->retry_times == 1) {
acd->state = ACD_PROBE;
start_listening(acd);
@@ -224,3 +236,30 @@ static gboolean acd_probe_timeout(gpointer acd_data)
return FALSE;
}
+static gboolean send_announce_packet(gpointer acd_data)
+{
+ ACDHost *acd = acd_data;
+
+ debug(acd, "sending ACD announce request");
+
+ send_arp_packet(acd->mac_address,
+ acd->requested_ip,
+ acd->requested_ip,
+ acd->ifindex);
+
+ remove_timeout(acd);
+
+ if (acd->state == ACD_DEFEND)
+ acd->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
+ DEFEND_INTERVAL,
+ acd_defend_timeout,
+ acd,
+ NULL);
+ else
+ acd->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
+ ANNOUNCE_INTERVAL,
+ acd_announce_timeout,
+ acd,
+ NULL);
+ return TRUE;
+}
--
2.16.2
------------------------------
Message: 5
Date: Wed, 21 Mar 2018 14:42:27 +0100
From: Peter Meerwald-Stadler <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [RFC PATCH 17/27] acd: add acd_defend_timeout and
acd_announce_timeout
Message-ID: <[email protected]>
From: Christian Spielberger <[email protected]>
---
src/acd.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/acd.c b/src/acd.c
index bcb49620..2963d44e 100644
--- a/src/acd.c
+++ b/src/acd.c
@@ -23,6 +23,9 @@
#include <errno.h>
#include <unistd.h>
#include <stdarg.h>
+#include <netinet/if_ether.h>
+#include <net/if_arp.h>
+#include <string.h>
typedef enum _acd_state {
ACD_PROBE,
@@ -31,6 +34,13 @@ typedef enum _acd_state {
ACD_DEFEND,
} ACDState;
+static const char* acd_state_texts[] = {
+ "PROBE",
+ "ANNOUNCE",
+ "MONITOR",
+ "DEFEND"
+};
+
struct _ACDHost {
ACDState state;
int ifindex;
@@ -322,10 +332,37 @@ void acdhost_stop(ACDHost *acd)
static gboolean acd_defend_timeout(gpointer acd_data)
{
+ ACDHost *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)
{
+ ACDHost *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(ACDHost *acd) {
--
2.16.2
------------------------------
Message: 6
Date: Wed, 21 Mar 2018 14:42:29 +0100
From: Peter Meerwald-Stadler <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [RFC PATCH 19/27] acd: add callback registration
Message-ID: <[email protected]>
From: Christian Spielberger <[email protected]>
---
include/acd.h | 12 ++++++++++++
src/acd.c | 29 +++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/include/acd.h b/include/acd.h
index aabe9b25..deaea130 100644
--- a/include/acd.h
+++ b/include/acd.h
@@ -38,6 +38,18 @@ void acdhost_stop(ACDHost *acd);
typedef void (*ACDHostEventFunc) (ACDHost *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(ACDHost *acd,
+ ACDHostEvent event,
+ ACDHostEventFunc func,
+ gpointer user_data);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/acd.c b/src/acd.c
index aabbedd5..f3a1c759 100644
--- a/src/acd.c
+++ b/src/acd.c
@@ -449,3 +449,32 @@ static int acd_recv_arp_packet(ACDHost *acd) {
return 0;
}
+
+void acdhost_register_event(ACDHost *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("Unknown %s event %d.", __FUNCTION__, event);
+ break;
+ }
+}
+
--
2.16.2
------------------------------
Message: 7
Date: Wed, 21 Mar 2018 14:42:31 +0100
From: Peter Meerwald-Stadler <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [RFC PATCH 21/27] service: add acd callback functions
Message-ID: <[email protected]>
From: Christian Spielberger <[email protected]>
---
src/service.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/src/service.c b/src/service.c
index 57aa9359..14e9a456 100644
--- a/src/service.c
+++ b/src/service.c
@@ -7501,19 +7501,90 @@ void __connman_service_cleanup(void)
}
static void acdhost_ipv4_available(ACDHost *acd, gpointer user_data)
+{
+ struct connman_service *service = user_data;
+ int err;
+
+ if (!service)
+ return;
+
+ if (!service->ipconfig_ipv4) {
+ connman_error("Service has no IPv4 configuration");
+ return;
+ }
+
+ err = __connman_ipconfig_address_add(service->ipconfig_ipv4);
+ if (err < 0)
+ goto err;
+
+ err = __connman_ipconfig_gateway_add(service->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 int service_start_ipv4ll(struct connman_service *service)
{
}
static void acdhost_ipv4_lost(ACDHost *acd, gpointer user_data)
{
+ struct connman_service *service = user_data;
+ struct connman_network *network;
+ enum connman_ipconfig_type type;
+ enum connman_ipconfig_method method;
+
+ if (!service)
+ return;
+
+ if (!service->ipconfig_ipv4)
+ return;
+
+ type = __connman_ipconfig_get_config_type(service->ipconfig_ipv4);
+ if (type != CONNMAN_IPCONFIG_TYPE_IPV4)
+ return;
+
+ __connman_ipconfig_address_remove(service->ipconfig_ipv4);
+
+ method = __connman_ipconfig_get_method(service->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,
service->ipconfig_ipv4);
+ } else {
+ /* Start IPv4LL ACD. */
+ if (service_start_ipv4ll(service) < 0)
+ connman_error("Could not start IPv4LL. "
+ "No address will be assigned");
+ }
}
static void acdhost_ipv4_conflict(ACDHost *acd, gpointer user_data)
{
+ struct connman_service *service = user_data;
+
+ /* Start IPv4LL ACD. */
+ if (service_start_ipv4ll(service) < 0)
+ connman_error("Could not start IPv4LL. "
+ "No address will be assigned");
}
static void acdhost_ipv4_maxconflict(ACDHost *acd, gpointer user_data)
{
+ struct connman_service *service = 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. */
}
int connman_service_start_acd(struct connman_service *service)
--
2.16.2
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 29, Issue 22
***************************************