Esempio n. 1
0
            def decode(self):
                nla_base.decode(self)

                offset = self.offset + 4
                self.value = {}
                (tsf,) = struct.unpack_from('Q', self.data, offset)
                self.value["VALUE"] = tsf
                # TSF is in microseconds
                self.value["TIME"] = datetime.timedelta(microseconds=tsf)
Esempio n. 2
0
 def decode(self):
     nla_base.decode(self)
     offset = self.offset + 4
     self.value = {}
     (ss,) = struct.unpack_from('i', self.data, offset)
     self.value["VALUE"] = ss
     self.value["SIGNAL_STRENGTH"] = {
         "VALUE": ss / 100.0,
         "UNITS": "dBm",
     }
Esempio n. 3
0
            def decode(self):
                nla_base.decode(self)

                self.value = {}

                init = offset = self.offset + 4

                while (offset - init) < (self.length - 4):
                    (msg_type, length) = struct.unpack_from(
                        'BB', self.data, offset
                    )
                    if msg_type == NL80211_BSS_ELEMENTS_SSID:
                        (self.value["SSID"],) = struct.unpack_from(
                            '%is' % length, self.data, offset + 2
                        )

                    if msg_type == NL80211_BSS_ELEMENTS_SUPPORTED_RATES:
                        supported_rates = self.binary_rates(offset + 2, length)
                        self.value["SUPPORTED_RATES"] = supported_rates

                    if msg_type == NL80211_BSS_ELEMENTS_CHANNEL:
                        (channel,) = struct.unpack_from(
                            'B', self.data, offset + 2
                        )
                        self.value["CHANNEL"] = channel

                    if msg_type == NL80211_BSS_ELEMENTS_TIM:
                        self.value["TRAFFIC INDICATION MAP"] = self.binary_tim(
                            offset + 2
                        )

                    if msg_type == NL80211_BSS_ELEMENTS_RSN:
                        (self.value["RSN"],) = struct.unpack_from(
                            '%is' % length, self.data, offset + 2
                        )

                    if msg_type == NL80211_BSS_ELEMENTS_EXTENDED_RATE:
                        extended_rates = self.binary_rates(offset + 2, length)
                        self.value["EXTENDED_RATES"] = extended_rates

                    if msg_type == NL80211_BSS_ELEMENTS_VENDOR:
                        # There may be multiple vendor IEs, create a list
                        if "VENDOR" not in self.value.keys():
                            self.value["VENDOR"] = []
                        (vendor_ie,) = struct.unpack_from(
                            '%is' % length, self.data, offset + 2
                        )
                        self.value["VENDOR"].append(vendor_ie)

                    offset += length + 2
Esempio n. 4
0
            def decode(self):
                nla_base.decode(self)
                self.value = {}
                self.value["AUTHORIZED"] = False
                self.value["SHORT_PREAMBLE"] = False
                self.value["WME"] = False
                self.value["MFP"] = False
                self.value["AUTHENTICATED"] = False
                self.value["TDLS_PEER"] = False
                self.value["ASSOCIATED"] = False

                init = offset = self.offset + 4
                while (offset - init) < (self.length - 4):
                    (msg_type, length) = struct.unpack_from(
                        'BB', self.data, offset
                    )
                    mask, set_ = struct.unpack_from(
                        'II', self.data, offset + 2
                    )

                    if mask & NL80211_STA_FLAG_AUTHORIZED:
                        if set_ & NL80211_STA_FLAG_AUTHORIZED:
                            self.value["AUTHORIZED"] = True

                    if mask & NL80211_STA_FLAG_SHORT_PREAMBLE:
                        if set_ & NL80211_STA_FLAG_SHORT_PREAMBLE:
                            self.value["SHORT_PREAMBLE"] = True

                    if mask & NL80211_STA_FLAG_WME:
                        if set_ & NL80211_STA_FLAG_WME:
                            self.value["WME"] = True

                    if mask & NL80211_STA_FLAG_MFP:
                        if set_ & NL80211_STA_FLAG_MFP:
                            self.value["MFP"] = True

                    if mask & NL80211_STA_FLAG_AUTHENTICATED:
                        if set_ & NL80211_STA_FLAG_AUTHENTICATED:
                            self.value["AUTHENTICATED"] = True

                    if mask & NL80211_STA_FLAG_TDLS_PEER:
                        if set_ & NL80211_STA_FLAG_TDLS_PEER:
                            self.value["TDLS_PEER"] = True

                    if mask & NL80211_STA_FLAG_ASSOCIATED:
                        if set_ & NL80211_STA_FLAG_ASSOCIATED:
                            self.value["ASSOCIATED"] = True

                    offset += length + 2
Esempio n. 5
0
            def decode(self):
                nla_base.decode(self)

                offset = self.offset + 4
                self.value = {}
                (capa,) = struct.unpack_from('H', self.data, offset)
                self.value["VALUE"] = capa

                s = []
                if capa & self.WLAN_CAPABILITY_ESS:
                    s.append("ESS")
                if capa & self.WLAN_CAPABILITY_IBSS:
                    s.append("IBSS")
                if capa & self.WLAN_CAPABILITY_CF_POLLABLE:
                    s.append("CfPollable")
                if capa & self.WLAN_CAPABILITY_CF_POLL_REQUEST:
                    s.append("CfPollReq")
                if capa & self.WLAN_CAPABILITY_PRIVACY:
                    s.append("Privacy")
                if capa & self.WLAN_CAPABILITY_SHORT_PREAMBLE:
                    s.append("ShortPreamble")
                if capa & self.WLAN_CAPABILITY_PBCC:
                    s.append("PBCC")
                if capa & self.WLAN_CAPABILITY_CHANNEL_AGILITY:
                    s.append("ChannelAgility")
                if capa & self.WLAN_CAPABILITY_SPECTRUM_MGMT:
                    s.append("SpectrumMgmt")
                if capa & self.WLAN_CAPABILITY_QOS:
                    s.append("QoS")
                if capa & self.WLAN_CAPABILITY_SHORT_SLOT_TIME:
                    s.append("ShortSlotTime")
                if capa & self.WLAN_CAPABILITY_APSD:
                    s.append("APSD")
                if capa & self.WLAN_CAPABILITY_RADIO_MEASURE:
                    s.append("RadioMeasure")
                if capa & self.WLAN_CAPABILITY_DSSS_OFDM:
                    s.append("DSSS-OFDM")
                if capa & self.WLAN_CAPABILITY_DEL_BACK:
                    s.append("DelayedBACK")
                if capa & self.WLAN_CAPABILITY_IMM_BACK:
                    s.append("ImmediateBACK")

                self.value['CAPABILITIES'] = " ".join(s)