/* Templates for 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_Templates {
import from General_Types all;
import from Osmocom_Types all;
import from IPCP_Types all;

template (present) IpcpPacket tr_IPCP(template (present) LcpCode code,
				      template (present) uint8_t identifier,
				      template (present) IpcpOptionList opts) := {
	code := code,
	identifier := identifier,
	len := ?,
	options := opts
}
template (value) IpcpPacket ts_IPCP(template (value) LcpCode code,
				    template (value) uint8_t identifier,
				    template (value) IpcpOptionList opts) := {
	code := code,
	identifier := identifier,
	len := 0,	/* overwritten */
	options := opts
}
template (present) IpcpOption tr_IPCP_PrimaryDns(template (present) OCT4 addr) := {
	code := IPCP_OPT_PrimaryDNS,
	len := 6,
	data := addr
}
template (value) IpcpOption ts_IPCP_PrimaryDns(template (value) OCT4 addr) := {
	code := IPCP_OPT_PrimaryDNS,
	len := 6,
	data := addr
}
template (present) IpcpOption tr_IPCP_SecondaryDns(template (present) OCT4 addr) := {
	code := IPCP_OPT_SecondaryDNS,
	len := 6,
	data := addr
}
template (value) IpcpOption ts_IPCP_SecondaryDns(template (value) OCT4 addr) := {
	code := IPCP_OPT_SecondaryDNS,
	len := 6,
	data := addr
}
template (present) IpcpPacket tr_IPCP_Ack_DNS(template (present) uint8_t identifier := ?,
					      template (present) OCT4 dns1 := ?,
					      template (present) OCT4 dns2 := ?) :=
	tr_IPCP(LCP_Configure_Ack, identifier,
		{ *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });

template (value) IpcpPacket ts_IPCP_ReqDNS(template (value) uint8_t identifier := 0) :=
	ts_IPCP(LCP_Configure_Request, identifier,
		{ ts_IPCP_PrimaryDns('00000000'O), ts_IPCP_SecondaryDns('00000000'O) });

template (value) IpcpPacket ts_IPCP_ReqDNS_Primary(template (value) uint8_t identifier := 0) :=
	ts_IPCP(LCP_Configure_Request, identifier,
		{ ts_IPCP_PrimaryDns('00000000'O) });
template (value) IpcpPacket ts_IPCP_ReqDNS_Secondary(template (value) uint8_t identifier := 0) :=
	ts_IPCP(LCP_Configure_Request, identifier,
		{ ts_IPCP_SecondaryDns('00000000'O) });

} with { encode "RAW" }