Hi Henri,

On Wed, Dec 01, 2010 at 02:22:52PM +0200, Henri Bragge wrote:
> Domains are appended to entry list just like nameservers, and finally exported
> to /etc/resolv.conf. Domains are written to resolv.conf in reverse order so
> that the most recently appended domain will have the highest priority.
First of all, to make sure we all agree here: This patch will add search
domains to resolv.conf only if dnsproxy is disabled.

Now about the patch, I have some comments:

> diff --git a/src/service.c b/src/service.c
> index b1842d6..d9026b8 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -85,7 +85,6 @@ struct connman_service {
>       char **nameservers;
>       char *nameserver;
>       char **domains;
> -     char *domainname;
So we want to keep domainname to keep track of the domain we got from DHCP.


>       /* 802.1x settings from the config files */
>       char *eap;
>       char *identity;
> @@ -368,6 +367,14 @@ static void update_nameservers(struct connman_service 
> *service)
>       } else if (service->nameserver != NULL)
>               connman_resolver_append(ifname, NULL, service->nameserver);
>  
> +     if (service->domains != NULL) {
> +             int i;
> +
> +             for (i = 0; service->domains[i]; i++)
> +                     connman_resolver_append(ifname, service->domains[i],
> +                                             NULL);
> +     }
Here you want to add service->domain if service->domains is NULL.

>       connman_resolver_flush();
>  }
>  
> @@ -831,15 +838,17 @@ static void append_dnsconfig(DBusMessageIter *iter, 
> void *user_data)
>  static void append_domain(DBusMessageIter *iter, void *user_data)
This one should be left unchanged.


>       struct connman_service *service = user_data;
> +     int i;
>  
>       if (is_connected(service) == FALSE && is_connecting(service) == FALSE)
>               return;
>  
> -     if (service->domainname == NULL)
> +     if (service->domains == NULL)
>               return;
>  
> -     dbus_message_iter_append_basic(iter,
> -                             DBUS_TYPE_STRING, &service->domainname);
> +     for (i = 0; service->domains[i]; i++)
> +             dbus_message_iter_append_basic(iter,
> +                             DBUS_TYPE_STRING, &service->domains[i]);
>  }
>  
>  static void append_domainconfig(DBusMessageIter *iter, void *user_data)
> @@ -1040,6 +1049,8 @@ static void domain_configuration_changed(struct 
> connman_service *service)
>                               CONNMAN_SERVICE_INTERFACE,
>                               "Domains.Configuration",
>                               DBUS_TYPE_STRING, append_domainconfig, service);
> +
> +     domain_changed(service);
No, we don't want to send that D-Bus signal in that case.


>  }
>  
>  static void proxy_changed(struct connman_service *service)
> @@ -1505,10 +1516,18 @@ void __connman_service_set_domainname(struct 
> connman_service *service,
>
Here as well, please keep this routine unchanged.


>       if (service == NULL)
>               return;
>  
> -     g_free(service->domainname);
> -     service->domainname = g_strdup(domainname);
> +     g_strfreev(service->domains);
> +     service->domains = NULL;
>  
> -     domain_changed(service);
> +     /* Leave domain list empty if domainname is unset */
> +     if (domainname != NULL && (g_strcmp0(domainname, "") != 0)) {
> +             service->domains = g_try_malloc0(sizeof(char *));
> +
> +             if (service->domains != NULL)
> +                     service->domains[0] = g_strdup(domainname);
> +     }
> +
> +     domain_configuration_changed(service);
>  }
>  
>  const char *connman_service_get_domainname(struct connman_service *service)
> @@ -1516,7 +1535,10 @@ const char *connman_service_get_domainname(struct 
> connman_service *service)
>       if (service == NULL)
>               return NULL;
>  
> -     return service->domainname;
> +     if (service->domains != NULL)
> +             return service->domains[0];
> +     else
> +             return NULL;
return service->domainname if service->domains is NULL.



>  }
>  
>  const char *connman_service_get_nameserver(struct connman_service *service)
> @@ -1986,7 +2008,7 @@ static DBusMessage *set_property(DBusConnection *conn,
>  
>               g_string_free(str, TRUE);
>  
> -             //update_domains(service);
> +             update_nameservers(service);
>               domain_configuration_changed(service);
>  
>               __connman_storage_save_service(service);
> @@ -2575,7 +2597,6 @@ static void service_free(gpointer user_data)
>       g_strfreev(service->excludes);
>  
>       g_free(service->nameserver);
> -     g_free(service->domainname);
This one should stay there.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to