コード例 #1
0
from pyroute2.common import map_namespace
from pyroute2.netlink import nlmsg

FR_ACT_UNSPEC = 0
FR_ACT_TO_TBL = 1
FR_ACT_GOTO = 2
FR_ACT_NOP = 3
FR_ACT_BLACKHOLE = 6
FR_ACT_UNREACHABLE = 7
FR_ACT_PROHIBIT = 8
(FR_ACT_NAMES, FR_ACT_VALUES) = map_namespace('FR_ACT', globals())


class fibmsg(nlmsg):
    '''
    IP rule message

    C structure::

        struct fib_rule_hdr {
            __u8        family;
            __u8        dst_len;
            __u8        src_len;
            __u8        tos;
            __u8        table;
            __u8        res1;   /* reserved */
            __u8        res2;   /* reserved */
            __u8        action;
            __u32       flags;
        };
    '''
コード例 #2
0
ファイル: __init__.py プロジェクト: ddyh2901/Webpage
NL80211_CMD_GET_COALESCE = 100
NL80211_CMD_SET_COALESCE = 101
NL80211_CMD_CHANNEL_SWITCH = 102
NL80211_CMD_VENDOR = 103
NL80211_CMD_SET_QOS_MAP = 104
NL80211_CMD_ADD_TX_TS = 105
NL80211_CMD_DEL_TX_TS = 106
NL80211_CMD_GET_MPP = 107
NL80211_CMD_JOIN_OCB = 108
NL80211_CMD_LEAVE_OCB = 109
NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 110
NL80211_CMD_TDLS_CHANNEL_SWITCH = 111
NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH = 112
NL80211_CMD_WIPHY_REG_CHANGE = 113
NL80211_CMD_MAX = NL80211_CMD_WIPHY_REG_CHANGE
(NL80211_NAMES, NL80211_VALUES) = map_namespace('NL80211_CMD_', globals())

NL80211_BSS_ELEMENTS_SSID = 0
NL80211_BSS_ELEMENTS_SUPPORTED_RATES = 1
NL80211_BSS_ELEMENTS_CHANNEL = 3
NL80211_BSS_ELEMENTS_TIM = 5
NL80211_BSS_ELEMENTS_RSN = 48
NL80211_BSS_ELEMENTS_EXTENDED_RATE = 50
NL80211_BSS_ELEMENTS_VENDOR = 221

BSS_MEMBERSHIP_SELECTOR_HT_PHY = 127
BSS_MEMBERSHIP_SELECTOR_VHT_PHY = 126

# interface types
NL80211_IFTYPE_UNSPECIFIED = 0
NL80211_IFTYPE_ADHOC = 1
コード例 #3
0
ファイル: arp.py プロジェクト: ddyh2901/Webpage
ARPHRD_FRAD = 770  # Frame Relay Access Device
ARPHRD_SKIP = 771  # SKIP vif
ARPHRD_LOOPBACK = 772  # Loopback device
ARPHRD_LOCALTLK = 773  # Localtalk device
ARPHRD_FDDI = 774  # Fiber Distributed Data Interface
ARPHRD_BIF = 775  # AP1000 BIF
ARPHRD_SIT = 776  # sit0 device - IPv6-in-IPv4
ARPHRD_IPDDP = 777  # IP over DDP tunneller
ARPHRD_IPGRE = 778  # GRE over IP
ARPHRD_PIMREG = 779  # PIMSM register interface
ARPHRD_HIPPI = 780  # High Performance Parallel Interface
ARPHRD_ASH = 781  # Nexus 64Mbps Ash
ARPHRD_ECONET = 782  # Acorn Econet
ARPHRD_IRDA = 783  # Linux-IrDA
# ARP works differently on different FC media .. so
ARPHRD_FCPP = 784  # Point to point fibrechannel
ARPHRD_FCAL = 785  # Fibrechannel arbitrated loop
ARPHRD_FCPL = 786  # Fibrechannel public loop
ARPHRD_FCFABRIC = 787  # Fibrechannel fabric
# 787->799 reserved for fibrechannel media types
ARPHRD_IEEE802_TR = 800  # Magic type ident for TR
ARPHRD_IEEE80211 = 801  # IEEE 802.11
ARPHRD_IEEE80211_PRISM = 802  # IEEE 802.11 + Prism2 header
ARPHRD_IEEE80211_RADIOTAP = 803  # IEEE 802.11 + radiotap header
ARPHRD_MPLS_TUNNEL = 899  # MPLS Tunnel Interface

ARPHRD_VOID = 0xFFFF  # Void type, nothing is known
ARPHRD_NONE = 0xFFFE  # zero header length

(ARPHRD_NAMES, ARPHRD_VALUES) = map_namespace("ARPHRD_", globals())
コード例 #4
0
ファイル: __init__.py プロジェクト: tmdzk/pyroute2
RTM_DELMDB = 85
RTM_GETMDB = 86
RTM_NEWNSID = 88
RTM_DELNSID = 89
RTM_GETNSID = 90
RTM_NEWSTATS = 92
RTM_GETSTATS = 94
RTM_NEWCACHEREPORT = 96
RTM_NEWLINKPROP = 108
RTM_DELLINKPROP = 109
RTM_GETLINKPROP = 110
# fake internal message types
RTM_NEWNETNS = 500
RTM_DELNETNS = 501
RTM_GETNETNS = 502
(RTM_NAMES, RTM_VALUES) = map_namespace('RTM_', globals())

