Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

wvinterface.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * Provides support for managing network interfaces.
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 
00024 class WvInterface
00025 {
00026     WvAddr *my_hwaddr;
00027     WvIPNet *my_ipaddr;
00028     
00029     WvLog err;
00030     
00031     
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     
00048     void rescan();
00049     
00051     const WvAddr &hwaddr();
00052     
00054     const WvIPNet &ipaddr();
00055     
00057     const WvIPAddr dstaddr();
00058     
00060     int getflags();
00061     
00063     int setflags(int clear, int set);
00064 
00066     bool isup();
00067     void up(bool enable);
00068 
00070     bool ispromisc();
00071     void promisc(bool enable);
00072     
00079     int setipaddr(const WvIPNet &addr);
00080     
00086     int setmtu(int mtu);
00087 
00093     int sethwaddr(const WvAddr &addr);
00094     
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 
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     
00109     bool isarp();
00110     int addarp(const WvIPNet &proto, const WvAddr &hw, bool proxy);
00111 
00113     int req(int ioctl_num, struct ifreq *ifr);
00114 
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     class Sorter : public WvInterfaceDictBase::Sorter
00137     {
00138     public:
00139         Sorter(WvInterfaceDict &l,
00140                WvInterfaceDictBase::Sorter::RealCompareFunc *f)
00141             : WvInterfaceDictBase::Sorter(l.slist, f)
00142             { }
00143     };
00144     
00145     WvInterfaceDict();
00146     ~WvInterfaceDict();
00147     
00148     void update();
00149     bool islocal(const WvAddr &addr);
00150     bool on_local_net(const WvIPNet &addr);
00151 
00152     WvInterface *operator[] (WvStringParm str)
00153         { return slist[str]; }
00154     
00155     //operator WvInterfaceDictBase ()
00156     //    { return slist; }
00157 };
00158 
00159 #endif // __WVINTERFACE_H

Generated on Sun Jul 10 17:30:56 2005 for WvStreams by  doxygen 1.4.0