/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
*  Peter Kremer - initial implementation and initial documentation
*  Attila Balasko
*  Gabor Bettesch
*  Gabor Szalai
******************************************************************************/
//
//  File:               UDP_Types.ttcn
//  Description:        UDP
//  Rev:                R4A
//  Prodnr:             CNL 113 420
//
module UDP_Types{

import from General_Types all;

external function f_UDP_enc ( in UDP_packet pdu ) return octetstring;
external function f_UDP_pseudo_header_enc ( in UDP_pseudo_header pdu ) return octetstring;
external function f_UDP_dec ( in octetstring data ) return UDP_packet;
external function f_UDP_checksum ( in octetstring data ) return OCT2;

type record UDP_header {
  LIN2_BO_LAST srcport,
  LIN2_BO_LAST dstport,
  LIN2_BO_LAST len,
  LIN2_BO_LAST cksum
} with { variant "FIELDORDER(msb)" }

type record UDP_packet {
  UDP_header header,
  octetstring payload
} with {
  variant (header) "LENGTHTO(header, payload), LENGTHINDEX(len)"
}

type union UDP_pseudo_header {
  UDP_pseudo_header_IPv4 ipv4,
  UDP_pseudo_header_IPv6 ipv6
} with { variant "FIELDORDER(msb)" }

type record UDP_pseudo_header_IPv4 {
  OCT4 srcaddr,
  OCT4 dstaddr,
  LIN1 zero,
  LIN1 proto,
  LIN2_BO_LAST plen
} with { variant "FIELDORDER(msb)" }

type record UDP_pseudo_header_IPv6 {
  OCT16 srcaddr,
  OCT16 dstaddr,
  LIN4_BO_LAST plen,
  LIN3_BO_LAST zero,
  LIN1 nextheader
} with { variant "FIELDORDER(msb)" }

type port UDPmsg_SP_PT message {
  inout UDP_packet;
}  with { extension "internal" }

} with { encode "RAW"}
