コード例 #1
0
ファイル: base.py プロジェクト: arend/py80211
	def create_map(self, map_attr, pol):
		nest_map = {}
		for key in nla_get_nested(map_attr):
			nest_list = self.create_list(key, pol)
			if len(nest_list) > 0:
				nest_map[nla_type(key)] = nest_list
		return nest_map
コード例 #2
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)
コード例 #3
0
ファイル: base.py プロジェクト: oprsystem/py80211
 def create_map(self, map_attr, pol):
     nest_map = {}
     for key in nl.nla_get_nested(map_attr):
         nest_list = self.create_list(key, pol)
         if len(nest_list) > 0:
             nest_map[nl.nla_type(key)] = nest_list
     return nest_map
コード例 #4
0
def msg_handler(m, a):
    try:
        e, attr = genl.py_genlmsg_parse(nl.nlmsg_hdr(m), 0,
                                        nl80211.NL80211_ATTR_MAX, None)
        if nl80211.NL80211_ATTR_WIPHY_NAME in attr:
            print('wiphy %s' %
                  nl.nla_get_string(attr[nl80211.NL80211_ATTR_WIPHY_NAME]))
        if nl80211.NL80211_ATTR_WIPHY_BANDS in attr:
            fpol = nl.nla_policy_array(nl80211.NL80211_FREQUENCY_ATTR_MAX + 1)
            fpol[nl80211.NL80211_FREQUENCY_ATTR_FREQ].type = nl.NLA_U32
            fpol[nl80211.NL80211_FREQUENCY_ATTR_DISABLED].type = nl.NLA_FLAG
            fpol[
                nl80211.NL80211_FREQUENCY_ATTR_PASSIVE_SCAN].type = nl.NLA_FLAG
            fpol[nl80211.NL80211_FREQUENCY_ATTR_NO_IBSS].type = nl.NLA_FLAG
            fpol[nl80211.NL80211_FREQUENCY_ATTR_RADAR].type = nl.NLA_FLAG
            fpol[nl80211.NL80211_FREQUENCY_ATTR_MAX_TX_POWER].type = nl.NLA_U32

            nattrs = nl.nla_get_nested(attr[nl80211.NL80211_ATTR_WIPHY_BANDS])
            for nattr in nattrs:
                handle_band(nattr, fpol)
        if nl80211.NL80211_ATTR_CIPHER_SUITES in attr:
            ciphers = nl.nla_data(attr[nl80211.NL80211_ATTR_CIPHER_SUITES])
            num = len(ciphers) / 4
            if num > 0:
                print("\tSupported Ciphers:")
                for i in range(0, num, 4):
                    print("\t\t* %s" % cipher_name(ciphers[i:i + 4]))
        if nl80211.NL80211_ATTR_SUPPORTED_IFTYPES in attr:
            print("\tSupported interface modes:")
            ifattr = nl.nla_get_nested(
                attr[nl80211.NL80211_ATTR_SUPPORTED_IFTYPES])
            for nl_mode in ifattr:
                print("\t\t* %s" %
                      nl80211.nl80211_iftype2str[nl.nla_type(nl_mode)])
        if nl80211.NL80211_ATTR_SOFTWARE_IFTYPES in attr:
            print("\tsoftware interface modes (can always be added):")
            ifattr = nl.nla_get_nested(
                attr[nl80211.NL80211_ATTR_SOFTWARE_IFTYPES])
            for nl_mode in ifattr:
                print("\t\t* %s" %
                      nl80211.nl80211_iftype2str[nl.nla_type(nl_mode)])
        return nl.NL_SKIP
    except Exception as e:
        (t, v, tb) = sys.exc_info()
        print v.message
        traceback.print_tb(tb)
コード例 #5
0
ファイル: base.py プロジェクト: oprsystem/py80211
 def create_nested_list(self, attr_list, aid):
     nest_list = []
     for nest_element in nl.nla_get_nested(attr_list):
         nest_obj = self.create_nested(nest_element, aid)
         if isinstance(nest_obj, nl80211_object):
             nest_obj.nla_type = nl.nla_type(nest_element)
         nest_list.append(nest_obj)
     return nest_list
