Deleted Added
full compact
ifieee80211.c (186105) ifieee80211.c (186904)
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 186105 2008-12-15 01:15:15Z sam $
27 * $FreeBSD: head/sbin/ifconfig/ifieee80211.c 186904 2009-01-08 17:12:47Z 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,

--- 1670 unchanged lines hidden (view full) ---

1706}
1707
1708static void
1709set80211rifs(const char *val, int d, int s, const struct afswtch *rafp)
1710{
1711 set80211(s, IEEE80211_IOC_RIFS, d, 0, NULL);
1712}
1713
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,

--- 1670 unchanged lines hidden (view full) ---

1706}
1707
1708static void
1709set80211rifs(const char *val, int d, int s, const struct afswtch *rafp)
1710{
1711 set80211(s, IEEE80211_IOC_RIFS, d, 0, NULL);
1712}
1713
1714static
1715DECL_CMD_FUNC(set80211tdmaslot, val, d)
1716{
1717 set80211(s, IEEE80211_IOC_TDMA_SLOT, atoi(val), 0, NULL);
1718}
1719
1720static
1721DECL_CMD_FUNC(set80211tdmaslotcnt, val, d)
1722{
1723 set80211(s, IEEE80211_IOC_TDMA_SLOTCNT, atoi(val), 0, NULL);
1724}
1725
1726static
1727DECL_CMD_FUNC(set80211tdmaslotlen, val, d)
1728{
1729 set80211(s, IEEE80211_IOC_TDMA_SLOTLEN, atoi(val), 0, NULL);
1730}
1731
1732static
1733DECL_CMD_FUNC(set80211tdmabintval, val, d)
1734{
1735 set80211(s, IEEE80211_IOC_TDMA_BINTERVAL, atoi(val), 0, NULL);
1736}
1737
1714static int
1715regdomain_sort(const void *a, const void *b)
1716{
1717#define CHAN_ALL \
1718 (IEEE80211_CHAN_ALLTURBO|IEEE80211_CHAN_HALF|IEEE80211_CHAN_QUARTER)
1719 const struct ieee80211_channel *ca = a;
1720 const struct ieee80211_channel *cb = b;
1721

--- 831 unchanged lines hidden (view full) ---

2553 }
2554 ie += tlv_len, len -= tlv_len;
2555 }
2556 printf(">");
2557 }
2558#undef N
2559}
2560
1738static int
1739regdomain_sort(const void *a, const void *b)
1740{
1741#define CHAN_ALL \
1742 (IEEE80211_CHAN_ALLTURBO|IEEE80211_CHAN_HALF|IEEE80211_CHAN_QUARTER)
1743 const struct ieee80211_channel *ca = a;
1744 const struct ieee80211_channel *cb = b;
1745

--- 831 unchanged lines hidden (view full) ---

2577 }
2578 ie += tlv_len, len -= tlv_len;
2579 }
2580 printf(">");
2581 }
2582#undef N
2583}
2584
2585static void
2586printtdmaie(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen)
2587{
2588 printf("%s", tag);
2589 if (verbose && ielen >= sizeof(struct ieee80211_tdma_param)) {
2590 const struct ieee80211_tdma_param *tdma =
2591 (const struct ieee80211_tdma_param *) ie;
2592
2593 /* XXX tstamp */
2594 printf("<v%u slot:%u slotcnt:%u slotlen:%u bintval:%u inuse:0x%x>",
2595 tdma->tdma_version, tdma->tdma_slot, tdma->tdma_slotcnt,
2596 LE_READ_2(&tdma->tdma_slotlen), tdma->tdma_bintval,
2597 tdma->tdma_inuse[0]);
2598 }
2599}
2600
2561/*
2562 * Copy the ssid string contents into buf, truncating to fit. If the
2563 * ssid is entirely printable then just copy intact. Otherwise convert
2564 * to hexadecimal. If the result is truncated then replace the last
2565 * three characters with "...".
2566 */
2567static int
2568copy_essid(char buf[], size_t bufsize, const u_int8_t *essid, size_t essid_len)

--- 107 unchanged lines hidden (view full) ---

