Search Linux Wireless

[PATCH] iw: misc minor updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Miscellaneous minor updates:
	Fixed char *phydev init in main()
	Whitespace cleanups
	Minimal help
	Aliased 'master' to 'ap' in nl modes list

-- 
Mike Kershaw/Dragorn <dragorn@xxxxxxxxxxxxxxxxxx>
GPG Fingerprint: 3546 89DF 3C9D ED80 3381  A661 D7B2 8822 738B BDB1

"We're sorry, Susy won't be attending classes for the rest of this academic 
year.  She caught the measles, and we had her shot."
From e86e4c5a5ff1bbe3a5e9c2fef7e28a8376646cb9 Mon Sep 17 00:00:00 2001
From: Mike Kershaw <dragorn@xxxxxxxxxxxxxxxxxx>
Date: Sat, 29 Sep 2007 19:17:20 -0400
Subject: [PATCH] Minor whitespace updates
 Fixed char *phy initialization in main() preventing add from working
 Aliased 'master' to 'ap' for nl80211 mode definitions
 Added minimal help


Signed-off-by: Mike Kershaw <dragorn@xxxxxxxxxxxxxxxxxx>
---
 interface.c |   15 +++++++++------
 iw.c        |   14 ++++++++++++--
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/interface.c b/interface.c
index 580a952..ec81614 100644
--- a/interface.c
+++ b/interface.c
@@ -33,7 +33,7 @@ static int get_if_type(int *argc, char ***argv, enum nl80211_iftype *type)
 	} else if (strcmp(tpstr, "monitor") == 0) {
 		*type = NL80211_IFTYPE_MONITOR;
 		return 1;
-	} else if (strcmp(tpstr, "ap") == 0) {
+	} else if (strcmp(tpstr, "ap") == 0 || strcmp(tpstr, "master") == 0) {
 		*type = NL80211_IFTYPE_AP;
 		return 1;
 	} else if (strcmp(tpstr, "ap_vlan") == 0) {
@@ -70,7 +70,7 @@ static int handle_interface_add(struct nl80211_state *state,
 
 	if (argc) {
 		tpset = get_if_type(&argc, &argv, &type);
-		if (tpset < 0)
+		if (tpset < 0) 
 			return -1;
 	}
 
@@ -79,16 +79,19 @@ static int handle_interface_add(struct nl80211_state *state,
 		return -1;
 	}
 
-        msg = nlmsg_alloc();
-	if (!msg)
-        	return -1;
+	msg = nlmsg_alloc();
+	if (!msg) {
+		fprintf(stderr, "failed to allocate netlink msg\n");
+		return -1;
+	}
 
 	genlmsg_put(msg, 0, 0, genl_family_get_id(state->nl80211), 0,
 		    0, NL80211_CMD_NEW_INTERFACE, 0);
 	if (dev)
 		NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(dev));
-	if (phy)
+	if (phy) {
 		return -1; /* XXX TODO */
+	}
 	NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, name);
 	if (tpset)
 		NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, type);
diff --git a/iw.c b/iw.c
index 1d04d58..ffbd691 100644
--- a/iw.c
+++ b/iw.c
@@ -90,11 +90,16 @@ static int get_phy_or_dev(int *argc, char ***argv, char **name)
 	return 0;
 }
 
+void usage(char *argv0) {
+	fprintf(stderr, "Usage: %s [options] {dev <phydev>} {interface <interface> } {COMMAND}\n"
+			"where COMMAND := { add | del }\n", argv0);
+}
+
 int main(int argc, char **argv)
 {
 	struct nl80211_state nlstate;
 	int err = 0, pod;
-	char *ifname, *phyname, *type;
+	char *ifname = NULL, *phyname = NULL, *type, *argv0;
 
 	err = nl80211_init(&nlstate);
 	if (err)
@@ -102,7 +107,12 @@ int main(int argc, char **argv)
 
 	/* strip off self */
 	argc--;
-	argv++;
+	argv0 = *argv++;
+
+	if (argc == 0 || (argc == 1 && strcmp(*argv, "help") == 0)) {
+		usage(argv0);
+		goto out;
+	}
 
 	pod = get_phy_or_dev(&argc, &argv, &ifname);
 	if (pod == 0) {
-- 
1.5.3.2

Attachment: pgpaDTTI9dEKj.pgp
Description: PGP signature


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux