ieee80211_ioctl.c (184274) | ieee80211_ioctl.c (186107) |
---|---|
1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_ioctl.c 184274 2008-10-25 23:32:24Z sam $"); | 28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_ioctl.c 186107 2008-12-15 01:26:33Z sam $"); |
29 30/* 31 * IEEE 802.11 ioctl support (FreeBSD-specific) 32 */ 33 34#include "opt_inet.h" 35#include "opt_ipx.h" 36#include "opt_wlan.h" --- 1514 unchanged lines hidden (view full) --- 1551} 1552 1553static __noinline int 1554ieee80211_ioctl_setchanlist(struct ieee80211vap *vap, struct ieee80211req *ireq) 1555{ 1556 struct ieee80211com *ic = vap->iv_ic; 1557 struct ieee80211req_chanlist list; 1558 u_char chanlist[IEEE80211_CHAN_BYTES]; | 29 30/* 31 * IEEE 802.11 ioctl support (FreeBSD-specific) 32 */ 33 34#include "opt_inet.h" 35#include "opt_ipx.h" 36#include "opt_wlan.h" --- 1514 unchanged lines hidden (view full) --- 1551} 1552 1553static __noinline int 1554ieee80211_ioctl_setchanlist(struct ieee80211vap *vap, struct ieee80211req *ireq) 1555{ 1556 struct ieee80211com *ic = vap->iv_ic; 1557 struct ieee80211req_chanlist list; 1558 u_char chanlist[IEEE80211_CHAN_BYTES]; |
1559 int i, j, nchan, error; | 1559 int i, nchan, error; |
1560 1561 if (ireq->i_len != sizeof(list)) 1562 return EINVAL; 1563 error = copyin(ireq->i_data, &list, sizeof(list)); 1564 if (error) 1565 return error; 1566 memset(chanlist, 0, sizeof(chanlist)); | 1560 1561 if (ireq->i_len != sizeof(list)) 1562 return EINVAL; 1563 error = copyin(ireq->i_data, &list, sizeof(list)); 1564 if (error) 1565 return error; 1566 memset(chanlist, 0, sizeof(chanlist)); |
1567 /* 1568 * Since channel 0 is not available for DS, channel 1 1569 * is assigned to LSB on WaveLAN. 1570 */ 1571 if (ic->ic_phytype == IEEE80211_T_DS) 1572 i = 1; 1573 else 1574 i = 0; | |
1575 nchan = 0; | 1567 nchan = 0; |
1576 for (j = 0; i <= IEEE80211_CHAN_MAX; i++, j++) { | 1568 for (i = 0; i < ic->ic_nchans; i++) { 1569 const struct ieee80211_channel *c = &ic->ic_channels[i]; |
1577 /* | 1570 /* |
1578 * NB: silently discard unavailable channels so users 1579 * can specify 1-255 to get all available channels. | 1571 * Calculate the intersection of the user list and the 1572 * available channels so users can do things like specify 1573 * 1-255 to get all available channels. |
1580 */ | 1574 */ |
1581 if (isset(list.ic_channels, j) && isset(ic->ic_chan_avail, i)) { 1582 setbit(chanlist, i); | 1575 if (isset(list.ic_channels, c->ic_ieee)) { 1576 setbit(chanlist, c->ic_ieee); |
1583 nchan++; 1584 } 1585 } 1586 if (nchan == 0) 1587 return EINVAL; 1588 if (ic->ic_bsschan != IEEE80211_CHAN_ANYC && /* XXX */ 1589 isclr(chanlist, ic->ic_bsschan->ic_ieee)) 1590 ic->ic_bsschan = IEEE80211_CHAN_ANYC; --- 294 unchanged lines hidden (view full) --- 1885{ 1886 struct ieee80211com *ic = vap->iv_ic; 1887 struct ieee80211_channel *c; 1888 1889 /* XXX 0xffff overflows 16-bit signed */ 1890 if (ireq->i_val == 0 || 1891 ireq->i_val == (int16_t) IEEE80211_CHAN_ANY) { 1892 c = IEEE80211_CHAN_ANYC; | 1577 nchan++; 1578 } 1579 } 1580 if (nchan == 0) 1581 return EINVAL; 1582 if (ic->ic_bsschan != IEEE80211_CHAN_ANYC && /* XXX */ 1583 isclr(chanlist, ic->ic_bsschan->ic_ieee)) 1584 ic->ic_bsschan = IEEE80211_CHAN_ANYC; --- 294 unchanged lines hidden (view full) --- 1879{ 1880 struct ieee80211com *ic = vap->iv_ic; 1881 struct ieee80211_channel *c; 1882 1883 /* XXX 0xffff overflows 16-bit signed */ 1884 if (ireq->i_val == 0 || 1885 ireq->i_val == (int16_t) IEEE80211_CHAN_ANY) { 1886 c = IEEE80211_CHAN_ANYC; |
1893 } else if ((u_int) ireq->i_val > IEEE80211_CHAN_MAX) { 1894 return EINVAL; | |
1895 } else { 1896 struct ieee80211_channel *c2; 1897 1898 c = findchannel(ic, ireq->i_val, vap->iv_des_mode); 1899 if (c == NULL) { 1900 c = findchannel(ic, ireq->i_val, 1901 IEEE80211_MODE_AUTO); 1902 if (c == NULL) --- 1412 unchanged lines hidden --- | 1887 } else { 1888 struct ieee80211_channel *c2; 1889 1890 c = findchannel(ic, ireq->i_val, vap->iv_des_mode); 1891 if (c == NULL) { 1892 c = findchannel(ic, ireq->i_val, 1893 IEEE80211_MODE_AUTO); 1894 if (c == NULL) --- 1412 unchanged lines hidden --- |