def family_constructor(c): """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/family.c#L37. Positional arguments: c -- nl_object-derived class instance. """ family = c if not hasattr(family, 'gf_ops'): setattr(family, 'gf_ops', nl_list_head(container_of=family)) if not hasattr(family, 'gf_mc_grps'): setattr(family, 'gf_mc_grps', nl_list_head(container_of=family)) nl_init_list_head(family.gf_ops) nl_init_list_head(family.gf_mc_grps)
def __init__(self): """Constructor.""" self.ce_refcnt = 0 self.ce_ops = None self.ce_cache = None self.ce_list = nl_list_head(container_of=self) self.ce_msgtype = 0 self.ce_flags = 0 self.ce_mask = 0
def __init__(self, o_hdrsize=0, o_id=0, o_name='', o_cache_ops=None, o_cmds=None, o_ncmds=0, o_list=None): """Constructor.""" self.o_hdrsize = o_hdrsize self.o_id = o_id self.o_name = o_name self.o_cache_ops = o_cache_ops self.o_cmds = o_cmds self.o_ncmds = o_ncmds self.o_list = o_list or nl_list_head() self.o_list.container_of = self
def family_free_data(c): """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/family.c#L45. Positional arguments: c -- nl_object-derived class instance. """ family = c if not hasattr(family, 'gf_ops'): setattr(family, 'gf_ops', nl_list_head(container_of=family)) if not hasattr(family, 'gf_mc_grps'): setattr(family, 'gf_mc_grps', nl_list_head(container_of=family)) ops = tmp = genl_family_op() grp = t_grp = genl_family_grp() if family is None: return for ops in nl_list_for_each_entry_safe(ops, tmp, family.gf_ops, 'o_list'): nl_list_del(ops.o_list) for grp in nl_list_for_each_entry_safe(grp, t_grp, family.gf_mc_grps, 'list_'): nl_list_del(grp.list_)
def __init__(self, nlo=None): """Constructor.""" super(genl_family, self).__init__() self.gf_id = 0 self.gf_name = None self.gf_version = 0 self.gf_hdrsize = 0 self.gf_maxattr = 0 self.gf_ops = nl_list_head(container_of=self) self.gf_mc_grps = nl_list_head(container_of=self) # "Cast" from nl_object instance. if nlo: self.ce_refcnt = nlo.ce_refcnt self.ce_ops = nlo.ce_ops self.ce_cache = nlo.ce_cache self.ce_list = nlo.ce_list self.ce_msgtype = nlo.ce_msgtype self.ce_flags = nlo.ce_flags self.ce_mask = nlo.ce_mask self.gf_ops = nlo.gf_ops self.gf_ops.container_of = self self.gf_mc_grps = nlo.gf_mc_grps self.gf_mc_grps.container_of = self
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation version 2.1 of the License. """ from libnl.cache_mngt import nl_cache_mngt_register from libnl.errno_ import NLE_EXIST, NLE_INVAL, NLE_MSGTYPE_NOSUPPORT, NLE_OPNOTSUPP, NLE_PROTO_MISMATCH from libnl.genl.genl import genlmsg_hdr, genlmsg_user_hdr from libnl.linux_private.genetlink import GENL_HDRLEN, GENL_HDRSIZE from libnl.linux_private.netlink import NETLINK_GENERIC from libnl.list_ import nl_list_add_tail, nl_list_for_each_entry, nl_list_head from libnl.msg import nlmsg_parse from libnl.netlink_private.netlink import BUG genl_ops_list = nl_list_head() # https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/mngt.c#L31 genl_ops_list.next_ = genl_ops_list.prev = genl_ops_list def lookup_cmd(ops, cmd_id): """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/mngt.c#L33. Positional arguments: ops -- genl_ops class instance. cmd_id -- integer. Returns: genl_cmd class instance or None. """ for i in range(ops.o_ncmds): cmd = ops.o_cmds[i]
def __init__(self, family=None, list_=None, name='', id_=0): """Constructor.""" self.family = family self.list_ = list_ or nl_list_head(container_of=self) self.name = name self.id_ = id_