Lines Matching full:netlink

19 # Generic Netlink code which should really be in some library, but I can't quickly find one.
23 class Netlink: class
24 # Netlink socket
32 # Netlink message
106 return f"Netlink error: {os.strerror(self.error)}\n{self.nl_msg}"
128 self.type = self._type & ~Netlink.NLA_TYPE_MASK
129 self.is_nest = self._type & Netlink.NLA_F_NESTED
201 if self.nl_type == Netlink.NLMSG_ERROR:
205 elif self.nl_type == Netlink.NLMSG_DONE:
211 if self.nl_flags & Netlink.NLM_F_ACK_TLVS and extack_off:
215 if extack.type == Netlink.NLMSGERR_ATTR_MSG:
217 elif extack.type == Netlink.NLMSGERR_ATTR_MISS_TYPE:
219 elif extack.type == Netlink.NLMSGERR_ATTR_MISS_NEST:
221 elif extack.type == Netlink.NLMSGERR_ATTR_OFFS:
223 elif extack.type == Netlink.NLMSGERR_ATTR_POLICY:
243 if attr.type == Netlink.NL_POLICY_TYPE_ATTR_TYPE:
245 policy['type'] = Netlink.AttrType(type).name
246 elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MIN_VALUE_S:
248 elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MAX_VALUE_S:
250 elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MIN_VALUE_U:
252 elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MAX_VALUE_U:
254 elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MIN_LENGTH:
256 elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MAX_LENGTH:
258 elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_BITFIELD32_MASK:
260 elif attr.type == Netlink.NL_POLICY_TYPE_ATTR_MASK:
307 with socket.socket(socket.AF_NETLINK, socket.SOCK_RAW, Netlink.NETLINK_GENERIC) as sock:
308 sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_CAP_ACK, 1)
310 msg = _genl_msg(Netlink.GENL_ID_CTRL,
311 Netlink.NLM_F_REQUEST | Netlink.NLM_F_ACK | Netlink.NLM_F_DUMP,
312 Netlink.CTRL_CMD_GETFAMILY, 1)
325 print("Netlink error:", nl_msg.error)
333 if attr.type == Netlink.CTRL_ATTR_FAMILY_ID:
335 elif attr.type == Netlink.CTRL_ATTR_FAMILY_NAME:
337 elif attr.type == Netlink.CTRL_ATTR_MAXATTR:
339 elif attr.type == Netlink.CTRL_ATTR_MCAST_GROUPS:
345 if entry_attr.type == Netlink.CTRL_ATTR_MCAST_GRP_NAME:
347 elif entry_attr.type == Netlink.CTRL_ATTR_MCAST_GRP_ID:
408 super().__init__(family_name, Netlink.NETLINK_GENERIC)
467 if self.proto == "netlink-raw":
476 # Note that netlink will use conservative (min) message size for
480 # Netlink will always allocate at least PAGE_SIZE - sizeof(skb_shinfo)
487 self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_CAP_ACK, 1)
488 self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_EXT_ACK, 1)
489 self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_GET_STRICT_CHK, 1)
506 self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_ADD_MEMBERSHIP,
554 nl_type |= Netlink.NLA_F_NESTED
595 nl_type |= Netlink.NLA_F_NESTED
919 print("Netlink error in ntf!?", os.strerror(-nl_msg.error))
923 print("Netlink done while checking for ntf!?")
945 nl_flags = Netlink.NLM_F_REQUEST | Netlink.NLM_F_ACK
991 print("Netlink warning:")
994 if Netlink.NLM_F_DUMP in req_flags:
1029 req_flags.append(Netlink.NLM_F_DUMP)