PcapPlusPlus  23.09
pcpp::SomeIpLayer Class Reference

#include <SomeIpLayer.h>

Inheritance diagram for pcpp::SomeIpLayer:
pcpp::Layer pcpp::IDataContainer pcpp::SomeIpSdLayer pcpp::SomeIpTpLayer

Classes

struct  someiphdr
 

Public Types

enum  MsgType : uint8_t {
  MsgType::REQUEST = 0x00, MsgType::REQUEST_ACK = 0x40, MsgType::REQUEST_NO_RETURN = 0x01, MsgType::REQUEST_NO_RETURN_ACK = 0x41,
  MsgType::NOTIFICATION = 0x02, MsgType::NOTIFICATION_ACK = 0x42, MsgType::RESPONSE = 0x80, MsgType::RESPONSE_ACK = 0xC0,
  MsgType::ERRORS = 0x81, MsgType::ERROR_ACK = 0xC1, MsgType::TP_REQUEST = 0x20, MsgType::TP_REQUEST_NO_RETURN = 0x21,
  MsgType::TP_NOTIFICATION = 0x22, MsgType::TP_RESPONSE = 0xa0, MsgType::TP_ERROR = 0xa1
}
 

Public Member Functions

 SomeIpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 SomeIpLayer (uint16_t serviceID, uint16_t methodID, uint16_t clientID, uint16_t sessionID, uint8_t interfaceVersion, MsgType type, uint8_t returnCode, const uint8_t *const data=nullptr, size_t dataLen=0)
 
 ~SomeIpLayer ()
 
someiphdrgetSomeIpHeader () const
 
uint32_t getMessageID () const
 
void setMessageID (uint32_t messageID)
 
uint16_t getServiceID () const
 
void setServiceID (uint16_t serviceID)
 
uint16_t getMethodID () const
 
void setMethodID (uint16_t methodID)
 
uint32_t getLengthField () const
 
uint32_t getRequestID () const
 
void setRequestID (uint32_t requestID)
 
uint16_t getSessionID () const
 
void setSessionID (uint16_t sessionID)
 
uint16_t getClientID () const
 
void setClientID (uint16_t clientID)
 
uint8_t getProtocolVersion () const
 
void setProtocolVersion (uint8_t version)
 
uint8_t getInterfaceVersion () const
 
void setInterfaceVersion (uint8_t version)
 
uint8_t getMessageTypeAsInt () const
 
SomeIpLayer::MsgType getMessageType () const
 
void setMessageType (MsgType type)
 
void setMessageType (uint8_t type)
 
uint8_t getReturnCode () const
 
void setReturnCode (uint8_t returnCode)
 
void setPayloadLength (uint32_t payloadLength)
 
uint8_t * getPduPayload () const
 
size_t getPduPayloadSize () const
 
size_t getHeaderLen () const
 
virtual void computeCalculateFields ()
 
void parseNextLayer ()
 
virtual std::string toString () const
 
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 LayerparseSomeIpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
static bool isSomeIpPort (uint16_t port)
 
static void addSomeIpPort (uint16_t port)
 
static void removeSomeIpPort (uint16_t port)
 
static void removeAllSomeIpPorts ()
 

Detailed Description

Represents a SOME/IP protocol layer

Member Enumeration Documentation

◆ MsgType

enum pcpp::SomeIpLayer::MsgType : uint8_t
strong

SOME/IP message types

Enumerator
REQUEST 

A request expecting a response (even void)

REQUEST_ACK 

Acknowledgment for REQUEST(optional)

REQUEST_NO_RETURN 

A fire&forget request

REQUEST_NO_RETURN_ACK 

Acknowledgment for REQUEST_NO_RETURN(informational)

NOTIFICATION 

A request of a notification expecting no response

NOTIFICATION_ACK 

Acknowledgment for NOTIFICATION(informational)

RESPONSE 

The response message

RESPONSE_ACK 

The Acknowledgment for RESPONSE(informational)

ERRORS 

The response containing an error

ERROR_ACK 

Acknowledgment for ERROR(informational)

TP_REQUEST 

A TP request expecting a response (even void)

TP_REQUEST_NO_RETURN 

A TP fire&forget request

TP_NOTIFICATION 

A TP request of a notification/event callback expecting no response

TP_RESPONSE 

The TP response message

TP_ERROR 

