Python socket.AF_NETLINK() Examples

The following are code examples for showing how to use socket.AF_NETLINK(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: darkc0de-old-stuff   Author: tuwid   File: socketcall_call.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
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 
Example 2
Project: enigma2   Author: OpenLD   File: Netlink.py    (license) View Source Project 5 votes vote down vote up
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)) 
Example 3
Project: enigma2   Author: Openeight   File: Netlink.py    (license) View Source Project 5 votes vote down vote up
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)) 
Example 4
Project: enigma2   Author: BlackHole   File: Netlink.py    (license) View Source Project 5 votes vote down vote up
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)) 
Example 5
Project: python-ptrace   Author: vstinner   File: socketcall.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 6
Project: enigma2-openpli-fulan   Author: Taapat   File: Netlink.py    (license) View Source Project 5 votes vote down vote up
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))