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 |
// $Id: PXScanModule.h,v 1.4 2006/09/11 22:02:54 spale Exp $ |
20 |
// |
21 |
#ifndef INCLUDED_PXSCANMODULE_H_ |
22 |
#define INCLUDED_PXSCANMODULE_H_ |
23 |
|
24 |
#include <fstream> |
25 |
#include <cstdlib> |
26 |
#include <ctime> |
27 |
|
28 |
#include <sys/types.h> |
29 |
#include <sys/socket.h> |
30 |
#include <netinet/in.h> |
31 |
|
32 |
#include <opas/opas.h> |
33 |
|
34 |
using std::ofstream; |
35 |
|
36 |
class PXScan; |
37 |
|
38 |
class PXScanModule |
39 |
{ |
40 |
public: |
41 |
PXScanModule(PXScan *inScan); |
42 |
virtual ~PXScanModule(); |
43 |
|
44 |
// Module interface (implement this when you create a new module) |
45 |
|
46 |
// You're advised to override this and call RegisterPXM() to enable stats |
47 |
virtual void InitModule() {} |
48 |
|
49 |
// You only need to implement this to start the scan (see examples...) |
50 |
virtual bool StartScan() = 0; |
51 |
|
52 |
// --End of interface-- |
53 |
|
54 |
// Recommended call in InitModule() (will enable stats for this module) |
55 |
|
56 |
void RegisterPXM(const char *inShortName, uint16_t inPort, |
57 |
uint32_t *inConnCountPtr, uint32_t *inProxyCountPtr) const; |
58 |
|
59 |
// Utilities available for modules |
60 |
|
61 |
virtual in_addr GetAddress() const; |
62 |
|
63 |
virtual bool IsLocalAddressSet() const; |
64 |
virtual in_addr GetLocalAddress() const; |
65 |
|
66 |
virtual time_t GetTimeout() const; |
67 |
|
68 |
// You can use this target to perform your proxy scan |
69 |
virtual in_addr GetTargetAddress() const; |
70 |
virtual uint16_t GetTargetPort() const; |
71 |
virtual char* GetTargetSecret() const; |
72 |
|
73 |
// Special for http proxy agent logging |
74 |
virtual bool LogAgent() const; |
75 |
virtual ofstream& GetFAgent(); |
76 |
|
77 |
// Finally, the result methods.. A scan modules should reply |
78 |
// (asynchronously) one of the 3 following methods |
79 |
|
80 |
// Not found. |
81 |
virtual void ProxyNotFound(); |
82 |
// Proxy found, fill the info. |
83 |
virtual void ProxyFound(uint16_t inTypeOfProxy, uint16_t inPort, |
84 |
const char *inDescr); |
85 |
// An fatal error occured (usually only ENETUNREACH) |
86 |
virtual void ScanError(int error); |
87 |
|
88 |
private: |
89 |
PXScan *mScan; // Opaque scan object, do not use. |
90 |
}; |
91 |
|
92 |
#endif // INCLUDED_PXSCANMODULE_H_ |