Commit 29e7343d authored by Peter V. Saveliev's avatar Peter V. Saveliev
Browse files

[WIP] use headerless NLA to decode ipset ematch

Bug-Url: https://github.com/svinota/pyroute2/pull/522
parent 5459350f
......@@ -69,7 +69,6 @@ class options(nla):
size += struct.calcsize(field[1])
start = self.offset + size
end = start + (self.length - size)
end = self.offset + self.length
data = self.data[start:end]
# TODO: it does not work :(
self['opt'] = self.parse_ematch_options(self, data)(data=data)
self['opt'] = self.parse_ematch_options(self, data)
......@@ -35,10 +35,10 @@ class nla_plus_tcf_ematch_opt(object):
kind = self['kind']
if kind in plugins:
return plugins[kind].options
else:
return self.hex
return self.hex
ret = plugins[kind].data(data=self.data)
ret.decode()
return ret
return hexdump(self.data)
def get_ematch_parms(kwarg):
......
import struct
from pyroute2.netlink import nla
from pyroute2.netlink import nlmsg
from pyroute2.netlink import nlmsg_base
# see em_ipset.c
IPSET_DIM = {
......@@ -85,13 +84,8 @@ def set_parameters(kwarg):
# Prepare value buffer
class options(nla):
nla_map = (('TCF_IP_SET_OPT', 'parse_ip_set_options'),
)
class parse_ip_set_options(nlmsg):
fields = (('ip_set_index', 'H'),
('ip_set_flags', 'B'),
('ip_set_mode', 'B'),
)
class data(nlmsg_base):
fields = (('ip_set_index', 'H'),
('ip_set_flags', 'B'),
('ip_set_mode', 'B'),
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment