ifieee80211.c (187801) | ifieee80211.c (187841) |
---|---|
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 187801 2009-01-27 23:42:14Z sam $ | 27 * $FreeBSD: head/sbin/ifconfig/ifieee80211.c 187841 2009-01-28 19:15:52Z sam $ |
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, --- 1748 unchanged lines hidden (view full) --- 1784 const struct ieee80211_channel *c = &chans[i]; 1785 if (c->ic_freq == freq && 1786 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) 1787 return c; 1788 } 1789 return NULL; 1790} 1791 | 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, --- 1748 unchanged lines hidden (view full) --- 1784 const struct ieee80211_channel *c = &chans[i]; 1785 if (c->ic_freq == freq && 1786 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) 1787 return c; 1788 } 1789 return NULL; 1790} 1791 |
1792static int 1793chanfind(const struct ieee80211_channel chans[], int nchans, int flags) 1794{ 1795 int i; 1796 1797 for (i = 0; i < nchans; i++) { 1798 const struct ieee80211_channel *c = &chans[i]; 1799 if ((c->ic_flags & flags) == flags) 1800 return 1; 1801 } 1802 return 0; 1803} 1804 |
|
1792static void 1793regdomain_addchans(struct ieee80211req_chaninfo *ci, 1794 const netband_head *bands, 1795 const struct ieee80211_regdomain *reg, 1796 uint32_t chanFlags, 1797 const struct ieee80211req_chaninfo *avail) 1798{ 1799 const struct netband *nb; 1800 const struct freqband *b; 1801 struct ieee80211_channel *c, *prev; | 1805static void 1806regdomain_addchans(struct ieee80211req_chaninfo *ci, 1807 const netband_head *bands, 1808 const struct ieee80211_regdomain *reg, 1809 uint32_t chanFlags, 1810 const struct ieee80211req_chaninfo *avail) 1811{ 1812 const struct netband *nb; 1813 const struct freqband *b; 1814 struct ieee80211_channel *c, *prev; |
1802 int freq, channelSep; | 1815 int freq, channelSep, hasHalfChans, hasQuarterChans; |
1803 1804 channelSep = (chanFlags & IEEE80211_CHAN_2GHZ) ? 0 : 40; | 1816 1817 channelSep = (chanFlags & IEEE80211_CHAN_2GHZ) ? 0 : 40; |
1818 hasHalfChans = chanfind(avail->ic_chans, avail->ic_nchans, 1819 IEEE80211_CHAN_HALF | 1820 (chanFlags & (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ))); 1821 hasQuarterChans = chanfind(avail->ic_chans, avail->ic_nchans, 1822 IEEE80211_CHAN_QUARTER | 1823 (chanFlags & (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ))); |
|
1805 LIST_FOREACH(nb, bands, next) { 1806 b = nb->band; 1807 if (verbose) 1808 printf("%s: chanFlags 0x%x b %p\n", 1809 __func__, chanFlags, b); 1810 prev = NULL; 1811 for (freq = b->freqStart; freq <= b->freqEnd; freq += b->chanSep) { 1812 uint32_t flags = nb->flags | b->flags; 1813 1814 /* check if device can operate on this frequency */ | 1824 LIST_FOREACH(nb, bands, next) { 1825 b = nb->band; 1826 if (verbose) 1827 printf("%s: chanFlags 0x%x b %p\n", 1828 __func__, chanFlags, b); 1829 prev = NULL; 1830 for (freq = b->freqStart; freq <= b->freqEnd; freq += b->chanSep) { 1831 uint32_t flags = nb->flags | b->flags; 1832 1833 /* check if device can operate on this frequency */ |
1815 if (chanlookup(avail->ic_chans, avail->ic_nchans, freq, chanFlags) == NULL) { | 1834 /* 1835 * XXX GSM frequency mapping is handled in the kernel 1836 * so we cannot find them in the calibration table; 1837 * just construct the list and the kernel will reject 1838 * if it's wrong. 1839 */ 1840 if (chanlookup(avail->ic_chans, avail->ic_nchans, freq, chanFlags) == NULL && 1841 (flags & IEEE80211_CHAN_GSM) == 0) { |
1816 if (verbose) 1817 printf("%u: skip, flags 0x%x not available\n", freq, chanFlags); 1818 continue; 1819 } | 1842 if (verbose) 1843 printf("%u: skip, flags 0x%x not available\n", freq, chanFlags); 1844 continue; 1845 } |
1820 /* 1821 * NB: don't enforce 1/2 and 1/4 rate channels being 1822 * specified in the device's calibration list for 1823 * 900MHz cards because most are not self-identifying. 1824 */ 1825 if ((flags & IEEE80211_CHAN_HALF) && 1826 ((chanFlags & IEEE80211_CHAN_HALF) == 0 && 1827 (flags & IEEE80211_CHAN_GSM) == 0)) { | 1846 if ((flags & IEEE80211_CHAN_HALF) && !hasHalfChans) { |
1828 if (verbose) | 1847 if (verbose) |
1829 printf("%u: skip, device does not support half-rate channels\n", freq); | 1848 printf("%u: skip, device does not " 1849 "support half-rate channel\n", 1850 freq); |
1830 continue; 1831 } 1832 if ((flags & IEEE80211_CHAN_QUARTER) && | 1851 continue; 1852 } 1853 if ((flags & IEEE80211_CHAN_QUARTER) && |
1833 ((chanFlags & IEEE80211_CHAN_QUARTER) == 0 && 1834 (flags & IEEE80211_CHAN_GSM) == 0)) { | 1854 !hasQuarterChans) { |
1835 if (verbose) | 1855 if (verbose) |
1836 printf("%u: skip, device does not support quarter-rate channels\n", freq); | 1856 printf("%u: skip, device does not " 1857 "support quarter-rate channel\n", 1858 freq); |
1837 continue; 1838 } 1839 if ((flags & IEEE80211_CHAN_HT20) && 1840 (chanFlags & IEEE80211_CHAN_HT20) == 0) { 1841 if (verbose) 1842 printf("%u: skip, device does not support HT20 operation\n", freq); 1843 continue; 1844 } --- 82 unchanged lines hidden (view full) --- 1927 * Note that we know we have enough space to hold all possible 1928 * channels because the devcaps list size was used to 1929 * allocate our request. 1930 */ 1931 ci->ic_nchans = 0; 1932 if (!LIST_EMPTY(&rd->bands_11b)) 1933 regdomain_addchans(ci, &rd->bands_11b, reg, 1934 IEEE80211_CHAN_B, &dc->dc_chaninfo); | 1859 continue; 1860 } 1861 if ((flags & IEEE80211_CHAN_HT20) && 1862 (chanFlags & IEEE80211_CHAN_HT20) == 0) { 1863 if (verbose) 1864 printf("%u: skip, device does not support HT20 operation\n", freq); 1865 continue; 1866 } --- 82 unchanged lines hidden (view full) --- 1949 * Note that we know we have enough space to hold all possible 1950 * channels because the devcaps list size was used to 1951 * allocate our request. 1952 */ 1953 ci->ic_nchans = 0; 1954 if (!LIST_EMPTY(&rd->bands_11b)) 1955 regdomain_addchans(ci, &rd->bands_11b, reg, 1956 IEEE80211_CHAN_B, &dc->dc_chaninfo); |
1935 if (!LIST_EMPTY(&rd->bands_11g)) { | 1957 if (!LIST_EMPTY(&rd->bands_11g)) |
1936 regdomain_addchans(ci, &rd->bands_11g, reg, 1937 IEEE80211_CHAN_G, &dc->dc_chaninfo); | 1958 regdomain_addchans(ci, &rd->bands_11g, reg, 1959 IEEE80211_CHAN_G, &dc->dc_chaninfo); |
1938 regdomain_addchans(ci, &rd->bands_11g, reg, 1939 IEEE80211_CHAN_G | IEEE80211_CHAN_HALF, 1940 &dc->dc_chaninfo); 1941 regdomain_addchans(ci, &rd->bands_11g, reg, 1942 IEEE80211_CHAN_G | IEEE80211_CHAN_QUARTER, 1943 &dc->dc_chaninfo); 1944 } 1945 if (!LIST_EMPTY(&rd->bands_11a)) { | 1960 if (!LIST_EMPTY(&rd->bands_11a)) |
1946 regdomain_addchans(ci, &rd->bands_11a, reg, 1947 IEEE80211_CHAN_A, &dc->dc_chaninfo); | 1961 regdomain_addchans(ci, &rd->bands_11a, reg, 1962 IEEE80211_CHAN_A, &dc->dc_chaninfo); |
1948 regdomain_addchans(ci, &rd->bands_11a, reg, 1949 IEEE80211_CHAN_A | IEEE80211_CHAN_HALF, 1950 &dc->dc_chaninfo); 1951 regdomain_addchans(ci, &rd->bands_11a, reg, 1952 IEEE80211_CHAN_A | IEEE80211_CHAN_QUARTER, 1953 &dc->dc_chaninfo); 1954 } | |
1955 if (!LIST_EMPTY(&rd->bands_11na)) { 1956 regdomain_addchans(ci, &rd->bands_11na, reg, 1957 IEEE80211_CHAN_A | IEEE80211_CHAN_HT20, 1958 &dc->dc_chaninfo); 1959 regdomain_addchans(ci, &rd->bands_11na, reg, 1960 IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U, 1961 &dc->dc_chaninfo); 1962 regdomain_addchans(ci, &rd->bands_11na, reg, --- 2850 unchanged lines hidden --- | 1963 if (!LIST_EMPTY(&rd->bands_11na)) { 1964 regdomain_addchans(ci, &rd->bands_11na, reg, 1965 IEEE80211_CHAN_A | IEEE80211_CHAN_HT20, 1966 &dc->dc_chaninfo); 1967 regdomain_addchans(ci, &rd->bands_11na, reg, 1968 IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U, 1969 &dc->dc_chaninfo); 1970 regdomain_addchans(ci, &rd->bands_11na, reg, --- 2850 unchanged lines hidden --- |