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

1 # SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
23 class Netlink:
96 'binary', 'string', 'nul-string',
97 'nested', 'nested-array',
100 class NlError(Exception):
103 self.error = -nl_msg.error
109 class ConfigError(Exception):
113 class NlAttr:
138 return format.big if byte_order == "big-endian" \
148 raise Exception(f"Auto-scalar len payload be 4 or 8 bytes, got {len(self.raw)}")
154 return self.raw.decode('ascii')[:-1]
167 class NlAttrs:
188 class NlMsg:
218 self.extack['miss-type'] = extack.as_scalar('u32')
220 self.extack['miss-nest'] = extack.as_scalar('u32')
222 self.extack['bad-attr-offs'] = extack.as_scalar('u32')
232 if 'miss-type' in self.extack and 'miss-nest' not in self.extack:
233 miss_type = self.extack['miss-type']
236 self.extack['miss-type'] = spec['name']
238 self.extack['miss-type-doc'] = spec['doc']
247 policy['min-value'] = attr.as_scalar('s64')
249 policy['max-value'] = attr.as_scalar('s64')
251 policy['min-value'] = attr.as_scalar('u64')
253 policy['max-value'] = attr.as_scalar('u64')
255 policy['min-length'] = attr.as_scalar('u32')
257 policy['max-length'] = attr.as_scalar('u32')
259 policy['bitfield32-mask'] = attr.as_scalar('u32')
276 class NlMsgs:
355 class GenlMsg:
372 class NetlinkProtocol:
406 class GenlProtocol(NetlinkProtocol):
434 class SpaceAttrs:
450 raise Exception(f"Attribute '{name}' not defined in any attribute-set")
458 class YnlFamily(SpecFamily):
467 if self.proto == "netlink-raw":
480 # Netlink will always allocate at least PAGE_SIZE - sizeof(skb_shinfo)
522 if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
558 attr_payload += self._add_attr(attr['nested-attributes'],
588 elif attr['type'] == 'sub-message':
601 raise Exception(f"Unknown attribute-set '{msg_format.attr_set}'")
605 pad = b'\x00' * ((4 - len(attr_payload) % 4) % 4)
610 if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
640 if attr_spec["sub-type"] == 'nest':
641 subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
643 elif attr_spec["sub-type"] == 'binary':
648 elif attr_spec["sub-type"] in NlAttr.type_formats:
649 subattrs = item.as_scalar(attr_spec['sub-type'], attr_spec.byte_order)
654 raise Exception(f'Unknown {attr_spec["sub-type"]} with name {attr_spec["name"]}')
660 for name in attr_spec['type-value']:
663 subattrs = self._decode(NlAttrs(value.raw), attr_spec['nested-attributes'])
691 raise Exception(f"No sub-message spec named {sub_msg} for {attr_spec.name}")
697 raise Exception(f"No message format for '{value}' in sub-message spec '{sub_msg}'")
714 … raise Exception(f"Unknown attribute-set '{attr_space}' when decoding '{attr_spec.name}'")
734 … subdict = self._decode(NlAttrs(attr.raw), attr_spec['nested-attributes'], search_attrs)
750 elif attr_spec["type"] == 'indexed-array':
758 elif attr_spec["type"] == 'sub-message':
760 elif attr_spec["type"] == 'nest-type-value':
789 self.attr_sets[attr_spec['nested-attributes']],
798 if 'bad-attr-offs' not in extack:
804 extack['bad-attr-offs'])
806 del extack['bad-attr-offs']
807 extack['bad-attr'] = path
813 for m in members:
814 if m.type in ['pad', 'binary']:
815 if m.struct:
816 size += self._struct_size(m.struct)
818 size += m.len
820 format = NlAttr.get_format(m.type, m.byte_order)
830 for m in members:
832 if m.type == 'pad':
833 offset += m.len
834 elif m.type == 'binary':
835 if m.struct:
836 len = self._struct_size(m.struct)
838 m.struct)
841 value = data[offset : offset + m.len]
842 offset += m.len
844 format = NlAttr.get_format(m.type, m.byte_order)
848 if m.enum:
849 value = self._decode_enum(value, m)
850 elif m.display_hint:
851 value = self._formatted_string(value, m.display_hint)
852 attrs[m.name] = value
858 for m in members:
859 value = vals.pop(m.name) if m.name in vals else None
860 if m.type == 'pad':
861 attr_payload += bytearray(m.len)
862 elif m.type == 'binary':
863 if m.struct:
866 attr_payload += self._encode_struct(m.struct, value)
869 attr_payload += bytearray(m.len)
875 format = NlAttr.get_format(m.type, m.byte_order)
919 print("Netlink error in ntf!?", os.strerror(-nl_msg.error))