ieee80211_hostap.c (7db788c66fe734d9f035ae2d2fc225f0dbe7c7d3) ieee80211_hostap.c (fe75b45213a403dc13c2e8a3bef5c83fa3b8225c)
1/*-
2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
3 * 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

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

474 struct ieee80211com *ic = ni->ni_ic;
475 struct ifnet *ifp = vap->iv_ifp;
476 struct ieee80211_frame *wh;
477 struct ieee80211_key *key;
478 struct ether_header *eh;
479 int hdrspace, need_tap = 1; /* mbuf need to be tapped. */
480 uint8_t dir, type, subtype, qos;
481 uint8_t *bssid;
1/*-
2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
3 * 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

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

474 struct ieee80211com *ic = ni->ni_ic;
475 struct ifnet *ifp = vap->iv_ifp;
476 struct ieee80211_frame *wh;
477 struct ieee80211_key *key;
478 struct ether_header *eh;
479 int hdrspace, need_tap = 1; /* mbuf need to be tapped. */
480 uint8_t dir, type, subtype, qos;
481 uint8_t *bssid;
482 int is_hw_decrypted = 0;
483 int has_decrypted = 0;
482
484
485 /*
486 * Some devices do hardware decryption all the way through
487 * to pretending the frame wasn't encrypted in the first place.
488 * So, tag it appropriately so it isn't discarded inappropriately.
489 */
490 if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_DECRYPTED))
491 is_hw_decrypted = 1;
492
483 if (m->m_flags & M_AMPDU_MPDU) {
484 /*
485 * Fastpath for A-MPDU reorder q resubmission. Frames
486 * w/ M_AMPDU_MPDU marked have already passed through
487 * here but were received out of order and been held on
488 * the reorder queue. When resubmitted they are marked
489 * with the M_AMPDU_MPDU flag and we can bypass most of
490 * the normal processing.

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

663 /*
664 * Handle privacy requirements. Note that we
665 * must not be preempted from here until after
666 * we (potentially) call ieee80211_crypto_demic;
667 * otherwise we may violate assumptions in the
668 * crypto cipher modules used to do delayed update
669 * of replay sequence numbers.
670 */
493 if (m->m_flags & M_AMPDU_MPDU) {
494 /*
495 * Fastpath for A-MPDU reorder q resubmission. Frames
496 * w/ M_AMPDU_MPDU marked have already passed through
497 * here but were received out of order and been held on
498 * the reorder queue. When resubmitted they are marked
499 * with the M_AMPDU_MPDU flag and we can bypass most of
500 * the normal processing.

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

673 /*
674 * Handle privacy requirements. Note that we
675 * must not be preempted from here until after
676 * we (potentially) call ieee80211_crypto_demic;
677 * otherwise we may violate assumptions in the
678 * crypto cipher modules used to do delayed update
679 * of replay sequence numbers.
680 */
671 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
681 if (is_hw_decrypted || wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
672 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
673 /*
674 * Discard encrypted frames when privacy is off.
675 */
676 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
677 wh, "WEP", "%s", "PRIVACY off");
678 vap->iv_stats.is_rx_noprivacy++;
679 IEEE80211_NODE_STAT(ni, rx_noprivacy);
680 goto out;
681 }
682 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
683 /*
684 * Discard encrypted frames when privacy is off.
685 */
686 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
687 wh, "WEP", "%s", "PRIVACY off");
688 vap->iv_stats.is_rx_noprivacy++;
689 IEEE80211_NODE_STAT(ni, rx_noprivacy);
690 goto out;
691 }
682 key = ieee80211_crypto_decap(ni, m, hdrspace);
683 if (key == NULL) {
692 if (ieee80211_crypto_decap(ni, m, hdrspace, &key) == 0) {
684 /* NB: stats+msgs handled in crypto_decap */
685 IEEE80211_NODE_STAT(ni, rx_wepfail);
686 goto out;
687 }
688 wh = mtod(m, struct ieee80211_frame *);
689 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
693 /* NB: stats+msgs handled in crypto_decap */
694 IEEE80211_NODE_STAT(ni, rx_wepfail);
695 goto out;
696 }
697 wh = mtod(m, struct ieee80211_frame *);
698 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
699 has_decrypted = 1;
690 } else {
691 /* XXX M_WEP and IEEE80211_F_PRIVACY */
692 key = NULL;
693 }
694
695 /*
696 * Save QoS bits for use below--before we strip the header.
697 */

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

