WvStreams
|
A WvInterface manages a particular network interface. More...
#include <wvinterface.h>
Public Member Functions | |
WvInterface (WvStringParm _name) | |
void | rescan () |
forget all stored information about the address(es) of this interface More... | |
const WvAddr & | hwaddr () |
get the hardware address of this interface More... | |
const WvIPNet & | ipaddr () |
get the local IP net of this interface More... | |
const WvIPAddr | dstaddr () |
get the point-to-point IP address of this interface More... | |
int | getflags () |
get the current kernel flags More... | |
int | setflags (int clear, int set) |
toggle kernel flags on this netdevice. More... | |
bool | isup () |
set the interface state up or down. More... | |
void | up (bool enable) |
bool | ispromisc () |
turn promiscuous (see-all-packets) mode on or off. More... | |
void | promisc (bool enable) |
int | ptp (bool enable, const WvIPNet &addr) |
turn point-to-point mode on or off. More... | |
int | setipaddr (const WvIPNet &addr) |
Sets the local address, netmask, and broadcast of this interface and set a route to the local net. More... | |
int | setmtu (int mtu) |
Sets the MTU of the interface. More... | |
int | sethwaddr (const WvAddr &addr) |
Set the hardware address of this interface. More... | |
int | addroute (const WvIPNet &dest, int metric=0, WvStringParm table="default") |
add a route to the given network through this interface. More... | |
int | addroute (const WvIPNet &dest, const WvIPAddr &gw, const WvIPAddr &src, int metric=0, WvStringParm table="default") |
int | delroute (const WvIPNet &dest, int metric=0, WvStringParm table="default") |
delete a route to the given network through this interface. More... | |
int | delroute (const WvIPNet &dest, const WvIPAddr &gw, int metric=0, WvStringParm table="default") |
bool | isarp () |
add an ARP entry on this interface More... | |
int | addarp (const WvIPNet &proto, const WvAddr &hw, bool proxy) |
int | req (int ioctl_num, struct ifreq *ifr) |
get/set information about an interface More... | |
int | req (int ioctl_num, struct iwreq *ifr) |
get/set information about a wireless interface More... | |
Public Attributes | |
WvString | name |
bool | valid |
A WvInterface manages a particular network interface.
It is allowed to have more than one WvInterface instance referring to the same physical interface, because that is more convenient.
Definition at line 24 of file wvinterface.h.
WvInterface::WvInterface | ( | WvStringParm | _name | ) |
Definition at line 37 of file wvinterface.cc.
WvInterface::~WvInterface | ( | ) |
Definition at line 45 of file wvinterface.cc.
void WvInterface::rescan | ( | ) |
forget all stored information about the address(es) of this interface
Definition at line 84 of file wvinterface.cc.
Referenced by sethwaddr(), and setipaddr().
const WvAddr & WvInterface::hwaddr | ( | ) |
get the hardware address of this interface
Definition at line 101 of file wvinterface.cc.
References req().
const WvIPNet & WvInterface::ipaddr | ( | ) |
get the local IP net of this interface
Definition at line 117 of file wvinterface.cc.
References req().
Referenced by setipaddr().
const WvIPAddr WvInterface::dstaddr | ( | ) |
get the point-to-point IP address of this interface
Definition at line 136 of file wvinterface.cc.
References getflags(), and req().
int WvInterface::getflags | ( | ) |
get the current kernel flags
Definition at line 147 of file wvinterface.cc.
References req().
Referenced by dstaddr(), isarp(), ispromisc(), and isup().
int WvInterface::setflags | ( | int | clear, |
int | set | ||
) |
toggle kernel flags on this netdevice.
Be careful!
Definition at line 157 of file wvinterface.cc.
References WvLog::perror(), and req().
Referenced by ptp().
bool WvInterface::isup | ( | ) |
set the interface state up or down.
Definition at line 183 of file wvinterface.cc.
References getflags().
Referenced by sethwaddr().
void WvInterface::up | ( | bool | enable | ) |
Definition at line 176 of file wvinterface.cc.
bool WvInterface::ispromisc | ( | ) |
turn promiscuous (see-all-packets) mode on or off.
Definition at line 212 of file wvinterface.cc.
References getflags().
void WvInterface::promisc | ( | bool | enable | ) |
Definition at line 189 of file wvinterface.cc.
int WvInterface::ptp | ( | bool | enable, |
const WvIPNet & | addr | ||
) |
turn point-to-point mode on or off.
Definition at line 195 of file wvinterface.cc.
References WvLog::perror(), req(), and setflags().
int WvInterface::setipaddr | ( | const WvIPNet & | addr | ) |
Sets the local address, netmask, and broadcast of this interface and set a route to the local net.
Returns 0 on success, else an error code.
Definition at line 218 of file wvinterface.cc.
References WvIPNet::base(), WvIPNet::bits(), ipaddr(), WvLog::perror(), and rescan().
int WvInterface::setmtu | ( | int | mtu | ) |
Sets the MTU of the interface.
Returns 0 on success, else an error code.
Definition at line 286 of file wvinterface.cc.
References WvLog::perror(), and req().
int WvInterface::sethwaddr | ( | const WvAddr & | addr | ) |
Set the hardware address of this interface.
Returns 0 on success, else an error code.
Definition at line 297 of file wvinterface.cc.
References isup(), WvLog::perror(), req(), and rescan().
int WvInterface::addroute | ( | const WvIPNet & | dest, |
int | metric = 0 , |
||
WvStringParm | table = "default" |
||
) |
add a route to the given network through this interface.
Definition at line 472 of file wvinterface.cc.
References addroute().
Referenced by addroute(), and WvIPRouteList::set_kernel().
int WvInterface::addroute | ( | const WvIPNet & | dest, |
const WvIPAddr & | gw, | ||
const WvIPAddr & | src, | ||
int | metric = 0 , |
||
WvStringParm | table = "default" |
||
) |
Definition at line 445 of file wvinterface.cc.
int WvInterface::delroute | ( | const WvIPNet & | dest, |
int | metric = 0 , |
||
WvStringParm | table = "default" |
||
) |
delete a route to the given network through this interface.
Definition at line 532 of file wvinterface.cc.
References delroute().
Referenced by delroute(), and WvIPRouteList::set_kernel().
int WvInterface::delroute | ( | const WvIPNet & | dest, |
const WvIPAddr & | gw, | ||
int | metric = 0 , |
||
WvStringParm | table = "default" |
||
) |
Definition at line 479 of file wvinterface.cc.
bool WvInterface::isarp | ( | ) |
add an ARP entry on this interface
Definition at line 581 of file wvinterface.cc.
References getflags().
Definition at line 539 of file wvinterface.cc.
int WvInterface::req | ( | int | ioctl_num, |
struct ifreq * | ifr | ||
) |
get/set information about an interface
Definition at line 51 of file wvinterface.cc.
Referenced by dstaddr(), getflags(), hwaddr(), ipaddr(), ptp(), setflags(), sethwaddr(), and setmtu().
int WvInterface::req | ( | int | ioctl_num, |
struct iwreq * | ifr | ||
) |
get/set information about a wireless interface
Definition at line 67 of file wvinterface.cc.
WvString WvInterface::name |
Definition at line 41 of file wvinterface.h.
bool WvInterface::valid |
Definition at line 42 of file wvinterface.h.