The TP response containing an error

Constructor & Destructor Documentation

◆ SomeIpLayer() [1/2]

pcpp::SomeIpLayer::SomeIpLayer ( 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 someiphdr)
[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

◆ SomeIpLayer() [2/2]

pcpp::SomeIpLayer::SomeIpLayer ( uint16_t  serviceID,
uint16_t  methodID,
uint16_t  clientID,
uint16_t  sessionID,
uint8_t  interfaceVersion,
MsgType  type,
uint8_t  returnCode,
const uint8_t *const  data = nullptr,
size_t  dataLen = 0 
)

Construct a new layer object

Parameters
[in]serviceIDService ID
[in]methodIDMethod ID
[in]clientIDClient ID
[in]sessionIDSession ID
[in]interfaceVersionInterface Version
[in]typeType of the message
[in]returnCodeReturn Code
[in]dataA pointer to the raw data
[in]dataLenSize of the data in bytes holds the reference to a data buffer. This option can be used to reduce the number of copies to generate packets.

◆ ~SomeIpLayer()

pcpp::SomeIpLayer::~SomeIpLayer ( )
inline

Destroy the layer object

Member Function Documentation

◆ addSomeIpPort()

static void pcpp::SomeIpLayer::addSomeIpPort ( uint16_t  port)
static

Adds port to a list of ports where pcap checks for SOME/IP communication. Each port must be removed at the end in order to have no memory leak.

Parameters
[in]portPort to add

◆ computeCalculateFields()

virtual void pcpp::SomeIpLayer::computeCalculateFields ( )
inlinevirtual

Does nothing for this layer

Implements pcpp::Layer.

Reimplemented in pcpp::SomeIpSdLayer, and pcpp::SomeIpTpLayer.

◆ getClientID()

uint16_t pcpp::SomeIpLayer::getClientID ( ) const

Get the clientID

Returns
uint16_t returned in host endian

◆ getHeaderLen()

size_t pcpp::SomeIpLayer::getHeaderLen ( ) const
inlinevirtual

Get the Length of the SOME/IP header inc payload

Returns
size_t

Implements pcpp::Layer.

◆ getInterfaceVersion()

uint8_t pcpp::SomeIpLayer::getInterfaceVersion ( ) const

Get the interfaceVersion

Returns
uint8_t

◆ getLengthField()

uint32_t pcpp::SomeIpLayer::getLengthField ( ) const

Get the Length Field of the SOME/IP header

Returns
uint32_t The length field of the SOME/IP header

◆ getMessageID()

uint32_t pcpp::SomeIpLayer::getMessageID ( ) const

Get the messageID

Returns
uint32_t returned in host endian

◆ getMessageType()

SomeIpLayer::MsgType pcpp::SomeIpLayer::getMessageType ( ) const

Get the message type

Returns
SomeIpLayer::MsgType

◆ getMessageTypeAsInt()

uint8_t pcpp::SomeIpLayer::getMessageTypeAsInt ( ) const

Get the message type

Returns
uint8_t

◆ getMethodID()

uint16_t pcpp::SomeIpLayer::getMethodID ( ) const

Get the methodID

Returns
uint16_t returned in host endian

◆ getOsiModelLayer()

OsiModelLayer pcpp::SomeIpLayer::getOsiModelLayer ( ) const
inlinevirtual
Returns
The OSI model layer of this layer

Implements pcpp::Layer.

◆ getPduPayload()

uint8_t* pcpp::SomeIpLayer::getPduPayload ( ) const
inline
Returns
A pointer for the layer payload, meaning the first byte after the header

◆ getPduPayloadSize()

size_t pcpp::SomeIpLayer::getPduPayloadSize ( ) const
inline
Returns
The size in bytes of the payload

◆ getProtocolVersion()

uint8_t pcpp::SomeIpLayer::getProtocolVersion ( ) const

Get the protocolVersion

Returns
uint8_t

◆ getRequestID()

uint32_t pcpp::SomeIpLayer::getRequestID ( ) const

Get the requestID

Returns
uint32_t returned in host endian

◆ getReturnCode()

uint8_t pcpp::SomeIpLayer::getReturnCode ( ) const

Get the returnCode

Returns
uint8_t

◆ getServiceID()

uint16_t pcpp::SomeIpLayer::getServiceID ( ) const

Get the serviceID

Returns
uint16_t returned in host endian

◆ getSessionID()

uint16_t pcpp::SomeIpLayer::getSessionID ( ) const

Get the sessionID

Returns
uint16_t returned in host endian

◆ getSomeIpHeader()

someiphdr* pcpp::SomeIpLayer::getSomeIpHeader ( ) const
inline

Get a pointer to the basic SOME/IP header. Notice this points directly to the data, so every change will change the actual packet data

Returns
A pointer to the someiphdr

◆ isSomeIpPort()

static bool pcpp::SomeIpLayer::isSomeIpPort ( uint16_t  port)
static

Checks if given port is a SOME/IP protocol port (only Service Discovery ports are checked for now)

Parameters
[in]portPort to check
Returns
true if SOME/IP protocol port, false if not

◆ parseNextLayer()

void pcpp::SomeIpLayer::parseNextLayer ( )
virtual

Identifies the following next layers: SomeIpLayer, SomeIpTpLayer, SomeIpSdLayer. Otherwise sets PayloadLayer

Implements pcpp::Layer.

◆ parseSomeIpLayer()

static Layer* pcpp::SomeIpLayer::parseSomeIpLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
static

A static method that creates a SOME/IP or SOME/IP-TP layer from packet raw data. Returns PayloadLayer if data is not valid.

Parameters
[in]dataA pointer to the raw data
[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
Returns
Layer* A newly allocated layer

◆ removeAllSomeIpPorts()

static void pcpp::SomeIpLayer::removeAllSomeIpPorts ( )
static

Removes all ports from a list of ports where pcap checks for SOME/IP communication.

◆ removeSomeIpPort()

static void pcpp::SomeIpLayer::removeSomeIpPort ( uint16_t  port)
static

Removes port from a list of ports where pcap checks for SOME/IP communication.

Parameters
[in]portPort to remove

◆ setClientID()

void pcpp::SomeIpLayer::setClientID ( uint16_t  clientID)

Set the Client ID

Parameters
[in]clientIDclientID to set

◆ setInterfaceVersion()

void pcpp::SomeIpLayer::setInterfaceVersion ( uint8_t  version)

Set the Interface Version

Parameters
[in]versionversion to set

◆ setMessageID()

void pcpp::SomeIpLayer::setMessageID ( uint32_t  messageID)

Set the Message ID

Parameters
[in]messageIDmessageID to set

◆ setMessageType() [1/2]

void pcpp::SomeIpLayer::setMessageType ( MsgType  type)

Set the Message Type

Parameters
[in]typeType to set

◆ setMessageType() [2/2]

void pcpp::SomeIpLayer::setMessageType ( uint8_t  type)

Set the Message Type

Parameters
[in]typeType to set

◆ setMethodID()

void pcpp::SomeIpLayer::setMethodID ( uint16_t  methodID)

Set the Method ID

Parameters
[in]methodIDmethodID to set

◆ setPayloadLength()

void pcpp::SomeIpLayer::setPayloadLength ( uint32_t  payloadLength)

Set the length field of the SOME/IP header

Parameters
[in]payloadLengthLength of the payload

◆ setProtocolVersion()

void pcpp::SomeIpLayer::setProtocolVersion ( uint8_t  version)

Set the Protocol Version

Parameters
[in]versionversion to set

◆ setRequestID()

void pcpp::SomeIpLayer::setRequestID ( uint32_t  requestID)

Set the Request ID

Parameters
[in]requestIDrequestID to set

◆ setReturnCode()

void pcpp::SomeIpLayer::setReturnCode ( uint8_t  returnCode)

Set the returnCode

Parameters
[in]returnCodeReturnCode to set

◆ setServiceID()

void pcpp::SomeIpLayer::setServiceID ( uint16_t  serviceID)

Set the Service ID

Parameters
[in]serviceIDserviceID to set

◆ setSessionID()

void pcpp::SomeIpLayer::setSessionID ( uint16_t  sessionID)

Set the Session ID

Parameters
[in]sessionIDsessionID to set

◆ toString()

virtual std::string pcpp::SomeIpLayer::toString ( ) const
virtual
Returns
The string representation of the SOME/IP layer

Implements pcpp::Layer.

Reimplemented in pcpp::SomeIpSdLayer, and pcpp::SomeIpTpLayer.