diff -ru bluez-utils-2.25.orig/pand/bnep.c bluez-utils-2.25/pand/bnep.c --- bluez-utils-2.25.orig/pand/bnep.c 2006-01-07 21:03:05.000000000 -0500 +++ bluez-utils-2.25/pand/bnep.c 2008-06-14 10:36:40.000000000 -0400 @@ -38,6 +38,7 @@ #include #include +#include #include "pand.h" @@ -145,6 +146,53 @@ return 0; } +static void run_devdown(char *dev, char *dst) +{ + char *argv[4], prog[40]; + struct sigaction sa; + + sprintf(prog, "%s/%s", PAND_CONFIG_DIR, PAND_DEVDOWN_CMD); + + if (access(prog, R_OK | X_OK)) + return; + + if (fork()) + return; + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); + + argv[0] = prog; + argv[1] = dev; + argv[2] = dst; + argv[3] = NULL; + execv(prog, argv); + exit(1); +} + +static int get_conninfo(uint8_t *dst, struct bnep_conninfo *d_ci) { + struct bnep_connlist_req req; + struct bnep_conninfo ci[48]; + int i; + + req.cnum = 48; + req.ci = ci; + if (ioctl(ctl, bnepgetconnlist, &req)) { + perror("Failed to get connection list"); + return -1; + } + + for (i=0; i < req.cnum; i++) { + if (memcmp(dst, ci[i].dst, sizeof(ci[i].dst)) == 0) { + memcpy(&ci[i], d_ci, sizeof(struct bnep_conninfo)); + return 0; + } + } + return 1; +} + int bnep_kill_connection(uint8_t *dst) { struct bnep_conndel_req req; @@ -155,6 +203,13 @@ perror("Failed to kill connection"); return -1; } + + { + struct bnep_conninfo ci; + + if (!get_conninfo(dst, &ci)) + run_devdown(ci.device, batostr((bdaddr_t *)ci.dst)); + } return 0; } @@ -176,6 +231,7 @@ memcpy(req.dst, ci[i].dst, ETH_ALEN); req.flags = 0; ioctl(ctl, bnepconndel, &req); + run_devdown(ci[i].device, batostr((bdaddr_t *)req.dst)); } return 0; } diff -ru bluez-utils-2.25.orig/pand/pand.h bluez-utils-2.25/pand/pand.h --- bluez-utils-2.25.orig/pand/pand.h 2006-01-07 21:03:05.000000000 -0500 +++ bluez-utils-2.25/pand/pand.h 2008-06-14 10:00:04.000000000 -0400 @@ -23,8 +23,9 @@ */ /* PAN scripts & commands */ -#define PAND_CONFIG_DIR "/etc/bluetooth/pan" +#define PAND_CONFIG_DIR "/etc/bluetooth/pan" #define PAND_DEVUP_CMD "dev-up" +#define PAND_DEVDOWN_CMD "dev-down" /* BNEP functions */ int bnep_init(void);