Пример #1
0
def handle_band(attr, fpol):
    e, battr = nl.py_nla_parse_nested(nl80211.NL80211_BAND_ATTR_MAX, attr,
                                      None)
    print("\tband %d:" % nl.nla_type(attr))
    if nl80211.NL80211_BAND_ATTR_FREQS in battr:
        for fattr in nl.nla_get_nested(battr[nl80211.NL80211_BAND_ATTR_FREQS]):
            handle_freq(fattr, fpol)
Пример #2
0
	def create_nested(self, attr, aid):
		try:
			if aid in self.nest_attr_map.keys():
				(nest_class, max_nest, nest_policy) = self.nest_attr_map[aid]
			e, nattr = py_nla_parse_nested(max_nest, attr, nest_policy)
			return factory.get_inst().create(nest_class, nattr, nest_policy)
		except Exception as e:
			return nla_type(attr)
Пример #3
0
 def create_nested(self, attr, aid):
     try:
         if aid in self.nest_attr_map.keys():
             (nest_class, max_nest, nest_policy) = self.nest_attr_map[aid]
         e, nattr = nl.py_nla_parse_nested(max_nest, attr, nest_policy)
         return factory.get_inst().create(nest_class, nattr, nest_policy)
     except Exception as e:
         return nl.nla_type(attr)
Пример #4
0
def handle_freq(attr, pol):
	e, fattr = nl.py_nla_parse_nested(nl80211.NL80211_FREQUENCY_ATTR_MAX, attr, pol)
	if nl80211.NL80211_FREQUENCY_ATTR_FREQ in fattr:
		freq = nl.nla_get_u32(fattr[nl80211.NL80211_FREQUENCY_ATTR_FREQ])
		sys.stdout.write("\t\tfreq %d MHz [%d]" % (freq, freq_to_ch(freq)))
	if nl80211.NL80211_FREQUENCY_ATTR_MAX_TX_POWER in fattr and not (nl80211.NL80211_FREQUENCY_ATTR_DISABLED in fattr):
		sys.stdout.write(" (%.1f dBm)" % (0.01 * nl.nla_get_u32(fattr[nl80211.NL80211_FREQUENCY_ATTR_MAX_TX_POWER])))
	if nl80211.NL80211_FREQUENCY_ATTR_DISABLED in fattr:
		sys.stdout.write(" (disabled)")
	sys.stdout.write("\n")
Пример #5
0
def handle_freq(attr, pol):
	e, fattr = nl.py_nla_parse_nested(nl80211.NL80211_FREQUENCY_ATTR_MAX, attr, pol)
	if nl80211.NL80211_FREQUENCY_ATTR_FREQ in fattr:
		freq = nl.nla_get_u32(fattr[nl80211.NL80211_FREQUENCY_ATTR_FREQ])
		sys.stdout.write("\t\tfreq %d MHz [%d]" % (freq, freq_to_ch(freq)))
	if nl80211.NL80211_FREQUENCY_ATTR_MAX_TX_POWER in fattr and not (nl80211.NL80211_FREQUENCY_ATTR_DISABLED in fattr):
		sys.stdout.write(" (%.1f dBm)" % (0.01 * nl.nla_get_u32(fattr[nl80211.NL80211_FREQUENCY_ATTR_MAX_TX_POWER])))
	if nl80211.NL80211_FREQUENCY_ATTR_DISABLED in fattr:
		sys.stdout.write(" (disabled)")
	sys.stdout.write("\n")
Пример #6
0
	def store_nested(self, attr, aid):
		nest_class = None
		if aid in self.nest_attr_map.keys():
			nest_class = self.nest_attr_map[aid]
		self._attrs[aid] = []
		for nest_element in nl.nla_get_nested(attr):
			if nest_class == None:
				self._attrs[aid].append(nl.nla_type(nest_element))
			else:
				e, nattr = nl.py_nla_parse_nested(nest_class.max_attr, nest_element, nest_class.policy)
				self._attrs[aid].append(nest_class(nattr))
Пример #7
0
	def handle(self, msg, arg):
		try:
			e, attrs = genl.py_genlmsg_parse(nl.nlmsg_hdr(msg), 0, nl80211.ATTR_MAX, None)
			if not nl80211.ATTR_BSS in attrs:
				return
			e, nattrs = nl.py_nla_parse_nested(len(bss_policy), attrs[nl80211.ATTR_BSS], bss_policy)
			self._bss.append(factory.get_inst().create(bss, nattrs, bss_policy))
		except Exception as e:
			(t,v,tb) = sys.exc_info()
			print v.message
			traceback.print_tb(tb)
		return nl.NL_SKIP
Пример #8
0
 def store_nested(self, attr, aid):
     nest_class = None
     if aid in self.nest_attr_map.keys():
         nest_class = self.nest_attr_map[aid]
     self._attrs[aid] = []
     for nest_element in nl.nla_get_nested(attr):
         if nest_class == None:
             self._attrs[aid].append(nl.nla_type(nest_element))
         else:
             e, nattr = nl.py_nla_parse_nested(nest_class.max_attr,
                                               nest_element,
                                               nest_class.policy)
             self._attrs[aid].append(nest_class(nattr))
Пример #9
0
 def handle(self, msg, arg):
     try:
         e, attrs = py_genlmsg_parse(nlmsg_hdr(msg), 0, nl80211.ATTR_MAX,
                                     None)
         if not nl80211.ATTR_BSS in attrs:
             return
         e, nattrs = py_nla_parse_nested(len(bss_policy),
                                         attrs[nl80211.ATTR_BSS],
                                         bss_policy)
         self._bss.append(factory.get_inst().create(bss, nattrs,
                                                    bss_policy))
     except Exception as e:
         (t, v, tb) = sys.exc_info()
         print(v.message)
         traceback.print_tb(tb)
     return NL_SKIP
Пример #10
0
def handle_band(attr, fpol):
	e, battr = nl.py_nla_parse_nested(nl80211.NL80211_BAND_ATTR_MAX, attr, None)
	print("\tband %d:" % nl.nla_type(attr))
	if nl80211.NL80211_BAND_ATTR_FREQS in battr:
		for fattr in nl.nla_get_nested(battr[nl80211.NL80211_BAND_ATTR_FREQS]):
			handle_freq(fattr, fpol)