TC_H_INGRESS = 0xfffffff1
TC_H_CLSACT = TC_H_INGRESS
TC_H_ROOT = 0xffffffff


RTMGRP_DEFAULTS = RTMGRP_IPV4_IFADDR |\
    RTMGRP_IPV6_IFADDR |\
    RTMGRP_IPV4_ROUTE |\
    RTMGRP_IPV6_ROUTE |\
    RTMGRP_IPV4_RULE |\
    RTMGRP_IPV6_RULE |\
    RTMGRP_NEIGH |\
    RTMGRP_LINK |\
    RTMGRP_TC |\
コード例 #5
0
IFF_NOTRAILERS = 0x20  # avoid use of trailers
IFF_RUNNING = 0x40  # interface RFC2863 OPER_UP
IFF_NOARP = 0x80  # no ARP protocol
IFF_PROMISC = 0x100  # receive all packets
IFF_ALLMULTI = 0x200  # receive all multicast packets
IFF_MASTER = 0x400  # master of a load balancer
IFF_SLAVE = 0x800  # slave of a load balancer
IFF_MULTICAST = 0x1000  # Supports multicast
IFF_PORTSEL = 0x2000  # can set media type
IFF_AUTOMEDIA = 0x4000  # auto media select active
IFF_DYNAMIC = 0x8000  # dialup device with changing addresses
IFF_LOWER_UP = 0x10000  # driver signals L1 up
IFF_DORMANT = 0x20000  # driver signals dormant
IFF_ECHO = 0x40000  # echo sent packets

(IFF_NAMES, IFF_VALUES) = map_namespace('IFF', globals())

IFF_MASK = IFF_UP |\
    IFF_DEBUG |\
    IFF_NOTRAILERS |\
    IFF_NOARP |\
    IFF_PROMISC |\
    IFF_ALLMULTI

IFF_VOLATILE = IFF_LOOPBACK |\
    IFF_POINTOPOINT |\
    IFF_BROADCAST |\
    IFF_ECHO |\
    IFF_MASTER |\
    IFF_SLAVE |\
    IFF_RUNNING |\
コード例 #6
0
ファイル: ndmsg.py プロジェクト: 0xD3ADB33F/pyroute2
NTF_ROUTER = 0x80

# neighbor cache entry states
NUD_INCOMPLETE = 0x01
NUD_REACHABLE = 0x02
NUD_STALE = 0x04
NUD_DELAY = 0x08
NUD_PROBE = 0x10
NUD_FAILED = 0x20

# dummy states
NUD_NOARP = 0x40
NUD_PERMANENT = 0x80
NUD_NONE = 0x00

(NTF_NAMES, NTF_VALUES) = map_namespace('NTF_', globals())
(NUD_NAMES, NUD_VALUES) = map_namespace('NUD_', globals())
flags = dict([(x[0][4:].lower(), x[1]) for x in NTF_NAMES.items()])
states = dict([(x[0][4:].lower(), x[1]) for x in NUD_NAMES.items()])


def states_a2n(s):
    # parse state string
    ss = s.split(',')
    ret = 0
    for state in ss:
        state = state.upper()
        if not state.startswith('NUD_'):
            state = 'NUD_' + state
        ret |= NUD_NAMES[state]
    return ret
コード例 #7
0
ファイル: iproute.py プロジェクト: rgacogne/pyroute2
RTM_NEWTCLASS = 40
RTM_DELTCLASS = 41
RTM_GETTCLASS = 42
RTM_NEWTFILTER = 44
RTM_DELTFILTER = 45
RTM_GETTFILTER = 46
RTM_NEWACTION = 48
RTM_DELACTION = 49
RTM_GETACTION = 50
RTM_NEWPREFIX = 52
RTM_GETMULTICAST = 58
RTM_GETANYCAST = 62
RTM_NEWNEIGHTBL = 64
RTM_GETNEIGHTBL = 66
RTM_SETNEIGHTBL = 67
(RTM_NAMES, RTM_VALUES) = map_namespace('RTM', globals())

TC_H_INGRESS = 0xfffffff1
TC_H_ROOT = 0xffffffff

RTNL_GROUPS = RTNLGRP_IPV4_IFADDR |\
    RTNLGRP_IPV6_IFADDR |\
    RTNLGRP_IPV4_ROUTE |\
    RTNLGRP_IPV6_ROUTE |\
    RTNLGRP_NEIGH |\
    RTNLGRP_LINK |\
    RTNLGRP_TC

