tools/net/ynl/pyynl/lib/ynl.py

Source file repositories/reference/linux-study-clean/tools/net/ynl/pyynl/lib/ynl.py

File Facts

System
Linux kernel
Corpus path
tools/net/ynl/pyynl/lib/ynl.py
Extension
.py
Size
55911 bytes
Lines
1462
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
#
# pylint: disable=missing-class-docstring, missing-function-docstring
# pylint: disable=too-many-branches, too-many-locals, too-many-instance-attributes
# pylint: disable=too-many-lines

"""
YAML Netlink Library

An implementation of the genetlink and raw netlink protocols.
"""

from collections import namedtuple
from enum import Enum
import functools
import os
import random
import socket
import struct
from struct import Struct
import sys
import ipaddress
import uuid
import queue
import selectors
import time

from .nlspec import SpecFamily

#
# Generic Netlink code which should really be in some library, but I can't quickly find one.
#


class YnlException(Exception):
    pass


# pylint: disable=too-few-public-methods
class Netlink:
    # Netlink socket
    SOL_NETLINK = 270

    NETLINK_ADD_MEMBERSHIP = 1
    NETLINK_LISTEN_ALL_NSID = 8
    NETLINK_CAP_ACK = 10
    NETLINK_EXT_ACK = 11
    NETLINK_GET_STRICT_CHK = 12

    # Netlink message
    NLMSG_ERROR = 2
    NLMSG_DONE = 3

    NLM_F_REQUEST = 1
    NLM_F_ACK = 4
    NLM_F_ROOT = 0x100
    NLM_F_MATCH = 0x200

    NLM_F_REPLACE = 0x100
    NLM_F_EXCL = 0x200
    NLM_F_CREATE = 0x400
    NLM_F_APPEND = 0x800

    NLM_F_CAPPED = 0x100
    NLM_F_ACK_TLVS = 0x200

    NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH

    NLA_F_NESTED = 0x8000
    NLA_F_NET_BYTEORDER = 0x4000

Annotation

Implementation Notes