5 * Copyright (C) 2007-2008 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
28 struct connman_network {
29 struct connman_element element;
30 enum connman_network_type type;
32 struct connman_network_driver *driver;
36 static void network_destruct(struct connman_element *element)
38 DBG("element %p name %s", element, element->name);
42 * connman_network_create:
43 * @identifier: network identifier (for example an unqiue name)
45 * Allocate a new network and assign the #identifier to it.
47 * Returns: a newly-allocated #connman_network structure
49 struct connman_network *connman_network_create(const char *identifier,
50 enum connman_network_type type)
52 struct connman_network *network;
54 DBG("identifier %s type %d", identifier, type);
56 network = g_try_new0(struct connman_network, 1);
60 DBG("network %p", network);
62 network->element.refcount = 1;
64 network->element.name = g_strdup(identifier);
65 network->element.type = CONNMAN_ELEMENT_TYPE_NETWORK;
66 network->element.index = -1;
68 network->element.network = network;
69 network->element.destruct = network_destruct;
77 * connman_network_ref:
78 * @network: network structure
80 * Increase reference counter of network
82 struct connman_network *connman_network_ref(struct connman_network *network)
84 if (connman_element_ref(&network->element) == NULL)
91 * connman_network_unref:
92 * @network: network structure
94 * Decrease reference counter of network
96 void connman_network_unref(struct connman_network *network)
98 connman_element_unref(&network->element);
101 static int network_probe(struct connman_element *element)
106 static void network_remove(struct connman_element *element)
110 static struct connman_driver network_driver = {
112 .type = CONNMAN_ELEMENT_TYPE_NETWORK,
113 .priority = CONNMAN_DRIVER_PRIORITY_LOW,
114 .probe = network_probe,
115 .remove = network_remove,
118 int __connman_network_init(void)
122 return connman_driver_register(&network_driver);
125 void __connman_network_cleanup(void)
129 connman_driver_unregister(&network_driver);