PcapPlusPlus  Next
SdpLayer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "IpAddress.h"
4 #include "TextBasedProtocol.h"
5 #include <vector>
6 
8 
11 namespace pcpp
12 {
13 
15 #define PCPP_SDP_PROTOCOL_VERSION_FIELD "v"
17 #define PCPP_SDP_ORIGINATOR_FIELD "o"
19 #define PCPP_SDP_SESSION_NAME_FIELD "s"
21 #define PCPP_SDP_INFO_FIELD "i"
23 #define PCPP_SDP_URI_FIELD "u"
25 #define PCPP_SDP_EMAIL_FIELD "e"
27 #define PCPP_SDP_PHONE_FIELD "p"
29 #define PCPP_SDP_CONNECTION_INFO_FIELD "c"
31 #define PCPP_SDP_BANDWIDTH_FIELD "b"
33 #define PCPP_SDP_TIME_FIELD "t"
35 #define PCPP_SDP_REPEAT_TIMES_FIELD "r"
37 #define PCPP_SDP_TIME_ZONE_FIELD "z"
39 #define PCPP_SDP_ENCRYPTION_KEY_FIELD "k"
41 #define PCPP_SDP_MEDIA_ATTRIBUTE_FIELD "a"
43 #define PCPP_SDP_MEDIA_NAME_FIELD "m"
44 
56  {
57  public:
63  SdpLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
64 
67 
86  SdpLayer(const std::string& username, long sessionID, long sessionVersion, IPv4Address ipAddress,
87  const std::string& sessionName, long startTime, long stopTime);
88 
89  ~SdpLayer() override = default;
90 
95  {}
96 
100  SdpLayer& operator=(const SdpLayer& other)
101  {
102  TextBasedProtocolMessage::operator=(other);
103  return *this;
104  }
105 
113 
122  uint16_t getMediaPort(const std::string& mediaType) const;
123 
142  bool addMediaDescription(const std::string& mediaType, uint16_t mediaPort, const std::string& mediaProtocol,
143  const std::string& mediaFormat, const std::vector<std::string>& mediaAttributes);
144 
145  // overridden methods
146 
148  {
149  return OsiModelSesionLayer;
150  }
151 
152  std::string toString() const override;
153 
154  protected:
155  // implementation of abstract methods
156  char getHeaderFieldNameValueSeparator() const override
157  {
158  return '=';
159  }
160  bool spacesAllowedBetweenHeaderFieldNameAndValue() const override
161  {
162  return false;
163  }
164  };
165 } // namespace pcpp
Definition: IpAddress.h:28
Definition: Layer.h:60
Definition: Packet.h:22
Definition: SdpLayer.h:56
SdpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
uint16_t getMediaPort(const std::string &mediaType) const
IPv4Address getOwnerIPv4Address() const
SdpLayer(const std::string &username, long sessionID, long sessionVersion, IPv4Address ipAddress, const std::string &sessionName, long startTime, long stopTime)
SdpLayer(const SdpLayer &other)
Definition: SdpLayer.h:94
SdpLayer & operator=(const SdpLayer &other)
Definition: SdpLayer.h:100
std::string toString() const override
bool addMediaDescription(const std::string &mediaType, uint16_t mediaPort, const std::string &mediaProtocol, const std::string &mediaFormat, const std::vector< std::string > &mediaAttributes)
SdpLayer()
An empty c'tor which initialize an empty message with no fields.
OsiModelLayer getOsiModelLayer() const override
Definition: SdpLayer.h:147
Definition: TextBasedProtocol.h:105
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
@ OsiModelSesionLayer
Session layer (layer 5)
Definition: ProtocolType.h:235