Python fcntl.ioctl() Examples
The following are 30
code examples of fcntl.ioctl().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
fcntl
, or try the search function
.
Example #1
Source File: ip.py From pynmap with GNU General Public License v3.0 | 8 votes |
def getLocalip(interface: str = "wlan0") -> str: """This function will return the Local IP Address of the interface""" if "nux" in sys.platform: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: return socket.inet_ntoa( fcntl.ioctl( s.fileno(), 0x8915, struct.pack('256s',interface[:15]) )[20:24] ) except IOError: print("{}[!] Error, unable to detect local ip address.".format(Colors.FAIL)) print("[!] Check your connection to network {}".format(Colors.ENDC)) exit() elif "darwin" in sys.platform: return [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][0]
Example #2
Source File: terminalsize.py From asciidots with GNU Affero General Public License v3.0 | 7 votes |
def _get_terminal_size_linux(): def ioctl_GWINSZ(fd): try: import fcntl import termios cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) return cr except: pass cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) if not cr: try: fd = os.open(os.ctermid(), os.O_RDONLY) cr = ioctl_GWINSZ(fd) os.close(fd) except: pass if not cr: try: cr = (os.environ['LINES'], os.environ['COLUMNS']) except: return None return int(cr[1]), int(cr[0])
Example #3
Source File: joystick.py From derplearning with MIT License | 7 votes |
def __connect(self): device_addr, hidraw_device, event_device = self.__find_device() if device_addr is None: return False self.__report_fd = os.open(hidraw_device, os.O_RDWR | os.O_NONBLOCK) self.__fd = FileIO(self.__report_fd, "rb+", closefd=False) self.__input_device = InputDevice(event_device) self.__input_device.grab() buf = bytearray(38) buf[0] = 0x02 try: return bool(fcntl.ioctl(self.__fd, 3223734279, bytes(buf))) except: pass if self.recv(): self.update_controller()
Example #4
Source File: smbus.py From Adafruit_Python_PureIO with MIT License | 7 votes |
def read_byte_data(self, addr, cmd): """Read a single byte from the specified cmd register of the device.""" assert ( self._device is not None ), "Bus must be opened before operations are made against it!" # Build ctypes values to marshall between ioctl and Python. reg = c_uint8(cmd) result = c_uint8() # Build ioctl request. request = make_i2c_rdwr_data( [ (addr, 0, 1, pointer(reg)), # Write cmd register. (addr, I2C_M_RD, 1, pointer(result)), # Read 1 byte as result. ] ) # Make ioctl call and return result data. ioctl(self._device.fileno(), I2C_RDWR, request) return result.value
Example #5
Source File: rmUtils.py From rainmachine-developer-resources with GNU General Public License v3.0 | 6 votes |
def getAlarmElapsedRealTime(): ### This method is used on Android to get the UP_TIME. elapsedTime = -1 try: alarmFile = open("/dev/alarm", 'r') if alarmFile: t = timespec() # ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME) = 0x40086134 result = fcntl.ioctl(alarmFile.fileno(), 0x40086134, t) if result == 0: elapsedTime = t.tv_sec alarmFile.close() except Exception, e: log.error(e)
Example #6
Source File: container.py From benchexec with Apache License 2.0 | 6 votes |
def activate_network_interface(iface): """Bring up the given network interface. @raise OSError: if interface does not exist or permissions are missing """ iface = iface.encode() sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_IP) try: # Get current interface flags from kernel ifreq = struct.pack( _STRUCT_IFREQ_LAYOUT_IFADDR_SAFAMILY, iface, socket.AF_INET, b"0" * 14 ) ifreq = fcntl.ioctl(sock, _SIOCGIFFLAGS, ifreq) if_flags = struct.unpack(_STRUCT_IFREQ_LAYOUT_IFFLAGS, ifreq)[1] # Set new flags ifreq = struct.pack( _STRUCT_IFREQ_LAYOUT_IFFLAGS, iface, if_flags | _IFF_UP, b"0" * 14 ) fcntl.ioctl(sock, _SIOCSIFFLAGS, ifreq) finally: sock.close()
Example #7
Source File: gateway.py From Jtyoui with MIT License | 6 votes |
def get_linux_ip(eth): """在Linux下获取IP""" assert os.name == 'posix', NotLinuxSystemError('不是Linux系统') import fcntl s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ip = socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', eth[:15]))) return ip[20:24]
Example #8
Source File: inputs.py From inputs with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __get_vibration_code(self, left_motor, right_motor, duration): """This is some crazy voodoo, if you can simplify it, please do.""" inner_event = struct.pack( '2h6x2h2x2H28x', 0x50, -1, duration, 0, int(left_motor * 65535), int(right_motor * 65535)) buf_conts = ioctl(self._write_device, 1076905344, inner_event) return int(codecs.encode(buf_conts[1:3], 'hex'), 16)
Example #9
Source File: _containers_attach.py From python-podman with Apache License 2.0 | 6 votes |
def resize_handler(self): """Send the new window size to conmon.""" def wrapped(signum, frame): # pylint: disable=unused-argument packed = fcntl.ioctl(self.pseudo_tty.stdout, termios.TIOCGWINSZ, struct.pack('HHHH', 0, 0, 0, 0)) rows, cols, _, _ = struct.unpack('HHHH', packed) logging.debug('Resize window(%dx%d) using %s', rows, cols, self.pseudo_tty.control_socket) # TODO: Need some kind of timeout in case pipe is blocked with open(self.pseudo_tty.control_socket, 'w') as skt: # send conmon window resize message skt.write('1 {} {}\n'.format(rows, cols)) return wrapped
Example #10
Source File: progress_bar.py From me-ica with GNU Lesser General Public License v2.1 | 6 votes |
def get_termsize(): """Return terminal size as a tuple (height, width).""" try: # this works on unix machines import struct, fcntl, termios height, width = struct.unpack("hhhh", fcntl.ioctl(0,termios.TIOCGWINSZ, "\000"*8))[0:2] if not (height and width): height, width = 24, 79 except ImportError: # for windows machins, use default values # Does anyone know how to get the console size under windows? # One approach is: # http://code.activestate.com/recipes/440694/ height, width = 24, 79 return height, width
Example #11
Source File: Sniffer.py From SimpleSniffer with GNU General Public License v3.0 | 6 votes |
def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24]) #嗅探
Example #12
Source File: multicast-relay.py From multicast-relay with GNU General Public License v3.0 | 6 votes |
def interfaces(self): if self.homebrewNetifaces: import array import fcntl maxInterfaces = 128 bufsiz = maxInterfaces * 40 nullByte = b'\0' s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ifNames = array.array('B', nullByte * bufsiz) ifNameLen = struct.unpack('iL', fcntl.ioctl( s.fileno(), 0x8912, # SIOCGIFCONF struct.pack('iL', bufsiz, ifNames.buffer_info()[0]) ))[0] if ifNameLen % self.ifNameStructLen != 0: print('Do you need to set --ifNameStructLen? %s/%s ought to have a remainder of zero.' % (ifNameLen, self.ifNameStructLen)) sys.exit(1) ifNames = ifNames.tostring() for i in range(0, ifNameLen, self.ifNameStructLen): name = ifNames[i:i+16].split(nullByte, 1)[0].decode() if not name: print('Cannot determine interface name: do you need to set --ifNameStructLen? %s/%s ought to have a remainder of zero.' % (ifNameLen, self.ifNameStructLen)) sys.exit(1) ip = socket.inet_ntoa(fcntl.ioctl(socket.socket(socket.AF_INET, socket.SOCK_DGRAM), 0x8915, struct.pack('256s', str(name)))[20:24]) # SIOCGIFADDR netmask = socket.inet_ntoa(fcntl.ioctl(socket.socket(socket.AF_INET, socket.SOCK_DGRAM), 0x891b, struct.pack('256s', str(name)))[20:24]) # SIOCGIFNETMASK broadcast = socket.inet_ntoa(fcntl.ioctl(socket.socket(socket.AF_INET, socket.SOCK_DGRAM), 0x8919, struct.pack('256s', str(name)))[20:24]) # SIOCGIFBRDADDR hwaddr = ':'.join(['%02x' % ord(char) for char in fcntl.ioctl(socket.socket(socket.AF_INET, socket.SOCK_DGRAM), 0x8927, struct.pack('256s', str(name)))[18:24]]) # SIOCGIFHWADDR self.interfaceAttrs[name] = {Netifaces.AF_LINK: [{'addr': hwaddr}], Netifaces.AF_INET: [{'addr': ip, 'netmask': netmask, 'broadcast': broadcast}]} return self.interfaceAttrs.keys() else: import netifaces return netifaces.interfaces()
Example #13
Source File: pdbpp.py From pdbpp with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_terminal_size(): fallback = (80, 24) try: from shutil import get_terminal_size except ImportError: try: import termios import fcntl import struct call = fcntl.ioctl(0, termios.TIOCGWINSZ, "\x00"*8) height, width = struct.unpack("hhhh", call)[:2] except (SystemExit, KeyboardInterrupt): raise except: width = int(os.environ.get('COLUMNS', fallback[0])) height = int(os.environ.get('COLUMNS', fallback[1])) # Work around above returning width, height = 0, 0 in Emacs width = width if width != 0 else fallback[0] height = height if height != 0 else fallback[1] return width, height else: return get_terminal_size(fallback)
Example #14
Source File: pyfakewebcam.py From pyfakewebcam with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, video_device, width, height, channels=3, input_pixfmt='RGB'): if channels != 3: raise NotImplementedError('Code only supports inputs with 3 channels right now. You tried to intialize with {} channels'.format(channels)) if input_pixfmt != 'RGB': raise NotImplementedError('Code only supports RGB pixfmt. You tried to intialize with {}'.format(input_pixfmt)) if not os.path.exists(video_device): sys.stderr.write('\n--- Make sure the v4l2loopback kernel module is loaded ---\n') sys.stderr.write('sudo modprobe v4l2loopback devices=1\n\n') raise FileNotFoundError('device does not exist: {}'.format(video_device)) self._channels = channels self._video_device = os.open(video_device, os.O_WRONLY | os.O_SYNC) self._settings = _v4l2.v4l2_format() self._settings.type = _v4l2.V4L2_BUF_TYPE_VIDEO_OUTPUT self._settings.fmt.pix.pixelformat = _v4l2.V4L2_PIX_FMT_YUYV self._settings.fmt.pix.width = width self._settings.fmt.pix.height = height self._settings.fmt.pix.field = _v4l2.V4L2_FIELD_NONE self._settings.fmt.pix.bytesperline = width * 2 self._settings.fmt.pix.sizeimage = width * height * 2 self._settings.fmt.pix.colorspace = _v4l2.V4L2_COLORSPACE_JPEG self._buffer = np.zeros((self._settings.fmt.pix.height, 2*self._settings.fmt.pix.width), dtype=np.uint8) self._yuv = np.zeros((self._settings.fmt.pix.height, self._settings.fmt.pix.width, 3), dtype=np.uint8) self._ones = np.ones((self._settings.fmt.pix.height, self._settings.fmt.pix.width, 1), dtype=np.uint8) self._rgb2yuv = np.array([[0.299, 0.587, 0.114, 0], [-0.168736, -0.331264, 0.5, 128], [0.5, -0.418688, -0.081312, 128]]) fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
Example #15
Source File: mame82_util.py From P4wnP1_nexmon_additions with GNU General Public License v3.0 | 6 votes |
def send_IOCTL(ioc, device_name = "wlan0"): # This code is untested, because our target (BCM43430a1) talks NETLINK # so on Pi0w sendNL_IOCTL should be used SIOCDEVPRIVATE = 0x89F0 # create ioctl ifreq ifr = nexconf.create_ifreq(device_name, ioc) # debug out ''' print repr(nexconf.c_struct2str(ifr)) print len(nexconf.c_struct2str(ifr)) print repr(string_at(ifr.ifr_data, sizeof(ioc))) ''' # send ioctl to kernel via UDP socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) fcntl.ioctl(s.fileno(), SIOCDEVPRIVATE, ifr) s.close()
Example #16
Source File: interface.py From XFLTReaT with MIT License | 6 votes |
def freebsd_set_ip_address(self, dev, ip, serverip, netmask): sockfd = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: #set ip, serverip and netmask ifaliasreq = struct.pack('<16sBBHI8sBBHI8sBBHI8sI', self.iface_name, 16, socket.AF_INET, 0, struct.unpack('<I', socket.inet_aton(ip))[0], '\x00'*8, 16, socket.AF_INET, 0, struct.unpack('<I', socket.inet_aton(serverip))[0], '\x00'*8, 16, socket.AF_INET, 0, struct.unpack('<I', socket.inet_aton('255.255.255.255'))[0], '\x00'*8, 0) fcntl.ioctl(sockfd, self.IOCTL_FREEBSD_SIOCAIFADDR, ifaliasreq) # get flags ifr = struct.pack('<16sh', self.iface_name, 0) flags = struct.unpack('<16sh', fcntl.ioctl(sockfd, self.IOCTL_FREEBSD_SIOCGIFFLAGS, ifr))[1] # set new flags flags = flags | self.IOCTL_FREEBSD_IFF_UP ifr = struct.pack('<16sh', self.iface_name, flags) # iface up fcntl.ioctl(sockfd, self.IOCTL_FREEBSD_SIOCSIFFLAGS, ifr) except Exception as e: common.internal_print("Something went wrong with setting up the interface.", -1) print(e) sys.exit(-1) # adding new route for forwarding packets properly. integer_ip = struct.unpack(">I", socket.inet_pton(socket.AF_INET, serverip))[0] rangeip = socket.inet_ntop(socket.AF_INET, struct.pack(">I", integer_ip & ((2**int(netmask))-1)<<32-int(netmask))) ps = subprocess.Popen(["route", "add", "-net", rangeip+"/"+netmask, serverip], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = ps.communicate() if stderr: if not "File exists" in stderr: common.internal_print("Error: adding client route: {0}".format(stderr), -1) sys.exit(-1) return
Example #17
Source File: interface.py From XFLTReaT with MIT License | 6 votes |
def freebsd_tun_alloc(self, dev, flags): try: sockfd = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ifr = struct.pack('<16si', 'tun', 0) self.iface_name = fcntl.ioctl(sockfd, self.IOCTL_FREEBSD_SIOCIFCREATE2, ifr) self.iface_name = self.iface_name.rstrip("\x00") buff = array.array('c', dev+"\x00") caddr_t, _ = buff.buffer_info() ifr = struct.pack('16sP', self.iface_name, caddr_t); fcntl.ioctl(sockfd, self.IOCTL_FREEBSD_SIOCSIFNAME, ifr) tun = os.open("/dev/"+self.iface_name, os.O_RDWR | os.O_NONBLOCK) self.iface_name = dev except IOError as e: print e common.internal_print("Error: Cannot create tunnel. Is {0} in use?".format(dev), -1) sys.exit(-1) return tun
Example #18
Source File: interface.py From XFLTReaT with MIT License | 6 votes |
def mac_set_ip_address(self, dev, ip, serverip, netmask): ifr = struct.pack('<16sBBHIIIBBHIIIBBHIII', self.iface_name, 16, socket.AF_INET, 0, struct.unpack('<L', socket.inet_pton(socket.AF_INET, ip))[0], 0, 0, 16, socket.AF_INET, 0, struct.unpack('<L', socket.inet_pton(socket.AF_INET, serverip))[0], 0, 0, 16, 0, 0, struct.unpack('<L', socket.inet_pton(socket.AF_INET, "255.255.255.255"))[0], 0, 0) try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) fcntl.ioctl(sock, self.IOCTL_MACOSX_SIOCAIFADDR, ifr) except Exception as e: common.internal_print("Something went wrong with setting up the interface.", -1) print(e) sys.exit(-1) # adding new route for forwarding packets properly. integer_ip = struct.unpack(">I", socket.inet_pton(socket.AF_INET, serverip))[0] rangeip = socket.inet_ntop(socket.AF_INET, struct.pack(">I", integer_ip & ((2**int(netmask))-1)<<32-int(netmask))) ps = subprocess.Popen(["route", "add", "-net", rangeip+"/"+netmask, serverip], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = ps.communicate() if stderr: if not "File exists" in stderr: common.internal_print("Error: adding client route: {0}".format(stderr), -1) sys.exit(-1) return
Example #19
Source File: rmTimeUtils.py From rainmachine-developer-resources with GNU General Public License v3.0 | 6 votes |
def getAlarmElapsedRealTime(): ### DEPRECATED: This method was used on Android to get the UP_TIME (replaced by monotonicTime()) elapsedTime = -1 try: alarmFile = open("/dev/alarm", 'r') if alarmFile: t = timespec() # ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME) = 0x40086134 result = fcntl.ioctl(alarmFile.fileno(), 0x40086134, t) if result == 0: elapsedTime = t.tv_sec alarmFile.close() except Exception, e: log.error(e)
Example #20
Source File: utils.py From optitrack with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_ip_address(ifname): """ Get the ip address from the specified interface. >>> get_ip_address('eth0') '192.168.0.7' @type ifname: string @param ifname: The interface name. Typical names are C{'eth0'}, C{'wlan0'}, etc. @rtype: string @return: The IP address of the specified interface. """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]))[20:24])
Example #21
Source File: interface.py From XFLTReaT with MIT License | 6 votes |
def lin_set_ip_address(self, dev, ip, serverip, netmask): sockfd = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: # set IP ifr = struct.pack('<16sH2s4s8s', dev, socket.AF_INET, "\x00"*2, socket.inet_aton(ip), "\x00"*8) fcntl.ioctl(sockfd, self.IOCTL_LINUX_SIOCSIFADDR, ifr) # get flags ifr = struct.pack('<16sh', dev, 0) flags = struct.unpack('<16sh', fcntl.ioctl(sockfd, self.IOCTL_LINUX_SIOCSIFFLAGS, ifr))[1] # set new flags flags = flags | self.IOCTL_LINUX_IFF_UP ifr = struct.pack('<16sh', dev, flags) # iface up fcntl.ioctl(sockfd, self.IOCTL_LINUX_SIOCSIFFLAGS, ifr) except Exception as e: common.internal_print("Something went wrong with setting up the interface.", -1) print(e) sys.exit(-1) # adding new route for forwarding packets properly. integer_ip = struct.unpack(">I", socket.inet_pton(socket.AF_INET, serverip))[0] rangeip = socket.inet_ntop(socket.AF_INET, struct.pack(">I", integer_ip & ((2**int(netmask))-1)<<32-int(netmask))) integer_netmask = struct.pack(">I", ((2**int(netmask))-1)<<32-int(netmask)) netmask = socket.inet_ntoa(integer_netmask) ps = subprocess.Popen(["route", "add", "-net", rangeip, "netmask", netmask, "dev", dev], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = ps.communicate() if stderr: if not "File exists" in stderr: common.internal_print("Error: adding client route: {0}".format(stderr), -1) sys.exit(-1) return
Example #22
Source File: termui.py From jbox with MIT License | 5 votes |
def get_terminal_size(): """Returns the current size of the terminal as tuple in the form ``(width, height)`` in columns and rows. """ # If shutil has get_terminal_size() (Python 3.3 and later) use that if sys.version_info >= (3, 3): import shutil shutil_get_terminal_size = getattr(shutil, 'get_terminal_size', None) if shutil_get_terminal_size: sz = shutil_get_terminal_size() return sz.columns, sz.lines if get_winterm_size is not None: return get_winterm_size() def ioctl_gwinsz(fd): try: import fcntl import termios cr = struct.unpack( 'hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) except Exception: return return cr cr = ioctl_gwinsz(0) or ioctl_gwinsz(1) or ioctl_gwinsz(2) if not cr: try: fd = os.open(os.ctermid(), os.O_RDONLY) try: cr = ioctl_gwinsz(fd) finally: os.close(fd) except Exception: pass if not cr or not cr[0] or not cr[1]: cr = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', DEFAULT_COLUMNS)) return int(cr[1]), int(cr[0])
Example #23
Source File: mame82_util.py From P4wnP1_nexmon_additions with GNU General Public License v3.0 | 5 votes |
def get_ch(): ioctl = nexconf.create_cmd_ioctl(29, "", False) res = nexconf.sendNL_IOCTL(ioctl) return struct.unpack("<I", res[:4])[0]
Example #24
Source File: __init__.py From recruit with Apache License 2.0 | 5 votes |
def get_terminal_size(): """Returns a tuple (x, y) representing the width(x) and the height(x) in characters of the terminal window.""" def ioctl_GWINSZ(fd): try: import fcntl import termios import struct cr = struct.unpack( 'hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234') ) except: return None if cr == (0, 0): return None return cr cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) if not cr: try: fd = os.open(os.ctermid(), os.O_RDONLY) cr = ioctl_GWINSZ(fd) os.close(fd) except: pass if not cr: cr = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80)) return int(cr[1]), int(cr[0])
Example #25
Source File: __init__.py From jbox with MIT License | 5 votes |
def get_terminal_size(): """Returns a tuple (x, y) representing the width(x) and the height(x) in characters of the terminal window.""" def ioctl_GWINSZ(fd): try: import fcntl import termios import struct cr = struct.unpack( 'hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234') ) except: return None if cr == (0, 0): return None return cr cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) if not cr: try: fd = os.open(os.ctermid(), os.O_RDONLY) cr = ioctl_GWINSZ(fd) os.close(fd) except: pass if not cr: cr = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80)) return int(cr[1]), int(cr[0])
Example #26
Source File: mame82_util.py From P4wnP1_nexmon_additions with GNU General Public License v3.0 | 5 votes |
def set_enable_karma(on=True): if on: ioctl = nexconf.create_cmd_ioctl(MaMe82_IO.CMD, struct.pack("IIB", MaMe82_IO.MAME82_IOCTL_ARG_TYPE_SET_ENABLE_KARMA, 1, 1), True) else: ioctl = nexconf.create_cmd_ioctl(MaMe82_IO.CMD, struct.pack("IIB", MaMe82_IO.MAME82_IOCTL_ARG_TYPE_SET_ENABLE_KARMA, 1, 0), True) nexconf.sendNL_IOCTL(ioctl)
Example #27
Source File: mame82_util.py From P4wnP1_nexmon_additions with GNU General Public License v3.0 | 5 votes |
def set_enable_karma_probe(on=True): if on: ioctl = nexconf.create_cmd_ioctl(MaMe82_IO.CMD, struct.pack("IIB", MaMe82_IO.MAME82_IOCTL_ARG_TYPE_SET_ENABLE_KARMA_PROBE, 1, 1), True) else: ioctl = nexconf.create_cmd_ioctl(MaMe82_IO.CMD, struct.pack("IIB", MaMe82_IO.MAME82_IOCTL_ARG_TYPE_SET_ENABLE_KARMA_PROBE, 1, 0), True) nexconf.sendNL_IOCTL(ioctl)
Example #28
Source File: mame82_util.py From P4wnP1_nexmon_additions with GNU General Public License v3.0 | 5 votes |
def set_enable_karma_beaconing(on=True): if on: ioctl = nexconf.create_cmd_ioctl(MaMe82_IO.CMD, struct.pack("IIB", MaMe82_IO.MAME82_IOCTL_ARG_TYPE_SET_ENABLE_KARMA_BEACON, 1, 1), True) else: ioctl = nexconf.create_cmd_ioctl(MaMe82_IO.CMD, struct.pack("IIB", MaMe82_IO.MAME82_IOCTL_ARG_TYPE_SET_ENABLE_KARMA_BEACON, 1, 0), True) nexconf.sendNL_IOCTL(ioctl)
Example #29
Source File: mame82_util.py From P4wnP1_nexmon_additions with GNU General Public License v3.0 | 5 votes |
def set_enable_custom_beaconing(on=True): if on: ioctl = nexconf.create_cmd_ioctl(MaMe82_IO.CMD, struct.pack("IIB", MaMe82_IO.MAME82_IOCTL_ARG_TYPE_SET_ENABLE_CUSTOM_BEACONS, 1, 1), True) else: ioctl = nexconf.create_cmd_ioctl(MaMe82_IO.CMD, struct.pack("IIB", MaMe82_IO.MAME82_IOCTL_ARG_TYPE_SET_ENABLE_CUSTOM_BEACONS, 1, 0), True) nexconf.sendNL_IOCTL(ioctl)
Example #30
Source File: server.py From SniffVPN with GNU General Public License v3.0 | 5 votes |
def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]))[20:24])