Coverage Report

Created: 2024-02-25 06:29

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