/* IPCP (IP Configuration Protocol) in TTCN-3
 * (C) 2017 Harald Welte <laforge@gnumonks.org>
 * All rights reserved.
 *
 * Released under the terms of GNU General Public License, Version 2 or
 * (at your option) any later version.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

module IPCP_Types {

import from Osmocom_Types all;

/* RFC1331 Section 6 */
type enumerated LcpCode {
	LCP_Configure_Request		('01'O),
	LCP_Configure_Ack		('02'O),
	LCP_Configure_Nak		('03'O),
	LCP_Configure_Reject		('04'O),
	LCP_Terminate_Requeest		('05'O),
	LCP_Terminate_Ack		('06'O),
	LCP_Code_Reject			('07'O),
	LCP_Protocol_Reject		('08'O),
	LCP_Echo_Request		('09'O),
	LCP_Echo_Reply			('10'O),
	LCP_Discarded_Request		('11'O),
	LCP_Reserved			('12'O)
} with { variant "FIELDLENGTH(8)" };

type record IpcpPacket {
	LcpCode		code,
	uint8_t		identifier,
	uint16_t	len,
	IpcpOptionList	options
} with { variant (len) "LENGTHTO(code,identifier,len,options)" };

/* RFC 1332 IP Control Protocol options, extensions in RFC 1877 */
type enumerated IpcpConfigOptCode {
	IPCP_OPT_IpAddresses		('01'O),
	IPCP_OPT_IpCompressionProtocol	('02'O),
	IPCP_OPT_IpAddress		('03'O),
	IPCP_OPT_MobileIPv4		('04'O),/* RFC 2290 */
	IPCP_OPT_PrimaryDNS		(129),	/* RFC 1877 */
	IPCP_OPT_PrimaryNBNS		(130),	/* RFC 1877 */
	IPCP_OPT_SecondaryDNS		(131),	/* RFC 1877 */
	IPCP_OPT_SecondaryNBNS		(132)	/* RFC 1877 */
} with { variant "FIELDLENGTH(8)" };

type record IpcpOption {
	IpcpConfigOptCode	code,
	uint8_t			len,
	octetstring		data
} with { variant (len) "LENGTHTO(code,len,data)" };

type record of IpcpOption IpcpOptionList;

external function enc_IpcpPacket(in IpcpPacket inp) return octetstring
with { extension "prototype(convert)" extension "encode(RAW)" };

external function dec_IpcpPacket(in octetstring inp) return IpcpPacket
with { extension "prototype(convert)" extension "decode(RAW)" };


} with { encode "RAW" ; variant "FIELDORDER(msb)" }
