2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
20 Christian Herdtweck, Intra2net AG 2015
21 Based on an example in Boost Documentation (by Christopher M. Kohlhoff)
22 and adaptation by Guilherme M. Ferreira
25 #ifndef ICMP_PACKET_FACTORY_H
26 #define ICMP_PACKET_FACTORY_H
32 #include <boost/asio.hpp>
34 #include "icmp/icmppacket.h"
37 void dump_packet(const std::string &data);
45 //-----------------------------------------------------------------------------
47 //-----------------------------------------------------------------------------
50 * @brief Class which constructs ICMP Packets, hiding from the class users the
51 * underlying details on how to build each packet.
53 * @param dump_mode: 0 to never dump, 1 to dump in case of parsing trouble,
56 class IcmpPacketFactory
59 /// directory and file name start used to dump packets;
60 /// will be concatenated with time and pattern that ensures unique file name
61 static std::string DumpFilePrefix;
62 static DumpMode PacketDumpMode;
64 static IcmpPacketItem create_icmp_packet(
65 const boost::asio::ip::icmp::socket::protocol_type &protocol,
68 static IcmpPacketItem create_icmp_packet_echo_request(
69 const boost::asio::ip::icmp::socket::protocol_type &protocol,
70 const uint16_t identifier,
71 const uint16_t sequence_number
75 #endif // ICMP_PACKET_FACTORY_H