Coverage Report

Created: 2023-01-17 06:15

/src/PcapPlusPlus/Packet++/header/IPLayer.h
Line
Count
Source
1
#ifndef PACKETPP_IP_LAYER
2
#define PACKETPP_IP_LAYER
3
4
#include "IpAddress.h"
5
#include "Layer.h"
6
7
/// @file
8
9
/**
10
 * \namespace pcpp
11
 * \brief The main namespace for the PcapPlusPlus lib
12
 */
13
namespace pcpp
14
{
15
  /**
16
   * @class IPLayer
17
   * This is an interface (abstract class) implemented in the IP layers (IPv4Layer and IPv6Layer).
18
   * It provides methods to fetch the source and destination IP addresses in an abdtract way
19
   * that hides the IP type (IPv4 or IPv6). This is useful for use-cases in which the IP type doesn't matter.
20
   * For example: if you're only interested in printing the IP address the IP type shouldn't matter.
21
   */
22
  class IPLayer
23
  {
24
  protected:
25
363k
    IPLayer() {}
26
  public:
27
    /**
28
     * An abstract method to get the source IP address
29
     * @return An IPAddress object containing the source address
30
     */
31
    virtual IPAddress getSrcIPAddress() const = 0;
32
33
    /**
34
     * An abstract method to get the destination IP address
35
     * @return An IPAddress object containing the destination address
36
     */
37
    virtual IPAddress getDstIPAddress() const = 0;
38
39
    /**
40
     * An empty destructor
41
     */
42
363k
    virtual ~IPLayer() {}
43
  };
44
}
45
46
#endif // PACKETPP_IP_LAYER