//
// $Copyright_v6PC$
//
// $Copyright$
//
// $Name:  $
//
// $TAHI: ct/spec/PingOverRouter.def,v 1.8 2004/04/02 03:47:51 kenta Exp $
//

#define TN_GL0_ADDR tn2v6(_GLOBAL0_UCAST_PRFX,_GLOBAL0_UCAST_PRFXLEN,"Link0")
#define TN_GL1_ADDR tn2v6(_GLOBAL1_UCAST_PRFX,_GLOBAL1_UCAST_PRFXLEN,"Link1")
#define NUT_GL0_ADDR nut2v6(_GLOBAL0_UCAST_PRFX,_GLOBAL0_UCAST_PRFXLEN,"Link0")
#define NUT_GL1_ADDR nut2v6(_GLOBAL1_UCAST_PRFX,_GLOBAL1_UCAST_PRFXLEN,"Link1")

#define PING_ID	0xffff
#define PING_SN	0x0001
#define HOP_LIMIT_BEFORE	64
#define HOP_LIMIT_AFTER		63	// for ISDN router, change to 62

//======================================================================
//
// Ping On Link0
//

FEM_icmp6_echo_request(
	echo_request_on_link0,
	_HETHER_tn2nut,
	{
		_SRC(TN_GL0_ADDR);
		_DST(NUT_GL0_ADDR);
	},
	{
		Identifier = PING_ID;
		SequenceNumber = PING_SN;
		payload = echo_data8;
	}
)

FEM_icmp6_echo_reply(
	echo_reply_on_link0,
	_HETHER_nut2tn,
	{
		_SRC(NUT_GL0_ADDR);
		_DST(TN_GL0_ADDR);
	},
	{
		Identifier = PING_ID;
		SequenceNumber = PING_SN;
		payload = echo_data8;
	}
)

//======================================================================
//
// Ping On Link1
//

FEM_icmp6_echo_request(
	echo_request_on_link1,
	_HETHER_tn2nut,
	{
		_SRC(TN_GL1_ADDR);
		_DST(NUT_GL1_ADDR);
	},
	{
		Identifier = PING_ID;
		SequenceNumber = PING_SN;
		payload = echo_data8;
	}
)

FEM_icmp6_echo_reply(
	echo_reply_on_link1,
	_HETHER_nut2tn,
	{
		_SRC(NUT_GL1_ADDR);
		_DST(TN_GL1_ADDR);
	},
	{
		Identifier = PING_ID;
		SequenceNumber = PING_SN;
		payload = echo_data8;
	}
)

//======================================================================
//
// ICMP echo request
//

FEM_icmp6_echo_request(
	echo_request_to_link0,
	_HETHER_tn2nut,
	{
		TrafficClass = 0;
		FlowLabel = 0;
		HopLimit = HOP_LIMIT_BEFORE;
		_SRC(TN_GL0_ADDR);
		_DST(TN_GL1_ADDR);
	},
	{
		Identifier = PING_ID;
		SequenceNumber = PING_SN;
		payload = echo_data8;
	}
)


FEM_icmp6_echo_request(
	echo_request_from_link1,
	_HETHER_nut2tn,
	{
		TrafficClass = 0;
		FlowLabel = 0;
		HopLimit = HOP_LIMIT_AFTER;
		_SRC(TN_GL0_ADDR);
		_DST(TN_GL1_ADDR);
	},
	{
		Identifier = PING_ID;
		SequenceNumber = PING_SN;
		payload = echo_data8;
	}
)

//======================================================================
//
// ICMP echo reply
//

FEM_icmp6_echo_reply(
	echo_reply_to_link1,
	_HETHER_tn2nut,
	{
		TrafficClass = 0;
		FlowLabel = 0;
		HopLimit = HOP_LIMIT_BEFORE;
		_SRC(TN_GL1_ADDR);
		_DST(TN_GL0_ADDR);
	},
	{
		Identifier = PING_ID;
		SequenceNumber = PING_SN;
		payload = echo_data8;
	}
)

