PcapPlusPlus  22.11
pcpp::PPPoEDiscoveryLayer Class Reference

#include <PPPoELayer.h>

Inheritance diagram for pcpp::PPPoEDiscoveryLayer:
pcpp::PPPoELayer pcpp::Layer pcpp::IDataContainer

Classes

class  PPPoETag
 
class  PPPoETagBuilder
 

Public Types

enum  PPPoETagTypes {
  PPPOE_TAG_EOL = 0x0000, PPPOE_TAG_SVC_NAME = 0x0101, PPPOE_TAG_AC_NAME = 0x0102, PPPOE_TAG_HOST_UNIQ = 0x0103,
  PPPOE_TAG_AC_COOKIE = 0x0104, PPPOE_TAG_VENDOR = 0x0105, PPPOE_TAG_CREDITS = 0x0106, PPPOE_TAG_METRICS = 0x0107,
  PPPOE_TAG_SEQ_NUM = 0x0108, PPPOE_TAG_CRED_SCALE = 0x0109, PPPOE_TAG_RELAY_ID = 0x0110, PPPOE_TAG_HURL = 0x0111,
  PPPOE_TAG_MOTM = 0x0112, PPPOE_TAG_MAX_PAYLD = 0x0120, PPPOE_TAG_IP_RT_ADD = 0x0121, PPPOE_TAG_SVC_ERR = 0x0201,
  PPPOE_TAG_AC_ERR = 0x0202, PPPOE_TAG_GENERIC_ERR = 0x0203
}
 
- Public Types inherited from pcpp::PPPoELayer
enum  PPPoECode {
  PPPOE_CODE_SESSION = 0x00, PPPOE_CODE_PADO = 0x07, PPPOE_CODE_PADI = 0x09, PPPOE_CODE_PADG = 0x0a,
  PPPOE_CODE_PADC = 0x0b, PPPOE_CODE_PADQ = 0x0c, PPPOE_CODE_PADR = 0x19, PPPOE_CODE_PADS = 0x65,
  PPPOE_CODE_PADT = 0xa7, PPPOE_CODE_PADM = 0xd3, PPPOE_CODE_PADN = 0xd4
}
 

Public Member Functions

 PPPoEDiscoveryLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 PPPoEDiscoveryLayer (uint8_t version, uint8_t type, PPPoELayer::PPPoECode code, uint16_t sessionId)
 
PPPoETag getTag (PPPoEDiscoveryLayer::PPPoETagTypes tagType) const
 
PPPoETag getFirstTag () const
 
PPPoETag getNextTag (const PPPoETag &tag) const
 
int getTagCount () const
 
PPPoETag addTag (const PPPoETagBuilder &tagBuilder)
 
PPPoETag addTagAfter (const PPPoETagBuilder &tagBuilder, PPPoETagTypes prevTagType)
 
bool removeTag (PPPoEDiscoveryLayer::PPPoETagTypes tagType)
 
bool removeAllTags ()
 
virtual void parseNextLayer ()
 
virtual size_t getHeaderLen () const
 
virtual std::string toString () const
 
- Public Member Functions inherited from pcpp::PPPoELayer
pppoe_headergetPPPoEHeader () const
 
virtual void computeCalculateFields ()
 
OsiModelLayer getOsiModelLayer () const
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
uint8_t * getData () const
 
size_t getDataLen () const
 
uint8_t * getLayerPayload () const
 
size_t getLayerPayloadSize () const
 
bool isAllocatedToPacket () const
 
void copyData (uint8_t *toArr) const
 
uint8_t * getDataPtr (size_t offset=0) const
 

Static Public Member Functions

static bool isDataValid (const uint8_t *data, size_t dataLen)
 

Detailed Description

Describes the PPPoE discovery protocol

Member Enumeration Documentation

◆ PPPoETagTypes

PPPoE tag types

Enumerator
PPPOE_TAG_EOL 

End-Of-List tag type

PPPOE_TAG_SVC_NAME 

Service-Name tag type

PPPOE_TAG_AC_NAME 

AC-Name tag type

PPPOE_TAG_HOST_UNIQ 

Host-Uniq tag type

PPPOE_TAG_AC_COOKIE 

AC-Cookie tag type

PPPOE_TAG_VENDOR 

Vendor-Specific tag type

PPPOE_TAG_CREDITS 

Credits tag type

PPPOE_TAG_METRICS 

Metrics tag type

PPPOE_TAG_SEQ_NUM 

Sequence Number tag type

PPPOE_TAG_CRED_SCALE 

Credit Scale Factor tag type

PPPOE_TAG_RELAY_ID 

Relay-Session-Id tag type

PPPOE_TAG_HURL 

HURL tag type

PPPOE_TAG_MOTM 

MOTM tag type

PPPOE_TAG_MAX_PAYLD 

PPP-Max-Payload tag type

PPPOE_TAG_IP_RT_ADD 

IP_Route_Add tag type

PPPOE_TAG_SVC_ERR 

