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)
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;
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;
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)
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)