def send_rlocs_list_for_eid(self, seq_nb, token, nb_of_rlocs): logger.info("Sending rlocs nb of '%d' for token %d with seq nb %d"%(nb_of_rlocs,token,seq_nb)) msg = nl.nlmsg_alloc() # returns void* genl.genlmsg_put(msg, 0, # port 0, # seq nb self.family_id, # family_id 0, # length of user header 0, # optional flags ELC_RESULTS, # cmd LIG_GENL_VERSION # version ) nl.nla_put_u32(msg, ELA_RLOCS_NUMBER, nb_of_rlocs ); nl.nla_put_u32(msg, ELA_MPTCP_TOKEN , token ); err = nl.nl_send_auto_complete(self.sk, msg); if err < 0: logger.error("Error while sending answer") nl.nlmsg_free(msg) return False nl.nlmsg_free(msg) return True
def send_rlocs_list_for_eid(self, seq_nb, token, nb_of_rlocs): logger.info("Sending rlocs nb of '%d' for token %d with seq nb %d"%(nb_of_rlocs,token,seq_nb)) # Remplacer ca par la classe Netlink associée msg = nl.nlmsg_alloc() # returns void* msg_header = genl.genlmsg_put(msg, 0, # port 0, # seq nb self.family_id, # family_id 0, # length of user header 0, # optional flags ELC_RESULTS, # cmd LIG_GENL_VERSION # version ) if not msg_header: logger.error("Could not create header") return False nl.nla_put_u32(msg, ELA_MPTCP_TOKEN , token ); nl.nla_put_u8(msg, ELA_RLOCS_NUMBER, nb_of_rlocs ); logger.debug("sEnding autocomplete") # rc = genlmsg_end(skb, msg_header); err = nl.nl_send_auto_complete(self.sk, msg); if err < 0: logger.error("Error while sending answer") nl.nlmsg_free(msg) return False # nl.nlmsg_free(msg) logger.debug("Message successfully sent") return True
def send_rlocs_list_for_eid(self, seq_nb, token, nb_of_rlocs): logger.info("Sending rlocs nb of '%d' for token %d with seq nb %d" % (nb_of_rlocs, token, seq_nb)) # Remplacer ca par la classe Netlink associée msg = nl.nlmsg_alloc() # returns void* msg_header = genl.genlmsg_put( msg, 0, # port 0, # seq nb self.family_id, # family_id 0, # length of user header 0, # optional flags ELC_RESULTS, # cmd LIG_GENL_VERSION # version ) if not msg_header: logger.error("Could not create header") return False nl.nla_put_u32(msg, ELA_MPTCP_TOKEN, token) nl.nla_put_u8(msg, ELA_RLOCS_NUMBER, nb_of_rlocs) logger.debug("sEnding autocomplete") # rc = genlmsg_end(skb, msg_header); err = nl.nl_send_auto_complete(self.sk, msg) if err < 0: logger.error("Error while sending answer") nl.nlmsg_free(msg) return False # nl.nlmsg_free(msg) logger.debug("Message successfully sent") return True
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)