FEM_icmp6_echo_reply(
	echo_reply_from_link0,
	_HETHER_nut2tn,
	{
		TrafficClass = 0;
		FlowLabel = 0;
		HopLimit = HOP_LIMIT_AFTER;
		_SRC(TN_GL1_ADDR);
		_DST(TN_GL0_ADDR);
	},
	{
		Identifier = PING_ID;
		SequenceNumber = PING_SN;
		payload = echo_data8;
	}
)

//----------------------------------------------------------------------
// Payload Data
//----------------------------------------------------------------------

Payload echo_data8 {
	data = {1,2,3,4,5,6,7,8};
}

//======================================================================
//
// NS and NA for Link0 (Link Local)
//

FEM_icmp6_ns(
	ns_from_link0_ll,
	_HETHER_nut2tnsolnode,
	{
		_SRC(nutv6());
		_DST(_IPV6_SOLNODE_MCAST(tnv6()));
		HopLimit = 255;
	},
	{
		TargetAddress = TN_GL0_ADDR;
		option = _SLLOPT_nut;
	}
)

FEM_icmp6_na(
	na_to_link0_ll,
	_HETHER_tn2nut,
	{
		_SRC(tnv6());
		_DST(nutv6());
		HopLimit = 255;
	},
	{
		SFlag = 1;
		OFlag = 1;
		TargetAddress = TN_GL0_ADDR;
		option = _TLLOPT_tn;
	}
)

//======================================================================
//
// NS and NA for Link0 (Global)
//

FEM_icmp6_ns(
	ns_from_link0,
	_HETHER_nut2tnsolnode,
	{
		_SRC(NUT_GL0_ADDR);
		_DST(_IPV6_SOLNODE_MCAST(tnv6()));
		HopLimit = 255;
	},
	{
		TargetAddress = TN_GL0_ADDR;
		option = _SLLOPT_nut;
	}
)

FEM_icmp6_na(
	na_to_link0,
	_HETHER_tn2nut,
	{
		_SRC(tnv6());
		_DST(NUT_GL0_ADDR);
		HopLimit = 255;
	},
	{
		SFlag = 1;
		OFlag = 1;
		TargetAddress = TN_GL0_ADDR;
		option = _TLLOPT_tn;
	}
)

//======================================================================
//
// NS and NA for Link1 (Link Local)
//

FEM_icmp6_ns(
	ns_from_link1_ll,
	_HETHER_nut2tnsolnode,
	{
		_SRC(nutv6());
		_DST(_IPV6_SOLNODE_MCAST(tnv6()));
		HopLimit = 255;
	},
	{
		TargetAddress = TN_GL1_ADDR;
		option = _SLLOPT_nut;
	}
)

FEM_icmp6_na(
	na_to_link1_ll,
	_HETHER_tn2nut,
	{
		_SRC(tnv6());
		_DST(nutv6());
		HopLimit = 255;
	},
	{
		SFlag = 1;
		OFlag = 1;
		TargetAddress = TN_GL1_ADDR;
		option = _TLLOPT_tn;
	}
)

//======================================================================
//
// NS and NA for Link1 (Global)
//

FEM_icmp6_ns(
	ns_from_link1,
	_HETHER_nut2tnsolnode,
	{
		_SRC(NUT_GL1_ADDR);
		_DST(_IPV6_SOLNODE_MCAST(tnv6()));
		HopLimit = 255;
	},
	{
		TargetAddress = TN_GL1_ADDR;
		option = _SLLOPT_nut;
	}
)

FEM_icmp6_na(
	na_to_link1,
	_HETHER_tn2nut,
	{
		_SRC(tnv6());
		_DST(NUT_GL1_ADDR);
		HopLimit = 255;
	},
	{
		SFlag = 1;
		OFlag = 1;
		TargetAddress = TN_GL1_ADDR;
		option = _TLLOPT_tn;
	}
)
