/*
* Wireless Tools
*
- * Jean II - HPLB '99
+ * Jean II - HPLB 97->99 - HPL 99->00
*
* Main code for "iwconfig". This is the generic tool for most
* manipulations...
* You need to link this code against "iwcommon.c" and "-lm".
+ *
+ * This file is released under the GPL license.
*/
#include "iwcommon.h" /* Header */
{
fprintf(stderr, "Usage: iwpriv interface [private-command [private-arguments]]\n");
fprintf(stderr, " interface [roam {on|off}]\n");
- fprintf(stderr, " interface [port [n]]\n");
+ fprintf(stderr, " interface [port {ad-hoc|managed|N}]\n");
exit(1);
}
case IW_PRIV_TYPE_INT:
/* Display args */
for(j = 0; j < n; j++)
- printf("%d ", ((u_int *) buffer)[i]);
+ printf("%d ", ((u_int *) buffer)[j]);
printf("\n");
break;
iwprivargs priv[16];
int number;
char ptype = 0;
+ char * modes[] = { "invalid", "managed (BSS)", "reserved", "ad-hoc" };
/* Read the private ioctls */
number = get_priv_info(skfd, ifname, priv);
{
/* So, we just want to see the current value... */
k = -1;
- while((++k < number) && strcmp(priv[k].name, "gport_type"));
+ while((++k < number) && strcmp(priv[k].name, "gport_type") &&
+ strcmp(priv[k].name, "get_port"));
if(k == number)
{
fprintf(stderr, "This device doesn't support getting port type\n");
ptype = *wrq.u.name;
/* Display it */
- printf("%-8.8s Port type is %d.\n\n", ifname, ptype);
+ printf("%-8.8s Current port mode is %s <port type is %d>.\n\n",
+ ifname, modes[(int) ptype], ptype);
return(0);
}
iw_usage();
/* Read it */
- if(sscanf(args[i], "%d", (int *) &ptype) != 1)
- iw_usage();
+ /* As a string... */
+ k = 0;
+ while((k < 4) && strncasecmp(args[i], modes[k], 2))
+ k++;
+ if(k < 4)
+ ptype = k;
+ else
+ /* ...or as an integer */
+ if(sscanf(args[i], "%d", (int *) &ptype) != 1)
+ iw_usage();
k = -1;
- while((++k < number) && strcmp(priv[k].name, "sport_type"));
+ while((++k < number) && strcmp(priv[k].name, "sport_type") &&
+ strcmp(priv[k].name, "set_port"));
if(k == number)
{
fprintf(stderr, "This device doesn't support setting port type\n");
if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
{
- fprintf(stderr, "Invalid port type\n");
+ fprintf(stderr, "Invalid port type (or setting not allowed)\n");
exit(0);
}