Linux bluetooth development
 help / color / mirror / Atom feed
From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Subject: [PATCH 2/5] network: Add helper function to remove an interface from a bridge
Date: Tue, 21 Aug 2012 13:45:52 +0300	[thread overview]
Message-ID: <1345545955-13144-3-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
In-Reply-To: <1345545955-13144-1-git-send-email-tomasz.bursztyka@linux.intel.com>

---
 profiles/network/common.c |   29 +++++++++++++++++++++++++++++
 profiles/network/common.h |    1 +
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/profiles/network/common.c b/profiles/network/common.c
index a223685..da493c1 100644
--- a/profiles/network/common.c
+++ b/profiles/network/common.c
@@ -268,3 +268,32 @@ int bnep_add_to_bridge(const char *devname, const char *bridge)
 
 	return 0;
 }
+
+int bnep_del_from_bridge(const char *devname, const char *bridge)
+{
+	int ifindex = if_nametoindex(devname);
+	struct ifreq ifr;
+	int sk, err;
+
+	if (!devname || !bridge)
+		return -EINVAL;
+
+	sk = socket(AF_INET, SOCK_STREAM, 0);
+	if (sk < 0)
+		return -1;
+
+	memset(&ifr, 0, sizeof(ifr));
+	strncpy(ifr.ifr_name, bridge, IFNAMSIZ - 1);
+	ifr.ifr_ifindex = ifindex;
+
+	err = ioctl(sk, SIOCBRDELIF, &ifr);
+
+	close(sk);
+
+	if (err < 0)
+		return err;
+
+	info("bridge %s: interface %s removed", bridge, devname);
+
+	return 0;
+}
diff --git a/profiles/network/common.h b/profiles/network/common.h
index cb1f08a..62f2f59 100644
--- a/profiles/network/common.h
+++ b/profiles/network/common.h
@@ -35,3 +35,4 @@ int bnep_connadd(int sk, uint16_t role, char *dev);
 int bnep_if_up(const char *devname);
 int bnep_if_down(const char *devname);
 int bnep_add_to_bridge(const char *devname, const char *bridge);
+int bnep_del_from_bridge(const char *devname, const char *bridge);
-- 
1.7.8.6


  parent reply	other threads:[~2012-08-21 10:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21 10:45 [PATCH 0/5] PAN server fixes Tomasz Bursztyka
2012-08-21 10:45 ` [PATCH 1/5] network: Keep track of session's interface name in server Tomasz Bursztyka
2012-08-21 10:45 ` Tomasz Bursztyka [this message]
2012-08-21 10:45 ` [PATCH 3/5] network: Release session's interface from bridge when unregistering Tomasz Bursztyka
2012-08-21 10:45 ` [PATCH 4/5] network: Kill underlying session's connection before freeing it Tomasz Bursztyka
2012-08-21 10:45 ` [PATCH 5/5] network: Remove sessions from server on DBus call Unregister Tomasz Bursztyka
2012-08-24  7:54 ` [PATCH 0/5] PAN server fixes Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345545955-13144-3-git-send-email-tomasz.bursztyka@linux.intel.com \
    --to=tomasz.bursztyka@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox