diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-03-27 22:11:29 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-03-27 22:11:29 +0000 |
commit | e7b6b11e91bb59eccf844abe4bb47b015b0c3cdf (patch) | |
tree | 204155dc06f7622c8d81250d64ca31ffc11c01b1 /network | |
parent | fab1c990ee59d3f41331f6c612ba302c2543710b (diff) |
Get rid of old ioctl compability hack.
Diffstat (limited to 'network')
-rw-r--r-- | network/common.c | 51 | ||||
-rw-r--r-- | network/common.h | 2 | ||||
-rw-r--r-- | network/connection.c | 12 |
3 files changed, 13 insertions, 52 deletions
diff --git a/network/common.c b/network/common.c index ec10cc34..593ea83c 100644 --- a/network/common.c +++ b/network/common.c @@ -44,17 +44,6 @@ static int ctl; #define NAP_UUID "00001116-0000-1000-8000-00805f9b34fb" #define GN_UUID "00001117-0000-1000-8000-00805f9b34fb" -/* Compatibility with old ioctls */ -#define OLD_BNEPCONADD 1 -#define OLD_BNEPCONDEL 2 -#define OLD_BNEPGETCONLIST 3 -#define OLD_BNEPGETCONINFO 4 - -static unsigned long bnepconnadd; -static unsigned long bnepconndel; -static unsigned long bnepgetconnlist; -static unsigned long bnepgetconninfo; - static struct { const char *name; /* Friendly name */ const char *uuid128; /* UUID 128 */ @@ -114,32 +103,10 @@ const char *bnep_name(uint16_t id) int bnep_init(void) { ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); + if (ctl < 0) { error("Failed to open control socket"); - return 1; - } - - /* Temporary ioctl compatibility hack */ - { - struct bnep_connlist_req req; - struct bnep_conninfo ci[1]; - - req.cnum = 1; - req.ci = ci; - - if (!ioctl(ctl, BNEPGETCONNLIST, &req)) { - /* New ioctls */ - bnepconnadd = BNEPCONNADD; - bnepconndel = BNEPCONNDEL; - bnepgetconnlist = BNEPGETCONNLIST; - bnepgetconninfo = BNEPGETCONNINFO; - } else { - /* Old ioctls */ - bnepconnadd = OLD_BNEPCONADD; - bnepconndel = OLD_BNEPCONDEL; - bnepgetconnlist = OLD_BNEPGETCONLIST; - bnepgetconninfo = OLD_BNEPGETCONINFO; - } + return -1; } return 0; @@ -151,14 +118,13 @@ int bnep_cleanup(void) return 0; } -int bnep_kill_connection(const char *addr) +int bnep_kill_connection(bdaddr_t *dst) { struct bnep_conndel_req req; - uint8_t *dst = (void *) strtoba(addr); - memcpy(req.dst, dst, ETH_ALEN); + baswap((bdaddr_t *)&req.dst, dst); req.flags = 0; - if (ioctl(ctl, bnepconndel, &req)) { + if (ioctl(ctl, BNEPCONNDEL, &req)) { error("Failed to kill connection"); return -1; } @@ -173,7 +139,7 @@ int bnep_kill_all_connections(void) req.cnum = 48; req.ci = ci; - if (ioctl(ctl, bnepgetconnlist, &req)) { + if (ioctl(ctl, BNEPGETCONNLIST, &req)) { error("Failed to get connection list"); return -1; } @@ -182,7 +148,8 @@ int bnep_kill_all_connections(void) struct bnep_conndel_req req; memcpy(req.dst, ci[i].dst, ETH_ALEN); req.flags = 0; - ioctl(ctl, bnepconndel, &req); + if (ioctl(ctl, BNEPCONNDEL, &req)) + error("Failed to kill connection"); } return 0; } @@ -195,7 +162,7 @@ int bnep_connadd(int sk, uint16_t role, char *dev) req.device[15] = '\0'; req.sock = sk; req.role = role; - if (ioctl(ctl, bnepconnadd, &req)) { + if (ioctl(ctl, BNEPCONNADD, &req)) { error("Failed to add device %s", dev); return -1; } diff --git a/network/common.h b/network/common.h index 820a2b3a..b3941e4f 100644 --- a/network/common.h +++ b/network/common.h @@ -28,7 +28,7 @@ uint16_t bnep_service_id(const char *svc); const char *bnep_uuid(uint16_t id); const char *bnep_name(uint16_t id); -int bnep_kill_connection(const char *addr); +int bnep_kill_connection(bdaddr_t *dst); int bnep_kill_all_connections(void); int bnep_connadd(int sk, uint16_t role, char *dev); diff --git a/network/connection.c b/network/connection.c index 4496f110..ff3f5aab 100644 --- a/network/connection.c +++ b/network/connection.c @@ -387,7 +387,6 @@ static DBusHandlerResult connection_disconnect(DBusConnection *conn, { struct network_conn *nc = data; DBusMessage *reply; - char addr[18]; if (!nc->up) { err_failed(conn, msg, "Device not connected"); @@ -395,8 +394,7 @@ static DBusHandlerResult connection_disconnect(DBusConnection *conn, } close(nc->sk); - ba2str(&nc->dst, addr); - bnep_kill_connection(addr); + bnep_kill_connection(&nc->dst); reply = dbus_message_new_method_return(msg); if (!reply) @@ -461,18 +459,14 @@ static DBusHandlerResult connection_message(DBusConnection *conn, static void connection_free(struct network_conn *nc) { - char addr[18]; - if (!nc) return; if (nc->path) g_free(nc->path); - if (nc->up) { - ba2str(&nc->dst, addr); - bnep_kill_connection(addr); - } + if (nc->up) + bnep_kill_connection(&nc->dst); if (nc->dev) g_free(nc->dev); |