Service-Name-Error tag type

PPPOE_TAG_AC_ERR 

AC-System-Error tag type

PPPOE_TAG_GENERIC_ERR 

Generic-Error tag type

Constructor & Destructor Documentation

◆ PPPoEDiscoveryLayer() [1/2]

pcpp::PPPoEDiscoveryLayer::PPPoEDiscoveryLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
inline

A constructor that creates the layer from an existing packet raw data

Parameters
[in]dataA pointer to the raw data (will be casted to pppoe_header)
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in

◆ PPPoEDiscoveryLayer() [2/2]

pcpp::PPPoEDiscoveryLayer::PPPoEDiscoveryLayer ( uint8_t  version,
uint8_t  type,
PPPoELayer::PPPoECode  code,
uint16_t  sessionId 
)
inline

A constructor that allocates a new PPPoE Discovery header with version, type, PPPoE code and session ID

Parameters
[in]versionPPPoE version
[in]typePPPoE type
[in]codePPPoE code enum
[in]sessionIdPPPoE session ID

Member Function Documentation

◆ addTag()

PPPoETag pcpp::PPPoEDiscoveryLayer::addTag ( const PPPoETagBuilder tagBuilder)

Add a new PPPoE Tag at the end of the layer

Parameters
[in]tagBuilderA PPPoETagBuilder object that contains the requested tag data to add
Returns
A PPPoETag object containing the newly added PPPoE Tag data or logical NULL (PPPoETag::isNull() == true) if addition failed

◆ addTagAfter()

PPPoETag pcpp::PPPoEDiscoveryLayer::addTagAfter ( const PPPoETagBuilder tagBuilder,
PPPoETagTypes  prevTagType 
)

Add a new PPPoE Tag after an existing one

Parameters
[in]tagBuilderA PPPoETagBuilder object that contains the requested tag data to add
[in]prevTagTypeThe PPPoE Tag which the newly added tag will come after
Returns
A PPPoETag object containing the newly added PPPoE Tag data or logical NULL (PPPoETag::isNull() == true) if addition failed

◆ getFirstTag()

PPPoETag pcpp::PPPoEDiscoveryLayer::getFirstTag ( ) const
Returns
The first tag in the PPPoE discovery layer. If the current layer contains no tags the returned value will contain a logical NULL (PPPoETag::isNull() == true)

◆ getHeaderLen()

virtual size_t pcpp::PPPoEDiscoveryLayer::getHeaderLen ( ) const
virtual
Returns
The header length which is size of strcut pppoe_header plus the total size of tags

Implements pcpp::Layer.

◆ getNextTag()

PPPoETag pcpp::PPPoEDiscoveryLayer::getNextTag ( const PPPoETag tag) const

Get the tag that comes right after the "tag" parameter. If the given tag is the last one, the returned value will contain a logical NULL (PPPoETag::isNull() == true)

Parameters
[in]tagA given tag
Returns
A PPPoETag object containing the tag that comes next, or logical NULL if the given tag: (1) was the last one; (2) contains a logical NULL or (3) doesn't belong to this packet

◆ getTag()

PPPoETag pcpp::PPPoEDiscoveryLayer::getTag ( PPPoEDiscoveryLayer::PPPoETagTypes  tagType) const

Get a PPPoE Tag by tag type.

Parameters
[in]tagTypeThe type of the tag to search
Returns
A PPPoETag object that contains the first tag that matches this type, or logical NULL (PPPoETag::isNull() == true) if no such tag found

◆ getTagCount()

int pcpp::PPPoEDiscoveryLayer::getTagCount ( ) const
Returns
The number of tags in this layer

◆ isDataValid()

bool pcpp::PPPoEDiscoveryLayer::isDataValid ( const uint8_t *  data,
size_t  dataLen 
)
inlinestatic

A static method that validates the input data

Parameters
[in]dataThe pointer to the beginning of byte stream of a packet
[in]dataLenThe length of the byte stream
Returns
True if the data is valid and can represent a PPPoED packet

◆ parseNextLayer()

virtual void pcpp::PPPoEDiscoveryLayer::parseNextLayer ( )
inlinevirtual

Does nothing for this layer (PPPoE discovery is always the last layer)

Implements pcpp::Layer.

◆ removeAllTags()

bool pcpp::PPPoEDiscoveryLayer::removeAllTags ( )

Remove all tags in this layer

Returns
True if all tags were successfully or false if removal failed for some reason (a proper error will be written to log)

◆ removeTag()

bool pcpp::PPPoEDiscoveryLayer::removeTag ( PPPoEDiscoveryLayer::PPPoETagTypes  tagType)

Remove an existing tag. Tag will be found by the tag type

Parameters
[in]tagTypeThe tag type to remove
Returns
True if tag was removed or false if tag wasn't found or if tag removal failed (in each case a proper error will be written to log)

◆ toString()

virtual std::string pcpp::PPPoEDiscoveryLayer::toString ( ) const
inlinevirtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.