]> code.delx.au - gnu-emacs/blob - test/etags/cp-src/Pctest.h
Add a test suite for etags
[gnu-emacs] / test / etags / cp-src / Pctest.h
1 // -*- c++ -*-
2 //
3 // $Id: Pctest.h,v 1.14 2000/01/19 17:14:42 bmah Exp $
4 //
5 // Pctest.h
6 // Bruce A. Mah <bmah@ca.sandia.gov>
7 //
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.
16 //
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.
20 //
21 //
22
23 #ifndef PCTEST_H
24 #define PCTEST_H
25
26 #include <stdio.h>
27
28 #if STDC_HEADERS
29 #include <stdlib.h>
30 #include <string.h>
31 #endif /* STDC_HEADERS */
32
33 #if HAVE_UNISTD_H
34 #include <sys/types.h>
35 #endif /* HAVE_UNISTD_H */
36
37 #include <sys/socket.h>
38 #include <sys/time.h>
39
40 #include "pc.h"
41 // #include "TestRecord.h"
42 class TestRecord;
43
44 // Action codes. ICMPv4 and ICMPv6 have different values for their type
45 // and code fields. The Pctest abstracts these differences.
46 typedef enum {
47 PctestActionValid, // store valid measurement (e.g. ICMP
48 // time exceeded)
49 PctestActionValidLasthop, // store valid measurement, this is last hop
50 // (e.g. ICMP port unreachable)
51 PctestActionFiltered, // packets filtered, give up (e.g.
52 // ICMP prohibited)
53 PctestActionAbort // huh? we haven't a clue
54 } PctestActionType;
55
56 class Pctest {
57
58 public:
59 Pctest() {
60 initialized = 0;
61 TimeSyscall(syscallTime);
62
63 IF_DEBUG(3, fprintf(stderr, "syscallTime.tv_usec = %ld\n", syscallTime.tv_usec));
64 }
65 virtual ~Pctest() { };
66
67 // Get gettimeofday() system call overhead.
68 virtual void TimeSyscall(struct timeval &diff);
69
70 // Get random payload buffer
71 virtual char *GeneratePayload(int size);
72
73 // Set target host for our tests (resolve if necessary)
74 virtual int SetTargetName(char *target) = 0;
75
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;
82
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);
88 };
89
90 virtual int GetMinSize() = 0;
91
92 protected:
93 int initialized; // initialization flag
94 char *targetName; // target hostname
95 struct timeval syscallTime; // estimated overhead for gettimeofday()
96
97 };
98
99 #endif /* PCTEST_H */