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. Re: [PATCH 1/3] [Pacrunner]: Domains are looked up to match
the host. (Patrik Flykt)
2. Re: R: R: [RFC] Wi-Fi Protected Setup (WPS) connection
(Patrik Flykt)
3. R: R: R: [RFC] Wi-Fi Protected Setup (WPS) connection
(MANIEZZO Marco (MM))
----------------------------------------------------------------------
Message: 1
Date: Thu, 16 Jun 2016 15:38:16 +0300
From: Patrik Flykt <[email protected]>
To: Atul Anand <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/3] [Pacrunner]: Domains are looked up to match
the host.
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"
Applied 3/3, 1/3 and 2/3. Thanks!
Patrik
On Thu, 2016-06-16 at 16:45 +0530, Atul Anand wrote:
> Pacrunner now scan stored domains to match the host of URL.
> In this way the most appropriate proxy config is selected to
> answer the proxy query.
> ---
> ?src/manager.c???|???7 +-
> ?src/pacrunner.h |???2 +
> ?src/proxy.c?????| 214
> +++++++++++++++++++++++++++++++++++++++++++++++++++++---
> ?3 files changed, 211 insertions(+), 12 deletions(-)
>
> diff --git a/src/manager.c b/src/manager.c
> index 1676466..5a8b4fd 100644
> --- a/src/manager.c
> +++ b/src/manager.c
> @@ -35,7 +35,6 @@ struct proxy_config {
> ? DBusConnection *conn;
> ? guint watch;
> ?
> - char **domains;
> ? char **nameservers;
> ?
> ? struct pacrunner_proxy *proxy;
> @@ -58,7 +57,6 @@ static void destroy_config(gpointer data)
> ? if (config->watch > 0)
> ? g_dbus_remove_watch(config->conn, config->watch);
> ?
> - g_strfreev(config->domains);
> ? g_strfreev(config->nameservers);
> ?
> ? g_free(config->sender);
> @@ -224,12 +222,13 @@ static DBusMessage
> *create_proxy_config(DBusConnection *conn,
> ? goto done;
> ? }
> ?
> - config->domains = domains;
> ? config->nameservers = nameservers;
> ?
> - domains = NULL;
> ? nameservers = NULL;
> ?
> + if (pacrunner_proxy_set_domains(config->proxy, domains) < 0)
> + pacrunner_error("Failed to set proxy domains");
> +
> ? if (g_str_equal(method, "direct")) {
> ? if (pacrunner_proxy_set_direct(config->proxy) < 0)
> ? pacrunner_error("Failed to set direct
> proxy");
> diff --git a/src/pacrunner.h b/src/pacrunner.h
> index 6731d7c..db534cf 100644
> --- a/src/pacrunner.h
> +++ b/src/pacrunner.h
> @@ -63,6 +63,8 @@ void pacrunner_proxy_unref(struct pacrunner_proxy
> *proxy);
> ?const char *pacrunner_proxy_get_interface(struct pacrunner_proxy
> *proxy);
> ?const char *pacrunner_proxy_get_script(struct pacrunner_proxy
> *proxy);
> ?
> +int pacrunner_proxy_set_domains(struct pacrunner_proxy *proxy,
> + char **domains);
> ?int pacrunner_proxy_set_direct(struct pacrunner_proxy *proxy);
> ?int pacrunner_proxy_set_manual(struct pacrunner_proxy *proxy,
> ? char **servers, char
> **excludes);
> diff --git a/src/proxy.c b/src/proxy.c
> index 8bb03af..2ebc75d 100644
> --- a/src/proxy.c
> +++ b/src/proxy.c
> @@ -23,6 +23,9 @@
> ?#include <config.h>
> ?#endif
> ?
> +#include <string.h>
> +#include <stdlib.h>
> +#include <arpa/inet.h>
> ?#include <errno.h>
> ?#include <pthread.h>
> ?
> @@ -37,6 +40,17 @@ struct pacrunner_proxy {
> ? char *script;
> ? GList **servers;
> ? GList **excludes;
> + GList *domains;
> +};
> +
> +struct proxy_domain {
> + char *domain;
> + int proto;
> + union {
> + struct in_addr ip4;
> + struct in6_addr ip6;
> + } addr;
> + int mask;
> ?};
> ?
> ?static GList *proxy_list = NULL;
> @@ -77,6 +91,15 @@ struct pacrunner_proxy *pacrunner_proxy_ref(struct
> pacrunner_proxy *proxy)
> ? return proxy;
> ?}
> ?
> +static void proxy_domain_destroy(gpointer data)
> +{
> + struct proxy_domain *domain = data;
> + g_return_if_fail(domain != NULL);
> +
> + g_free(domain->domain);
> + g_free(domain);
> +}
> +
> ?static void reset_proxy(struct pacrunner_proxy *proxy)
> ?{
> ? DBG("proxy %p", proxy);
> @@ -92,6 +115,10 @@ static void reset_proxy(struct pacrunner_proxy
> *proxy)
> ?
> ? __pacrunner_manual_destroy_excludes(proxy->excludes);
> ? proxy->excludes = NULL;
> +
> + if (proxy->domains)
> + g_list_free_full(proxy->domains,
> proxy_domain_destroy);
> + proxy->domains = NULL;
> ?}
> ?
> ?void pacrunner_proxy_unref(struct pacrunner_proxy *proxy)
> @@ -130,6 +157,76 @@ const char *pacrunner_proxy_get_script(struct
> pacrunner_proxy *proxy)
> ? return proxy->script;
> ?}
> ?
> +int pacrunner_proxy_set_domains(struct pacrunner_proxy *proxy, char
> **domains)
> +{
> + int len;
> + char *slash, **domain;
> + char ip[INET6_ADDRSTRLEN + 1];
> +
> + DBG("proxy %p domains %p", proxy, domains);
> +
> + if (!proxy)
> + return -EINVAL;
> +
> + if (!domains)
> + return -EINVAL;
> +
> + for (domain = domains; *domain; domain++) {
> + struct proxy_domain *data;
> +
> + data = g_malloc0(sizeof(struct proxy_domain));
> +
> + slash = strchr(*domain, '/');
> + if (!slash) {
> + data->domain = g_strdup(*domain);
> + data->proto = 0;
> +
> + proxy->domains = g_list_append(proxy-
> >domains, data);
> + continue;
> + }
> +
> + len = slash - *domain;
> + if (len > INET6_ADDRSTRLEN) {
> + g_free(data);
> + continue;
> + }
> +
> + strncpy(ip, *domain, len);
> + ip[len] = '\0';
> +
> + if (inet_pton(AF_INET, ip, &(data->addr.ip4)) == 1)
> {
> + data->domain = NULL;
> + data->proto = 4;
> +
> + errno = 0;
> + data->mask = strtol(slash + 1, NULL, 10);
> + if (errno || data->mask < 0 || data->mask >
> 32) {
> + g_free(data);
> + continue;
> + }
> +
> + proxy->domains = g_list_append(proxy-
> >domains, data);
> + } else if (inet_pton(AF_INET6, ip, &(data-
> >addr.ip6)) == 1) {
> + data->domain = NULL;
> + data->proto = 6;
> +
> + errno = 0;
> + data->mask = strtol(slash + 1, NULL, 10);
> + if (errno || data->mask < 0 || data->mask >
> 128) {
> + g_free(data);
> + continue;
> + }
> +
> + proxy->domains = g_list_append(proxy-
> >domains, data);
> + } else {
> + g_free(data);
> + continue;
> + }
> + }
> +
> + return 0;
> +}
> +
> ?static int set_method(struct pacrunner_proxy *proxy,
> ? enum pacrunner_proxy_method
> method)
> ?{
> @@ -324,10 +421,61 @@ int pacrunner_proxy_disable(struct
> pacrunner_proxy *proxy)
> ? return 0;
> ?}
> ?
> +static int compare_legacy_ip_in_net(struct in_addr *host,
> + struct proxy_domain *match)
> +{
> + if (ntohl(host->s_addr ^ match->addr.ip4.s_addr) >> (32 -
> match->mask))
> + return -1;
> +
> + return 0;
> +}
> +
> +static int compare_ipv6_in_net(struct in6_addr *host,
> + struct proxy_domain *match)
> +{
> + int i, shift;
> +
> + for (i = 0; i < (match->mask)/8; i++) {
> + if (host->s6_addr[i] != match->addr.ip6.s6_addr[i])
> + return -1;
> + }
> +
> + if ((match->mask) % 8) {
> + /**
> + ?* If mask bits are not multiple of 8 , 1-7 bits are
> left
> + ?* to be compared.
> + ?*/
> + shift = 8 - (match->mask - (i*8));
> +
> + if ((host->s6_addr[i] >> shift) !=
> + (match->addr.ip6.s6_addr[i] >> shift))
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> +static int compare_host_in_domain(const char *host, struct
> proxy_domain *match)
> +{
> + size_t hlen = strlen(host);
> + size_t dlen = strlen(match->domain);
> +
> + if ((hlen >= dlen) && (strcmp(host + (hlen - dlen),
> + match->domain) ==
> 0)) {
> + if (hlen == dlen || host[hlen - dlen - 1] == '.')
> + return 0;
> + }
> +
> + return -1;
> +}
> +
> ?char *pacrunner_proxy_lookup(const char *url, const char *host)
> ?{
> - GList *list;
> - struct pacrunner_proxy *selected_proxy = NULL;
> + GList *l, *list;
> + struct in_addr ip4_addr;
> + struct in6_addr ip6_addr;
> + struct pacrunner_proxy *selected_proxy = NULL,
> *default_proxy = NULL;
> + int protocol = 0;
> ?
> ? DBG("url %s host %s", url, host);
> ?
> @@ -340,17 +488,67 @@ char *pacrunner_proxy_lookup(const char *url,
> const char *host)
> ? return NULL;
> ? }
> ?
> + if (inet_pton(AF_INET, host, &ip4_addr) == 1) {
> + protocol = 4;
> + } else if (inet_pton(AF_INET6, host, &ip6_addr) == 1) {
> + protocol = 6;
> + } else if (host[0] == '[') {
> + char ip[INET6_ADDRSTRLEN + 1];
> + int len = strlen(host);
> +
> + if (len < INET6_ADDRSTRLEN + 2 && host[len - 1] ==
> ']') {
> + strncpy(ip, host + 1, len - 2);
> + ip[len - 2] = '\0';
> +
> + if (inet_pton(AF_INET6, ip, &ip6_addr) == 1)
> + protocol = 6;
> + }
> + }
> +
> ? for (list = g_list_first(proxy_list); list; list =
> g_list_next(list)) {
> ? struct pacrunner_proxy *proxy = list->data;
> ?
> - if (proxy->method == PACRUNNER_PROXY_METHOD_MANUAL
> ||
> - proxy->method ==
> PACRUNNER_PROXY_METHOD_AUTO) {
> - selected_proxy = proxy;
> - break;
> - } else if (proxy->method ==
> PACRUNNER_PROXY_METHOD_DIRECT)
> - selected_proxy = proxy;
> + if (!proxy->domains) {
> + if (!default_proxy)
> + default_proxy = proxy;
> + continue;
> + }
> +
> + for (l = g_list_first(proxy->domains); l; l =
> g_list_next(l)) {
> + struct proxy_domain *data = l->data;
> +
> + if (data->proto != protocol)
> + continue;
> +
> + switch (protocol) {
> + case 4:
> + if
> (compare_legacy_ip_in_net(&ip4_addr,
> + data
> ) == 0) {
> + selected_proxy = proxy;
> + goto found;
> + }
> + break;
> + case 6:
> + if (compare_ipv6_in_net(&ip6_addr,
> + data) == 0)
> {
> + selected_proxy = proxy;
> + goto found;
> + }
> + break;
> + default:
> + if (compare_host_in_domain(host,
> data) == 0) {
> + selected_proxy = proxy;
> + goto found;
> + }
> + break;
> + }
> + }
> ? }
> ?
> + if (!selected_proxy)
> + selected_proxy = default_proxy;
> +
> +found:
> ? pthread_mutex_unlock(&proxy_mutex);
> ?
> ? if (!selected_proxy)
------------------------------
Message: 2
Date: Thu, 16 Jun 2016 15:59:59 +0300
From: Patrik Flykt <[email protected]>
To: "MANIEZZO Marco (MM)" <[email protected]>, Tomasz
Bursztyka <[email protected]>, "[email protected]"
<[email protected]>
Cc: "Blanquicet-Melendez Jose (MM)"
<[email protected]>
Subject: Re: R: R: [RFC] Wi-Fi Protected Setup (WPS) connection
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"
Hi,
On Thu, 2016-06-16 at 12:24 +0000, MANIEZZO Marco (MM) wrote:
> void Start_STA_WPS(string authentication)
When this is needed for P2P, then this should be part of the P2P
technology API, right? With that modification no guessing is done, P2P
is used when when StartWPS() is called for the P2P technology. Same for
WiFi technology.
?
> void CancelWPS(void)
>?
> void Start_AP_WPS(string authentication)
For AP one needs tethering turned on. So starting and stopping of AP
WPS should follow whether tethering is enabled for WiFi and again only
a call to to StartWPS() is needed. Or is there a situation where
tethering is enabled but another WiFi device is idle and one actually
wants the other WiFi device to activate STA WPS?
The role selection should by default go as enrollee for non-tethering
WiFi and registrar when tethering if the role is something one cares
about?
Cheers,
Patrik
------------------------------
Message: 3
Date: Thu, 16 Jun 2016 14:03:37 +0000
From: "MANIEZZO Marco (MM)" <[email protected]>
To: Patrik Flykt <[email protected]>, Tomasz Bursztyka
<[email protected]>, "[email protected]"
<[email protected]>
Cc: "Blanquicet-Melendez Jose (MM)"
<[email protected]>
Subject: R: R: R: [RFC] Wi-Fi Protected Setup (WPS) connection
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Hi Patrik,
For P2P connection the WPS topic is completely separated because it relies on
Peer.Connect (that uses its WPS current code) while the methods below belong to
Technology. But the P2P interface, when not connected, may also support to be a
STA or AP and if it is not the only one WiFi interface in the system very
probably the user doesn't want connman starts WPS (AP or STA) on it if by
chance it is the first coming in its hands :), so connman will consider it only
as last chance.
We are working with Marvell chipsets and they expose three separated interfaces
for STA, AP and P2P (capable of concurrent connections): then we need to
distinguish STA WPS and AP WPS. Anyway the same would happen if you have a
laptop with embedded WiFi capable of STA WPS and then you plug an usb dongle
you want to use as AP WPS, for instance..
We would also add the event Technology.WPSEvent(string event) to signal at
least "success" or "pwd-auth-fail" (we can also add "pbc-overlap").
Regards,
Marco
-----Messaggio originale-----
Da: Patrik Flykt [mailto:[email protected]]
Inviato: gioved? 16 giugno 2016 15:00
A: MANIEZZO Marco (MM); Tomasz Bursztyka; [email protected]
Cc: Blanquicet-Melendez Jose (MM)
Oggetto: Re: R: R: [RFC] Wi-Fi Protected Setup (WPS) connection
Hi,
On Thu, 2016-06-16 at 12:24 +0000, MANIEZZO Marco (MM) wrote:
> void Start_STA_WPS(string authentication)
When this is needed for P2P, then this should be part of the P2P technology
API, right? With that modification no guessing is done, P2P is used when when
StartWPS() is called for the P2P technology. Same for WiFi technology.
> void CancelWPS(void)
>
> void Start_AP_WPS(string authentication)
For AP one needs tethering turned on. So starting and stopping of AP WPS should
follow whether tethering is enabled for WiFi and again only a call to to
StartWPS() is needed. Or is there a situation where tethering is enabled but
another WiFi device is idle and one actually wants the other WiFi device to
activate STA WPS?
The role selection should by default go as enrollee for non-tethering WiFi and
registrar when tethering if the role is something one cares about?
Cheers,
Patrik
________________________________
VISITA IL NOSTRO NUOVO SITO WEB! - VISIT OUR NEW WEB SITE!
www.magnetimarelli.com
Confidential Notice: This message - including its attachments - may contain
proprietary, confidential and/or legally protected information and is intended
solely for the use of the designated addressee(s) above. If you are not the
intended recipient be aware that any downloading, copying, disclosure,
distribution or use of the contents of the above information is strictly
prohibited.
If you have received this communication by mistake, please forward the message
back to the sender at the email address above, delete the message from all
mailboxes and any other electronic storage medium and destroy all copies.
Disclaimer Notice: Internet communications cannot be guaranteed to be safe or
error-free. Therefore we do not assure that this message is complete or
accurate and we do not accept liability for any errors or omissions in the
contents of this message.
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 8, Issue 21
**************************************