764 goto err;
765 }
766 } else {
767 /*
768 * When denying unencrypted frames, discard
769 * any non-PAE frames received without encryption.
770 */
771 if ((vap->iv_flags & IEEE80211_F_DROPUNENC) &&
700 } else {
701 /* XXX M_WEP and IEEE80211_F_PRIVACY */
702 key = NULL;
703 }
704
705 /*
706 * Save QoS bits for use below--before we strip the header.
707 */

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

774 goto err;
775 }
776 } else {
777 /*
778 * When denying unencrypted frames, discard
779 * any non-PAE frames received without encryption.
780 */
781 if ((vap->iv_flags & IEEE80211_F_DROPUNENC) &&
772 (key == NULL && (m->m_flags & M_WEP) == 0) &&
782 ((has_decrypted == 0) && (m->m_flags & M_WEP) == 0) &&
783 (is_hw_decrypted == 0) &&
773 eh->ether_type != htons(ETHERTYPE_PAE)) {
774 /*
775 * Drop unencrypted frames.
776 */
777 vap->iv_stats.is_rx_unencrypted++;
778 IEEE80211_NODE_STAT(ni, rx_unencrypted);
779 goto out;
780 }

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

846 * Discard encrypted frames when privacy is off.
847 */
848 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
849 wh, NULL, "%s", "WEP set but PRIVACY off");
850 vap->iv_stats.is_rx_noprivacy++;
851 goto out;
852 }
853 hdrspace = ieee80211_hdrspace(ic, wh);
784 eh->ether_type != htons(ETHERTYPE_PAE)) {
785 /*
786 * Drop unencrypted frames.
787 */
788 vap->iv_stats.is_rx_unencrypted++;
789 IEEE80211_NODE_STAT(ni, rx_unencrypted);
790 goto out;
791 }

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

857 * Discard encrypted frames when privacy is off.
858 */
859 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
860 wh, NULL, "%s", "WEP set but PRIVACY off");
861 vap->iv_stats.is_rx_noprivacy++;
862 goto out;
863 }
864 hdrspace = ieee80211_hdrspace(ic, wh);
854 key = ieee80211_crypto_decap(ni, m, hdrspace);
855 if (key == NULL) {
865 if (ieee80211_crypto_decap(ni, m, hdrspace, &key) == 0) {
856 /* NB: stats+msgs handled in crypto_decap */
857 goto out;
858 }
859 wh = mtod(m, struct ieee80211_frame *);
860 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
866 /* NB: stats+msgs handled in crypto_decap */
867 goto out;
868 }
869 wh = mtod(m, struct ieee80211_frame *);
870 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
871 has_decrypted = 1;
861 }
862 /*
863 * Pass the packet to radiotap before calling iv_recv_mgmt().
864 * Otherwise iv_recv_mgmt() might pass another packet to
865 * radiotap, resulting in out of order packet captures.
866 */
867 if (ieee80211_radiotap_active_vap(vap))
868 ieee80211_radiotap_rx(vap, m);

--- 1524 unchanged lines hidden ---
872 }
873 /*
874 * Pass the packet to radiotap before calling iv_recv_mgmt().
875 * Otherwise iv_recv_mgmt() might pass another packet to
876 * radiotap, resulting in out of order packet captures.
877 */
878 if (ieee80211_radiotap_active_vap(vap))
879 ieee80211_radiotap_rx(vap, m);

--- 1524 unchanged lines hidden ---