5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 static GSList *driver_list = NULL;
32 static gint compare_priority(gconstpointer a, gconstpointer b)
34 const struct connman_utsname_driver *driver1 = a;
35 const struct connman_utsname_driver *driver2 = b;
37 return driver2->priority - driver1->priority;
41 * connman_utsname_driver_register:
42 * @driver: utsname driver definition
44 * Register a new utsname driver
46 * Returns: %0 on success
48 int connman_utsname_driver_register(struct connman_utsname_driver *driver)
50 DBG("driver %p name %s", driver, driver->name);
52 driver_list = g_slist_insert_sorted(driver_list, driver,
59 * connman_utsname_driver_unregister:
60 * @driver: utsname driver definition
62 * Remove a previously registered utsname driver
64 void connman_utsname_driver_unregister(struct connman_utsname_driver *driver)
66 DBG("driver %p name %s", driver, driver->name);
68 driver_list = g_slist_remove(driver_list, driver);
71 int __connman_utsname_set_hostname(const char *hostname)
75 DBG("hostname %s", hostname);
77 for (list = driver_list; list; list = list->next) {
78 struct connman_utsname_driver *driver = list->data;
80 DBG("driver %p name %s", driver, driver->name);
82 if (driver->set_hostname == NULL)
85 if (driver->set_hostname(hostname) == 0)
92 int __connman_utsname_set_domainname(const char *domainname)
96 DBG("domainname %s", domainname);
98 for (list = driver_list; list; list = list->next) {
99 struct connman_utsname_driver *driver = list->data;
101 DBG("driver %p name %s", driver, driver->name);
103 if (driver->set_domainname == NULL)
106 if (driver->set_domainname(domainname) == 0)