| |
- __builtin__.object
-
- addr
- arp
- eth
- fw
- intf
- ip
- rand
- route
- tun
class addr(__builtin__.object) |
|
addr(addrtxt=None) -> network address object
Create a network address object (optionally from its human-readable
representation). Ethernet, IP, and IPv6 address types are currently
supported. |
|
Methods defined here:
- __add__(...)
- x.__add__(y) <==> x+y
- __cmp__(...)
- x.__cmp__(y) <==> cmp(x,y)
- __contains__(...)
- x.__contains__(y) <==> y in x
- __copy__(...)
- __hash__(...)
- x.__hash__() <==> hash(x)
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- __int__(...)
- x.__int__() <==> int(x)
- __iter__(...)
- x.__iter__() <==> iter(x)
- __long__(...)
- x.__long__() <==> long(x)
- __radd__(...)
- x.__radd__(y) <==> y+x
- __repr__(...)
- x.__repr__() <==> repr(x)
- bcast(...)
- Return an addr object for our broadcast address.
- net(...)
- Return an addr object for our network address.
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
- bits = <attribute 'bits' of 'dnet.addr' objects>
- Address bitlength integer.
- eth = <attribute 'eth' of 'dnet.addr' objects>
- Ethernet MAC address as binary string.
- ip = <attribute 'ip' of 'dnet.addr' objects>
- IPv4 address as binary string.
- ip6 = <attribute 'ip6' of 'dnet.addr' objects>
- IPv6 address as binary string.
- type = <attribute 'type' of 'dnet.addr' objects>
- Address type (ADDR_TYPE_*) integer.
|
class arp(__builtin__.object) |
|
arp() -> ARP table object
Open a handle to the system ARP table. |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- __iter__(...)
- x.__iter__() <==> iter(x)
- add(...)
- Add an entry to the system ARP table.
Arguments:
pa -- ADDR_TYPE_IP network address object
ha -- ADDR_TYPE_ETH network address object
- delete(...)
- Delete an entry from the system ARP table.
Arguments:
pa -- ADDR_TYPE_IP network address object
- get(...)
- Return the hardware address for a given protocol address
in the system ARP table.
Arguments:
pa -- ADDR_TYPE_IP network address object
- loop(...)
- Iterate over the system ARP table, invoking a user callback
with each entry, returning the status of the callback routine.
Keyword arguments:
callback -- callback function with ((pa, ha), arg) prototype.
If this function returns a non-zero value, the loop
will break early.
arg -- optional callback argument
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class eth(__builtin__.object) |
|
eth(device) -> Ethernet device object
Open the specified Ethernet device for sending. |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- get(...)
- Return the MAC address associated with the device as a
binary string.
- send(...)
- Send an Ethernet frame, returning the number of bytes sent
or -1 on failure.
Arguments:
frame -- binary string representing an Ethernet frame
- set(...)
- Set the MAC address for the device, returning 0 on success,
-1 on failure.
Arguments:
eth_addr -- 6-byte binary string (e.g. '\x00\xde\xad\xbe\xef\x00')
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class fw(__builtin__.object) |
|
fw() -> Firewall ruleset object
Open a handle to the local network firewall configuration. |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- __iter__(...)
- x.__iter__() <==> iter(x)
- add(...)
- Add a firewall rule specified as a dict.
Dict values:
device -- interface name (string)
op -- operation (FW_OP_*) (integer)
dir -- direction (FW_DIR_*) (integer)
proto -- IP protocol (IP_PROTO_*) (integer)
src -- source address / net (addr object)
dst -- destination address / net (addr object)
sport -- source port range or ICMP type/mask (list of 2 integers)
dport -- dest port range or ICMP code/mask (list of 2 integers)
- delete(...)
- Delete a firewall rule specified as a dict.
- loop(...)
- Iterate over the local firewall ruleset, invoking a user callback
with each entry, returning the status of the callback routine.
Keyword arguments:
callback -- callback function with (dict, arg) prototype.
If this function returns a non-zero value, the loop
will break early.
arg -- optional callback argument
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class intf(__builtin__.object) |
|
intf() -> Interface table object
Open a handle to the system network interface table. |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- __iter__(...)
- x.__iter__() <==> iter(x)
- get(...)
- Return the configuration for a network interface as a dict.
- get_dst(...)
- Return the configuration for the best interface with which to
reach the specified dst address.
- get_src(...)
- Return the configuration for the interface whose primary address
matches the specified source address.
- loop(...)
- Iterate over the system interface table, invoking a user callback
with each entry, returning the status of the callback routine.
Keyword arguments:
callback -- callback function with (dict, arg) prototype.
If this function returns a non-zero value, the loop
will break early.
arg -- optional callback argument
- set(...)
- Set the configuration for an interface from a dict.
Dict values:
name -- name of interface to set (string)
flags -- interface flags (INTF_FLAG_*) (integer bitmask)
mtu -- interface MTU (integer)
addr -- primary network address (addr object)
dst_addr -- point-to-point dst address (addr object)
link_addr -- link-layer address (addr object)
alias_addrs -- additional network addresses (list of addr objects)
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class ip(__builtin__.object) |
|
ip() -> Raw IP object
Open a raw IP socket for sending. |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- send(...)
- Send an IP packet, returning the number of bytes sent
or -1 on failure.
Arguments:
pkt -- binary string representing an IP packet
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class rand(__builtin__.object) |
|
rand() -> Pseudo-random number generator
Obtain a handle for fast, cryptographically strong pseudo-random
number generation. The starting seed is derived from the system
random data source device (if one exists), or from the current time
and random stack contents. |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- add(...)
- Add additional entropy into the PRNG mix.
Arguments:
string -- binary string
- get(...)
- Return a string of random bytes.
Arguments:
len -- number of random bytes to generate
- set(...)
- Initialize the PRNG from a known seed.
Arguments:
string -- binary string seed value
- uint16(...)
- Return a random 16-bit integer.
- uint32(...)
- Return a random 32-bit integer.
- uint8(...)
- Return a random 8-bit integer.
- xrange(...)
- xrange([start,] stop) -> xrange object
Return a random permutation iterator to walk an unsigned integer range,
like xrange().
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class route(__builtin__.object) |
|
route() -> Routing table object
Open a handle to the system routing table. |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- __iter__(...)
- x.__iter__() <==> iter(x)
- add(...)
- Add an entry to the system routing table.
Arguments:
dst -- ADDR_TYPE_IP network address object
gw -- ADDR_TYPE_IP network address object
- delete(...)
- Delete an entry from the system routing table.
Arguments:
dst -- ADDR_TYPE_IP network address object
- get(...)
- Return the hardware address for a given protocol address
in the system routing table.
Arguments:
dst -- ADDR_TYPE_IP network address object
- loop(...)
- Iterate over the system routing table, invoking a user callback
with each entry, returning the status of the callback routine.
Keyword arguments:
callback -- callback function with ((dst, gw), arg) prototype.
If this function returns a non-zero value, the loop
will break early.
arg -- optional callback argument
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class tun(__builtin__.object) |
|
tun(src, dst[, mtu]) -> Network tunnel interface handle
Obtain a handle to a network tunnel interface, to which packets
destined for dst are delivered (with source addresses rewritten to
src), where they may be read by a userland process and processed
as desired. Packets written back to the handle are injected into
the kernel networking subsystem. |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- close(...)
- fileno(...)
- Return file descriptor for tunnel handle.
- recv(...)
- Return the next packet delivered to the tunnel interface.
- send(...)
- Send an IP packet, returning the number of bytes sent
or -1 on failure.
Arguments:
pkt -- binary string representing an IP packet
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
- fd = <attribute 'fd' of 'dnet.tun' objects>
- File descriptor for tunnel handle.
- name = <attribute 'name' of 'dnet.tun' objects>
- Tunnel interface name.
| |