ancontrol.c (114601) | ancontrol.c (119156) |
---|---|
1/* 2 * Copyright 1997, 1998, 1999 3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 33#if 0 34#ifndef lint 35static const char copyright[] = "@(#) Copyright (c) 1997, 1998, 1999\ 36 Bill Paul. All rights reserved."; 37#endif 38#endif 39#include <sys/cdefs.h> | 1/* 2 * Copyright 1997, 1998, 1999 3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 33#if 0 34#ifndef lint 35static const char copyright[] = "@(#) Copyright (c) 1997, 1998, 1999\ 36 Bill Paul. All rights reserved."; 37#endif 38#endif 39#include <sys/cdefs.h> |
40__FBSDID("$FreeBSD: head/usr.sbin/ancontrol/ancontrol.c 114601 2003-05-03 21:06:42Z obrien $"); | 40__FBSDID("$FreeBSD: head/usr.sbin/ancontrol/ancontrol.c 119156 2003-08-20 03:46:05Z ambrisko $"); |
41 42#include <sys/types.h> 43#include <sys/cdefs.h> 44#include <sys/socket.h> 45#include <sys/ioctl.h> 46#include <sys/socket.h> 47 48#include <arpa/inet.h> --- 47 unchanged lines hidden (view full) --- 96#define ACT_DUMPSTATS 1 97#define ACT_DUMPCONFIG 2 98#define ACT_DUMPSTATUS 3 99#define ACT_DUMPCAPS 4 100#define ACT_DUMPSSID 5 101#define ACT_DUMPAP 6 102 103#define ACT_SET_OPMODE 7 | 41 42#include <sys/types.h> 43#include <sys/cdefs.h> 44#include <sys/socket.h> 45#include <sys/ioctl.h> 46#include <sys/socket.h> 47 48#include <arpa/inet.h> --- 47 unchanged lines hidden (view full) --- 96#define ACT_DUMPSTATS 1 97#define ACT_DUMPCONFIG 2 98#define ACT_DUMPSTATUS 3 99#define ACT_DUMPCAPS 4 100#define ACT_DUMPSSID 5 101#define ACT_DUMPAP 6 102 103#define ACT_SET_OPMODE 7 |
104#define ACT_SET_SSID1 8 105#define ACT_SET_SSID2 9 106#define ACT_SET_SSID3 10 | 104#define ACT_SET_SSID 8 |
107#define ACT_SET_FREQ 11 108#define ACT_SET_AP1 12 109#define ACT_SET_AP2 13 110#define ACT_SET_AP3 14 111#define ACT_SET_AP4 15 112#define ACT_SET_DRIVERNAME 16 113#define ACT_SET_SCANMODE 17 114#define ACT_SET_TXRATE 18 --- 65 unchanged lines hidden (view full) --- 180 181 if (s == -1) 182 err(1, "socket"); 183 184 if (ioctl(s, SIOCSAIRONET, &ifr) == -1) 185 err(1, "SIOCSAIRONET"); 186 187 close(s); | 105#define ACT_SET_FREQ 11 106#define ACT_SET_AP1 12 107#define ACT_SET_AP2 13 108#define ACT_SET_AP3 14 109#define ACT_SET_AP4 15 110#define ACT_SET_DRIVERNAME 16 111#define ACT_SET_SCANMODE 17 112#define ACT_SET_TXRATE 18 --- 65 unchanged lines hidden (view full) --- 178 179 if (s == -1) 180 err(1, "socket"); 181 182 if (ioctl(s, SIOCSAIRONET, &ifr) == -1) 183 err(1, "SIOCSAIRONET"); 184 185 close(s); |
186printf("Hello %s %s %d\n",__FILE__,__FUNCTION__,__LINE__); |
|
188 189 return; 190} 191 192static void an_printstr(str, len) 193 char *str; 194 int len; 195{ --- 447 unchanged lines hidden (view full) --- 643 printf("\n"); 644 645 return; 646} 647 648static void an_dumpssid(iface) 649 const char *iface; 650{ | 187 188 return; 189} 190 191static void an_printstr(str, len) 192 char *str; 193 int len; 194{ --- 447 unchanged lines hidden (view full) --- 642 printf("\n"); 643 644 return; 645} 646 647static void an_dumpssid(iface) 648 const char *iface; 649{ |
651 struct an_ltv_ssidlist *ssid; | 650 struct an_ltv_ssidlist_new *ssid; |
652 struct an_req areq; | 651 struct an_req areq; |
652 int i, max; |
|
653 654 areq.an_len = sizeof(areq); 655 areq.an_type = AN_RID_SSIDLIST; 656 657 an_getval(iface, &areq); 658 | 653 654 areq.an_len = sizeof(areq); 655 areq.an_type = AN_RID_SSIDLIST; 656 657 an_getval(iface, &areq); 658 |
659 ssid = (struct an_ltv_ssidlist *)&areq; 660 printf("SSID 1:\t\t\t[ %.*s ]\n", ssid->an_ssid1_len, ssid->an_ssid1); 661 printf("SSID 2:\t\t\t[ %.*s ]\n", ssid->an_ssid2_len, ssid->an_ssid2); 662 printf("SSID 3:\t\t\t[ %.*s ]\n", ssid->an_ssid3_len, ssid->an_ssid3); | 659 max = (areq.an_len - 4) / sizeof(struct an_ltv_ssid_entry); 660 if ( max > MAX_SSIDS ) { 661 printf("To many SSIDs only printing %d of %d\n", 662 MAX_SSIDS, max); 663 max = MAX_SSIDS; 664 } 665 ssid = (struct an_ltv_ssidlist_new *)&areq; 666 for (i = 0; i < max; i++) 667 printf("SSID %2d:\t\t\t[ %.*s ]\n", i + 1, 668 ssid->an_entry[i].an_len, 669 ssid->an_entry[i].an_ssid); |
663 664 return; 665} 666 667static void an_dumpconfig(iface) 668 const char *iface; 669{ 670 struct an_ltv_genconfig *cfg; --- 506 unchanged lines hidden (view full) --- 1177 exit(0); 1178} 1179 1180static void an_setssid(iface, act, arg) 1181 const char *iface; 1182 int act; 1183 void *arg; 1184{ | 670 671 return; 672} 673 674static void an_dumpconfig(iface) 675 const char *iface; 676{ 677 struct an_ltv_genconfig *cfg; --- 506 unchanged lines hidden (view full) --- 1184 exit(0); 1185} 1186 1187static void an_setssid(iface, act, arg) 1188 const char *iface; 1189 int act; 1190 void *arg; 1191{ |
1185 struct an_ltv_ssidlist *ssid; | 1192 struct an_ltv_ssidlist_new *ssid; |
1186 struct an_req areq; | 1193 struct an_req areq; |
1194 int max; |
|
1187 1188 areq.an_len = sizeof(areq); 1189 areq.an_type = AN_RID_SSIDLIST; 1190 1191 an_getval(iface, &areq); | 1195 1196 areq.an_len = sizeof(areq); 1197 areq.an_type = AN_RID_SSIDLIST; 1198 1199 an_getval(iface, &areq); |
1192 ssid = (struct an_ltv_ssidlist *)&areq; | 1200 ssid = (struct an_ltv_ssidlist_new *)&areq; |
1193 | 1201 |
1194 switch (act) { 1195 case ACT_SET_SSID1: 1196 bzero(ssid->an_ssid1, sizeof(ssid->an_ssid1)); 1197 strlcpy(ssid->an_ssid1, (char *)arg, sizeof(ssid->an_ssid1)); 1198 ssid->an_ssid1_len = strlen(ssid->an_ssid1); 1199 break; 1200 case ACT_SET_SSID2: 1201 bzero(ssid->an_ssid2, sizeof(ssid->an_ssid2)); 1202 strlcpy(ssid->an_ssid2, (char *)arg, sizeof(ssid->an_ssid2)); 1203 ssid->an_ssid2_len = strlen(ssid->an_ssid2); 1204 break; 1205 case ACT_SET_SSID3: 1206 bzero(ssid->an_ssid3, sizeof(ssid->an_ssid3)); 1207 strlcpy(ssid->an_ssid3, (char *)arg, sizeof(ssid->an_ssid3)); 1208 ssid->an_ssid3_len = strlen(ssid->an_ssid3); 1209 break; 1210 default: 1211 errx(1, "unknown action"); 1212 break; | 1202 max = (areq.an_len - 4) / sizeof(struct an_ltv_ssid_entry); 1203 if ( max > MAX_SSIDS ) { 1204 printf("To many SSIDs only printing %d of %d\n", 1205 MAX_SSIDS, max); 1206 max = MAX_SSIDS; |
1213 } 1214 | 1207 } 1208 |
1209 if ( act > max ) { 1210 errx(1, "bad modifier %d: there " 1211 "are only %d SSID settings", act, max); 1212 exit(1); 1213 } 1214 1215 bzero(ssid->an_entry[act-1].an_ssid, 1216 sizeof(ssid->an_entry[act-1].an_ssid)); 1217 strlcpy(ssid->an_entry[act-1].an_ssid, (char *)arg, 1218 sizeof(ssid->an_entry[act-1].an_ssid)); 1219 ssid->an_entry[act-1].an_len 1220 = strlen(ssid->an_entry[act-1].an_ssid); 1221 |
|
1215 an_setval(iface, &areq); | 1222 an_setval(iface, &areq); |
1223 |
|
1216 exit(0); 1217} 1218 1219#ifdef ANCACHE 1220static void an_zerocache(iface) 1221 const char *iface; 1222{ 1223 struct an_req areq; --- 473 unchanged lines hidden (view full) --- 1697 act = ACT_SET_MYNAME; 1698 arg = optarg; 1699 break; 1700 case 'm': 1701 act = ACT_SET_MAC; 1702 arg = optarg; 1703 break; 1704 case 'n': | 1224 exit(0); 1225} 1226 1227#ifdef ANCACHE 1228static void an_zerocache(iface) 1229 const char *iface; 1230{ 1231 struct an_req areq; --- 473 unchanged lines hidden (view full) --- 1705 act = ACT_SET_MYNAME; 1706 arg = optarg; 1707 break; 1708 case 'm': 1709 act = ACT_SET_MAC; 1710 arg = optarg; 1711 break; 1712 case 'n': |
1705 switch(modifier) { 1706 case 0: 1707 case 1: 1708 act = ACT_SET_SSID1; 1709 break; 1710 case 2: 1711 act = ACT_SET_SSID2; 1712 break; 1713 case 3: 1714 act = ACT_SET_SSID3; 1715 break; 1716 default: 1717 errx(1, "bad modifier %d: there" 1718 "are only 3 SSID settings", modifier); 1719 usage(p); 1720 break; 1721 } | 1713 if (modifier == 0) 1714 modifier = 1; 1715 act = ACT_SET_SSID; |
1722 arg = optarg; 1723 break; 1724 case 'o': 1725 act = ACT_SET_OPMODE; 1726 arg = optarg; 1727 break; 1728 case 'c': 1729 act = ACT_SET_FREQ; --- 65 unchanged lines hidden (view full) --- 1795 an_dumpssid(iface); 1796 break; 1797 case ACT_DUMPAP: 1798 an_dumpap(iface); 1799 break; 1800 case ACT_DUMPRSSIMAP: 1801 an_dumprssimap(iface); 1802 break; | 1716 arg = optarg; 1717 break; 1718 case 'o': 1719 act = ACT_SET_OPMODE; 1720 arg = optarg; 1721 break; 1722 case 'c': 1723 act = ACT_SET_FREQ; --- 65 unchanged lines hidden (view full) --- 1789 an_dumpssid(iface); 1790 break; 1791 case ACT_DUMPAP: 1792 an_dumpap(iface); 1793 break; 1794 case ACT_DUMPRSSIMAP: 1795 an_dumprssimap(iface); 1796 break; |
1803 case ACT_SET_SSID1: 1804 case ACT_SET_SSID2: 1805 case ACT_SET_SSID3: 1806 an_setssid(iface, act, arg); | 1797 case ACT_SET_SSID: 1798 an_setssid(iface, modifier, arg); |
1807 break; 1808 case ACT_SET_AP1: 1809 case ACT_SET_AP2: 1810 case ACT_SET_AP3: 1811 case ACT_SET_AP4: 1812 an_setap(iface, act, arg); 1813 break; 1814 case ACT_SET_TXRATE: --- 28 unchanged lines hidden --- | 1799 break; 1800 case ACT_SET_AP1: 1801 case ACT_SET_AP2: 1802 case ACT_SET_AP3: 1803 case ACT_SET_AP4: 1804 an_setap(iface, act, arg); 1805 break; 1806 case ACT_SET_TXRATE: --- 28 unchanged lines hidden --- |