-from http://blueman.tuxfamily.org
[packages/bluez-utils.git] / bluez-utils-bnep_ifup.patch
1 --- network/bridge.c.orig       2008/05/06 18:40:54     1.11
2 +++ network/bridge.c    2008/05/06 21:46:05     1.12
3 @@ -119,6 +119,7 @@
4         if (ifindex == 0)
5                 return -ENODEV;
6  
7 +       memset(&ifr, 0, sizeof(ifr));
8         strncpy(ifr.ifr_name, name, IFNAMSIZ);
9         ifr.ifr_ifindex = ifindex;
10
11 --- network/common.c.orig       2008/02/02 03:37:43     1.20
12 +++ network/common.c    2008/05/06 21:46:05     1.21
13 @@ -164,6 +164,7 @@
14  {
15         struct bnep_conndel_req req;
16  
17 +       memset(&req, 0, sizeof(req));
18         baswap((bdaddr_t *)&req.dst, dst);
19         req.flags = 0;
20         if (ioctl(ctl, BNEPCONNDEL, &req)) {
21 @@ -192,10 +193,12 @@
22         }
23  
24         for (i=0; i < req.cnum; i++) {
25 -               struct bnep_conndel_req req;
26 -               memcpy(req.dst, ci[i].dst, ETH_ALEN);
27 -               req.flags = 0;
28 -               ioctl(ctl, BNEPCONNDEL, &req);
29 +               struct bnep_conndel_req del;
30 +
31 +               memset(&del, 0, sizeof(del));
32 +               memcpy(del.dst, ci[i].dst, ETH_ALEN);
33 +               del.flags = 0;
34 +               ioctl(ctl, BNEPCONNDEL, &del);
35         }
36         return 0;
37  }
38 @@ -204,6 +207,7 @@
39  {
40         struct bnep_connadd_req req;
41  
42 +       memset(&req, 0, sizeof(req));
43         strncpy(req.device, dev, 16);
44         req.device[15] = '\0';
45         req.sock = sk;
46 @@ -223,17 +227,31 @@
47  {
48  }
49  
50 +static int bnep_exec(const char **argv)
51 +{
52 +       int pid;
53 +       GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH;
54 +
55 +       if (!g_spawn_async(NULL, (char **) argv, NULL, flags, bnep_setup, NULL,
56 +                               &pid, NULL)) {
57 +               error("Unable to execute %s %s", *argv[0], *argv[1]);
58 +               return -EINVAL;
59 +       }
60 +
61 +       return pid;
62 +}
63 +
64  int bnep_if_up(const char *devname, uint16_t id)
65  {
66 -       int sd, err, pid;
67 +       int sd, err;
68         struct ifreq ifr;
69         const char *argv[5];
70 -       struct bnep_data *bnep;
71 -       GSpawnFlags flags;
72 +       struct bnep_data *bnep = NULL;
73         GSList *l;
74  
75         /* Check if a script is running */
76 -       if ((l = g_slist_find_custom(pids, devname, find_devname))) {
77 +       l = g_slist_find_custom(pids, devname, find_devname);
78 +       if (l) {
79                 bnep = l->data;
80  
81                 if (bnep->script && !strcmp(bnep->script, "avahi-autoipd")) {
82 @@ -242,13 +260,8 @@
83                         argv[2] = "--refresh";
84                         argv[3] = NULL;
85  
86 -                       flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH;
87 -                       g_spawn_async(NULL, (char **) argv, NULL, flags,
88 -                                       bnep_setup, (gpointer) devname, &pid,
89 -                                       NULL);
90 +                       bnep->pid = bnep_exec(argv);
91                 }
92 -
93 -               return bnep->pid;
94         }
95  
96         sd = socket(AF_INET6, SOCK_DGRAM, 0);
97 @@ -265,6 +278,9 @@
98                 return -err;
99         }
100  
101 +       if (bnep)
102 +               return bnep->pid;
103 +
104         bnep = g_new0(struct bnep_data, 1);
105         bnep->devname = g_strdup(devname);
106  
107 @@ -291,15 +307,8 @@
108         } else
109                 argv[2] = NULL;
110  
111 -       flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH;
112 -       if (!g_spawn_async(NULL, (char **) argv, NULL, flags, bnep_setup,
113 -                               (gpointer) devname, &pid, NULL)) {
114 -               error("Unable to execute %s", argv[0]);
115 -               return -EINVAL;
116 -       }
117 -
118 -       bnep->pid = pid;
119 -       g_child_watch_add(pid, script_exited, bnep);
120 +       bnep->pid = bnep_exec(argv);
121 +       g_child_watch_add(bnep->pid, script_exited, bnep);
122  
123  done:
124         pids = g_slist_append(pids, bnep);
125 @@ -325,7 +334,7 @@
126         if (!bnep->pid)
127                 goto done;
128  
129 -       if (bnep->script && !strcmp (bnep->script, "avahi-autoipd")) {
130 +       if (bnep->script && !strcmp(bnep->script, "avahi-autoipd")) {
131                 argv[0] = bnep->script;
132                 argv[1] = devname;
133                 argv[2] = "--kill";
134 @@ -352,12 +361,7 @@
135         ifr.ifr_flags &= ~IFF_UP;
136  
137         /* Bring down the interface */
138 -       if ((ioctl(sd, SIOCSIFFLAGS, (caddr_t) &ifr)) < 0) {
139 -               err = errno;
140 -               error("Could not bring down %d. %s(%d)", devname, strerror(err),
141 -                       err);
142 -               return -err;
143 -       }
144 +       ioctl(sd, SIOCSIFFLAGS, (caddr_t) &ifr);
145  
146         pids = g_slist_remove(pids, bnep);
147
148 --- network/connection.c.orig   2008/02/02 03:37:43     1.46
149 +++ network/connection.c        2008/05/06 21:46:05     1.47
150 @@ -90,6 +90,7 @@
151                                                 DBUS_TYPE_INVALID);
152         }
153         info("%s disconnected", nc->dev);
154 +       bnep_if_down(nc->dev);
155         nc->state = DISCONNECTED;
156         memset(nc->dev, 0, 16);
157         strncpy(nc->dev, prefix, strlen(prefix));
158  
This page took 0.047601 seconds and 3 git commands to generate.