3 // $Id: Pctest.h,v 1.14 2000/01/19 17:14:42 bmah Exp $
6 // Bruce A. Mah <bmah@ca.sandia.gov>
8 // This work was first produced by an employee of Sandia National
9 // Laboratories under a contract with the U.S. Department of Energy.
10 // Sandia National Laboratories dedicates whatever right, title or
11 // interest it may have in this software to the public. Although no
12 // license from Sandia is needed to copy and use this software,
13 // copying and using the software might infringe the rights of
14 // others. This software is provided as-is. SANDIA DISCLAIMS ANY
15 // WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
17 // Header for virtual base class of tests. A particular protocol (e.g.
18 // IPv4, IPv6) will override the methods of this base class
19 // with protocol-specific implementations.
31 #endif /* STDC_HEADERS */
34 #include <sys/types.h>
35 #endif /* HAVE_UNISTD_H */
37 #include <sys/socket.h>
41 // #include "TestRecord.h"
44 // Action codes. ICMPv4 and ICMPv6 have different values for their type
45 // and code fields. The Pctest abstracts these differences.
47 PctestActionValid
, // store valid measurement (e.g. ICMP
49 PctestActionValidLasthop
, // store valid measurement, this is last hop
50 // (e.g. ICMP port unreachable)
51 PctestActionFiltered
, // packets filtered, give up (e.g.
53 PctestActionAbort
// huh? we haven't a clue
61 TimeSyscall(syscallTime
);
63 IF_DEBUG(3, fprintf(stderr
, "syscallTime.tv_usec = %ld\n", syscallTime
.tv_usec
));
65 virtual ~Pctest() { };
67 // Get gettimeofday() system call overhead.
68 virtual void TimeSyscall(struct timeval
&diff
);
70 // Get random payload buffer
71 virtual char *GeneratePayload(int size
);
73 // Set target host for our tests (resolve if necessary)
74 virtual int SetTargetName(char *target
) = 0;
76 // Get target host name and address
77 virtual char *GetTargetName() { return targetName
; };
78 virtual char *GetPrintableAddress() = 0;
79 virtual char *GetPrintableAddress(void *a
) = 0;
80 virtual char *GetName(void *a
) = 0;
81 virtual char *GetAddressFamily() = 0;
83 // Perform a test and return statistics
84 virtual int Test(TestRecord
&tr
) = 0;
85 virtual PctestActionType
GetAction(TestRecord
&tr
) = 0;
86 virtual PctestActionType
GetAction(TestRecord
*tr
) {
87 return this->GetAction(*tr
);
90 virtual int GetMinSize() = 0;
93 int initialized
; // initialization flag
94 char *targetName
; // target hostname
95 struct timeval syscallTime
; // estimated overhead for gettimeofday()