Allowing provision by interface name can be helpful in some situations where
interface names never change. In all other situations where the interface name 
is very
likely to change the MAC should still be used as identifier for provisioning.
---
 doc/config-format.txt |    2 ++
 src/config.c          |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/doc/config-format.txt b/doc/config-format.txt
index c255177..ca98995 100644
--- a/doc/config-format.txt
+++ b/doc/config-format.txt
@@ -56,6 +56,8 @@ Allowed fields:
   interface is used. The byte values must have prefix 0 added,
   the bytes must be separated by ":" char and its length must be
   exactly 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 = 17 characters.
+- Interface: Name of the interface to configure. If MAC is also set it must
+  be the MAC address of the specified interface.
 - Nameservers: Comma separated list of nameservers
 - SearchDomains: Comma separated list of DNS search domains
 - Timeservers: Comma separated list of timeservers
diff --git a/src/config.c b/src/config.c
index 05c654b..e94e835 100644
--- a/src/config.c
+++ b/src/config.c
@@ -66,6 +66,7 @@ struct connman_config_service {
        char *ipv6_gateway;
        char *ipv6_privacy;
        char *mac;
+       char *interface;
        char **nameservers;
        char **search_domains;
        char **timeservers;
@@ -108,6 +109,7 @@ static connman_bool_t cleanup = FALSE;
 #define SERVICE_KEY_IPv6               "IPv6"
 #define SERVICE_KEY_IPv6_PRIVACY       "IPv6.Privacy"
 #define SERVICE_KEY_MAC                "MAC"
+#define SERVICE_KEY_INTERFACE          "Interface"
 #define SERVICE_KEY_NAMESERVERS        "Nameservers"
 #define SERVICE_KEY_SEARCH_DOMAINS     "SearchDomains"
 #define SERVICE_KEY_TIMESERVERS        "Timeservers"
@@ -236,6 +238,7 @@ free_only:
        g_free(config_service->ipv6_gateway);
        g_free(config_service->ipv6_privacy);
        g_free(config_service->mac);
+       g_free(config_service->interface);
        g_strfreev(config_service->nameservers);
        g_strfreev(config_service->search_domains);
        g_strfreev(config_service->timeservers);
@@ -485,6 +488,12 @@ static connman_bool_t load_service_generic(GKeyFile 
*keyfile,
                service->mac = str;
        }
 
+       str = g_key_file_get_string(keyfile, group, SERVICE_KEY_INTERFACE, 
NULL);
+       if (str != NULL) {
+               g_free(service->interface);
+               service->interface = str;
+       }
+
        str = g_key_file_get_string(keyfile, group, SERVICE_KEY_DOMAIN, NULL);
        if (str != NULL) {
                g_free(service->domain_name);
@@ -1106,6 +1115,24 @@ static void provision_service(gpointer key, gpointer 
value,
                        return;
        }
 
+       if (config->interface != NULL) {
+               struct connman_device *device;
+               const char *device_interface;
+
+               device = connman_network_get_device(network);
+               if (device == NULL) {
+                       connman_error("Network device is missing");
+                       return;
+               }
+
+               device_interface = connman_device_get_string(device, 
"Interface");
+
+               DBG("wants %s has %s", config->interface, device_interface);
+
+               if (g_ascii_strcasecmp(device_interface, config->interface) != 
0)
+                       return;
+       }
+
        if (g_strcmp0(config->type, "wifi") == 0 &&
                                type == CONNMAN_SERVICE_TYPE_WIFI) {
                ssid = connman_network_get_blob(network, "WiFi.SSID",
-- 
1.7.10.4

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to