rtypes = {'RTN_UNSPEC': 0,
          'RTN_UNICAST': 1,      # Gateway or direct route
          'RTN_LOCAL': 2,        # Accept locally
コード例 #8
0
ファイル: fibmsg.py プロジェクト: 0xD3ADB33F/pyroute2
from pyroute2.common import map_namespace
from pyroute2.netlink import nlmsg

FR_ACT_UNSPEC = 0
FR_ACT_TO_TBL = 1
FR_ACT_GOTO = 2
FR_ACT_NOP = 3
FR_ACT_BLACKHOLE = 6
FR_ACT_UNREACHABLE = 7
FR_ACT_PROHIBIT = 8
(FR_ACT_NAMES, FR_ACT_VALUES) = map_namespace('FR_ACT', globals())


class fibmsg(nlmsg):
    '''
    IP rule message

    C structure::

        struct fib_rule_hdr {
            __u8        family;
            __u8        dst_len;
            __u8        src_len;
            __u8        tos;
            __u8        table;
            __u8        res1;   /* reserved */
            __u8        res2;   /* reserved */
            __u8        action;
            __u32       flags;
        };
コード例 #9
0
ファイル: arp.py プロジェクト: bouttier/pyroute2
ARPHRD_FRAD = 770    # Frame Relay Access Device
ARPHRD_SKIP = 771    # SKIP vif
ARPHRD_LOOPBACK = 772    # Loopback device
ARPHRD_LOCALTLK = 773    # Localtalk device
ARPHRD_FDDI = 774    # Fiber Distributed Data Interface
ARPHRD_BIF = 775    # AP1000 BIF
ARPHRD_SIT = 776    # sit0 device - IPv6-in-IPv4
ARPHRD_IPDDP = 777    # IP over DDP tunneller
ARPHRD_IPGRE = 778    # GRE over IP
ARPHRD_PIMREG = 779    # PIMSM register interface
ARPHRD_HIPPI = 780    # High Performance Parallel Interface
ARPHRD_ASH = 781    # Nexus 64Mbps Ash
ARPHRD_ECONET = 782    # Acorn Econet
ARPHRD_IRDA = 783    # Linux-IrDA
## ARP works differently on different FC media .. so
ARPHRD_FCPP = 784    # Point to point fibrechannel
ARPHRD_FCAL = 785    # Fibrechannel arbitrated loop
ARPHRD_FCPL = 786    # Fibrechannel public loop
ARPHRD_FCFABRIC = 787    # Fibrechannel fabric
## 787->799 reserved for fibrechannel media types
ARPHRD_IEEE802_TR = 800    # Magic type ident for TR
ARPHRD_IEEE80211 = 801    # IEEE 802.11
ARPHRD_IEEE80211_PRISM = 802    # IEEE 802.11 + Prism2 header
ARPHRD_IEEE80211_RADIOTAP = 803    # IEEE 802.11 + radiotap header
ARPHRD_MPLS_TUNNEL = 899    # MPLS Tunnel Interface

ARPHRD_VOID = 0xFFFF    # Void type, nothing is known
ARPHRD_NONE = 0xFFFE    # zero header length

(ARPHRD_NAMES, ARPHRD_VALUES) = map_namespace("ARPHRD_", globals())
コード例 #10
0
IFF_NOTRAILERS = 0x20  # avoid use of trailers
IFF_RUNNING = 0x40  # interface RFC2863 OPER_UP
IFF_NOARP = 0x80  # no ARP protocol
IFF_PROMISC = 0x100  # receive all packets
IFF_ALLMULTI = 0x200  # receive all multicast packets
IFF_MASTER = 0x400  # master of a load balancer
IFF_SLAVE = 0x800  # slave of a load balancer
IFF_MULTICAST = 0x1000  # Supports multicast
IFF_PORTSEL = 0x2000  # can set media type
IFF_AUTOMEDIA = 0x4000  # auto media select active
IFF_DYNAMIC = 0x8000  # dialup device with changing addresses
IFF_LOWER_UP = 0x10000  # driver signals L1 up
IFF_DORMANT = 0x20000  # driver signals dormant
IFF_ECHO = 0x40000  # echo sent packets

(IFF_NAMES, IFF_VALUES) = map_namespace("IFF", globals())

IFF_MASK = IFF_UP | IFF_DEBUG | IFF_NOTRAILERS | IFF_NOARP | IFF_PROMISC | IFF_ALLMULTI

IFF_VOLATILE = (
    IFF_LOOPBACK
    | IFF_POINTOPOINT
    | IFF_BROADCAST
    | IFF_ECHO
    | IFF_MASTER
    | IFF_SLAVE
    | IFF_RUNNING
    | IFF_LOWER_UP
    | IFF_DORMANT
)
コード例 #11
0
ファイル: __init__.py プロジェクト: 0xD3ADB33F/pyroute2
DEVLINK_CMD_SB_POOL_SET = 16
DEVLINK_CMD_SB_POOL_NEW = 17
DEVLINK_CMD_SB_POOL_DEL = 18
DEVLINK_CMD_SB_PORT_POOL_GET = 19
DEVLINK_CMD_SB_PORT_POOL_SET = 20
DEVLINK_CMD_SB_PORT_POOL_NEW = 21
DEVLINK_CMD_SB_PORT_POOL_DEL = 22
DEVLINK_CMD_SB_TC_POOL_BIND_GET = 23
DEVLINK_CMD_SB_TC_POOL_BIND_SET = 24
DEVLINK_CMD_SB_TC_POOL_BIND_NEW = 25
DEVLINK_CMD_SB_TC_POOL_BIND_DEL = 26
DEVLINK_CMD_SB_OCC_SNAPSHOT = 27
DEVLINK_CMD_SB_OCC_MAX_CLEAR = 28
DEVLINK_CMD_MAX = DEVLINK_CMD_SB_OCC_MAX_CLEAR

(DEVLINK_NAMES, DEVLINK_VALUES) = map_namespace('DEVLINK_CMD_', globals())

# port type
DEVLINK_PORT_TYPE_NOTSET = 0
DEVLINK_PORT_TYPE_AUTO = 1
DEVLINK_PORT_TYPE_ETH = 2
DEVLINK_PORT_TYPE_IB = 3

# threshold type
DEVLINK_SB_POOL_TYPE_INGRESS = 0
DEVLINK_SB_POOL_TYPE_EGRESS = 1

DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX = 20


class devlinkcmd(genlmsg):
コード例 #12
0
ファイル: __init__.py プロジェクト: svinota/pyroute2
NL80211_CMD_GET_COALESCE = 100
NL80211_CMD_SET_COALESCE = 101
NL80211_CMD_CHANNEL_SWITCH = 102
NL80211_CMD_VENDOR = 103
NL80211_CMD_SET_QOS_MAP = 104
NL80211_CMD_ADD_TX_TS = 105
NL80211_CMD_DEL_TX_TS = 106
NL80211_CMD_GET_MPP = 107
NL80211_CMD_JOIN_OCB = 108
NL80211_CMD_LEAVE_OCB = 109
NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 110
NL80211_CMD_TDLS_CHANNEL_SWITCH = 111
NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH = 112
NL80211_CMD_WIPHY_REG_CHANGE = 113
NL80211_CMD_MAX = NL80211_CMD_WIPHY_REG_CHANGE
(NL80211_NAMES, NL80211_VALUES) = map_namespace('NL80211_CMD_', globals())

NL80211_BSS_ELEMENTS_SSID = 0
NL80211_BSS_ELEMENTS_SUPPORTED_RATES = 1
NL80211_BSS_ELEMENTS_CHANNEL = 3
NL80211_BSS_ELEMENTS_TIM = 5
NL80211_BSS_ELEMENTS_RSN = 48
NL80211_BSS_ELEMENTS_EXTENDED_RATE = 50
NL80211_BSS_ELEMENTS_VENDOR = 221

BSS_MEMBERSHIP_SELECTOR_HT_PHY = 127
BSS_MEMBERSHIP_SELECTOR_VHT_PHY = 126

# interface types
NL80211_IFTYPE_UNSPECIFIED = 0
NL80211_IFTYPE_ADHOC = 1
コード例 #13
0
ファイル: rtmsg.py プロジェクト: celebdor/pyroute2
from socket import inet_pton
from socket import AF_UNSPEC
from socket import AF_INET
from socket import AF_INET6
from pyroute2.common import AF_MPLS
from pyroute2.common import hexdump
from pyroute2.common import map_namespace
from pyroute2.netlink import nlmsg
from pyroute2.netlink import nla

RTNH_F_DEAD = 1
RTNH_F_PERVASIVE = 2
RTNH_F_ONLINK = 4
RTNH_F_OFFLOAD = 8
RTNH_F_LINKDOWN = 16
(RTNH_F_NAMES, RTNH_F_VALUES) = map_namespace('RTNH_F', globals())

LWTUNNEL_ENCAP_NONE = 0
LWTUNNEL_ENCAP_MPLS = 1
LWTUNNEL_ENCAP_IP = 2
LWTUNNEL_ENCAP_ILA = 3
LWTUNNEL_ENCAP_IP6 = 4
LWTUNNEL_ENCAP_SEG6 = 5
LWTUNNEL_ENCAP_BPF = 6
LWTUNNEL_ENCAP_SEG6_LOCAL = 7


class nlflags(object):

    def encode(self):
        if isinstance(self['flags'], (set, tuple, list)):
コード例 #14
0
ファイル: nl80211_scan.py プロジェクト: linuxlizard/duwt
NL80211_BSS_ELEMENTS_SSID = 0
NL80211_BSS_ELEMENTS_SUPPORTED_RATES = 1
NL80211_BSS_ELEMENTS_CHANNEL = 3
NL80211_BSS_ELEMENTS_TIM = 5
NL80211_BSS_ELEMENTS_COUNTRY = 7
NL80211_BSS_ELEMENTS_HT_CAPABILITIES = 45
NL80211_BSS_ELEMENTS_RSN = 48
NL80211_BSS_ELEMENTS_EXTENDED_RATE = 50
NL80211_BSS_ELEMENTS_HT_OPERATION = 61
NL80211_BSS_ELEMENTS_EXT_CAPABILITIES = 127
NL80211_BSS_ELEMENTS_VHT_CAPABILITIES = 191
NL80211_BSS_ELEMENTS_VHT_OPERATION = 192
NL80211_BSS_ELEMENTS_VENDOR = 221
(NL80211_BSS_ELEMENTS_NAMES, NL80211_BSS_ELEMENTS_VALUES) =\
    map_namespace('NL80211_BSS_ELEMENTS_', globals())

BSS_MEMBERSHIP_SELECTOR_HT_PHY = 127
BSS_MEMBERSHIP_SELECTOR_VHT_PHY = 126

OUI_IEEE = "00-0f-ac"
OUI_MSFT = "00-50-f2"
OUI_WFA = "50-6f-9a"


class IE:
    # note: using the raw integers in the descendents so can keep the hierarchy
    # in numerical order
    ID = -1

    Grammar = collections.namedtuple("Grammar", ("offset", "mask", "name"))
コード例 #15
0
DEVLINK_CMD_SB_POOL_SET = 16
DEVLINK_CMD_SB_POOL_NEW = 17
DEVLINK_CMD_SB_POOL_DEL = 18
DEVLINK_CMD_SB_PORT_POOL_GET = 19
DEVLINK_CMD_SB_PORT_POOL_SET = 20
DEVLINK_CMD_SB_PORT_POOL_NEW = 21
DEVLINK_CMD_SB_PORT_POOL_DEL = 22
DEVLINK_CMD_SB_TC_POOL_BIND_GET = 23
DEVLINK_CMD_SB_TC_POOL_BIND_SET = 24
DEVLINK_CMD_SB_TC_POOL_BIND_NEW = 25
DEVLINK_CMD_SB_TC_POOL_BIND_DEL = 26
DEVLINK_CMD_SB_OCC_SNAPSHOT = 27
DEVLINK_CMD_SB_OCC_MAX_CLEAR = 28
DEVLINK_CMD_MAX = DEVLINK_CMD_SB_OCC_MAX_CLEAR

(DEVLINK_NAMES, DEVLINK_VALUES) = map_namespace('DEVLINK_CMD_', globals())

# port type
DEVLINK_PORT_TYPE_NOTSET = 0
DEVLINK_PORT_TYPE_AUTO = 1
DEVLINK_PORT_TYPE_ETH = 2
DEVLINK_PORT_TYPE_IB = 3

# threshold type
DEVLINK_SB_POOL_TYPE_INGRESS = 0
DEVLINK_SB_POOL_TYPE_EGRESS = 1

DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX = 20


class devlinkcmd(genlmsg):
コード例 #16
0
NL80211_CMD_GET_COALESCE = 100
NL80211_CMD_SET_COALESCE = 101
NL80211_CMD_CHANNEL_SWITCH = 102
NL80211_CMD_VENDOR = 103
NL80211_CMD_SET_QOS_MAP = 104
NL80211_CMD_ADD_TX_TS = 105
NL80211_CMD_DEL_TX_TS = 106
NL80211_CMD_GET_MPP = 107
NL80211_CMD_JOIN_OCB = 108
NL80211_CMD_LEAVE_OCB = 109
NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 110
NL80211_CMD_TDLS_CHANNEL_SWITCH = 111
NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH = 112
NL80211_CMD_WIPHY_REG_CHANGE = 113
NL80211_CMD_MAX = NL80211_CMD_WIPHY_REG_CHANGE
(NL80211_NAMES, NL80211_VALUES) = map_namespace('NL80211_CMD_', globals())

NL80211_BSS_ELEMENTS_SSID = 0
NL80211_BSS_ELEMENTS_SUPPORTED_RATES = 1
NL80211_BSS_ELEMENTS_CHANNEL = 3
NL80211_BSS_ELEMENTS_VENDOR = 221

BSS_MEMBERSHIP_SELECTOR_HT_PHY = 127
BSS_MEMBERSHIP_SELECTOR_VHT_PHY = 126


class nl80211cmd(genlmsg):
    nla_map = (
        ('NL80211_ATTR_UNSPEC', 'none'), ('NL80211_ATTR_WIPHY', 'hex'),
        ('NL80211_ATTR_WIPHY_NAME',
         'asciiz'), ('NL80211_ATTR_IFINDEX', 'uint32'), ('NL80211_ATTR_IFNAME',
コード例 #17
0
IFF_NOTRAILERS = 0x20  # avoid use of trailers
IFF_RUNNING = 0x40  # interface RFC2863 OPER_UP
IFF_NOARP = 0x80  # no ARP protocol
IFF_PROMISC = 0x100  # receive all packets
IFF_ALLMULTI = 0x200  # receive all multicast packets
IFF_MASTER = 0x400  # master of a load balancer
IFF_SLAVE = 0x800  # slave of a load balancer
IFF_MULTICAST = 0x1000  # Supports multicast
IFF_PORTSEL = 0x2000  # can set media type
IFF_AUTOMEDIA = 0x4000  # auto media select active
IFF_DYNAMIC = 0x8000  # dialup device with changing addresses
IFF_LOWER_UP = 0x10000  # driver signals L1 up
IFF_DORMANT = 0x20000  # driver signals dormant
IFF_ECHO = 0x40000  # echo sent packets

(IFF_NAMES, IFF_VALUES) = map_namespace('IFF', globals())

IFF_MASK = IFF_UP |\
    IFF_DEBUG |\
    IFF_NOTRAILERS |\
    IFF_NOARP |\
    IFF_PROMISC |\
    IFF_ALLMULTI

IFF_VOLATILE = IFF_LOOPBACK |\
    IFF_POINTOPOINT |\
    IFF_BROADCAST |\
    IFF_ECHO |\
    IFF_MASTER |\
    IFF_SLAVE |\
    IFF_RUNNING |\
コード例 #18
0
ファイル: __init__.py プロジェクト: craneworks/pyroute2
IFF_NOTRAILERS = 0x20  # avoid use of trailers
IFF_RUNNING = 0x40  # interface RFC2863 OPER_UP
IFF_NOARP = 0x80  # no ARP protocol
IFF_PROMISC = 0x100  # receive all packets
IFF_ALLMULTI = 0x200  # receive all multicast packets
IFF_MASTER = 0x400  # master of a load balancer
IFF_SLAVE = 0x800  # slave of a load balancer
IFF_MULTICAST = 0x1000  # Supports multicast
IFF_PORTSEL = 0x2000  # can set media type
IFF_AUTOMEDIA = 0x4000  # auto media select active
IFF_DYNAMIC = 0x8000  # dialup device with changing addresses
IFF_LOWER_UP = 0x10000  # driver signals L1 up
IFF_DORMANT = 0x20000  # driver signals dormant
IFF_ECHO = 0x40000  # echo sent packets

(IFF_NAMES, IFF_VALUES) = map_namespace('IFF', globals())

IFF_MASK = IFF_UP |\
    IFF_DEBUG |\
    IFF_NOTRAILERS |\
    IFF_NOARP |\
    IFF_PROMISC |\
    IFF_ALLMULTI

IFF_VOLATILE = IFF_LOOPBACK |\
    IFF_POINTOPOINT |\
    IFF_BROADCAST |\
    IFF_ECHO |\
    IFF_MASTER |\
    IFF_SLAVE |\
    IFF_RUNNING |\
コード例 #19
0
ファイル: ifinfmsg.py プロジェクト: bschlinker/pyroute2
IFF_NOTRAILERS = 0x20  # avoid use of trailers
IFF_RUNNING = 0x40  # interface RFC2863 OPER_UP
IFF_NOARP = 0x80  # no ARP protocol
IFF_PROMISC = 0x100  # receive all packets
IFF_ALLMULTI = 0x200  # receive all multicast packets
IFF_MASTER = 0x400  # master of a load balancer
IFF_SLAVE = 0x800  # slave of a load balancer
IFF_MULTICAST = 0x1000  # Supports multicast
IFF_PORTSEL = 0x2000  # can set media type
IFF_AUTOMEDIA = 0x4000  # auto media select active
IFF_DYNAMIC = 0x8000  # dialup device with changing addresses
IFF_LOWER_UP = 0x10000  # driver signals L1 up
IFF_DORMANT = 0x20000  # driver signals dormant
IFF_ECHO = 0x40000  # echo sent packets

(IFF_NAMES, IFF_VALUES) = map_namespace('IFF', globals())

IFF_MASK = IFF_UP |\
    IFF_DEBUG |\
    IFF_NOTRAILERS |\
    IFF_NOARP |\
    IFF_PROMISC |\
    IFF_ALLMULTI

IFF_VOLATILE = IFF_LOOPBACK |\
    IFF_POINTOPOINT |\
    IFF_BROADCAST |\
    IFF_ECHO |\
    IFF_MASTER |\
    IFF_SLAVE |\
    IFF_RUNNING |\
コード例 #20
0
ファイル: fibmsg.py プロジェクト: abn/pyroute2
from pyroute2.common import map_namespace
from pyroute2.netlink import nlmsg

FR_ACT_UNSPEC = 0
FR_ACT_TO_TBL = 1
FR_ACT_GOTO = 2
FR_ACT_NOP = 3
FR_ACT_BLACKHOLE = 6
FR_ACT_UNREACHABLE = 7
FR_ACT_PROHIBIT = 8
(FR_ACT_NAMES, FR_ACT_VALUES) = map_namespace("FR_ACT", globals())


class fibmsg(nlmsg):
    """
    IP rule message

    C structure::

        struct fib_rule_hdr {
            __u8        family;
            __u8        dst_len;
            __u8        src_len;
            __u8        tos;
            __u8        table;
            __u8        res1;   /* reserved */
            __u8        res2;   /* reserved */
            __u8        action;
            __u32       flags;
        };
    """
コード例 #21
0
IFF_BROADCAST = 0x2
IFF_DEBUG = 0x4
IFF_LOOPBACK = 0x8
IFF_POINTOPOINT = 0x10
IFF_STATICARP = 0x20
IFF_RUNNING = 0x40
IFF_NOARP = 0x80
IFF_PROMISC = 0x100
IFF_ALLMULTI = 0x200
IFF_OACTIVE = 0x400
IFF_SIMPLEX = 0x800
IFF_LINK0 = 0x1000
IFF_LINK1 = 0x2000
IFF_LINK2 = 0x4000
IFF_MULTICAST = 0x8000
(IFF_NAMES, IFF_VALUES) = map_namespace('IFF', globals())


class bsdmsg(nlmsg_base):

    __slots__ = ()
    header = (('length', 'H'), ('version', 'B'), ('type', 'B'), ('hdrlen',
                                                                 'H'))


class if_msg(bsdmsg):

    __slots__ = ()
    fields = (('ifm_index', 'H'), ('ifm_tableid', 'H'), ('ifm_pad1', 'B'),
              ('ifm_pad2', 'B'), ('ifm_addrs', 'i'), ('ifm_flags', 'i'),
              ('ifm_xflags', 'i'), ('ifi_type', 'B'), ('ifi_addrlen', 'B'),
コード例 #22
0
# GENZ_GENL_FAMILY_NAME   = 'genz_cmd'
# GENZ_GENL_VERSION       = 1

# Commands are matched from kern_recv.c::struct genl_ops genz_gnl_ops.
# Kernel convention is not to use zero as an index or base value.

GENZ_C_PREFIX            = 'GENZ_C_'

GENZ_C_ADD_COMPONENT     = 1    # from genz_genl.h "enum"
GENZ_C_REMOVE_COMPONENT  = 2
GENZ_C_SYMLINK_COMPONENT = 3

# Coalesce the commands into a forward and reverse map.
# From https://www.open-mesh.org/attachments/857/neighbor_extend_dump.py

(GENZ_C_name2num, GENZ_C_num2name) = map_namespace(GENZ_C_PREFIX, globals())
# These mixins are given to pyroute2 to build packed structs for sending to
# C routines (libnl).  They're just linked lookup tables whose attributes are
# proscribed by internals.  The choices for encoding (uint32, asciiz, etc)
# are each a class in netlink/__init.__.py "class nlmsg_atoms".  If you
# don't like those choices, add a class here then add it as a new class
# attribute to nlmsg.  Only override __init__ for a set_trace, nothing else.
# See also netlink/__init__.py::register_nlas() for optional fields.


class DefaultMessageModel(genlmsg):
    """
        The set of all Netlink Attributes (NLAs) that could be passed.
    This is the analog of the kernel "struct nla_policy".
    """
コード例 #23
0
ファイル: __init__.py プロジェクト: sebschrader/pyroute2
NL80211_CMD_GET_COALESCE = 100
NL80211_CMD_SET_COALESCE = 101
NL80211_CMD_CHANNEL_SWITCH = 102
NL80211_CMD_VENDOR = 103
NL80211_CMD_SET_QOS_MAP = 104
NL80211_CMD_ADD_TX_TS = 105
NL80211_CMD_DEL_TX_TS = 106
NL80211_CMD_GET_MPP = 107
NL80211_CMD_JOIN_OCB = 108
NL80211_CMD_LEAVE_OCB = 109
NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 110
NL80211_CMD_TDLS_CHANNEL_SWITCH = 111
NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH = 112
NL80211_CMD_WIPHY_REG_CHANGE = 113
NL80211_CMD_MAX = NL80211_CMD_WIPHY_REG_CHANGE
(NL80211_NAMES, NL80211_VALUES) = map_namespace('NL80211_CMD_', globals())

NL80211_BSS_ELEMENTS_SSID = 0
NL80211_BSS_ELEMENTS_SUPPORTED_RATES = 1
NL80211_BSS_ELEMENTS_CHANNEL = 3
NL80211_BSS_ELEMENTS_TIM = 5
NL80211_BSS_ELEMENTS_EXTENDED_RATE = 50
NL80211_BSS_ELEMENTS_VENDOR = 221

BSS_MEMBERSHIP_SELECTOR_HT_PHY = 127
BSS_MEMBERSHIP_SELECTOR_VHT_PHY = 126

# interface types
NL80211_IFTYPE_UNSPECIFIED = 0
NL80211_IFTYPE_ADHOC = 1
NL80211_IFTYPE_STATION = 2
コード例 #24
0
ファイル: __init__.py プロジェクト: 0x90/pyroute2
NL80211_CMD_GET_COALESCE = 100
NL80211_CMD_SET_COALESCE = 101
NL80211_CMD_CHANNEL_SWITCH = 102
NL80211_CMD_VENDOR = 103
NL80211_CMD_SET_QOS_MAP = 104
NL80211_CMD_ADD_TX_TS = 105
NL80211_CMD_DEL_TX_TS = 106
NL80211_CMD_GET_MPP = 107
NL80211_CMD_JOIN_OCB = 108
NL80211_CMD_LEAVE_OCB = 109
NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 110
NL80211_CMD_TDLS_CHANNEL_SWITCH = 111
NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH = 112
NL80211_CMD_WIPHY_REG_CHANGE = 113
NL80211_CMD_MAX = NL80211_CMD_WIPHY_REG_CHANGE
(NL80211_NAMES, NL80211_VALUES) = map_namespace('NL80211_CMD_', globals())

NL80211_BSS_ELEMENTS_SSID = 0
NL80211_BSS_ELEMENTS_SUPPORTED_RATES = 1
NL80211_BSS_ELEMENTS_CHANNEL = 3
NL80211_BSS_ELEMENTS_VENDOR = 221

BSS_MEMBERSHIP_SELECTOR_HT_PHY = 127
BSS_MEMBERSHIP_SELECTOR_VHT_PHY = 126


class nl80211cmd(genlmsg):
    nla_map = (('NL80211_ATTR_UNSPEC', 'none'),
               ('NL80211_ATTR_WIPHY', 'hex'),
               ('NL80211_ATTR_WIPHY_NAME', 'asciiz'),
               ('NL80211_ATTR_IFINDEX', 'uint32'),
コード例 #25
0
NTF_ROUTER = 0x80

# neighbor cache entry states
NUD_INCOMPLETE = 0x01
NUD_REACHABLE = 0x02
NUD_STALE = 0x04
NUD_DELAY = 0x08
NUD_PROBE = 0x10
NUD_FAILED = 0x20

# dummy states
NUD_NOARP = 0x40
NUD_PERMANENT = 0x80
NUD_NONE = 0x00

(NTF_NAMES, NTF_VALUES) = map_namespace('NTF_', globals())
(NUD_NAMES, NUD_VALUES) = map_namespace('NUD_', globals())
flags = dict([(x[0][4:].lower(), x[1]) for x in NTF_NAMES.items()])
states = dict([(x[0][4:].lower(), x[1]) for x in NUD_NAMES.items()])


def states_a2n(s):
    # parse state string
    ss = s.split(',')
    ret = 0
    for state in ss:
        state = state.upper()
        if not state.startswith('NUD_'):
            state = 'NUD_' + state
        ret |= NUD_NAMES[state]
    return ret
コード例 #26
0
ファイル: __init__.py プロジェクト: roolebo/pyroute2
NL80211_CMD_GET_COALESCE = 100
NL80211_CMD_SET_COALESCE = 101
NL80211_CMD_CHANNEL_SWITCH = 102
NL80211_CMD_VENDOR = 103
NL80211_CMD_SET_QOS_MAP = 104
NL80211_CMD_ADD_TX_TS = 105
NL80211_CMD_DEL_TX_TS = 106
NL80211_CMD_GET_MPP = 107
NL80211_CMD_JOIN_OCB = 108
NL80211_CMD_LEAVE_OCB = 109
NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 110
NL80211_CMD_TDLS_CHANNEL_SWITCH = 111
NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH = 112
NL80211_CMD_WIPHY_REG_CHANGE = 113
NL80211_CMD_MAX = NL80211_CMD_WIPHY_REG_CHANGE
(NL80211_NAMES, NL80211_VALUES) = map_namespace("NL80211_CMD_", globals())

NL80211_BSS_ELEMENTS_SSID = 0
NL80211_BSS_ELEMENTS_SUPPORTED_RATES = 1
NL80211_BSS_ELEMENTS_CHANNEL = 3
NL80211_BSS_ELEMENTS_TIM = 5
NL80211_BSS_ELEMENTS_EXTENDED_RATE = 50
NL80211_BSS_ELEMENTS_VENDOR = 221

BSS_MEMBERSHIP_SELECTOR_HT_PHY = 127
BSS_MEMBERSHIP_SELECTOR_VHT_PHY = 126

# interface types
NL80211_IFTYPE_UNSPECIFIED = 0
NL80211_IFTYPE_ADHOC = 1
NL80211_IFTYPE_STATION = 2
コード例 #27
0
from socket import inet_pton
from socket import AF_UNSPEC
from socket import AF_INET
from socket import AF_INET6
from pyroute2.common import AF_MPLS
from pyroute2.common import hexdump
from pyroute2.common import map_namespace
from pyroute2.netlink import nlmsg
from pyroute2.netlink import nla

RTNH_F_DEAD = 1
RTNH_F_PERVASIVE = 2
RTNH_F_ONLINK = 4
RTNH_F_OFFLOAD = 8
RTNH_F_LINKDOWN = 16
(RTNH_F_NAMES, RTNH_F_VALUES) = map_namespace('RTNH_F', globals())

LWTUNNEL_ENCAP_NONE = 0
LWTUNNEL_ENCAP_MPLS = 1
LWTUNNEL_ENCAP_IP = 2
LWTUNNEL_ENCAP_ILA = 3
LWTUNNEL_ENCAP_IP6 = 4
LWTUNNEL_ENCAP_SEG6 = 5
LWTUNNEL_ENCAP_BPF = 6
LWTUNNEL_ENCAP_SEG6_LOCAL = 7


class nlflags(object):

    def encode(self):
        if isinstance(self['flags'], (set, tuple, list)):
コード例 #28
0
ファイル: iproute.py プロジェクト: vnvo/pyroute2
RTM_NEWTCLASS = 40
RTM_DELTCLASS = 41
RTM_GETTCLASS = 42
RTM_NEWTFILTER = 44
RTM_DELTFILTER = 45
RTM_GETTFILTER = 46
RTM_NEWACTION = 48
RTM_DELACTION = 49
RTM_GETACTION = 50
RTM_NEWPREFIX = 52
RTM_GETMULTICAST = 58
RTM_GETANYCAST = 62
RTM_NEWNEIGHTBL = 64
RTM_GETNEIGHTBL = 66
RTM_SETNEIGHTBL = 67
(RTM_NAMES, RTM_VALUES) = map_namespace("RTM", globals())

rtypes = {
    "RTN_UNSPEC": 0,
    "RTN_UNICAST": 1,  # Gateway or direct route
    "RTN_LOCAL": 2,  # Accept locally
    "RTN_BROADCAST": 3,  # Accept locally as broadcast
    #                        send as broadcast
    "RTN_ANYCAST": 4,  # Accept locally as broadcast,
    #                        but send as unicast
    "RTN_MULTICAST": 5,  # Multicast route
    "RTN_BLACKHOLE": 6,  # Drop
    "RTN_UNREACHABLE": 7,  # Destination is unreachable
    "RTN_PROHIBIT": 8,  # Administratively prohibited
    "RTN_THROW": 9,  # Not in this table
    "RTN_NAT": 10,  # Translate this address