PcapPlusPlus
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)
 
 PPPoEDiscoveryLayer (const PPPoEDiscoveryLayer &other)
 
PPPoETaggetTag (PPPoEDiscoveryLayer::PPPoETagTypes tagType)
 
PPPoETaggetFirstTag ()
 
PPPoETaggetNextTag (PPPoETag *tag)
 
int getTagCount ()
 
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 ()
 
virtual std::string toString ()
 
- Public Member Functions inherited from pcpp::PPPoELayer
pppoe_headergetPPPoEHeader ()
 
virtual void computeCalculateFields ()
 
OsiModelLayer getOsiModelLayer ()
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer ()
 
LayergetPrevLayer ()
 
ProtocolType getProtocol ()
 
uint8_t * getData ()
 
size_t getDataLen ()
 
uint8_t * getLayerPayload ()
 
size_t getLayerPayloadSize ()
 
bool isAllocatedToPacket ()
 
void copyData (uint8_t *toArr)
 
uint8_t * getDataPtr (size_t offset=0)
 

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/3]

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/3]

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

◆ PPPoEDiscoveryLayer() [3/3]

pcpp::PPPoEDiscoveryLayer::PPPoEDiscoveryLayer ( const PPPoEDiscoveryLayer other)
inline

A copy constructor that copies the entire header from the other PPPoEDiscoveryLayer

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 ( )
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 ( )
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)

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)

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 ( )
Returns
The number of tags in this layer

◆ 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 ( )
inlinevirtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.