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): ...@@ -69,7 +69,6 @@ class options(nla):
size += struct.calcsize(field[1]) size += struct.calcsize(field[1])
start = self.offset + size start = self.offset + size
end = start + (self.length - size) end = self.offset + self.length
data = self.data[start:end] data = self.data[start:end]
# TODO: it does not work :( self['opt'] = self.parse_ematch_options(self, data)
self['opt'] = self.parse_ematch_options(self, data)(data=data)
...@@ -35,10 +35,10 @@ class nla_plus_tcf_ematch_opt(object): ...@@ -35,10 +35,10 @@ class nla_plus_tcf_ematch_opt(object):
kind = self['kind'] kind = self['kind']
if kind in plugins: if kind in plugins:
return plugins[kind].options ret = plugins[kind].data(data=self.data)
else: ret.decode()
return self.hex return ret
return self.hex return hexdump(self.data)
def get_ematch_parms(kwarg): def get_ematch_parms(kwarg):
......
import struct import struct
from pyroute2.netlink import nla from pyroute2.netlink import nlmsg_base
from pyroute2.netlink import nlmsg
# see em_ipset.c # see em_ipset.c
IPSET_DIM = { IPSET_DIM = {
...@@ -85,13 +84,8 @@ def set_parameters(kwarg): ...@@ -85,13 +84,8 @@ def set_parameters(kwarg):
# Prepare value buffer # Prepare value buffer
class options(nla): class data(nlmsg_base):
nla_map = (('TCF_IP_SET_OPT', 'parse_ip_set_options'), fields = (('ip_set_index', 'H'),
) ('ip_set_flags', 'B'),
('ip_set_mode', 'B'),
)
class parse_ip_set_options(nlmsg):
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