コード例 #6
0
ファイル: base.py プロジェクト: oprsystem/py80211
 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)
コード例 #7
0
ファイル: base.py プロジェクト: arend/py80211
	def create_nested_list(self, attr_list, aid):
		nest_list = []
		for nest_element in nla_get_nested(attr_list):
			nest_obj = self.create_nested(nest_element, aid)
			if isinstance(nest_obj, nl80211_object):
				nest_obj.nla_type = nla_type(nest_element)
			nest_list.append(nest_obj)
		return nest_list
コード例 #8
0
ファイル: base.py プロジェクト: arend/py80211
	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)
コード例 #9
0
ファイル: base.py プロジェクト: FomkaV/wifi-arsenal
	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))
コード例 #10
0
ファイル: wiphy.py プロジェクト: DedulyaOtmoroz/libnl
def msg_handler(m, a):
	try:
		e, attr = genl.py_genlmsg_parse(nl.nlmsg_hdr(m), 0,
						nl80211.NL80211_ATTR_MAX, None)
		if nl80211.NL80211_ATTR_WIPHY_NAME in attr:
			print('wiphy %s' % nl.nla_get_string(attr[nl80211.NL80211_ATTR_WIPHY_NAME]))
		if nl80211.NL80211_ATTR_WIPHY_BANDS in attr:
			fpol = nl.nla_policy_array(nl80211.NL80211_FREQUENCY_ATTR_MAX + 1)
			fpol[nl80211.NL80211_FREQUENCY_ATTR_FREQ].type = nl.NLA_U32
			fpol[nl80211.NL80211_FREQUENCY_ATTR_DISABLED].type = nl.NLA_FLAG
			fpol[nl80211.NL80211_FREQUENCY_ATTR_PASSIVE_SCAN].type = nl.NLA_FLAG
			fpol[nl80211.NL80211_FREQUENCY_ATTR_NO_IBSS].type = nl.NLA_FLAG
			fpol[nl80211.NL80211_FREQUENCY_ATTR_RADAR].type = nl.NLA_FLAG
			fpol[nl80211.NL80211_FREQUENCY_ATTR_MAX_TX_POWER].type = nl.NLA_U32

			nattrs = nl.nla_get_nested(attr[nl80211.NL80211_ATTR_WIPHY_BANDS])
			for nattr in nattrs:
				handle_band(nattr, fpol)
		if nl80211.NL80211_ATTR_CIPHER_SUITES in attr:
			ciphers = nl.nla_data(attr[nl80211.NL80211_ATTR_CIPHER_SUITES])
			num = len(ciphers) / 4
			if num > 0:
				print("\tSupported Ciphers:");
				for i in range(0, num, 4):
					print("\t\t* %s" % cipher_name(ciphers[i:i+4]))
		if nl80211.NL80211_ATTR_SUPPORTED_IFTYPES in attr:
			print("\tSupported interface modes:")
			ifattr = nl.nla_get_nested(attr[nl80211.NL80211_ATTR_SUPPORTED_IFTYPES])
			for nl_mode in ifattr:
				print("\t\t* %s" % nl80211.nl80211_iftype2str[nl.nla_type(nl_mode)])
		if nl80211.NL80211_ATTR_SOFTWARE_IFTYPES in attr:
			print("\tsoftware interface modes (can always be added):")
			ifattr = nl.nla_get_nested(attr[nl80211.NL80211_ATTR_SOFTWARE_IFTYPES])
			for nl_mode in ifattr:
				print("\t\t* %s" % nl80211.nl80211_iftype2str[nl.nla_type(nl_mode)])
		return nl.NL_SKIP
	except Exception as e:
		(t,v,tb) = sys.exc_info()
		print v.message
		traceback.print_tb(tb)
コード例 #11
0
ファイル: base.py プロジェクト: szehl/wifi-arsenal
 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))
コード例 #12
0
ファイル: wiphy.py プロジェクト: DedulyaOtmoroz/libnl
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)