Skip to main content
Open topic with navigation

ethernetPacket Selectors: <protocol>.byteOffset

CAPL Functions » Ethernet » Function Overview » ethernetPacket » Selector <protocol>.byteOffset Valid for: CANoe DE • CANoe4SW DE

Selectors

Syntax: dword ethernetPacket.<protocol>.byteOffset;

Description

Returns the byte-offset of the protocol payload within the Ethernet packet. The selector is read only. Offset 0 is directly after the Ethertype. If <protocol> is not contained in the packet, the selector returns 0. ethernetPacket::protocol::IsAvailable can be used to find out if the protocol is available.

Parameters

Return Values

Byte-offset

Example

ethernetPacket pkt;
word           offset, length, i;

// initialize packet with IPv4 and UDP protocols
pkt.udp.Init();
pkt.udp.ResizeData(10);

offset = pkt.udp.byteOffset;
length = pkt.udp.byteLength;

write ( "Protocol udp is at byte %d:%d", offset, length );

for( i = 0; i < length; i++ )
{
  pkt.byte( offset+i ) = i;
}

// calculate UDP and IPv4 checksum and send Ethernet packet
pkt.CompletePacket();
output( pkt );