Ejemplo n.º 1
0
 def getfield(self, pkt, s):
     remain = b""
     if self.length_from:
         remain, s = StrLenField.getfield(self, pkt, s)
     # Decode the compressed DNS message
     decoded, _, left = dns_get_str(s, 0, pkt)
     # returns (remaining, decoded)
     return left + remain, decoded
Ejemplo n.º 2
0
 def getfield(self, pkt, s):
     dtype = pkt.attribute_data_type
     length = _ZCL_attr_length.get(dtype, None)
     if length is None:
         return b"", self.m2i(pkt, s)
     elif isinstance(length, tuple):  # Variable length
         size, fmt = length
         # We add size as we include the length tag in the string
         length = struct.unpack(fmt, s[:size])[0] + size
     if isinstance(length, int):
         self.length_from = lambda x: length
         return StrLenField.getfield(self, pkt, s)
     return s