def create_genl_message_type(class_name, family_id_or_name, *fields,
                             **kwargs):

    name_to_key = {}
    key_to_name = {}
    key_to_attr_list_type = {}
    for i, (name, attr_list_type) in enumerate(fields):
        key = i + 1
        name_to_key[name.upper()] = key
        key_to_name[key] = name
        key_to_attr_list_type[key] = attr_list_type

    @message_class
    class MessageType:
        family = family_id_or_name
        required_modules = kwargs.get('required_modules', [])

        def __init__(self, cmd, attr_list=_unset, version=0x1,
                     flags=MessageFlags.ACK_REQUEST):
            if not isinstance(cmd, int):
                self.cmd = name_to_key[cmd.upper()]
            else:
                self.cmd = cmd

            self.version = version
            self.flags = flags

            if attr_list is _unset:
                kls = key_to_attr_list_type[self.cmd]
                self.attr_list = kls is not None and kls() or kls
            else:
                self.attr_list = attr_list

        def get_attr_list(self):
            return self.attr_list

        def __repr__(self):
            return '%s(cmd=%s, attr_list=%s, version=0x%x, flags=0x%x)' % (
                class_name, repr(key_to_name[self.cmd]), repr(self.attr_list),
                self.version, self.flags)

        @staticmethod
        def unpack(data):
            cmd, version = struct.unpack(str('=BBxx'), data[:4])
            attr_list = key_to_attr_list_type[cmd].unpack(data[4:])
            return MessageType(cmd, attr_list)

        @staticmethod
        def pack(msg):
            s = array.array(
                str('B'), struct.pack(str('=BBxx'), msg.cmd, msg.version))
            s.extend(key_to_attr_list_type[msg.cmd].pack(msg.attr_list))
            return s

    return MessageType

# This is a global map of unpackers.  The @message_class decorator inserts
# new message classes into this map so it can be used for the purpose of
# deserializing netlink messages from NetlinkSocket::recv
Create a new genl_message_type which is a class offering the appropriate
dataset/ETHPy150Open facebook/gnlpy/netlink.py/create_genl_message_type