Unfortunantly it wasn't that easy. This version doesn't segfault with bad input :) Also just noticed there is a bunch of stuff going on with ifconfig in current. So I guess this can just be a conversation starter, and perhaps whomever is doing the work can possibly put something like this in.

Index: ifconfig.c
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.362
diff -u -p -u -r1.362 ifconfig.c
--- ifconfig.c    27 Feb 2018 22:32:26 -0000    1.362
+++ ifconfig.c    10 Aug 2018 01:31:10 -0000
@@ -793,9 +793,13 @@ main(int argc, char *argv[])
                 } else
                     noarg = 0;

-                if (noarg == 0)
-                    (*p->c_func)(NULL, 0);
-                else
+                if (noarg == 0) {
+                    if (strcmp(p->c_name, "scan") == 0) {
+                        (*p->c_func)(NULL, 0);
+                        goto done;
+                    } else
+                        (*p->c_func)(NULL, 0);
+                } else
                     goto nextarg;
             } else if (p->c_parameter == NEXTARG) {
 nextarg:
@@ -863,6 +867,7 @@ nextarg:
         if (ioctl(s, rafp->af_aifaddr, rafp->af_addreq) < 0)
             err(1, "SIOCAIFADDR");
     }
+done:
     return (0);
 }

@@ -1994,9 +1999,7 @@ setifchan(const char *val, int d)
 void
 setifscan(const char *val, int d)
 {
-    if (shownet80211chans || shownet80211nodes)
-        usage();
-    shownet80211nodes = 1;
+    return(ieee80211_listnodes());
 }

 #ifndef SMALL
@@ -2201,7 +2204,6 @@ ieee80211_status(void)
         putchar(' ');
         printb_status(ifr.ifr_flags, IEEE80211_F_USERBITS);
     }
-
     putchar('\n');
     if (shownet80211chans)
         ieee80211_listchans();


-------- Forwarded Message --------
Subject:        [patch] ifconfig.c
Date:   Thu, 9 Aug 2018 18:20:47 -0500
From:   Edgar Pettijohn III <ed...@pettijohn-web.com>
To:     tech@openbsd.org



I hate to assume, but I'm going to assume that if one wants to scan for
ap's for their wifi interface to connect to they don't care about
anything else. I also removed what to me is one too many tabs.


Index: ifconfig.c
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.362
diff -u -p -u -r1.362 ifconfig.c
--- ifconfig.c    27 Feb 2018 22:32:26 -0000    1.362
+++ ifconfig.c    9 Aug 2018 23:16:59 -0000
@@ -772,6 +772,11 @@ main(int argc, char *argv[])
             return bridge_rule(argc, argv, -1);
         }
 #endif
+        if (strcmp(p->c_name, "scan") == 0) {
+            ieee80211_listnodes();
+            return 0;
+        }
+
         if (p->c_name == 0 && setaddr)
             for (i = setaddr; i > 0; i--) {
                 p++;
@@ -2288,7 +2293,7 @@ ieee80211_listnodes(void)
         qsort(nr, na.na_nodes, sizeof(*nr), rssicmp);

     for (i = 0; i < na.na_nodes; i++) {
-        printf("\t\t");
+        printf("\t");
         ieee80211_printnode(&nr[i]);
         putchar('\n');
     }


Reply via email to