00001
00002
00003
00004
00005
00006
00007
00008
#ifndef __WVINTERFACE_H
00009
#define __WVINTERFACE_H
00010
00011
#include "wvaddr.h"
00012
#include "wvhashtable.h"
00013
#include "wvlog.h"
00014
00015
struct ifreq;
00016
struct iwreq;
00017
struct rtentry;
00018
00019
00020
00021
00022
00023
00024 class WvInterface
00025 {
00026
WvAddr *my_hwaddr;
00027
WvIPNet *my_ipaddr;
00028
00029
WvLog err;
00030
00031
00032
00033
void fill_rte(
struct rtentry *rte,
char ifname[17],
00034
const WvIPNet &dest,
const WvIPAddr &gw,
00035
int metric);
00036
00037
int really_addroute(
const WvIPNet &dest,
const WvIPAddr &gw,
00038
const WvIPAddr &src,
int metric,
00039
WvStringParm table,
bool shutup);
00040
public:
00041 WvString name;
00042 bool valid;
00043
00044
WvInterface(
WvStringParm _name);
00045
~WvInterface();
00046
00047
00048
void rescan();
00049
00050
00051
const WvAddr &
hwaddr();
00052
00053
00054
const WvIPNet &
ipaddr();
00055
00056
00057
const WvIPAddr dstaddr();
00058
00059
00060
int getflags();
00061
00062
00063
int setflags(
int clear,
int set);
00064
00065
00066
bool isup();
00067
void up(
bool enable);
00068
00069
00070
bool ispromisc();
00071
void promisc(
bool enable);
00072
00073
00074
00075
00076
00077
00078
00079
int setipaddr(
const WvIPNet &addr);
00080
00081
00082
00083
00084
00085
00086
int setmtu(
int mtu);
00087
00088
00089
00090
00091
00092
00093
int sethwaddr(
const WvAddr &addr);
00094
00095
00096
int addroute(
const WvIPNet &dest,
int metric = 0,
00097
WvStringParm table =
"default");
00098
int addroute(
const WvIPNet &dest,
const WvIPAddr &gw,
00099
const WvIPAddr &src,
int metric = 0,
00100
WvStringParm table =
"default");
00101
00102
00103
int delroute(
const WvIPNet &dest,
int metric = 0,
00104
WvStringParm table =
"default");
00105
int delroute(
const WvIPNet &dest,
const WvIPAddr &gw,
int metric = 0,
00106
WvStringParm table =
"default");
00107
00108
00109
bool isarp();
00110
int addarp(
const WvIPNet &proto,
const WvAddr &hw,
bool proxy);
00111
00112
00113
int req(
int ioctl_num,
struct ifreq *ifr);
00114
00115
00116
int req(
int ioctl_num,
struct iwreq *ifr);
00117 };
00118
00119
DeclareWvDict2(WvInterfaceDictBase,
WvInterface,
WvString, name);
00120
00121 class WvInterfaceDict
00122 {
00123
public:
00124 WvLog log;
00125
static WvInterfaceDictBase
slist;
00126
static int links;
00127
00128 class Iter :
public WvInterfaceDictBase::
Iter
00129 {
00130
public:
00131 Iter(
WvInterfaceDict &l)
00132 : WvInterfaceDictBase::
Iter(l.slist)
00133 { }
00134 };
00135
00136
WvInterfaceDict();
00137
~WvInterfaceDict();
00138
00139
void update();
00140
bool islocal(
const WvAddr &addr);
00141
bool on_local_net(
const WvIPNet &addr);
00142
00143 WvInterface *operator[] (
WvStringParm str)
00144 {
return slist[str]; }
00145
00146
00147
00148 };
00149
00150
#endif // __WVINTERFACE_H