~cyphermox/ubuntu/natty/connman/release-0.64

« back to all changes in this revision

Viewing changes to src/udev-compat.c

  • Committer: Mathieu Trudel-Lapierre
  • Date: 2010-11-30 15:51:10 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: mathieu.trudel-lapierre@canonical.com-20101130155110-32g0usyc4jbl131x
New upstream release 0.64.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *
3
 
 *  Connection Manager
4
 
 *
5
 
 *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
6
 
 *
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.
10
 
 *
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.
15
 
 *
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
19
 
 *
20
 
 */
21
 
 
22
 
#ifdef HAVE_CONFIG_H
23
 
#include <config.h>
24
 
#endif
25
 
 
26
 
#include <glib.h>
27
 
 
28
 
#include "connman.h"
29
 
 
30
 
static GSList *device_list = NULL;
31
 
 
32
 
static struct connman_device *find_device(int index)
33
 
{
34
 
        GSList *list;
35
 
 
36
 
        for (list = device_list; list; list = list->next) {
37
 
                struct connman_device *device = list->data;
38
 
 
39
 
                if (connman_device_get_index(device) == index)
40
 
                        return device;
41
 
        }
42
 
 
43
 
        return NULL;
44
 
}
45
 
 
46
 
static void detect_newlink(unsigned short type, int index,
47
 
                                        unsigned flags, unsigned change)
48
 
{
49
 
        struct connman_device *device;
50
 
        enum connman_device_type devtype;
51
 
 
52
 
        DBG("type %d index %d", type, index);
53
 
 
54
 
        devtype = __connman_inet_get_device_type(index);
55
 
 
56
 
        switch (devtype) {
57
 
        case CONNMAN_DEVICE_TYPE_UNKNOWN:
58
 
        case CONNMAN_DEVICE_TYPE_VENDOR:
59
 
        case CONNMAN_DEVICE_TYPE_WIMAX:
60
 
        case CONNMAN_DEVICE_TYPE_BLUETOOTH:
61
 
        case CONNMAN_DEVICE_TYPE_CELLULAR:
62
 
        case CONNMAN_DEVICE_TYPE_GPS:
63
 
                return;
64
 
        case CONNMAN_DEVICE_TYPE_ETHERNET:
65
 
        case CONNMAN_DEVICE_TYPE_WIFI:
66
 
                break;
67
 
        }
68
 
 
69
 
        device = find_device(index);
70
 
        if (device != NULL)
71
 
                return;
72
 
 
73
 
        device = connman_inet_create_device(index);
74
 
        if (device == NULL)
75
 
                return;
76
 
 
77
 
        if (connman_device_register(device) < 0) {
78
 
                connman_device_unref(device);
79
 
                return;
80
 
        }
81
 
 
82
 
        device_list = g_slist_append(device_list, device);
83
 
}
84
 
 
85
 
static void detect_dellink(unsigned short type, int index,
86
 
                                        unsigned flags, unsigned change)
87
 
{
88
 
        struct connman_device *device;
89
 
 
90
 
        DBG("type %d index %d", type, index);
91
 
 
92
 
        device = find_device(index);
93
 
        if (device == NULL)
94
 
                return;
95
 
 
96
 
        device_list = g_slist_remove(device_list, device);
97
 
 
98
 
        connman_device_unregister(device);
99
 
        connman_device_unref(device);
100
 
}
101
 
 
102
 
static struct connman_rtnl detect_rtnl = {
103
 
        .name           = "detect",
104
 
        .priority       = CONNMAN_RTNL_PRIORITY_LOW,
105
 
        .newlink        = detect_newlink,
106
 
        .dellink        = detect_dellink,
107
 
};
108
 
 
109
 
char *__connman_udev_get_devtype(const char *ifname)
110
 
{
111
 
        return NULL;
112
 
}
113
 
 
114
 
void __connman_udev_rfkill(const char *sysname, connman_bool_t blocked)
115
 
{
116
 
        DBG("sysname %s blocked %d", sysname, blocked);
117
 
}
118
 
 
119
 
connman_bool_t __connman_udev_get_blocked(int phyindex)
120
 
{
121
 
        return FALSE;
122
 
}
123
 
 
124
 
int __connman_udev_init(void)
125
 
{
126
 
        DBG("");
127
 
 
128
 
        return connman_rtnl_register(&detect_rtnl);
129
 
}
130
 
 
131
 
void __connman_udev_start(void)
132
 
{
133
 
        DBG("");
134
 
}
135
 
 
136
 
void __connman_udev_cleanup(void)
137
 
{
138
 
        GSList *list;
139
 
 
140
 
        DBG("");
141
 
 
142
 
        connman_rtnl_unregister(&detect_rtnl);
143
 
 
144
 
        for (list = device_list; list; list = list->next) {
145
 
                struct connman_device *device = list->data;
146
 
 
147
 
                connman_device_unregister(device);
148
 
                connman_device_unref(device);
149
 
        }
150
 
 
151
 
        g_slist_free(device_list);
152
 
        device_list = NULL;
153
 
}