2676
2677static __inline int
2678isatherosoui(const u_int8_t *frm)
2679{
2680 return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI);
2681}
2682
2683static __inline int
2601/*
2602 * Copy the ssid string contents into buf, truncating to fit. If the
2603 * ssid is entirely printable then just copy intact. Otherwise convert
2604 * to hexadecimal. If the result is truncated then replace the last
2605 * three characters with "...".
2606 */
2607static int
2608copy_essid(char buf[], size_t bufsize, const u_int8_t *essid, size_t essid_len)

--- 107 unchanged lines hidden (view full) ---

2716
2717static __inline int
2718isatherosoui(const u_int8_t *frm)
2719{
2720 return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI);
2721}
2722
2723static __inline int
2724istdmaoui(const uint8_t *frm)
2725{
2726 return frm[1] > 3 && LE_READ_4(frm+2) == ((TDMA_OUI_TYPE<<24)|TDMA_OUI);
2727}
2728
2729static __inline int
2684iswpsoui(const uint8_t *frm)
2685{
2686 return frm[1] > 3 && LE_READ_4(frm+2) == ((WPS_OUI_TYPE<<24)|WPA_OUI);
2687}
2688
2689static const char *
2690iename(int elemid)
2691{

--- 52 unchanged lines hidden (view full) ---

2744 else if (iswmeinfo(vp))
2745 printwmeinfo(" WME", vp, 2+vp[1], maxcols);
2746 else if (iswmeparam(vp))
2747 printwmeparam(" WME", vp, 2+vp[1], maxcols);
2748 else if (isatherosoui(vp))
2749 printathie(" ATH", vp, 2+vp[1], maxcols);
2750 else if (iswpsoui(vp))
2751 printwpsie(" WPS", vp, 2+vp[1], maxcols);
2730iswpsoui(const uint8_t *frm)
2731{
2732 return frm[1] > 3 && LE_READ_4(frm+2) == ((WPS_OUI_TYPE<<24)|WPA_OUI);
2733}
2734
2735static const char *
2736iename(int elemid)
2737{

--- 52 unchanged lines hidden (view full) ---

2790 else if (iswmeinfo(vp))
2791 printwmeinfo(" WME", vp, 2+vp[1], maxcols);
2792 else if (iswmeparam(vp))
2793 printwmeparam(" WME", vp, 2+vp[1], maxcols);
2794 else if (isatherosoui(vp))
2795 printathie(" ATH", vp, 2+vp[1], maxcols);
2796 else if (iswpsoui(vp))
2797 printwpsie(" WPS", vp, 2+vp[1], maxcols);
2798 else if (istdmaoui(vp))
2799 printtdmaie(" TDMA", vp, 2+vp[1], maxcols);
2752 else if (verbose)
2753 printie(" VEN", vp, 2+vp[1], maxcols);
2754 break;
2755 case IEEE80211_ELEMID_RSN:
2756 printrsnie(" RSN", vp, 2+vp[1], maxcols);
2757 break;
2758 case IEEE80211_ELEMID_HTCAP:
2759 printhtcap(" HTCAP", vp, 2+vp[1], maxcols);

--- 427 unchanged lines hidden (view full) ---

3187list_keys(int s)
3188{
3189}
3190
3191#define IEEE80211_C_BITS \
3192 "\20\1STA\7FF\10TURBOP\11IBSS\12PMGT" \
3193 "\13HOSTAP\14AHDEMO\15SWRETRY\16TXPMGT\17SHSLOT\20SHPREAMBLE" \
3194 "\21MONITOR\22DFS\30WPA1\31WPA2\32BURST\33WME\34WDS\36BGSCAN" \
2800 else if (verbose)
2801 printie(" VEN", vp, 2+vp[1], maxcols);
2802 break;
2803 case IEEE80211_ELEMID_RSN:
2804 printrsnie(" RSN", vp, 2+vp[1], maxcols);
2805 break;
2806 case IEEE80211_ELEMID_HTCAP:
2807 printhtcap(" HTCAP", vp, 2+vp[1], maxcols);

--- 427 unchanged lines hidden (view full) ---

3235list_keys(int s)
3236{
3237}
3238
3239#define IEEE80211_C_BITS \
3240 "\20\1STA\7FF\10TURBOP\11IBSS\12PMGT" \
3241 "\13HOSTAP\14AHDEMO\15SWRETRY\16TXPMGT\17SHSLOT\20SHPREAMBLE" \
3242 "\21MONITOR\22DFS\30WPA1\31WPA2\32BURST\33WME\34WDS\36BGSCAN" \
3195 "\37TXFRAG"
3243 "\37TXFRAG\40TDMA"
3196
3197#define IEEE80211_CRYPTO_BITS \
3198 "\20\1WEP\2TKIP\3AES\4AES_CCM\5TKIPMIC\6CKIP\12PMGT"
3199
3200#define IEEE80211_HTCAP_BITS \
3201 "\20\1LDPC\2CHWIDTH40\5GREENFIELD\6SHORTGI20\7SHORTGI40\10TXSTBC" \
3202 "\21AMPDU\22AMSDU\23HT"
3203

--- 1054 unchanged lines hidden (view full) ---

4258 LINE_CHECK("roaming UNKNOWN (0x%x)",
4259 val);
4260 break;
4261 }
4262 }
4263 }
4264 }
4265
3244
3245#define IEEE80211_CRYPTO_BITS \
3246 "\20\1WEP\2TKIP\3AES\4AES_CCM\5TKIPMIC\6CKIP\12PMGT"
3247
3248#define IEEE80211_HTCAP_BITS \
3249 "\20\1LDPC\2CHWIDTH40\5GREENFIELD\6SHORTGI20\7SHORTGI40\10TXSTBC" \
3250 "\21AMPDU\22AMSDU\23HT"
3251

