示例#1
0
 def decode(self):
     nla_string.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)
示例#2
0
 def decode(self):
     nla_string.decode(self)
     family = struct.unpack('H', self['value'][:2])[0]
     addr = self['value'][2:]
     if 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}
示例#3
0
 def decode(self):
     # Decode the data
     nla_string.decode(self)
     # Convert the packed IP address to its string representation
     self['value'] = inet_ntop(AF_INET6, self['value'])