Peter Qiu | e9b7580 | 2015-01-20 15:24:15 -0800 | [diff] [blame] | 1 | // Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SHILL_ARP_CLIENT_TEST_HELPER_H_ |
| 6 | #define SHILL_ARP_CLIENT_TEST_HELPER_H_ |
| 7 | |
| 8 | #include <base/macros.h> |
| 9 | |
| 10 | #include "shill/arp_packet.h" |
| 11 | #include "shill/mock_arp_client.h" |
| 12 | #include "shill/net/byte_string.h" |
| 13 | #include "shill/net/ip_address.h" |
| 14 | |
| 15 | namespace shill { |
| 16 | |
| 17 | // Class for simulate ARP client receiving ARP packets for unit test purpose. |
| 18 | class ArpClientTestHelper { |
| 19 | public: |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 20 | explicit ArpClientTestHelper(MockArpClient* client); |
Peter Qiu | e9b7580 | 2015-01-20 15:24:15 -0800 | [diff] [blame] | 21 | virtual ~ArpClientTestHelper(); |
| 22 | |
| 23 | void GeneratePacket(uint16_t operation, |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 24 | const IPAddress& local_ip, |
| 25 | const ByteString& local_mac, |
| 26 | const IPAddress& remote_ip, |
| 27 | const ByteString& remote_mac); |
Peter Qiu | e9b7580 | 2015-01-20 15:24:15 -0800 | [diff] [blame] | 28 | |
| 29 | private: |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 30 | bool SimulateReceivePacket(ArpPacket* packet, ByteString* sender); |
Peter Qiu | e9b7580 | 2015-01-20 15:24:15 -0800 | [diff] [blame] | 31 | |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 32 | MockArpClient* client_; |
Peter Qiu | e9b7580 | 2015-01-20 15:24:15 -0800 | [diff] [blame] | 33 | ArpPacket packet_; |
| 34 | |
| 35 | DISALLOW_COPY_AND_ASSIGN(ArpClientTestHelper); |
| 36 | }; |
| 37 | |
| 38 | } // namespace shill |
| 39 | |
| 40 | #endif // SHILL_ARP_CLIENT_TEST_HELPER_H_ |