<--previous | contents | next-->

Interface class

Individual interfaces are represented as instances of the Interface class.

Interface

Interface()

The Interface class should never be instantiated by the user. Interface instances can be retrieved using IFConfig, discussed in the previous section.

flags

The flags attribute is used both to set and retrieve interface flags. That is, values assigned to this attribute, will automatically be set on the interface as well. The following flags are available:

Name

The interface name.

Iftype

The Iftype attribute can be inspected for a text representation of the interface type. For a complete list of possibile types see the IFT_* variables in net/iftypes.h. Note that the text returned by this attribute will not have the IFT_ prefix - i.e. IFT_ETHER is represented simply as ETHER.

mtu

The mtu attribute is used both to set and retrieve interface MTU. That is, values assigned to this attribute, will automatically be set on the interface as well.

metric

The metric attribute is used both to set and retrieve interface metric. That is, values assigned to this attribute, will automatically be set on the interface as well.

addresses

A list of addresses for this interface. The value returned is a list of dictionaries, the format of which would be tedious to explain here, but should be obvious upon inspection.

media

The media attribute is used to inspect and manipulate the media types and options of an interface. If media options do not apply to an interface, the media attribute will be set to None. For more information, see the documentation covering the Media Class.

addAddress(addr, mask=None)

Add an IPv4 or IPv6 address to the interface. The mask specification is optional, and can be given either as a prefix length (i.e. "24"), or as an address (i.e. "255.255.255.0"). The default masks are 24 for IPv4 and 64 for IPv6. IPv6 addresses can make use of all the standard abbreviations and notations.

delAddress(addr)

Delete the specified address from the interface.

setAddress(addr, mask=None)

Set an address. The arguments are treated identically to those of addAddress, but the first existing address of the same type (i.e. IPv4 or IPv6) is first removed from the interface.


<--previous | contents | next--> (12/21/04)
PyOpenbsd v0.1 Manual