Lines Matching full:raw

128     def __init__(self, raw, offset):
129 self._len, self._type = struct.unpack("HH", raw[offset : offset + 4])
134 self.raw = raw[offset + 4 : offset + self.payload_len]
146 return format.unpack(self.raw)[0]
149 if len(self.raw) != 4 and len(self.raw) != 8:
150 raise Exception(f"Auto-scalar len payload be 4 or 8 bytes, got {len(self.raw)}")
151 real_type = attr_type[0] + str(len(self.raw) * 8)
153 return format.unpack(self.raw)[0]
156 return self.raw.decode('ascii')[:-1]
159 return self.raw
163 return [ x[0] for x in format.iter_unpack(self.raw) ]
166 return f"[type:{self.type} len:{self._len}] {self.raw}"
197 self.raw = msg[offset + 16 : offset + self.nl_len]
204 self.error = struct.unpack("i", self.raw[0:4])[0]
208 self.error = struct.unpack("i", self.raw[0:4])[0]
215 extack_attrs = NlAttrs(self.raw[extack_off:])
226 self.extack['policy'] = self._decode_policy(extack.raw)
235 def _decode_policy(self, raw):
237 for attr in NlAttrs(raw):
275 msg = f"nl_len = {self.nl_len} ({len(self.raw)}) nl_flags = 0x{self.nl_flags:x} nl_type = {self.nl_type}"
339 for attr in NlAttrs(gm.raw):
348 for entry in NlAttrs(attr.raw):
351 for entry_attr in NlAttrs(entry.raw):
365 self.genl_cmd, self.genl_version, _ = struct.unpack_from("BBH", nl_msg.raw, 0)
366 self.raw = nl_msg.raw[4:]
401 msg.raw_attrs = NlAttrs(msg.raw, fixed_header_size)
474 if self.proto == "netlink-raw":
646 def _get_enum_or_unknown(self, enum, raw):
648 name = enum.entries_by_val[raw].name
651 name = f"Unknown({raw})"
656 def _decode_enum(self, raw, attr_spec):
661 while raw:
662 if raw & 1:
664 raw >>= 1
667 value = self._get_enum_or_unknown(enum, raw)
672 decoded = self._decode_struct(attr.raw, attr_spec.struct_name)
689 while offset < len(attr.raw):
690 item = NlAttr(attr.raw, offset)
694 subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
716 value = NlAttr(value.raw, 0)
718 subattrs = self._decode(NlAttrs(value.raw), attr_spec['nested-attributes'])
724 return self._decode(NlAttrs(attr.raw), None)
762 decoded.update(self._decode_struct(attr.raw, msg_format.fixed_header))
766 subdict = self._decode(NlAttrs(attr.raw, offset), msg_format.attr_set)
790 subdict = self._decode(NlAttrs(attr.raw), attr_spec['nested-attributes'], search_attrs)
811 value, selector = struct.unpack("II", attr.raw)
860 subpath = self._decode_extack_path(NlAttrs(attr.raw), sub_attrs,
951 def _formatted_string(self, raw, display_hint):
953 formatted = ':'.join('%02x' % b for b in raw)
955 if isinstance(raw, int):
956 formatted = hex(raw)
958 formatted = bytes.hex(raw, ' ')
960 formatted = format(ipaddress.ip_address(raw))
962 formatted = str(uuid.UUID(bytes=raw))
964 formatted = raw
971 raw = ip.packed
973 raw = int(ip)
976 raw = bytes.fromhex(string)
978 raw = int(string, 16)
982 return raw
987 msg['raw'] = decoded
991 attrs.update(self._decode_struct(decoded.raw, op.fixed_header))
1130 rsp_msg.update(self._decode_struct(decoded.raw, op.fixed_header))