5 * Copyright (C) 2007-2012 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);
72 * connman_utsname_get_hostname:
74 * Returns current hostname
76 const char *connman_utsname_get_hostname(void)
82 for (list = driver_list; list; list = list->next) {
83 struct connman_utsname_driver *driver = list->data;
86 DBG("driver %p name %s", driver, driver->name);
88 if (!driver->get_hostname)
91 hostname = driver->get_hostname();
99 int __connman_utsname_set_hostname(const char *hostname)
103 DBG("hostname %s", hostname);
105 for (list = driver_list; list; list = list->next) {
106 struct connman_utsname_driver *driver = list->data;
108 DBG("driver %p name %s", driver, driver->name);
110 if (!driver->set_hostname)
113 if (driver->set_hostname(hostname) == 0)
120 int __connman_utsname_set_domainname(const char *domainname)
124 DBG("domainname %s", domainname);
126 for (list = driver_list; list; list = list->next) {
127 struct connman_utsname_driver *driver = list->data;
129 DBG("driver %p name %s", driver, driver->name);
131 if (!driver->set_domainname)
134 if (driver->set_domainname(domainname) == 0)