Python socket 模块,AF_NETLINK 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用socket.AF_NETLINK

项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def createText(self):
        syscall = self.function.name
        name = self.name
        argtype = self.type
        value = self.value
        if syscall == "socket":
            if name == "family":
                return SOCKET_FAMILY.get(value, value)
            if name == "type":
                return SOCKET_TYPE.get(value, value)
            if name == "protocol":
                return SOCKET_PROTOCOL.get(value, value)
        if syscall == "setsockopt":
            if name == "level":
                return SETSOCKOPT_LEVEL.get(value, value)
            if name == "optname":
                return SETSOCKOPT_OPTNAME.get(value, value)
            if name == "optval":
                optlen = self.function["optlen"].value
                if optlen == 4:
                    text = self.function.process.readStruct(self.value, c_int)
                    return self.formatPointer("<%s>" % text, self.value)
        if argtype == "struct sockaddr*":
            address = self.value
            addr = self.function.process.readStruct(address, sockaddr)
            family = addr.family
            if family == AF_INET:
                return self.readStruct(self.value, sockaddr_in)
            elif family == AF_FILE:
                return self.readStruct(self.value, sockaddr_un)
            elif family == AF_NETLINK:
                return self.readStruct(self.value, sockaddr_nl)
            else:
                family = SOCKET_FAMILY.get(family, family)
                return self.formatPointer("<sockaddr family=%s>" % family, address)
        return None
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def __init__(self):
        NETLINK_KOBJECT_UEVENT = 15 # hasn't landed in socket yet, see linux/netlink.h
        socket.socket.__init__(self, socket.AF_NETLINK, socket.SOCK_DGRAM, NETLINK_KOBJECT_UEVENT)
        self.bind((os.getpid(), -1))
项目:enigma2    作者:Openeight    | 项目源码 | 文件源码
def __init__(self):
        NETLINK_KOBJECT_UEVENT = 15 # hasn't landed in socket yet, see linux/netlink.h
        socket.socket.__init__(self, socket.AF_NETLINK, socket.SOCK_DGRAM, NETLINK_KOBJECT_UEVENT)
        self.bind((os.getpid(), -1))
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def __init__(self):
        NETLINK_KOBJECT_UEVENT = 15 # hasn't landed in socket yet, see linux/netlink.h
        socket.socket.__init__(self, socket.AF_NETLINK, socket.SOCK_DGRAM, NETLINK_KOBJECT_UEVENT)
        self.bind((os.getpid(), -1))
项目:python-ptrace    作者:vstinner    | 项目源码 | 文件源码
def formatSockaddr(argument, argtype):
    address = argument.value
    value = argument.function.process.readStruct(address, sockaddr)
    family = value.family
    if family == AF_INET:
        return argument.readStruct(address, sockaddr_in)
    if family == AF_INET6:
        return argument.readStruct(address, sockaddr_in6)
    if family == AF_FILE:
        return argument.readStruct(address, sockaddr_un)
    if RUNNING_LINUX:
        if family == AF_NETLINK:
            return argument.readStruct(address, sockaddr_nl)
    family = SOCKET_FAMILY.get(family, family)
    return argument.formatPointer("<sockaddr family=%s>" % family, address)
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
def __init__(self):
        NETLINK_KOBJECT_UEVENT = 15 # hasn't landed in socket yet, see linux/netlink.h
        socket.socket.__init__(self, socket.AF_NETLINK, socket.SOCK_DGRAM, NETLINK_KOBJECT_UEVENT)
        self.bind((os.getpid(), -1))