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

wvipfirewall.h

Go to the documentation of this file.
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 "wvstringlist.h"
00017 #include "wvaddr.h"
00018 
00019 
00020 DeclareWvList(WvIPPortAddr);
00021 
00022 /** Class to handle Linux 2.4 IPTables */
00023 class WvIPFirewall
00024 {
00025     class Redir
00026     {
00027     public:
00028         WvIPPortAddr src;
00029         int dstport;
00030         
00031         Redir(const WvIPPortAddr &_src, int _dstport) : src(_src)
00032             { dstport = _dstport; }
00033     };
00034 
00035     DeclareWvList(Redir);
00036 
00037     RedirList redirs;
00038     WvIPPortAddrList addrs;
00039     WvStringList protos;
00040     
00041     WvString port_command(const char *cmd, const char *proto,
00042                           const WvIPPortAddr &addr);
00043     WvString redir_command(const char *cmd,
00044                            const WvIPPortAddr &src, int dstport);
00045     WvString proto_command(const char *cmd, const char *proto);
00046     const char *shutup() const
00047         { return ignore_errors ? " >/dev/null 2>/dev/null " : ""; }
00048     
00049 public:
00050     WvIPFirewall();
00051     ~WvIPFirewall();
00052     
00053     static bool enable, ignore_errors;
00054     
00055     void zap();
00056     void add_port(const WvIPPortAddr &addr);
00057     void add_redir(const WvIPPortAddr &src, int dstport);
00058     void add_proto(WvStringParm proto);
00059     void del_proto(WvStringParm proto);
00060     void del_port(const WvIPPortAddr &addr);
00061     void del_redir(const WvIPPortAddr &src, int dstport);
00062 };
00063 
00064 #endif // __WVIPFIREWALL_H

Generated on Wed Dec 15 15:08:11 2004 for WvStreams by  doxygen 1.3.9.1