def execute(self): c = self.get_context() interface = self.get_interface() handle = convert_handle(self["handle"]) try: parent = convert_handle(c["parent"]) except ValueError: parent = TC_H_ROOT info = getattr(self, "tcm_info", 0) tcm = tcmsg(socket.AF_UNSPEC, interface.if_index, handle, parent, info, self.attrs) msg = Message(type=self.type, flags=NLM_F_EXCL | NLM_F_CREATE | NLM_F_REQUEST | NLM_F_ACK, service_template=tcm) connection.send(msg) resp = connection.recv() return resp
def __init__(self, match, flowid, **kwargs): U32Filter.__init__(self, match, **kwargs) prio = kwargs.get('prio', 3) protocol = ETH_P_IP self.tcm_info = prio << 16 | protocol flow = u32_classid(convert_handle(flowid)) self.attrs.append(Attr(TCA_OPTIONS, flow.pack() + self.selector.pack()))
def execute(self): c = self.get_context() interface = self.get_interface() handle = convert_handle(self['handle']) try: parent = convert_handle(c['parent']) except ValueError: parent = TC_H_ROOT info = getattr(self, 'tcm_info', 0) tcm = tcmsg(socket.AF_UNSPEC, interface.if_index, handle, parent, info, self.attrs) msg = Message(type=self.type, flags=NLM_F_EXCL | NLM_F_CREATE | NLM_F_REQUEST | NLM_F_ACK, service_template=tcm) connection.send(msg) resp = connection.recv() return resp
def __init__(self, match, ifb, **kwargs): U32Filter.__init__(self, match, **kwargs) prio = kwargs.get('prio', 2) protocol = ETH_P_IP self.tcm_info = prio << 16 | protocol if_index = get_if_index(ifb) flow = u32_classid(convert_handle(0x10001)) action = u32_mirred_action(if_index) self.attrs.append(Attr(TCA_OPTIONS, flow.pack()+action.pack()+self.selector.pack()))