1 |
michael |
3252 |
// 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: PXSession.h,v 1.1.1.1 2003/12/30 17:09:02 mbuna Exp $ |
20 |
|
|
// |
21 |
|
|
#ifndef INCLUDED_PXSESSION_H_ |
22 |
|
|
#define INCLUDED_PXSESSION_H_ |
23 |
|
|
|
24 |
|
|
#ifdef HAVE_CONFIG_H |
25 |
|
|
#include "config.h" |
26 |
|
|
#endif |
27 |
|
|
|
28 |
|
|
#include <opas/opas.h> |
29 |
|
|
#include <peak/peak.h> |
30 |
|
|
|
31 |
|
|
class PXServer; |
32 |
|
|
|
33 |
|
|
class PXSession |
34 |
|
|
{ |
35 |
|
|
enum { PX_SESSION_STATUS_VALID, PX_SESSION_STATUS_INVALID }; |
36 |
|
|
|
37 |
|
|
friend class PXServer; |
38 |
|
|
public: |
39 |
|
|
PXSession(PXServer *inServer, peak_stream inStream); |
40 |
|
|
|
41 |
|
|
void Invalidate(); |
42 |
|
|
bool IsValid() const { return mStatus == PX_SESSION_STATUS_VALID; } |
43 |
|
|
int GetStatus() const { return mStatus; } |
44 |
|
|
|
45 |
|
|
void Retain() { mRefCnt++; } |
46 |
|
|
void Release(); |
47 |
|
|
|
48 |
|
|
void ScanCompletedNoProxy(const opas_msg_query &inQuery); |
49 |
|
|
void ScanCompletedProxy(const opas_msg_query &inQuery, |
50 |
|
|
uint16_t inTypeOfProxy, uint16_t inPort, |
51 |
|
|
const char *inDescr); |
52 |
|
|
void ScanCompletedWithError(const opas_msg_query &inQuery); |
53 |
|
|
|
54 |
|
|
void ScanResultNoProxy(const opas_msg_query &inQuery, bool fromCache); |
55 |
|
|
void ScanResultProxy(const opas_msg_query &inQuery, bool fromCache, |
56 |
|
|
time_t ts, uint16_t inTypeOfProxy, uint16_t inPort, |
57 |
|
|
const char *inDescr); |
58 |
|
|
void ScanResultError(const opas_msg_query &inQuery, int error); |
59 |
|
|
|
60 |
|
|
protected: |
61 |
|
|
virtual ~PXSession(); |
62 |
|
|
|
63 |
|
|
void ReplyStatus(uint32_t inUserData); |
64 |
|
|
void ReplyStats(uint32_t inUserData); |
65 |
|
|
void HandleRemove(opas_msg_user_header &umsg, void *data); |
66 |
|
|
|
67 |
|
|
void Query(opas_msg_query &inQuery); |
68 |
|
|
void MsgUser(opas_msg_user_header &umsg, void *data); |
69 |
|
|
void MsgUserUnknown(opas_msg_user_header &umsg); |
70 |
|
|
void ScanDone(opas_msg_query &inQuery); |
71 |
|
|
|
72 |
|
|
void ProcessEvent(peak_stream s, int type); |
73 |
|
|
void EventRead(peak_stream s); |
74 |
|
|
|
75 |
|
|
static void EventCallback(peak_stream s, int type, void *context); |
76 |
|
|
|
77 |
|
|
static void OPASSend(const void *data, uint32_t length, void *uptr); |
78 |
|
|
static void OPASQuery(struct opas_msg_query *queryp, void *context); |
79 |
|
|
static void OPASReplyNoProxy(struct opas_msg_query *replyp, void *context); |
80 |
|
|
static void OPASReplyProxy(struct opas_msg_reply_proxy *replyp, |
81 |
|
|
void *context); |
82 |
|
|
|
83 |
|
|
static void OPASQuery6(struct opas_msg_query6 *queryp, void *context); |
84 |
|
|
static void OPASReply6NoProxy(struct opas_msg_query6 *replyp, |
85 |
|
|
void *context); |
86 |
|
|
static void OPASReply6Proxy(struct opas_msg_reply6_proxy *replyp, |
87 |
|
|
void *context); |
88 |
|
|
|
89 |
|
|
static void OPASMsgUser(struct opas_msg_user_header *umsgp, void *data, |
90 |
|
|
void *context); |
91 |
|
|
|
92 |
|
|
PXServer *mServer; |
93 |
|
|
opas_session_t mOPASSession; |
94 |
|
|
peak_stream mStream; |
95 |
|
|
bool mTimedOut; |
96 |
|
|
int mRefCnt, mStatus; |
97 |
|
|
|
98 |
|
|
uint32_t mQueryCount; |
99 |
|
|
uint32_t mScannedCount; |
100 |
|
|
uint32_t mProxyCount; |
101 |
|
|
uint32_t mErrorCount; |
102 |
|
|
}; |
103 |
|
|
|
104 |
|
|
#endif // INCLUDED_PXSESSION_H_ |