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/g/1/g15m-HEAD/trunk/lglcd/Examples/PyNetstat.py g15m(Download)
lPort = item.dwLocalPort
lPort = socket.ntohs(lPort)
lAddr = item.dwLocalAddr
lAddr = socket.inet_ntoa(struct.pack('L', lAddr))
portState = item.dwState
# only record TCP ports where we're listening on our external
lPort = socket.ntohs(lPort)
lAddr = item.dwLocalAddr
lAddr = socket.inet_ntoa(struct.pack('L', lAddr))
# only record UDP ports where we're listening on our external
# (or all) connections
src/g/1/g15m-HEAD/lglcd/Examples/PyNetstat.py g15m(Download)
lPort = item.dwLocalPort
lPort = socket.ntohs(lPort)
lAddr = item.dwLocalAddr
lAddr = socket.inet_ntoa(struct.pack('L', lAddr))
portState = item.dwState
# only record TCP ports where we're listening on our external
lPort = socket.ntohs(lPort)
lAddr = item.dwLocalAddr
lAddr = socket.inet_ntoa(struct.pack('L', lAddr))
# only record UDP ports where we're listening on our external
# (or all) connections
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/p/y/PyFunge-0.5-rc2/funge/fp/fp_SOCK.py PyFunge(Download)
def pop_address(ip):
host, port = ip.popmany(2)
host = struct.pack('I', host)
return (socket.inet_ntoa(host), port)
def push_address(ip, addr):
host, port = addr
src/s/y/synce-HEAD/sync-engine/SyncEngine/dtptserver.py synce(Download)
raise NotImplementedError("Unhandled family %d" % family)
port = struct.unpack(">H", buf[10:12])[0]
addr = socket.inet_ntoa(buf[12:16])
logger.debug("Connecting to %s:%s" % (addr, port))
ext_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def _unserialize_sockaddr(self, data):
family = struct.unpack("<H", data[0:2])[0]
if family == socket.AF_INET:
port = struct.unpack(">H", data[2:4])[0]
return (family, socket.inet_ntoa(data[4:8]), port)
else:
src/s/y/synce-HEAD/device-manager/manager/DTPT.py synce(Download)
raise NotImplementedError("Unhandled family %d" % family)
port = struct.unpack(">H", buf[10:12])[0]
addr = socket.inet_ntoa(buf[12:16])
ext_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
errno = ext_socket.connect_ex((addr, port))
def _unserialize_sockaddr(self, data):
family = struct.unpack("<H", data[0:2])[0]
if family == socket.AF_INET:
port = struct.unpack(">H", data[2:4])[0]
return (family, socket.inet_ntoa(data[4:8]), port)
else:
raise NotImplementedError("Unhandled family %d" % family)
src/s/o/socksproxy-0.1/socksproxy/protocol.py socksproxy(Download)
except socket.gaierror:
logging.exception("resolving %s", name)
elif addr_type == 1:
to_host = socket.inet_ntoa(data[1:5])
idx = 5
elif addr_type == 4:
to_host = socket.inet_ntop(socket.AF_INET6, data[1:17])
idx = 17
elif self.version == 4:
# version 4
to_host = socket.inet_ntoa(data[3:7])
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/p/y/pygstlib-HEAD/util/localip.py pygstlib(Download)
def get_ip_for_if(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])
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next