diff -ur wireless_tools.25/iwconfig.c wireless_tools.25-ct/iwconfig.c --- wireless_tools.25/iwconfig.c 2002-08-17 00:10:42.000000000 +0200 +++ wireless_tools.25-ct/iwconfig.c 2003-04-08 16:21:27.000000000 +0200 @@ -13,6 +13,8 @@ #include "iwlib.h" /* Header */ +static int display_ap_name = 0; /* -ct: display ap name */ + /************************* MISC SUBROUTINES **************************/ /*------------------------------------------------------------------*/ @@ -22,7 +24,8 @@ static void iw_usage(void) { - fprintf(stderr, "Usage: iwconfig interface [essid {NN|on|off}]\n"); + fprintf(stderr, "Usage: iwconfig interface [-d, --display-ap-name]\n"); + fprintf(stderr, " [essid {NN|on|off}]\n"); fprintf(stderr, " [nwid {NN|on|off}]\n"); fprintf(stderr, " [mode {managed|ad-hoc|...}\n"); fprintf(stderr, " [freq N.NNNN[k|M|G]]\n"); @@ -211,6 +214,11 @@ char * ifname) { char buffer[128]; /* Temporary buffer */ + FILE *fh; /* -ct: fh: /etc/ap.list */ + char linebuf[512]; /* -ct: temporary buffer */ + char ap_name[495]; /* -ct: accesspoint name */ + char ap_addr[17]; /* -ct: ap's hw_addr */ + int found_ap = 0; /* -ct: found ap? */ /* One token is more of less 5 characters, 14 tokens per line */ int tokens = 3; /* For name */ @@ -285,10 +293,40 @@ /* Oups ! No Access Point in Ad-Hoc mode */ if((info->has_mode) && (info->mode == IW_MODE_ADHOC)) - printf("Cell:"); + { + printf("Cell:"); + printf(" %s ", iw_pr_ether(buffer, info->ap_addr.sa_data)); + } else - printf("Access Point:"); - printf(" %s ", iw_pr_ether(buffer, info->ap_addr.sa_data)); + { + printf("Access Point:"); + + if(display_ap_name == 1 && (fh = fopen("/etc/ap.list","r"))) + { + while ((fgets(linebuf, 512, fh)) != NULL) + { + if (linebuf[0] == '#') // comment! + continue; + + sscanf(linebuf,"%s %s", &ap_addr, &ap_name); + + if(strcasecmp(ap_addr, iw_pr_ether(buffer, info->ap_addr.sa_data)) == NULL) + { + printf(" %s ",ap_name); + found_ap = 1; + fclose(fh); + break; + } + } + + if(found_ap == NULL) + printf(" %s ", iw_pr_ether(buffer, info->ap_addr.sa_data)); + } + else + { + printf(" %s ", iw_pr_ether(buffer, info->ap_addr.sa_data)); + } + } } /* Display the currently used/set bit-rate */ @@ -1353,21 +1391,34 @@ exit(-1); } - /* No argument : show the list of all device + info */ - if(argc == 1) - iw_enum_devices(skfd, &print_info, NULL, 0); - else - /* Special case for help... */ - if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help"))) - iw_usage(); + /* Only -d argument : show the list of all device + info + ap_name */ + if((argc == 2 && !strcmp(argv[1], "--display-ap-name")) || (argc == 2 && !strcmp(argv[1], "-d"))) + { + display_ap_name = 1; + iw_enum_devices(skfd, &print_info, NULL, 0); + } + else + /* No argument : show the list of all device + info */ + if(argc == 1) + iw_enum_devices(skfd, &print_info, NULL, 0); else - /* Special case for version... */ - if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) - goterr = iw_print_version_info("iwconfig"); + /* Special case for help... */ + if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help"))) + iw_usage(); else - /* The device name must be the first argument */ - if(argc == 2) - print_info(skfd, argv[1], NULL, 0); + /* Special case for version... */ + if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) + goterr = iw_print_version_info("iwconfig"); + else + if((argc == 3 && !strcmp(argv[2], "--display-ap-name")) || (argc == 3 && !strcmp(argv[2], "-d"))) + { + display_ap_name = 1; + print_info(skfd, argv[1], NULL, 0); + } + else + /* The device name must be the first argument */ + if(argc == 2) + print_info(skfd, argv[1], NULL, 0); else /* The other args on the line specify options to be set... */ goterr = set_info(skfd, argv + 2, argc - 2, argv[1]);