def tunnel_create(self, tunnel_id, peer_tunnel_id, socket): """ Creates a new L2TP tunnel. :param tunnel_id: Local tunnel identifier :param peer_tunnel_id: Remote peer tunnel identifier :param socket: UDP socket file descriptor """ msg = self._create_message(L2TP_CMD_TUNNEL_CREATE, [ netlink.U32Attr(L2TP_ATTR_CONN_ID, tunnel_id), netlink.U32Attr(L2TP_ATTR_PEER_CONN_ID, peer_tunnel_id), netlink.U8Attr(L2TP_ATTR_PROTO_VERSION, 3), netlink.U16Attr(L2TP_ATTR_ENCAP_TYPE, L2TP_ENCAPTYPE_UDP), netlink.U32Attr(L2TP_ATTR_FD, socket), ]) msg.send(self.connection) try: self.connection.recv() except OSError, e: if e.errno == errno.EEXIST: # This tunnel identifier is already in use; make sure to remove it from # our pool of assignable tunnel identifiers. raise L2TPTunnelExists(tunnel_id) raise NetlinkError
def nrc_inject_mgmt_frame(self, stype): attrs = [] attrs.append(netlink.U8Attr(NL_MGMT_FRAME_INJECTION_STYPE, stype)) req = netlink.GenlMessage(self._fid, NL_MGMT_FRAME_INJECTION, flags=netlink.NLM_F_REQUEST | netlink.NLM_F_ACK, attrs=attrs) resp = req.send_and_recv(self._conn)
def wfa_capi_sta_send_addba_tid(self, tid): attrs = [] attrs.append(netlink.U8Attr(NL_WFA_CAPI_PARAM_TID, tid)) req = netlink.GenlMessage(self._fid, NL_WFA_CAPI_STA_SEND_ADDBA, flags=netlink.NLM_F_REQUEST | netlink.NLM_F_ACK, attrs=attrs) resp = req.send_and_recv(self._conn) resp_attrs = netlink.parse_attributes(resp.payload[4:]) return resp_attrs[NL_WFA_CAPI_PARAM_RESP].nulstr()