WvStreams
include/wvinterface.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2005 Net Integration Technologies, Inc.
4 *
5 * Provides support for managing network interfaces.
6 */
7
8#ifndef __WVINTERFACE_H
9#define __WVINTERFACE_H
10
11#include "wvaddr.h"
12#include "wvhashtable.h"
13#include "wvlog.h"
14
15struct ifreq;
16struct iwreq;
17struct rtentry;
18
24class WvInterface
25{
26 WvAddr *my_hwaddr;
27 WvIPNet *my_ipaddr;
28
29 WvLog err;
30
31
33 void fill_rte(struct rtentry *rte, char ifname[17],
34 const WvIPNet &dest, const WvIPAddr &gw,
35 int metric);
36
37 int really_addroute(const WvIPNet &dest, const WvIPAddr &gw,
38 const WvIPAddr &src, int metric,
39 WvStringParm table, bool shutup);
40public:
41 WvString name;
42 bool valid;
43
46
48 void rescan();
49
51 const WvAddr &hwaddr();
52
54 const WvIPNet &ipaddr();
55
58
60 int getflags();
61
63 int setflags(int clear, int set);
64
66 bool isup();
67 void up(bool enable);
68
70 bool ispromisc();
71 void promisc(bool enable);
72
74 int ptp(bool enable, const WvIPNet &addr);
75
82 int setipaddr(const WvIPNet &addr);
83
89 int setmtu(int mtu);
90
96 int sethwaddr(const WvAddr &addr);
97
99 int addroute(const WvIPNet &dest, int metric = 0,
100 WvStringParm table = "default");
101 int addroute(const WvIPNet &dest, const WvIPAddr &gw,
102 const WvIPAddr &src, int metric = 0,
103 WvStringParm table = "default");
104
106 int delroute(const WvIPNet &dest, int metric = 0,
107 WvStringParm table = "default");
108 int delroute(const WvIPNet &dest, const WvIPAddr &gw, int metric = 0,
109 WvStringParm table = "default");
110
112 bool isarp();
113 int addarp(const WvIPNet &proto, const WvAddr &hw, bool proxy);
114
116 int req(int ioctl_num, struct ifreq *ifr);
117
119 int req(int ioctl_num, struct iwreq *ifr);
120};
121
122DeclareWvDict2(WvInterfaceDictBase, WvInterface, WvString, name);
123
124class WvInterfaceDict
125{
126public:
127 WvLog log;
128 static WvInterfaceDictBase slist;
129 static int links;
130
131 class Iter : public WvInterfaceDictBase::Iter
132 {
133 public:
134 Iter(WvInterfaceDict &l)
135 : WvInterfaceDictBase::Iter(l.slist)
136 { }
137 };
138
139 class Sorter : public WvInterfaceDictBase::Sorter
140 {
141 public:
142 Sorter(WvInterfaceDict &l,
143 WvInterfaceDictBase::Sorter::RealCompareFunc *f)
144 : WvInterfaceDictBase::Sorter(l.slist, f)
145 { }
146 };
147
150
151 void update();
152 WvString islocal(const WvAddr &addr);
153 bool on_local_net(const WvIPNet &addr);
154
155 WvInterface *operator[] (WvStringParm str)
156 { return slist[str]; }
157
158 //operator WvInterfaceDictBase ()
159 // { return slist; }
160};
161
162#endif // __WVINTERFACE_H
Base class for different address types, each of which will have the ability to convert itself to/from...
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
An IP address is made up of a "dotted quad" – four decimal numbers in the form www....
An IP network comprises two WvIPAddr structures: an address and a netmask.
A WvInterface manages a particular network interface.
int setflags(int clear, int set)
toggle kernel flags on this netdevice.
int setipaddr(const WvIPNet &addr)
Sets the local address, netmask, and broadcast of this interface and set a route to the local net.
int req(int ioctl_num, struct iwreq *ifr)
get/set information about a wireless interface
const WvIPAddr dstaddr()
get the point-to-point IP address of this interface
bool isarp()
add an ARP entry on this interface
const WvIPNet & ipaddr()
get the local IP net of this interface
int delroute(const WvIPNet &dest, int metric=0, WvStringParm table="default")
delete a route to the given network through this interface.
int ptp(bool enable, const WvIPNet &addr)
turn point-to-point mode on or off.
int req(int ioctl_num, struct ifreq *ifr)
get/set information about an interface
bool isup()
set the interface state up or down.
const WvAddr & hwaddr()
get the hardware address of this interface
int getflags()
get the current kernel flags
void rescan()
forget all stored information about the address(es) of this interface
int setmtu(int mtu)
Sets the MTU of the interface.
int sethwaddr(const WvAddr &addr)
Set the hardware address of this interface.
bool ispromisc()
turn promiscuous (see-all-packets) mode on or off.
int addroute(const WvIPNet &dest, int metric=0, WvStringParm table="default")
add a route to the given network through this interface.
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
WvString is an implementation of a simple and efficient printable-string class.