ifieee80211.c (188784) | ifieee80211.c (189096) |
---|---|
1/* 2 * Copyright 2001 The Aerospace Corporation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * | 1/* 2 * Copyright 2001 The Aerospace Corporation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * |
27 * $FreeBSD: head/sbin/ifconfig/ifieee80211.c 188784 2009-02-19 05:28:03Z sam $ | 27 * $FreeBSD: head/sbin/ifconfig/ifieee80211.c 189096 2009-02-27 00:31:34Z rpaulo $ |
28 */ 29 30/*- 31 * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. 32 * All rights reserved. 33 * 34 * This code is derived from software contributed to The NetBSD Foundation 35 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, --- 4626 unchanged lines hidden (view full) --- 4662}; 4663 4664static void 4665wlan_create(int s, struct ifreq *ifr) 4666{ 4667 static const uint8_t zerobssid[IEEE80211_ADDR_LEN]; 4668 4669 if (params.icp_parent[0] == '\0') | 28 */ 29 30/*- 31 * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. 32 * All rights reserved. 33 * 34 * This code is derived from software contributed to The NetBSD Foundation 35 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, --- 4626 unchanged lines hidden (view full) --- 4662}; 4663 4664static void 4665wlan_create(int s, struct ifreq *ifr) 4666{ 4667 static const uint8_t zerobssid[IEEE80211_ADDR_LEN]; 4668 4669 if (params.icp_parent[0] == '\0') |
4670 errx(1, "must specify a parent when creating a wlan device"); | 4670 errx(1, "must specify a parent device (wlandev) when creating " 4671 "a wlan device"); |
4671 if (params.icp_opmode == IEEE80211_M_WDS && 4672 memcmp(params.icp_bssid, zerobssid, sizeof(zerobssid)) == 0) 4673 errx(1, "no bssid specified for WDS (use wlanbssid)"); 4674 ifr->ifr_data = (caddr_t) ¶ms; 4675 if (ioctl(s, SIOCIFCREATE2, ifr) < 0) 4676 err(1, "SIOCIFCREATE2"); 4677} 4678 4679static 4680DECL_CMD_FUNC(set80211clone_wlandev, arg, d) 4681{ 4682 strlcpy(params.icp_parent, arg, IFNAMSIZ); | 4672 if (params.icp_opmode == IEEE80211_M_WDS && 4673 memcmp(params.icp_bssid, zerobssid, sizeof(zerobssid)) == 0) 4674 errx(1, "no bssid specified for WDS (use wlanbssid)"); 4675 ifr->ifr_data = (caddr_t) ¶ms; 4676 if (ioctl(s, SIOCIFCREATE2, ifr) < 0) 4677 err(1, "SIOCIFCREATE2"); 4678} 4679 4680static 4681DECL_CMD_FUNC(set80211clone_wlandev, arg, d) 4682{ 4683 strlcpy(params.icp_parent, arg, IFNAMSIZ); |
4683 clone_setcallback(wlan_create); | |
4684} 4685 4686static 4687DECL_CMD_FUNC(set80211clone_wlanbssid, arg, d) 4688{ 4689 const struct ether_addr *ea; 4690 4691 ea = ether_aton(arg); 4692 if (ea == NULL) 4693 errx(1, "%s: cannot parse bssid", arg); 4694 memcpy(params.icp_bssid, ea->octet, IEEE80211_ADDR_LEN); | 4684} 4685 4686static 4687DECL_CMD_FUNC(set80211clone_wlanbssid, arg, d) 4688{ 4689 const struct ether_addr *ea; 4690 4691 ea = ether_aton(arg); 4692 if (ea == NULL) 4693 errx(1, "%s: cannot parse bssid", arg); 4694 memcpy(params.icp_bssid, ea->octet, IEEE80211_ADDR_LEN); |
4695 clone_setcallback(wlan_create); | |
4696} 4697 4698static 4699DECL_CMD_FUNC(set80211clone_wlanaddr, arg, d) 4700{ 4701 const struct ether_addr *ea; 4702 4703 ea = ether_aton(arg); 4704 if (ea == NULL) 4705 errx(1, "%s: cannot parse addres", arg); 4706 memcpy(params.icp_macaddr, ea->octet, IEEE80211_ADDR_LEN); 4707 params.icp_flags |= IEEE80211_CLONE_MACADDR; | 4695} 4696 4697static 4698DECL_CMD_FUNC(set80211clone_wlanaddr, arg, d) 4699{ 4700 const struct ether_addr *ea; 4701 4702 ea = ether_aton(arg); 4703 if (ea == NULL) 4704 errx(1, "%s: cannot parse addres", arg); 4705 memcpy(params.icp_macaddr, ea->octet, IEEE80211_ADDR_LEN); 4706 params.icp_flags |= IEEE80211_CLONE_MACADDR; |
4708 clone_setcallback(wlan_create); | |
4709} 4710 4711static 4712DECL_CMD_FUNC(set80211clone_wlanmode, arg, d) 4713{ 4714#define iseq(a,b) (strncasecmp(a,b,sizeof(b)-1) == 0) 4715 if (iseq(arg, "sta")) 4716 params.icp_opmode = IEEE80211_M_STA; --- 7 unchanged lines hidden (view full) --- 4724 params.icp_opmode = IEEE80211_M_WDS; 4725 else if (iseq(arg, "monitor")) 4726 params.icp_opmode = IEEE80211_M_MONITOR; 4727 else if (iseq(arg, "tdma")) { 4728 params.icp_opmode = IEEE80211_M_AHDEMO; 4729 params.icp_flags |= IEEE80211_CLONE_TDMA; 4730 } else 4731 errx(1, "Don't know to create %s for %s", arg, name); | 4707} 4708 4709static 4710DECL_CMD_FUNC(set80211clone_wlanmode, arg, d) 4711{ 4712#define iseq(a,b) (strncasecmp(a,b,sizeof(b)-1) == 0) 4713 if (iseq(arg, "sta")) 4714 params.icp_opmode = IEEE80211_M_STA; --- 7 unchanged lines hidden (view full) --- 4722 params.icp_opmode = IEEE80211_M_WDS; 4723 else if (iseq(arg, "monitor")) 4724 params.icp_opmode = IEEE80211_M_MONITOR; 4725 else if (iseq(arg, "tdma")) { 4726 params.icp_opmode = IEEE80211_M_AHDEMO; 4727 params.icp_flags |= IEEE80211_CLONE_TDMA; 4728 } else 4729 errx(1, "Don't know to create %s for %s", arg, name); |
4732 clone_setcallback(wlan_create); | |
4733#undef iseq 4734} 4735 4736static void 4737set80211clone_beacons(const char *val, int d, int s, const struct afswtch *rafp) 4738{ 4739 /* NB: inverted sense */ 4740 if (d) 4741 params.icp_flags &= ~IEEE80211_CLONE_NOBEACONS; 4742 else 4743 params.icp_flags |= IEEE80211_CLONE_NOBEACONS; | 4730#undef iseq 4731} 4732 4733static void 4734set80211clone_beacons(const char *val, int d, int s, const struct afswtch *rafp) 4735{ 4736 /* NB: inverted sense */ 4737 if (d) 4738 params.icp_flags &= ~IEEE80211_CLONE_NOBEACONS; 4739 else 4740 params.icp_flags |= IEEE80211_CLONE_NOBEACONS; |
4744 clone_setcallback(wlan_create); | |
4745} 4746 4747static void 4748set80211clone_bssid(const char *val, int d, int s, const struct afswtch *rafp) 4749{ 4750 if (d) 4751 params.icp_flags |= IEEE80211_CLONE_BSSID; 4752 else 4753 params.icp_flags &= ~IEEE80211_CLONE_BSSID; | 4741} 4742 4743static void 4744set80211clone_bssid(const char *val, int d, int s, const struct afswtch *rafp) 4745{ 4746 if (d) 4747 params.icp_flags |= IEEE80211_CLONE_BSSID; 4748 else 4749 params.icp_flags &= ~IEEE80211_CLONE_BSSID; |
4754 clone_setcallback(wlan_create); | |
4755} 4756 4757static void 4758set80211clone_wdslegacy(const char *val, int d, int s, const struct afswtch *rafp) 4759{ 4760 if (d) 4761 params.icp_flags |= IEEE80211_CLONE_WDSLEGACY; 4762 else 4763 params.icp_flags &= ~IEEE80211_CLONE_WDSLEGACY; | 4750} 4751 4752static void 4753set80211clone_wdslegacy(const char *val, int d, int s, const struct afswtch *rafp) 4754{ 4755 if (d) 4756 params.icp_flags |= IEEE80211_CLONE_WDSLEGACY; 4757 else 4758 params.icp_flags &= ~IEEE80211_CLONE_WDSLEGACY; |
4764 clone_setcallback(wlan_create); | |
4765} 4766 4767static struct cmd ieee80211_cmds[] = { 4768 DEF_CMD_ARG("ssid", set80211ssid), 4769 DEF_CMD_ARG("nwid", set80211ssid), 4770 DEF_CMD_ARG("stationname", set80211stationname), 4771 DEF_CMD_ARG("station", set80211stationname), /* BSD/OS */ 4772 DEF_CMD_ARG("channel", set80211channel), --- 157 unchanged lines hidden (view full) --- 4930ieee80211_ctor(void) 4931{ 4932#define N(a) (sizeof(a) / sizeof(a[0])) 4933 int i; 4934 4935 for (i = 0; i < N(ieee80211_cmds); i++) 4936 cmd_register(&ieee80211_cmds[i]); 4937 af_register(&af_ieee80211); | 4759} 4760 4761static struct cmd ieee80211_cmds[] = { 4762 DEF_CMD_ARG("ssid", set80211ssid), 4763 DEF_CMD_ARG("nwid", set80211ssid), 4764 DEF_CMD_ARG("stationname", set80211stationname), 4765 DEF_CMD_ARG("station", set80211stationname), /* BSD/OS */ 4766 DEF_CMD_ARG("channel", set80211channel), --- 157 unchanged lines hidden (view full) --- 4924ieee80211_ctor(void) 4925{ 4926#define N(a) (sizeof(a) / sizeof(a[0])) 4927 int i; 4928 4929 for (i = 0; i < N(ieee80211_cmds); i++) 4930 cmd_register(&ieee80211_cmds[i]); 4931 af_register(&af_ieee80211); |
4932 clone_setdefcallback("wlan", wlan_create); |
|
4938#undef N 4939} | 4933#undef N 4934} |