Ejemplo n.º 1
0
 def encode(self):
     family = self.get('family', AF_UNSPEC)
     if family in (AF_INET, AF_INET6):
         addr = inet_pton(family, self['addr'])
     else:
         raise TypeError('Family %s not supported for RTA_VIA' % family)
     self['value'] = struct.pack('H', family) + addr
     nla_string.encode(self)
Ejemplo n.º 2
0
 def encode(self):
     parms = self.parent.get_encoded('TCA_TBF_PARMS') or \
         self.parent.get_encoded('TCA_HTB_PARMS') or \
         self.parent.get_encoded('TCA_POLICE_TBF')
     if parms is not None:
         self.value = getattr(parms, self.__class__.__name__)
         self['value'] = struct.pack('I' * 256,
                                     *(int(x) for x in self.value))
     nla_string.encode(self)
Ejemplo n.º 3
0
 def encode(self):
     # Convert to network byte order
     self['value'] = inet_pton(AF_INET6, self['value'])
     # Finally encode as nla
     nla_string.encode(self)
Ejemplo n.º 4
0
 def encode(self):
     self['value'] = struct.pack('B' * 256,
                                 *(int(x) for x in self.value))
     nla_string.encode(self)