ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/vendor/pxys2-2.0.0/pxyscand/src/PXServer.h
Revision: 3252
Committed: Wed Apr 2 20:41:43 2014 UTC (10 years ago) by michael
Content type: text/x-chdr
File size: 3209 byte(s)
Log Message:
- Imported pxys2-2.0.0

File Contents

# Content
1 // Copyright (C) 2003, 2004 Stephane Thiell
2 //
3 // This file is part of pxyscand (from pxys)
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // $Id: PXServer.h,v 1.3 2004/01/10 14:32:29 mbuna Exp $
20 //
21 #ifndef INCLUDED_PXSERVER_H_
22 #define INCLUDED_PXSERVER_H_
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include "PXIPCacheT.h" // IP cache template class
29 #include "PXRepeater.h"
30 #include "PXServiceMsg.h"
31
32 #include <list>
33 #include <map>
34 #include <opas/opas.h>
35 #include <peak/peak.h>
36
37 #define MAX_SESSIONS 64
38
39 using std::list;
40
41 class PXConfig;
42 class PXCore;
43 class PXScan;
44 class PXScanManager;
45 class PXSession;
46
47 struct IPLess
48 {
49 bool operator()(const in_addr &x, const in_addr &y) const
50 {
51 return x.s_addr < y.s_addr;
52 }
53 };
54
55 struct PXProxyBinInfo
56 {
57 uint32_t cache_hits;
58 uint16_t type;
59 uint16_t port;
60 char descr[100];
61 };
62
63 class PXServer : public PXRepeater
64 {
65 typedef std::map<in_addr, PXScan*, IPLess> scanMapType;
66 typedef scanMapType::value_type scanMapPairType;
67
68 public:
69 PXServer(PXConfig *inConfig, PXScanManager *inScanManager, PXCore *inCore);
70 ~PXServer();
71
72 int Start();
73 void Rehash();
74
75 void SessionClosed(PXSession *inSession);
76 void CreateStatus(PXSStatus **outStatus, size_t *outSize) const;
77 void GetStats(PXSStats &oStats);
78
79 void NewScanIP4(const opas_msg_query &inQuery, PXSession *inSession);
80 void DeleteScanIP4(const opas_msg_query &inQuery);
81 void ScanIP4ResultNoProxy(const opas_msg_query &inQuery);
82 void ScanIP4ResultProxy(const opas_msg_query &inQuery,
83 uint16_t inTypeOfProxy, uint16_t inPort,
84 const char *inDescr);
85 bool RemoveAddressFromCache(const in_addr &inAddress);
86 bool RemoveAddressFromCache(const in6_addr &inAddress);
87
88 protected:
89 void ProcessEvent(peak_stream s, int type);
90 void EventRead(peak_stream s);
91 void NewConnection(peak_stream s);
92
93 void RepeaterFire();
94
95 static void EventCallback(peak_stream s, int type, void *context);
96
97 PXConfig *mConfig;
98 PXScanManager *mScanManager;
99 PXCore *mCore;
100
101 PXIPCacheT<in_addr> * mIP4Cache;
102 PXIPCacheT<in_addr> * mPX4Cache;
103
104 peak_stream mLStream;
105 peak_task_mutex mCacheMutex, mScanMutex;
106 list<PXSession*> mSessions;
107 uint32_t mSessionCount;
108 uint32_t mSessionRejectedCount;
109 scanMapType mScans;
110
111 uint32_t mQueryCount;
112 uint32_t mScannedCount;
113 uint32_t mProxyCount;
114 uint32_t mNoScanHits;
115 uint32_t mIPCacheHits;
116 uint32_t mPXCacheHits;
117 uint32_t mInProgressCount;
118
119 };
120
121 #endif // INCLUDED_PXSERVER_H_