--- 1054 unchanged lines hidden (view full) ---

4306 LINE_CHECK("roaming UNKNOWN (0x%x)",
4307 val);
4308 break;
4309 }
4310 }
4311 }
4312 }
4313
4266 if (get80211val(s, IEEE80211_IOC_BEACON_INTERVAL, &val) != -1) {
4314 if (opmode == IEEE80211_M_AHDEMO) {
4315 if (get80211val(s, IEEE80211_IOC_TDMA_SLOT, &val) != -1)
4316 LINE_CHECK("tdmaslot %u", val);
4317 if (get80211val(s, IEEE80211_IOC_TDMA_SLOTCNT, &val) != -1)
4318 LINE_CHECK("tdmaslotcnt %u", val);
4319 if (get80211val(s, IEEE80211_IOC_TDMA_SLOTLEN, &val) != -1)
4320 LINE_CHECK("tdmaslotlen %u", val);
4321 if (get80211val(s, IEEE80211_IOC_TDMA_BINTERVAL, &val) != -1)
4322 LINE_CHECK("tdmabintval %u", val);
4323 } else if (get80211val(s, IEEE80211_IOC_BEACON_INTERVAL, &val) != -1) {
4267 /* XXX default define not visible */
4268 if (val != 100 || verbose)
4269 LINE_CHECK("bintval %u", val);
4270 }
4271
4272 if (wme && verbose) {
4273 LINE_BREAK();
4274 list_wme(s);

--- 206 unchanged lines hidden (view full) ---

4481 else if (iseq(arg, "ibss") || iseq(arg, "adhoc"))
4482 params.icp_opmode = IEEE80211_M_IBSS;
4483 else if (iseq(arg, "ap") || iseq(arg, "host"))
4484 params.icp_opmode = IEEE80211_M_HOSTAP;
4485 else if (iseq(arg, "wds"))
4486 params.icp_opmode = IEEE80211_M_WDS;
4487 else if (iseq(arg, "monitor"))
4488 params.icp_opmode = IEEE80211_M_MONITOR;
4324 /* XXX default define not visible */
4325 if (val != 100 || verbose)
4326 LINE_CHECK("bintval %u", val);
4327 }
4328
4329 if (wme && verbose) {
4330 LINE_BREAK();
4331 list_wme(s);

--- 206 unchanged lines hidden (view full) ---

4538 else if (iseq(arg, "ibss") || iseq(arg, "adhoc"))
4539 params.icp_opmode = IEEE80211_M_IBSS;
4540 else if (iseq(arg, "ap") || iseq(arg, "host"))
4541 params.icp_opmode = IEEE80211_M_HOSTAP;
4542 else if (iseq(arg, "wds"))
4543 params.icp_opmode = IEEE80211_M_WDS;
4544 else if (iseq(arg, "monitor"))
4545 params.icp_opmode = IEEE80211_M_MONITOR;
4489 else
4546 else if (iseq(arg, "tdma")) {
4547 params.icp_opmode = IEEE80211_M_AHDEMO;
4548 params.icp_flags |= IEEE80211_CLONE_TDMA;
4549 } else
4490 errx(1, "Don't know to create %s for %s", arg, name);
4491 clone_setcallback(wlan_create);
4492#undef iseq
4493}
4494
4495static void
4496set80211clone_beacons(const char *val, int d, int s, const struct afswtch *rafp)
4497{

--- 159 unchanged lines hidden (view full) ---

4657 DEF_CMD("rifs", 1, set80211rifs),
4658 DEF_CMD("-rifs", 0, set80211rifs),
4659 DEF_CMD("smps", IEEE80211_HTCAP_SMPS_ENA, set80211smps),
4660 DEF_CMD("smpsdyn", IEEE80211_HTCAP_SMPS_DYNAMIC, set80211smps),
4661 DEF_CMD("-smps", IEEE80211_HTCAP_SMPS_OFF, set80211smps),
4662 /* XXX for testing */
4663 DEF_CMD_ARG("chanswitch", set80211chanswitch),
4664
4550 errx(1, "Don't know to create %s for %s", arg, name);
4551 clone_setcallback(wlan_create);
4552#undef iseq
4553}
4554
4555static void
4556set80211clone_beacons(const char *val, int d, int s, const struct afswtch *rafp)
4557{

--- 159 unchanged lines hidden (view full) ---

4717 DEF_CMD("rifs", 1, set80211rifs),
4718 DEF_CMD("-rifs", 0, set80211rifs),
4719 DEF_CMD("smps", IEEE80211_HTCAP_SMPS_ENA, set80211smps),
4720 DEF_CMD("smpsdyn", IEEE80211_HTCAP_SMPS_DYNAMIC, set80211smps),
4721 DEF_CMD("-smps", IEEE80211_HTCAP_SMPS_OFF, set80211smps),
4722 /* XXX for testing */
4723 DEF_CMD_ARG("chanswitch", set80211chanswitch),
4724
4725 DEF_CMD_ARG("tdmaslot", set80211tdmaslot),
4726 DEF_CMD_ARG("tdmaslotcnt", set80211tdmaslotcnt),
4727 DEF_CMD_ARG("tdmaslotlen", set80211tdmaslotlen),
4728 DEF_CMD_ARG("tdmabintval", set80211tdmabintval),
4729
4665 /* vap cloning support */
4666 DEF_CLONE_CMD_ARG("wlanaddr", set80211clone_wlanaddr),
4667 DEF_CLONE_CMD_ARG("wlanbssid", set80211clone_wlanbssid),
4668 DEF_CLONE_CMD_ARG("wlandev", set80211clone_wlandev),
4669 DEF_CLONE_CMD_ARG("wlanmode", set80211clone_wlanmode),
4670 DEF_CLONE_CMD("beacons", 1, set80211clone_beacons),
4671 DEF_CLONE_CMD("-beacons", 0, set80211clone_beacons),
4672 DEF_CLONE_CMD("bssid", 1, set80211clone_bssid),

--- 21 unchanged lines hidden ---
4730 /* vap cloning support */
4731 DEF_CLONE_CMD_ARG("wlanaddr", set80211clone_wlanaddr),
4732 DEF_CLONE_CMD_ARG("wlanbssid", set80211clone_wlanbssid),
4733 DEF_CLONE_CMD_ARG("wlandev", set80211clone_wlandev),
4734 DEF_CLONE_CMD_ARG("wlanmode", set80211clone_wlanmode),
4735 DEF_CLONE_CMD("beacons", 1, set80211clone_beacons),
4736 DEF_CLONE_CMD("-beacons", 0, set80211clone_beacons),
4737 DEF_CLONE_CMD("bssid", 1, set80211clone_bssid),

--- 21 unchanged lines hidden ---