1 |
// Copyright (C) 2003 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 |
#define RCSID "$Id: PXScanModule.cc,v 1.4 2006/09/11 22:02:54 spale Exp $" |
20 |
|
21 |
#ifdef HAVE_CONFIG_H |
22 |
#include "config.h" |
23 |
#endif |
24 |
|
25 |
#include "PXScanModule.h" |
26 |
#include "PXScan.h" |
27 |
#include "PXScanManager.h" |
28 |
#include "PXConfig.h" |
29 |
#include <iostream> |
30 |
|
31 |
using std::clog; |
32 |
using std::endl; |
33 |
|
34 |
PXScanModule::PXScanModule(PXScan *inScan) |
35 |
: mScan(inScan) |
36 |
{ |
37 |
} |
38 |
|
39 |
PXScanModule::~PXScanModule() |
40 |
{ |
41 |
} |
42 |
|
43 |
void |
44 |
PXScanModule::RegisterPXM(const char *inShortName, |
45 |
uint16_t inPort, |
46 |
uint32_t *inConnCountPtr, |
47 |
uint32_t *inProxyCountPtr) const |
48 |
{ |
49 |
mScan->SneakModule(inShortName, inPort, inConnCountPtr, inProxyCountPtr); |
50 |
} |
51 |
|
52 |
/* Cheap wrapper to hide class PXScan and others from the modules */ |
53 |
in_addr |
54 |
PXScanModule::GetAddress() const |
55 |
{ |
56 |
return mScan->GetAddress(); |
57 |
} |
58 |
|
59 |
bool |
60 |
PXScanModule::IsLocalAddressSet() const |
61 |
{ |
62 |
return mScan->mScanManager->mConfig->HasSourcePool(); |
63 |
} |
64 |
|
65 |
in_addr |
66 |
PXScanModule::GetLocalAddress() const |
67 |
{ |
68 |
return mScan->mScanManager->mConfig->GetOneFromSourcePool(); |
69 |
} |
70 |
|
71 |
time_t |
72 |
PXScanModule::GetTimeout() const |
73 |
{ |
74 |
return mScan->mScanManager->mConfig->scanner.timeout; |
75 |
} |
76 |
|
77 |
in_addr |
78 |
PXScanModule::GetTargetAddress() const |
79 |
{ |
80 |
return mScan->mScanManager->GetTargetAddress(); |
81 |
} |
82 |
|
83 |
uint16_t |
84 |
PXScanModule::GetTargetPort() const |
85 |
{ |
86 |
return mScan->mScanManager->GetTargetPort(); |
87 |
} |
88 |
|
89 |
char * |
90 |
PXScanModule::GetTargetSecret() const |
91 |
{ |
92 |
return mScan->mScanManager->GetTargetSecret(); |
93 |
} |
94 |
|
95 |
bool |
96 |
PXScanModule::LogAgent() const |
97 |
{ |
98 |
return mScan->mScanManager->GetFAgent().is_open(); |
99 |
} |
100 |
|
101 |
ofstream& |
102 |
PXScanModule::GetFAgent() |
103 |
{ |
104 |
return mScan->mScanManager->GetFAgent(); |
105 |
} |
106 |
|
107 |
void |
108 |
PXScanModule::ProxyNotFound() |
109 |
{ |
110 |
mScan->Completed(this); |
111 |
} |
112 |
|
113 |
void |
114 |
PXScanModule::ProxyFound(uint16_t inTypeOfProxy, uint16_t inPort, |
115 |
const char *inDescr) |
116 |
{ |
117 |
mScan->ProxyFound(inTypeOfProxy, inPort, inDescr); |
118 |
mScan->Completed(this); |
119 |
} |
120 |
|
121 |
void |
122 |
PXScanModule::ScanError(int error) |
123 |
{ |
124 |
mScan->Error(error); |
125 |
mScan->Completed(this); |
126 |
} |