PcapPlusPlus  20.08
pcpp::PPPoEDiscoveryLayer Class Reference

#include <PPPoELayer.h>

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

Classes

struct  PPPoETag
 

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)
 
PPPoETaggetTag (PPPoEDiscoveryLayer::PPPoETagTypes tagType) const
 
PPPoETaggetFirstTag () const
 
PPPoETaggetNextTag (PPPoETag *tag) const
 
int getTagCount () const
 
PPPoETagaddTag (PPPoETagTypes tagType, uint16_t tagLength, const uint8_t *tagData)
 
PPPoETagaddTagAfter (PPPoETagTypes tagType, uint16_t tagLength, const uint8_t *tagData, PPPoETag *prevTag)
 
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 ( PPPoETagTypes  tagType,
uint16_t  tagLength,
const uint8_t *  tagData 
)

Add a new tag at the end of the layer (after the last tag)

Parameters
[in]tagTypeThe type of the added tag
[in]tagLengthThe length of the tag data
[in]tagDataA pointer to the tag data. This data will be copied to added tag data. Notice the length of tagData must be tagLength
Returns
A pointer to the new added tag. Notice this is a pointer to the real data casted to PPPoETag type (as opposed to a copy of the tag data). So changes in this return value will affect the packet data

◆ addTagAfter()

PPPoETag* pcpp::PPPoEDiscoveryLayer::addTagAfter ( PPPoETagTypes  tagType,
uint16_t  tagLength,
const uint8_t *  tagData,
PPPoETag prevTag 
)

Add a new tag after an existing tag

Parameters
[in]tagTypeThe type of the added tag
[in]tagLengthThe length of the tag data
[in]tagDataA pointer to the tag data. This data will be copied to added tag data. Notice the length of tagData must be tagLength
[in]prevTagThe tag which the new added tag will come after
Returns
A pointer to the new added tag. Notice this is a pointer to the real data casted to PPPoETag type (as opposed to a copy of the tag data). So changes in this return value will affect the packet data

◆ getFirstTag()

PPPoETag* pcpp::PPPoEDiscoveryLayer::getFirstTag ( ) const
Returns
The first tag in the PPPoE discovery layer, or NULL if no tags exist. Notice the return value is a pointer to the real data casted to PPPoETag type (as opposed to a copy of the tag data). So changes in the return value will affect the packet data

◆ 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 ( PPPoETag tag) const

Get the tag which come next to "tag" parameter. If "tag" is NULL or then NULL will be returned. If "tag" is the last tag NULL will be returned. Notice the return value is a pointer to the real data casted to PPPoETag type (as opposed to a copy of the tag data). So changes in the return value will affect the packet data

Parameters
[in]tagThe tag to start search
Returns
The next tag or NULL if "tag" is NULL or "tag" is the last tag

◆ getTag()

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

Retrieve a PPPoE tag by tag type. If packet consists of multiple tags of the same type, the first tag will be returned. If packet contains no tags of the tag type NULL will be returned. Notice the return value is a pointer to the real data casted to PPPoETag type (as opposed to a copy of the tag data). So changes in the return value will affect the packet data

Parameters
[in]tagTypeThe type of the tag to search
Returns
A pointer to the tag data casted to PPPoETag*

◆ 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.