summaryrefslogtreecommitdiff
path: root/android/pan.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2014-02-06 16:28:42 +0100
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-02-07 11:21:22 +0200
commit7bb2a16843813044a194afee1afe6015b1359991 (patch)
treed2999948c30fd72ec8bee492c49d13e17d0d70f9 /android/pan.c
parent5ab76c6042343202dc712e7d69103a76c5c36590 (diff)
downloadbluez-7bb2a16843813044a194afee1afe6015b1359991.tar.gz
android/pan: Bring bridge interface down before removing it
Otherwise bridge will be 'in use' and won't be removed.
Diffstat (limited to 'android/pan.c')
-rw-r--r--android/pan.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/android/pan.c b/android/pan.c
index 418e2a42c..bcbb3d8ad 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -132,6 +132,31 @@ static int nap_create_bridge(void)
return err;
}
+static int bridge_if_down(void)
+{
+ struct ifreq ifr;
+ int sk, err;
+
+ sk = socket(AF_INET, SOCK_DGRAM, 0);
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, BNEP_BRIDGE, IF_NAMESIZE - 1);
+
+ ifr.ifr_flags &= ~IFF_UP;
+
+ /* Bring down the interface */
+ err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr);
+
+ close(sk);
+
+ if (err < 0) {
+ error("pan: Could not bring down %s", BNEP_BRIDGE);
+ return err;
+ }
+
+ return 0;
+}
+
static int nap_remove_bridge(void)
{
int sk, err;
@@ -141,6 +166,8 @@ static int nap_remove_bridge(void)
if (!nap_dev.bridge)
return 0;
+ bridge_if_down();
+
sk = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (sk < 0)
return -EOPNOTSUPP;