Skip to main content
Open topic with navigation CAPL Functions » Ethernet » Function Overview » ethernetPacket::GetSourceIPAddress

ethernetPacket::GetSourceIPAddress

Valid for: CANoe DE • CANoe4SW DE

Method Syntax

long ethernetPacket.GetSourceIPAddress( ip_Address address );

Description

Assigns the source IP address to an ip_Address variable. Note: The ethernetPacket must contain IPv4 or IPv6 protocol. Use ethernetPacket::<protocol>.IsAvailable() before calling this method.

Parameters

  • address: IP address is assigned to this variable.

Return Values

  • 0: success
  • -1: No IPv4 or IPv6 protocol available in packet.

Example

on ethernetPacket *
{
  // otherwise access ethernetPacket packet with packet.GetSourceIPAddress(addressSrc) ...
  ip_Address addressSrc, addressDst;
  char strAddressSrc[60], strAddressDst[60];

  this.GetSourceIPAddress(addressSrc);
  this.GetDestinationIPAddress(addressDst);
  addressSrc.PrintAddressToString(strAddressSrc);
  addressDst.PrintAddressToString(strAddressDst);
  write("from %s to %s", strAddressSrc, strAddressDst);
}
See Also