Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Mar 2014 00:26:25 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r262759 - head/tools/tools/iwn/iwnstats
Message-ID:  <201403050026.s250QPJa093904@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Wed Mar  5 00:26:25 2014
New Revision: 262759
URL: http://svnweb.freebsd.org/changeset/base/262759

Log:
  Add command line parsing - and an -i <ifname> option so I can monitor
  multiple iwn interfaces.
  
  Tested:
  
  * Intel 5100

Modified:
  head/tools/tools/iwn/iwnstats/main.c

Modified: head/tools/tools/iwn/iwnstats/main.c
==============================================================================
--- head/tools/tools/iwn/iwnstats/main.c	Tue Mar  4 23:55:04 2014	(r262758)
+++ head/tools/tools/iwn/iwnstats/main.c	Wed Mar  5 00:26:25 2014	(r262759)
@@ -252,12 +252,42 @@ iwn_print(struct iwnstats *is)
 	printf("--\n");
 }
 
+static void
+usage(void)
+{
+	printf("Usage: iwnstats [-h] [-i ifname]\n");
+	printf("    -h:			Help\n");
+	printf("    -i <ifname>:	Use ifname (default %s)\n",
+	    IWN_DEFAULT_IF);
+}
+
 int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
 {
 	struct iwnstats *is;
+	int ch;
+	char *ifname;
+
+	ifname = strdup(IWN_DEFAULT_IF);
+
+	/* Parse command line arguments */
+	while ((ch = getopt(argc, argv,
+	    "hi:")) != -1) {
+		switch (ch) {
+		case 'i':
+			if (ifname)
+				free(ifname);
+			ifname = strdup(optarg);
+			break;
+		default:
+		case '?':
+		case 'h':
+			usage();
+			exit(1);
+		}
+	}
 
-	is = iwnstats_new(IWN_DEFAULT_IF);
+	is = iwnstats_new(ifname);
 
 	if (is == NULL) {
 		fprintf(stderr, "%s: couldn't allocate new stats structure\n",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403050026.s250QPJa093904>