Modified wlanctl to print all request type commands, not just dot11req. Added support for printing all the mib items.

This commit is contained in:
joellen 2000-01-29 22:17:27 +00:00
parent 7d27d17666
commit f6bb3e9527
3 changed files with 143 additions and 36 deletions

View File

@ -44,6 +44,7 @@
#include <wlan/p80211types.h>
#include <wlan/p80211meta.h>
#include <wlan/p80211metamsg.h>
#include <wlan/p80211metamib.h>
#include <wlan/p80211msg.h>
#include "wlanctl.h"
@ -87,14 +88,15 @@ void print_allrequests(void);
void usage(void)
{
printf("wlanctl: - control utility for 802.11 devices\n");
printf(" usage: wlanctl interface|version|commands cmd cmdarg [cmdarg...]\n\n");
printf(" usage: wlanctl interface|version|commands|mibs cmd cmdarg [cmdarg...]\n\n");
printf(" where \"interface\" is the name of a wireless\n");
printf(" network interface. Running \'ifconfig\' will list\n");
printf(" all network interfaces.\n\n");
printf(" Refer to the wlanctl man page or run \n");
printf(" \'wlanctl commands\' for more details\n\n");
printf(" Refer to the wlanctl man page for more details.\n\n");
printf(" For a list of available commands, run \'wlanctl commands\'\n\n");
printf(" For a list of available mib items, run \'wlanctl mibs\'\n");
}
@ -117,64 +119,169 @@ void print_allrequests(void)
int j;
int k;
UINT32 did;
p80211meta_t *request;
p80211meta_t *msg_item;
grplistitem_t *grp;
int nargs;
int msg_cat;
int ncats;
int ncmds;
int nitems;
p80211enum_t *enump;
/* TODO: Fix this for multiple message categories */
ncats = GETMETASIZE(msg_catlist);
ncmds = GETMETASIZE(msg_catlist[P80211SEC_DOT11REQ].grplist);
for (msg_cat = 1; msg_cat < ncats; msg_cat++ ) {
for (i = 1; i < ncmds; i++) {
did = P80211DID_MKSECTION(P80211SEC_DOT11REQ) | P80211DID_MKGROUP(i);
if ( (grp = p80211_did2grp(msg_catlist, did)) != NULL ) {
if ( strstr(msg_catlist[msg_cat].name, "req") == NULL ) {
continue;
}
printf("Command: %s\n", grp->name);
request = grp->itemlist;
nargs = GETMETASIZE(request);
ncmds = GETMETASIZE(msg_catlist[msg_cat].grplist);
for ( j = 1; j < nargs; j++)
{
if ( P80211ITEM_ISREQUEST(request[j].flags) ) {
for (i = 1; i < ncmds; i++ ) {
did = P80211DID_MKSECTION(msg_cat) | P80211DID_MKGROUP(i);
if ( (grp = p80211_did2grp(msg_catlist, did)) != NULL ) {
printf("Command: %s\n", grp->name);
msg_item = grp->itemlist;
nitems = GETMETASIZE(msg_item);
for ( j = 1; j < nitems; j++)
{
if ( P80211ITEM_ISREQUEST(msg_item[j].flags) ) {
printf( " %s(%s):",
msg_item[j].name,
P80211ITEM_ISREQUIRED(msg_item[j].flags) ?
"required" : "optional");
switch (P80211DID_TYPE(msg_item[j].did)) {
case P80211_TYPE_OCTETSTR:
printf("OCTETSTR{");
printf("maxlen=%ld}", msg_item[j].maxlen);
break;
case P80211_TYPE_DISPLAYSTR:
printf("DISPLAYSTR{");
printf("maxlen=%ld}", msg_item[j].maxlen);
break;
case P80211_TYPE_BOUNDEDINT:
printf("BOUNDEDINT{");
printf("min=%ld, max=%ld}",
msg_item[j].min,
msg_item[j].max);
break;
case P80211_TYPE_INT:
printf("INT");
break;
case P80211_TYPE_ENUMINT:
printf("\n ENUMINT{\n");
enump = msg_item[j].enumptr;
for ( k = 0; k < enump->nitems; k++){
printf(" %s", enump->list[k].name);
if ( k < enump->nitems - 1) {
printf("|\n");
}
}
printf("}");
break;
case P80211_TYPE_UNKDATA:
printf("UNKDATA{");
printf("maxlen=%ld}", msg_item[j].maxlen);
break;
default:
printf("ERROR: unknown type!\n");
break;
}
printf("\n");
}
}
}
else {
printf("help.c: invalid group did\n");
}
}
}
}
/*----------------------------------------------------------------
* print_allmibs
*
* Traverse all of the mib items in the mib metadata. Print the
* name of the group, the name of each mib item and any
* validation requirements.
*
* Arguments:
* none
*
* Returns:
* nothing
----------------------------------------------------------------*/
void print_allmibs(void)
{
int i;
int j;
int k;
UINT32 did;
p80211meta_t *mib_item;
grplistitem_t *grp;
int mib_cat;
int ncats;
int ncmds;
int nitems;
p80211enum_t *enump;
ncats = GETMETASIZE(mib_catlist);
for (mib_cat = 1; mib_cat < ncats; mib_cat++ ) {
ncmds = GETMETASIZE(mib_catlist[mib_cat].grplist);
for (i = 1; i < ncmds; i++ ) {
did = P80211DID_MKSECTION(mib_cat) | P80211DID_MKGROUP(i);
if ( (grp = p80211_did2grp(mib_catlist, did)) != NULL ) {
printf("Mib Group: %s\n", grp->name);
mib_item = grp->itemlist;
nitems = GETMETASIZE(mib_item);
for ( j = 1; j < nitems; j++) {
printf( " %s(%s):",
request[j].name,
P80211ITEM_ISREQUIRED(request[j].flags) ?
mib_item[j].name,
P80211ITEM_ISREQUIRED(mib_item[j].flags) ?
"required" : "optional");
switch (P80211DID_TYPE(request[j].did)) {
switch (P80211DID_TYPE(mib_item[j].did)) {
case P80211_TYPE_OCTETSTR:
printf("OCTETSTR{");
printf("maxlen=%ld}", request[j].maxlen);
printf("maxlen=%ld}", mib_item[j].maxlen);
break;
case P80211_TYPE_DISPLAYSTR:
printf("DISPLAYSTR{");
printf("maxlen=%ld}", request[j].maxlen);
printf("DISPLAYSTR{");
printf("maxlen=%ld}", mib_item[j].maxlen);
break;
case P80211_TYPE_BOUNDEDINT:
printf("BOUNDEDINT{");
printf("min=%ld, max=%ld}",
request[j].min,
request[j].max);
mib_item[j].min,
mib_item[j].max);
break;
case P80211_TYPE_INT:
printf("INT");
break;
case P80211_TYPE_ENUMINT:
printf("ENUMINT{");
enump = request[j].enumptr;
printf("\n ENUMINT{\n");
enump = mib_item[j].enumptr;
for ( k = 0; k < enump->nitems; k++){
printf("%s", enump->list[k].name);
printf(" %s", enump->list[k].name);
if ( k < enump->nitems - 1) {
printf("|");
printf("|\n");
}
}
printf("}");
break;
case P80211_TYPE_UNKDATA:
printf("UNKDATA");
printf("UNKDATA{");
printf("maxlen=%ld}", mib_item[j].maxlen);
break;
default:
printf("ERROR: unknown type!\n");
@ -183,13 +290,9 @@ void print_allrequests(void)
printf("\n");
}
}
}
else {
printf("help.c: invalid group did\n");
else {
printf("help.c: invalid group did\n");
}
}
}
}

View File

@ -111,6 +111,9 @@ int main ( int argc, char **argv )
else if ( argc < 4 && argc >= 2 && strcmp( argv[1], "commands") == 0) {
print_allrequests();
}
else if ( argc < 4 && argc >= 2 && strcmp( argv[1], "mibs") == 0) {
print_allmibs();
}
else if ( argc < 4 ) {
usage();
} else {

View File

@ -59,6 +59,7 @@ extern char *cmdcats[];
void usage(void); /* help.c */
void print_allrequests(void); /* help.c */
void print_allmibs(void); /* help.c */
#endif /* _WLANCTL_H */