-
Notifications
You must be signed in to change notification settings - Fork 30
/
Service.h
149 lines (122 loc) · 2.42 KB
/
Service.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#pragma once
#include <vector>
#include <chrono>
#include "Stdafx.h"
/*!
* List of reasons which caused the host to be determined as it is.
*/
typedef enum
{
/*!
* Error occurred during scan.
*/
AR_ScanFailed = -1,
/*!
* Service hasn't yet been scanned.
*/
AR_NotScanned = 0,
/*!
* Service is being scanned.
*/
AR_InProgress = 1,
/*!
* Service is alive, but still being scanned.
*/
AR_InProgress_Extra = 2,
/*!
* Service didn't reply within specified timeframe.
*/
AR_TimedOut = 3,
/*!
* ICMP Destination Unreachable received.
*/
AR_IcmpUnreachable = 4,
/*!
* Service replied within specified timeframe.
*/
AR_ReplyReceived = 5
} AliveReason;
/*!
* Represents a service in the form of an IP/port.
*/
class Service
{
public:
/*!
* Remote address.
*/
std::string address;
/*!
* Remote port.
*/
unsigned short port;
/*!
* Remote protocol.
*/
IPPROTO protocol;
/*!
* Whether the service is alive at this host.
*/
bool alive;
/*!
* Reason for the value specified in `alive`.
* Negative values are errors, positive values are scanner-dependent reasons.
*/
AliveReason reason;
/*!
* Service banner, if any.
*/
std::string banner;
/*!
* CPE names of the service.
*/
std::vector<std::string> cpe;
/*!
* Time of last packet sent to this service.
*/
std::chrono::time_point<std::chrono::system_clock> date;
/*!
* Parent host of this service.
*/
class Host* host;
/*!
* Object store reserved for the scanner.
*/
void* data;
/*!
* Copies the specified instance.
*
* \param service Instance to copy.
*/
Service(const Service& service);
/*!
* Creates a new instance of this type.
*
* \param address Remote address.
* \param port Remote port.
* \param protocol Remote protocol, otherwise TCP.
*/
Service(const std::string& address, unsigned short port, IPPROTO protocol = IPPROTO_TCP);
/*!
* Resolves the value of the enum `AliveReason` to its textual representation.
*
* \param reason Enum value.
*
* \return Textual representation.
*/
static std::string ReasonString(AliveReason reason);
/*!
* Frees up the resources allocated during the lifetime of this instance.
*/
~Service();
};
/*!
* Represents a list of services.
*/
typedef std::vector<Service*> Services;
/*!
* Frees up the structures allocated within this array.
*
* \param services List of services.
*/
void freeServices(Services& services);