Lines Matching +full:m +full:- +full:class

1 # SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
25 class Netlink:
98 'binary', 'string', 'nul-string',
99 'nested', 'nested-array',
102 class NlError(Exception):
105 self.error = -nl_msg.error
111 class ConfigError(Exception):
115 class NlAttr:
140 return format.big if byte_order == "big-endian" \
150 raise Exception(f"Auto-scalar len payload be 4 or 8 bytes, got {len(self.raw)}")
156 return self.raw.decode('ascii')[:-1]
169 class NlAttrs:
190 class NlMsg:
220 self.extack['miss-type'] = extack.as_scalar('u32')
222 self.extack['miss-nest'] = extack.as_scalar('u32')
224 self.extack['bad-attr-offs'] = extack.as_scalar('u32')
242 policy['min-value'] = attr.as_scalar('s64')
244 policy['max-value'] = attr.as_scalar('s64')
246 policy['min-value'] = attr.as_scalar('u64')
248 policy['max-value'] = attr.as_scalar('u64')
250 policy['min-length'] = attr.as_scalar('u32')
252 policy['max-length'] = attr.as_scalar('u32')
254 policy['bitfield32-mask'] = attr.as_scalar('u32')
263 if 'miss-type' in self.extack and 'miss-nest' not in self.extack:
264 miss_type = self.extack['miss-type']
267 self.extack['miss-type'] = spec['name']
269 self.extack['miss-type-doc'] = spec['doc']
283 class NlMsgs:
362 class GenlMsg:
379 class NetlinkProtocol:
413 class GenlProtocol(NetlinkProtocol):
441 class SpaceAttrs:
457 raise Exception(f"Attribute '{name}' not defined in any attribute-set")
465 class YnlFamily(SpecFamily):
474 if self.proto == "netlink-raw":
487 # Netlink will always allocate at least PAGE_SIZE - sizeof(skb_shinfo)
529 if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
564 sub_space = attr['nested-attributes']
566 elif attr['type'] == 'indexed-array' and attr['sub-type'] == 'nest':
568 sub_space = attr['nested-attributes']
607 elif attr['type'] == 'sub-message':
620 raise Exception(f"Unknown attribute-set '{msg_format.attr_set}'")
627 pad = b'\x00' * ((4 - len(attr_payload) % 4) % 4)
658 if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
693 if attr_spec["sub-type"] == 'nest':
694 subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
696 elif attr_spec["sub-type"] == 'binary':
701 elif attr_spec["sub-type"] in NlAttr.type_formats:
702 subattr = item.as_scalar(attr_spec['sub-type'], attr_spec.byte_order)
709 raise Exception(f'Unknown {attr_spec["sub-type"]} with name {attr_spec["name"]}')
715 for name in attr_spec['type-value']:
718 subattrs = self._decode(NlAttrs(value.raw), attr_spec['nested-attributes'])
746 raise Exception(f"No sub-message spec named {sub_msg} for {attr_spec.name}")
752 raise Exception(f"No message format for '{value}' in sub-message spec '{sub_msg}'")
769 raise Exception(f"Unknown attribute-set '{msg_format.attr_set}' when decoding '{attr_spec.name}'")
790 subdict = self._decode(NlAttrs(attr.raw), attr_spec['nested-attributes'], search_attrs)
808 elif attr_spec["type"] == 'indexed-array':
816 elif attr_spec["type"] == 'sub-message':
818 elif attr_spec["type"] == 'nest-type-value':
849 sub_attrs = self.attr_sets[attr_spec['nested-attributes']]
851 elif attr_spec['type'] == 'sub-message':
854 raise Exception(f"Can't resolve sub-message of {attr_spec['name']} for extack")
869 if 'bad-attr-offs' not in extack:
876 extack['bad-attr-offs'], search_attrs)
878 del extack['bad-attr-offs']
879 extack['bad-attr'] = path
885 for m in members:
886 if m.type in ['pad', 'binary']:
887 if m.struct:
888 size += self._struct_size(m.struct)
890 size += m.len
892 format = NlAttr.get_format(m.type, m.byte_order)
902 for m in members:
904 if m.type == 'pad':
905 offset += m.len
906 elif m.type == 'binary':
907 if m.struct:
908 len = self._struct_size(m.struct)
910 m.struct)
913 value = data[offset : offset + m.len]
914 offset += m.len
916 format = NlAttr.get_format(m.type, m.byte_order)
920 if m.enum:
921 value = self._decode_enum(value, m)
922 elif m.display_hint:
923 value = self._formatted_string(value, m.display_hint)
924 attrs[m.name] = value
930 for m in members:
931 value = vals.pop(m.name) if m.name in vals else None
932 if m.type == 'pad':
933 attr_payload += bytearray(m.len)
934 elif m.type == 'binary':
935 if m.struct:
938 attr_payload += self._encode_struct(m.struct, value)
941 attr_payload += bytearray(m.len)
947 format = NlAttr.get_format(m.type, m.byte_order)
959 elif display_hint in [ 'ipv4', 'ipv6', 'ipv4-or-v6' ]:
968 if attr_spec.display_hint in ['ipv4', 'ipv6', 'ipv4-or-v6']:
1008 print("Netlink error in ntf!?", os.strerror(-nl_msg.error))
1032 timeout = start_time + duration - time.time()