]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testIcmp.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / tests / testIcmp.h
1 /*
2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_SRC_TESTS_TESTICMP_H
10 #define SQUID_SRC_TESTS_TESTICMP_H
11
12 #include "compat/cppunit.h"
13
14 #if USE_ICMP
15
16 #include "icmp/Icmp.h"
17
18 class stubIcmp : public Icmp
19 {
20 public:
21 stubIcmp() {};
22 virtual ~stubIcmp() {};
23 virtual int Open() { return 0; };
24 virtual void Close() {};
25
26 /// Construct ECHO request
27 virtual void SendEcho(Ip::Address &to, int opcode, const char *payload, int len) {};
28
29 /// Handle ICMP responses.
30 virtual void Recv(void) {};
31
32 /* methods to relay test data from tester to private methods being tested */
33 int testChecksum(unsigned short *ptr, int size) { return CheckSum(ptr,size); };
34 int testHops(int ttl) { return ipHops(ttl); };
35 };
36 #endif
37
38 /**
39 * test the ICMP base class.
40 */
41 class testIcmp : public CPPUNIT_NS::TestFixture
42 {
43 CPPUNIT_TEST_SUITE( testIcmp );
44 CPPUNIT_TEST( testChecksum );
45 CPPUNIT_TEST( testHops );
46 CPPUNIT_TEST_SUITE_END();
47
48 protected:
49 void testChecksum();
50 void testHops();
51 };
52
53 #endif /* SQUID_SRC_TESTS_TESTICMP_H */
54