All Samples(372) | Call(321) | Derive(0) | Import(51)
inet_ntoa(packed_ip) -> ip_address_string Convert an IP address from 32-bit packed binary format to string format
src/s/n/snimpy-0.5/examples/list-routes.py snimpy(Download)
#!/usr/bin/snimpy
from socket import inet_ntoa
load("IP-FORWARD-MIB")
m=M()
if dsttype != "ipv4" or nhtype != "ipv4":
print "Non-IPv4 route"
continue
print "%15s/%-2d via %-15s" % (inet_ntoa(dst), prefix, inet_ntoa(nh))
src/b/t/btqueue-HEAD/trunk/btqueue/BitQueue/ip2cc.py btqueue(Download)
#!/usr/local/bin/python -O from __future__ import generators from bsddb import btopen from socket import inet_aton, inet_ntoa, error import urllib import re
try:
first, record = db.last()
except KeyError:
raise KeyError(inet_ntoa(ip))
else:
if first!=ip:
first, record = db.previous()
assert first<=ip
return first, record
def __iter__(self):
try:
first, record = self.__db.first()
yield (inet_ntoa(first), inet_ntoa(record[:4])), \
self.unpack(record[4:])
while 1:
first, record = self.__db.next()
yield (inet_ntoa(first), inet_ntoa(record[:4])), \
self.unpack(record[4:])
except KeyError:
pass
raise DuplicateError(
'Range %s-%s intersects ' % (first_str, last_str) +
'with existing entry %s-%s' %
(inet_ntoa(db_first), inet_ntoa(db_last)))
break
self.__db[first] = last+self.pack(info)
first = parts[3]
first_int = struct.unpack('!I', inet_aton(first))[0]
last_int = first_int+int(parts[4])-1
last = inet_ntoa(struct.pack('!I', last_int))
try:
netname = olddb[first].split(':')[1]
#if netname == 'Unknown':
first_int = struct.unpack('!I', inet_aton(first))[0]
length = pow(2,32-int(prefix))
last_int = first_int+length-1
last = inet_ntoa(struct.pack('!I', last_int))
print first,last,record['descr']
try:
self.add(first,last,record['descr'])
db.fetch(olddb)
os.rename(db_file+'.new', db_file)
elif sys.argv[1]=='-set':
ip = inet_ntoa(sys.argv[2])
new_location = inet_ntoa(sys.argv[3])
if db_file.endswith('.new'):
db_file = db_file[:-4]
src/b/t/btqueue-HEAD/btqueue/BitQueue/ip2cc.py btqueue(Download)
#!/usr/local/bin/python -O from __future__ import generators from bsddb import btopen from socket import inet_aton, inet_ntoa, error import urllib import re
try:
first, record = db.last()
except KeyError:
raise KeyError(inet_ntoa(ip))
else:
if first!=ip:
first, record = db.previous()
assert first<=ip
return first, record
def __iter__(self):
try:
first, record = self.__db.first()
yield (inet_ntoa(first), inet_ntoa(record[:4])), \
self.unpack(record[4:])
while 1:
first, record = self.__db.next()
yield (inet_ntoa(first), inet_ntoa(record[:4])), \
self.unpack(record[4:])
except KeyError:
pass
raise DuplicateError(
'Range %s-%s intersects ' % (first_str, last_str) +
'with existing entry %s-%s' %
(inet_ntoa(db_first), inet_ntoa(db_last)))
break
self.__db[first] = last+self.pack(info)
first = parts[3]
first_int = struct.unpack('!I', inet_aton(first))[0]
last_int = first_int+int(parts[4])-1
last = inet_ntoa(struct.pack('!I', last_int))
try:
netname = olddb[first].split(':')[1]
#if netname == 'Unknown':
first_int = struct.unpack('!I', inet_aton(first))[0]
length = pow(2,32-int(prefix))
last_int = first_int+length-1
last = inet_ntoa(struct.pack('!I', last_int))
print first,last,record['descr']
try:
self.add(first,last,record['descr'])
db.fetch(olddb)
os.rename(db_file+'.new', db_file)
elif sys.argv[1]=='-set':
ip = inet_ntoa(sys.argv[2])
new_location = inet_ntoa(sys.argv[3])
if db_file.endswith('.new'):
db_file = db_file[:-4]
src/b/u/buteo-HEAD/plugins/network.py buteo(Download)
Copyright (c) 2009 Christian Hans
Licensed under the terms of the GPL v2
"""
from socket import socket, SOCK_DGRAM, AF_INET, inet_ntoa
from fcntl import ioctl
from struct import pack, unpack
from array import array
hwaddr.append(hex(ord(char))[2:])
return ':'.join(hwaddr)
else:
return inet_ntoa(info[20:24])
# returns a list with dictionaries including network interface data
# like ifconfig (for 32bit and 64bit Linux kernels)
src/w/o/wolpertinger-HEAD/scripts/wolper-mcp.py wolpertinger(Download)
import warnings from datetime import datetime from socket import gethostbyname, htonl, ntohl, inet_aton, inet_ntoa from struct import pack, unpack # disable warnings
for row in self.db_cursor:
ip = pack("I", row[0])
hosts.append(inet_ntoa(ip))
print inet_ntoa(ip)
# show uniq open ports
for row in self.db_cursor:
ip = pack("I", row[0])
hosts.append(inet_ntoa(ip))
# get open ports
self.db_cursor.execute(r"select r.port, h.ip, s.name from result as r, host as h, services as s where scan_id=? and r.host_id=h.id and r.port=s.port order by h.ip asc, r.port asc", (int(scan_id),))
service = row[2]
# store result in results list
results.append((port, inet_ntoa(ip), service))
return results
if row[0] == 1 or row[0] == 2:
drones.append(("local drone", 0, typ))
else:
drones.append((inet_ntoa(ip), port, typ))
return drones
for row in self.db_cursor:
ip = pack("I", row[0])
hosts.append(inet_ntoa(ip))
# get and show some portscan statistics
info = self.get_portscan_info(ref_id)
print "Scanned hosts:\t\t", num_hosts
print "Scanned ports:\t\t", num_ports
print "Open ports:\t\t", len(total_results)
print "Source IP:\t\t", inet_ntoa(source_ip)
print "Packets per second:\t", pps
print "Listener drone:\t\t%s (%d/tcp)" % (drones[-1][0], drones[-1][1])
src/p/y/PyTide-HEAD/NetworkTools/DNS/Lib.py PyTide(Download)
from struct import pack as struct_pack
from struct import unpack as struct_unpack
from socket import inet_ntoa, inet_aton
def pack16bit(n):
return struct_pack('!H', n)
def bin2addr(n):
return inet_ntoa(struct_pack('!L', n))
# Packing class
class Packer:
" packer base class. supports basic byte/16bit/32bit/addr/string/name "
src/o/r/orcatorrent-HEAD/Core/BitTornado/BT1/Rerequester.py orcatorrent(Download)
from threading import Thread, Lock, currentThread from cStringIO import StringIO from traceback import print_exc,print_stack from socket import error, gethostbyname, inet_aton, inet_ntoa from random import shuffle from sha import sha from time import time
try:
ip, port = unpack("!4sH", peer)
if DEBUG_DHT:
print >>sys.stderr,"Rerequester: DHT: Got",inet_ntoa(ip), int(port)
p.append({'ip': inet_ntoa(ip),
'port':port})
except:
src/p/y/python-ptrace-0.6.2/ptrace/syscall/socketcall.py python-ptrace(Download)
from ptrace.cpu_info import CPU_WORD_SIZE from ptrace.ctypes_tools import ntoh_ushort, ntoh_uint from ptrace.syscall.socketcall_constants import SOCKETCALL, SOCKET_FAMILY from ptrace.syscall.socketcall_struct import sockaddr, sockaddr_in, sockaddr_un from ctypes import c_int from ptrace.os_tools import RUNNING_LINUX from socket import AF_INET, inet_ntoa
'127.0.0.1'
"""
ip_bytes = pack("!I", ip)
return inet_ntoa(ip_bytes)
AF_FILE = 1
src/t/o/torrentcast-HEAD/BTL/IPTools.py torrentcast(Download)
# License.
from struct import pack, unpack
from socket import inet_aton, inet_ntoa
def compact(ip, port):
return pack("!4sH", inet_aton(ip), port) # ! == "network order"
# 4s == "4-byte string."
# H == "unsigned short"
def uncompact(x):
ip, port = unpack("!4sH", x)
return inet_ntoa(ip), port
src/w/c/wc3helper-HEAD/trunk/libs/ip2cc/update.py wc3helper(Download)
#!/usr/bin/env python # $Id: update.py,v 1.4 2005/03/23 15:18:41 ods Exp $ from urllib2 import urlopen from socket import inet_aton, inet_ntoa import struct, sys, os from ip2cc import cc2name
first = parts[3]
first_int = struct.unpack('!I', inet_aton(first))[0]
last_int = first_int+int(parts[4])-1
last = inet_ntoa(struct.pack('!I', last_int))
try:
self.add(first, last, parts[1].upper())
except ValueError:
1 | 2 | 3 | 4 | 5 | 6 Next