本文整理汇总了Python中pyroute2.netlink.nla.decode函数的典型用法代码示例。如果您正苦于以下问题:Python decode函数的具体用法?Python decode怎么用?Python decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: decode
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]))
# Save segs
self['segs'] = segs
# Init tlvs
self['tlvs'] = ''
# If hmac is used
if self.has_hmac():
# Point to the start of hmac
hmac = addresses[n_segs * 16:n_segs * 16 + 40]
# Save tlvs section
self['tlvs'] = hexdump(hmac)
# Show also the hmac key
self['hmac'] = hexdump(hmac[4:8])
开发者ID:celebdor,项目名称:pyroute2,代码行数:31,代码来源:rtmsg.py
示例2: decode
def decode(self):
nla.decode(self)
r_prio = self['value'][:2]
r_addr = self['value'][2:]
self.value = {'prio': struct.unpack('H', r_prio)[0],
'addr': ':'.join('%02x' % (i) for i in
struct.unpack('BBBBBB',
r_addr))}
开发者ID:bschlinker,项目名称:pyroute2,代码行数:8,代码来源:ifinfmsg.py
示例3: decode
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
开发者ID:GateprotectGmbH,项目名称:pyroute2,代码行数:9,代码来源:cls_u32.py
示例4: decode
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(',')
开发者ID:celebdor,项目名称:pyroute2,代码行数:9,代码来源:cls_flow.py
示例5: decode
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)
开发者ID:FirefighterBlu3,项目名称:pyroute2,代码行数:10,代码来源:tcmsg.py
示例6: decode
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()
开发者ID:0xD3ADB33F,项目名称:pyroute2,代码行数:11,代码来源:sched_fq_codel.py
示例7: decode
def decode(self):
nla.decode(self)
offset = self.offset + 16
self['keys'] = []
nkeys = self['nkeys']
while nkeys:
key = self.u32_key(data=self.data, offset=offset)
key.decode()
offset += 16
self['keys'].append(key)
nkeys -= 1
开发者ID:0xD3ADB33F,项目名称:pyroute2,代码行数:11,代码来源:cls_u32.py
示例8: decode
def decode(self):
nla.decode(self)
family = struct.unpack('H', self['value'][:2])[0]
addr = self['value'][2:]
if len(addr):
if (family == AF_INET and len(addr) == 4) or \
(family == AF_INET6 and len(addr) == 16):
addr = inet_ntop(family, addr)
else:
addr = hexdump(addr)
self.value = {'family': family, 'addr': addr}
开发者ID:kinhvan017,项目名称:pyroute2,代码行数:11,代码来源:rtmsg.py
示例9: decode
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
开发者ID:celebdor,项目名称:pyroute2,代码行数:12,代码来源:__init__.py
示例10: decode
def decode(self):
nla.decode(self)
size = 0
for field in self.fields + self.header:
if 'opt' in field:
# Ignore this field as it a hack used to brain encoder
continue
size += struct.calcsize(field[1])
start = self.offset + size
end = self.offset + self.length
data = self.data[start:end]
self['opt'] = self.parse_ematch_options(self, data)
开发者ID:celebdor,项目名称:pyroute2,代码行数:13,代码来源:cls_basic.py
示例11: decode
def decode(self):
nla.decode(self)
self.value = state_by_code[self["value"]]
开发者ID:kansifang,项目名称:ip-white-list-of-firewall,代码行数:3,代码来源:ifinfmsg.py
示例12: decode
def decode(self):
nla.decode(self)
self['mac'] = ':'.join(['%02x' % x for x
in self['mac'][:6]])
开发者ID:svinota,项目名称:pyroute2,代码行数:4,代码来源:__init__.py
示例13: decode
def decode(self):
nla.decode(self)
self.value = self.ops.get(self['value'])
开发者ID:GateprotectGmbH,项目名称:pyroute2,代码行数:3,代码来源:nftables.py
示例14: decode
def decode(self):
nla.decode(self)
self.value = '%s:%s' % (self['start'], self['end'])
开发者ID:svinota,项目名称:pyroute2,代码行数:3,代码来源:fibmsg.py
示例15: decode
def decode(self):
nla.decode(self)
self['ac_comm'] = self['ac_comm'][:self['ac_comm'].find('\0')]
开发者ID:0xD3ADB33F,项目名称:pyroute2,代码行数:3,代码来源:__init__.py
示例16: decode
def decode(self):
nla.decode(self)
self.value = frozenset(o for i, o in enumerate(self.ops)
if self['value'] & 1 << i)
开发者ID:svinota,项目名称:pyroute2,代码行数:4,代码来源:nftsocket.py
注:本文中的pyroute2.netlink.nla.decode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论