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

wvipfirewall.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * WvIPFirewall is an extremely simple hackish class that handles the Linux
00006  * 2.4 "iptables" firewall.  It's okay to create more than one instance
00007  * of this class; they'll co-operate.
00008  * 
00009  * They need you to have created the appropriate firewall tables already,
00010  * however, and call them from the right places in the Input and/or Forward
00011  * firewalls.
00012  */
00013 #ifndef __WVIPFIREWALL_H
00014 #define __WVIPFIREWALL_H
00015 
00016 #include "wvinterface.h"
00017 #include "wvstringlist.h"
00018 #include "wvaddr.h"
00019 
00020 
00021 DeclareWvList(WvIPPortAddr);
00022 
00024 class WvIPFirewall
00025 {
00026     class Redir
00027     {
00028     public:
00029         WvIPPortAddr src;
00030         int dstport;
00031         
00032         Redir(const WvIPPortAddr &_src, int _dstport) : src(_src)
00033             { dstport = _dstport; }
00034     };
00035 
00036     class RedirAll
00037     {
00038     public:
00039         int dstport;
00040         
00041         RedirAll(int _dstport) 
00042             { dstport = _dstport; }
00043     };
00044 
00045     class RedirPortRange
00046     {
00047     public:
00048         WvIPPortAddr src_min;
00049         WvIPPortAddr src_max;
00050         int dstport;
00051         
00052         RedirPortRange(const WvIPPortAddr &_src_min,
00053                 const WvIPPortAddr &_src_max, int _dstport)
00054             : src_min(_src_min), src_max(_src_max)
00055             { dstport = _dstport; }
00056     };
00057 
00058     DeclareWvList(Redir);
00059     DeclareWvList(RedirAll);
00060     DeclareWvList(RedirPortRange);
00061 
00062     RedirList redirs;
00063     RedirAllList redir_alls;
00064     RedirPortRangeList redir_port_ranges;
00065 
00066     WvIPPortAddrList addrs;
00067     WvStringList protos;
00068     
00069     WvString port_command(const char *cmd, const char *proto,
00070                           const WvIPPortAddr &addr);
00071     WvString redir_command(const char *cmd,
00072                            const WvIPPortAddr &src, int dstport);
00073     WvString redir_port_range_command(const char *cmd,
00074         const WvIPPortAddr &src_min, const WvIPPortAddr &src_max, int dstport);
00075     WvString redir_all_command(const char *cmd, int dstport);
00076     WvString proto_command(const char *cmd, const char *proto);
00077     WvString forward_command(const char *cmd, const char *proto,
00078                              const WvIPPortAddr &src,
00079                              const WvIPPortAddr &dst, bool snat);
00080     WvLog log;
00081     const char *shutup() const
00082         { return ignore_errors ? " >/dev/null 2>/dev/null " : ""; }
00083     
00084 public:
00085     WvIPFirewall();
00086     ~WvIPFirewall();
00087     
00088     static bool enable, ignore_errors;
00089     
00090     void zap();
00091     void add_port(const WvIPPortAddr &addr);
00092     void add_redir(const WvIPPortAddr &src, int dstport);
00093     void add_redir_all(int dstport);
00094     void add_redir_port_range(const WvIPPortAddr &src_min,
00095             const WvIPPortAddr &src_max, int dstport);
00096     void add_proto(WvStringParm proto);
00097     void add_forward(const WvIPPortAddr &src, const WvIPPortAddr &dst,
00098             bool snat);
00099     void del_proto(WvStringParm proto);
00100     void del_port(const WvIPPortAddr &addr);
00101     void del_redir(const WvIPPortAddr &src, int dstport);
00102     void del_forward(const WvIPPortAddr &src, const WvIPPortAddr &dst,
00103             bool snat);
00104     void del_redir_all(int dstport);
00105     void del_redir_port_range(const WvIPPortAddr &src_min,
00106             const WvIPPortAddr &src_max, int dstport);
00107 };
00108 
00109 #endif // __WVIPFIREWALL_H

Generated on Sun Jul 10 18:25:52 2005 for WvStreams by  doxygen 1.4.0