]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
Minor updates
authorMike Kershaw <dragorn@kismetwireless.net>
Sat, 29 Sep 2007 23:17:20 +0000 (19:17 -0400)
committerJohannes Berg <johannes@sipsolutions.net>
Sun, 30 Sep 2007 14:44:01 +0000 (16:44 +0200)
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@kismetwireless.net>
interface.c
iw.c

index 580a95224071f8301ef8b5cd11b254c8b57e4d39..b54a66cd29cc90e5d0bc759e0c5fa2398f77e4e4 100644 (file)
@@ -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) {
@@ -79,9 +79,11 @@ 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);
diff --git a/iw.c b/iw.c
index 1d04d584a3a6122e6db7ff15c0765260fa8370c4..c2b53ee236fc3244eb65cdc587b26fe37fd181e5 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -90,11 +90,17 @@ 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 +108,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) {