Skip to contentSkip to conversation

iw: misc minor updates

PATCH Applied Mike Kershaw 2 participants 2 messages Sep 29, 2007 – Sep 30, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iw: misc minor updates

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

Signature · 5 lines
Mike Kershaw/Dragorn <[email protected]>
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 <[email protected]>
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

---
 interface.c |   15 +++++++++------
 iw.c        |   14 ++++++++++++--
 2 files changed, 21 insertions(+), 8 deletions(-)
interface.c +9 -6
index 580a952..ec81614 100644
@@ -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);
iw.c +12 -2
index 1d04d58..ffbd691 100644
@@ -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) {
Signature · 1 line
1.5.3.2
#1 lore raw
Quoted 5 lines · Mike Kershaw

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

Thanks, applied with some small fixes. It'd help if you could inline patches and make the description just in the mail :)

johannes