Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def decode(self):
# Decode the data
nla.decode(self)
# Extract the encap mode
self['mode'] = (self.r_encapmodes
.get(self['encapmode'], "encap"))
# Calculate offset of the segs
offset = self.offset + 16
# Point the addresses
addresses = self.data[offset:]
# Extract the number of segs
n_segs = self['segments_left'] + 1
# Init segs
segs = []
# Move 128 bit in each step
for i in range(n_segs):
# Save the segment
segs.append(inet_ntop(AF_INET6,
addresses[i * 16:i * 16 + 16]))
def decode(self):
nla.decode(self)
self['mac'] = ':'.join(['%02x' % x for x
in self['mac'][:6]])
def decode(self):
nla.decode(self)
parms = self.parent.get_attr('TCA_TBF_PARMS') or \
self.parent.get_attr('TCA_HTB_PARMS') or \
self.parent.get_attr('TCA_POLICE_TBF')
if parms is not None:
rtab = struct.unpack('I' * (len(self['value']) / 4),
self['value'])
self.value = rtab
setattr(parms, self.__class__.__name__, rtab)
def decode(self):
nla.decode(self)
# read the type
kind = struct.unpack('I', self.buf.read(4))[0]
if kind == self.TCA_FQ_CODEL_XSTATS_QDISC:
self.fields = self.qdisc_fields
elif kind == self.TCA_FQ_CODEL_XSTATS_CLASS:
self.fields = self.class_fields
else:
raise TypeError("Unknown xstats type")
self.decode_fields()
def decode(self):
nla.decode(self)
keys = ''
for key, value in tc_flow_keys.items():
if value & self['flow_keys']:
keys = '{0},{1}'.format(keys, key)
self['flow_keys'] = keys.strip(',')
def decode(self):
nla.decode(self)
if isinstance(self['value'], tuple):
self['value'] = (self['value'][0] & 0xffffffffffffffff) | \
(self['value'][1] << 64)
def decode(self):
nla.decode(self)
for key, value in tc_flow_modes.items():
if self['flow_mode'] == value:
self['flow_mode'] = key
break
def decode(self):
# Fix tcpi_rcv_scale amd delivery_rate bit fields.
# In the C:
#
# __u8 tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
# __u8 tcpi_delivery_rate_app_limited:1;
#
nla.decode(self)
self['tcpi_rcv_wscale'] = self['tcpi_snd_wscale'] & 0xf
self['tcpi_snd_wscale'] = self['tcpi_snd_wscale'] & 0xf0 >> 4
self['tcpi_delivery_rate_app_limited'] = \
self['tcpi_delivery_rate_app_limited'] & 0x80 >> 7
def decode(self):
nla.decode(self)
self['keys'] = []
nkeys = self['nkeys']
while nkeys:
key = self.u32_key(self.buf)
key.decode()
self['keys'].append(key)
nkeys -= 1