コード例 #1
0
ファイル: base.py プロジェクト: arend/py80211
	def _send(self, msg):
		try:
			nl_send_auto_complete(self._sock, msg)
			while self.busy > 0:
				nl_recvmsgs(self._sock, self._rx_cb)
		except Exception as e:
			if self.busy > 0:
				raise e
		if self.busy < 0:
			raise CommandFailedError(msg, self.busy)
コード例 #2
0
 def _send(self, msg):
     try:
         nl_send_auto_complete(self._sock, msg)
         while self.busy > 0:
             nl_recvmsgs(self._sock, self._rx_cb)
     except Exception as e:
         if self.busy > 0:
             raise e
     if self.busy < 0:
         raise CommandFailedError(msg, self.busy)
コード例 #3
0
ファイル: daemon.py プロジェクト: teto/xp_couplage
	def run(self):
		err = 0
		# cbd.done > 0 and not err < 0
		while True:
			# expects handle / cb configuration
			# see nl.c:965
			err = nl.nl_recvmsgs(self.sk, self.rx_cb)
			# err = nl.nl_recvmsgs_default(self.sk)
			if err < 0:
				logger.error( "In nl_recvmsgs: %d: %s"% (err, nl.nl_geterror(err)) )
				break;
コード例 #4
0
	def run(self):
		err = 0
		# cbd.done > 0 and not err < 0
		while True:
			# expects handle / cb configuration
			# see nl.c:965
			err = nl.nl_recvmsgs(self.sk, self.rx_cb)
			# err = nl.nl_recvmsgs_default(self.sk)
			if err < 0:
				logger.error( "Error for nl_recvmsgs: %d: %s"% (err, nl.nl_geterror(err)) )
				break;
コード例 #5
0
    return nl.NL_STOP


try:
    cbd = test_class()
    tx_cb = nl.nl_cb_alloc(nl.NL_CB_DEFAULT)
    rx_cb = nl.nl_cb_clone(tx_cb)
    s = nl.nl_socket_alloc_cb(tx_cb)
    nl.py_nl_cb_err(rx_cb, nl.NL_CB_CUSTOM, error_handler, cbd)
    nl.py_nl_cb_set(rx_cb, nl.NL_CB_FINISH, nl.NL_CB_CUSTOM, finish_handler,
                    cbd)
    nl.py_nl_cb_set(rx_cb, nl.NL_CB_ACK, nl.NL_CB_CUSTOM, ack_handler, cbd)
    nl.py_nl_cb_set(rx_cb, nl.NL_CB_VALID, nl.NL_CB_CUSTOM, msg_handler, cbd)

    genl.genl_connect(s)
    family = genl.genl_ctrl_resolve(s, 'nl80211')
    m = nl.nlmsg_alloc()
    genl.genlmsg_put(m, 0, 0, family, 0, 0, nl80211.NL80211_CMD_GET_WIPHY, 0)
    nl.nla_put_u32(m, nl80211.NL80211_ATTR_WIPHY, 0)

    err = nl.nl_send_auto_complete(s, m)
    if err < 0:
        nl.nlmsg_free(msg)

    while cbd.done > 0 and not err < 0:
        err = nl.nl_recvmsgs(s, rx_cb)
except Exception as e:
    (t, v, tb) = sys.exc_info()
    print v.message
    traceback.print_tb(tb)
コード例 #6
0
ファイル: iface.py プロジェクト: DedulyaOtmoroz/libnl
	a.done = 0
	return nl.NL_STOP

try:
	cbd = test_class()
	tx_cb = nl.nl_cb_alloc(nl.NL_CB_DEFAULT)
	rx_cb = nl.nl_cb_clone(tx_cb)
	s = nl.nl_socket_alloc_cb(tx_cb)
	nl.py_nl_cb_err(rx_cb, nl.NL_CB_CUSTOM, error_handler, cbd);
	# nl.py_nl_cb_set(rx_cb, nl.NL_CB_FINISH, nl.NL_CB_CUSTOM, finish_handler, cbd);
	nl.py_nl_cb_set(rx_cb, nl.NL_CB_ACK, nl.NL_CB_CUSTOM, ack_handler, cbd);
	nl.py_nl_cb_set(rx_cb, nl.NL_CB_VALID, nl.NL_CB_CUSTOM, msg_handler, cbd);

	genl.genl_connect(s)
	family = genl.genl_ctrl_resolve(s, 'nl80211')
	m = nl.nlmsg_alloc()
	genl.genlmsg_put(m, 0, 0, family, 0, 0, nl80211.NL80211_CMD_GET_INTERFACE, 0)
	nl.nla_put_u32(m, nl80211.NL80211_ATTR_IFINDEX, nl.if_nametoindex('wlan0'))

	err = nl.nl_send_auto_complete(s, m);
	if err < 0:
		nl.nlmsg_free(msg)

	while cbd.done > 0 and not err < 0:
		err = nl.nl_recvmsgs(s, rx_cb)

except Exception as e:
	(t, v, tb) = sys.exc_info()
	print v.message
	traceback.print_tb(tb)