// $Copyright$
//
// $Id: sendNsBasicLinkGlob.def,v 1.1.1.1 2000/09/28 00:14:48 sekiya Exp $

#include "nd.def"

//----------------------------------------------------------------------
// echo-request
//	TN(link-local) ==> NUT(global)
//----------------------------------------------------------------------
FEM_icmp6_echo_request(echo_request, _HETHER_tn2nut,
	{
	 _SRC(tnv6());
	 _DST(nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN));},
	{
	 payload=echo_data;
	}
)

//----------------------------------------------------------------------
// echo-reply
//	NUT(global) ==> TN(link-local)
//----------------------------------------------------------------------
FEM_icmp6_echo_reply(echo_reply, _HETHER_nut2tn,
	{
	 _SRC(nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN));
	 _DST(tnv6());
	},
	{
	 payload=echo_data;
	}
)

//----------------------------------------------------------------------
Payload echo_data {
	data=repeat(0x11,10);
}

//----------------------------------------------------------------------
// unicast NA
//	TN(link-local) ==> NUT(global)
//	target=TN(link-local)
//	r=0, s=1, o=1
//	w/ TLLA
//----------------------------------------------------------------------
FEM_icmp6_na(na_to_global, _HETHER_tn2nut,
	{
	 _SRC(tnv6());
	 _DST(nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN));
	 HopLimit=255;
	},
	{
	 RFlag=0;
	 SFlag=1;
	 OFlag=1;
	 TargetAddress=tnv6();
	 option=_TLLOPT_tn;
	}
)

//----------------------------------------------------------------------
// unicast NA
//	TN(link-local) ==> NUT(link-local)
//	target=TN(link-local)
//	r=0, s=1, o=1
//	w/ TLLA
//----------------------------------------------------------------------
FEM_icmp6_na(na_to_link, _HETHER_tn2nut,
	{
	 _SRC(tnv6());
	 _DST(nutv6());
	 HopLimit=255;
	},
	{
	 RFlag=0;
	 SFlag=1;
	 OFlag=1;
	 TargetAddress=tnv6();
	 option=_TLLOPT_tn;
	}
)

//----------------------------------------------------------------------
// multicast NS
//	NUT(global) ==> TN(solicited-node[link-local])
//	target=TN(link-local)
//	w/ SLLA
//----------------------------------------------------------------------
FEM_icmp6_ns(multicast_ns_from_global, _HETHER_nut2tnsolnode,
	{
	 _SRC(nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN));
	 _DST(_IPV6_SOLNODE_MCAST(tnv6()));
	 HopLimit=255;
	},
	{
	 TargetAddress=tnv6();
	 option=_SLLOPT_nut;
	}
)

//----------------------------------------------------------------------
// multicast NS
//	NUT(link-local) ==> TN(solicited-node[link-local])
//	target=TN(link-local)
//	w/ SLLA
//----------------------------------------------------------------------
FEM_icmp6_ns(multicast_ns_from_link, _HETHER_nut2tnsolnode,
	{
	 _SRC(nutv6());
	 _DST(_IPV6_SOLNODE_MCAST(tnv6()));
	 HopLimit=255;
	},
	{
	 TargetAddress=tnv6();
	 option=_SLLOPT_nut;
	}
)

//----------------------------------------------------------------------
// unicast NS
//	NUT(global) ==> TN(link-local)
//	target=TN(link-local)
//----------------------------------------------------------------------
FEM_icmp6_ns(unicast_ns_from_global, _HETHER_nut2tn,
	{
	 _SRC(nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN));
	 _DST(tnv6());
	 HopLimit=255;
	},
	{
	 TargetAddress=tnv6();
	}
)

//----------------------------------------------------------------------
// unicast NS
//	NUT(global) ==> TN(link-local)
//	target=TN(link-local)
//----------------------------------------------------------------------
FEM_icmp6_ns(unicast_ns_from_global_sll, _HETHER_nut2tn,
	{
	 _SRC(nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN));
	 _DST(tnv6());
	 HopLimit=255;
	},
	{
	 TargetAddress=tnv6();
	 option=_SLLOPT_nut;
	}
)

//----------------------------------------------------------------------
// unicast NS
//	NUT(link-local) ==> TN(link-local)
//	target=TN(link-local)
//----------------------------------------------------------------------
FEM_icmp6_ns(unicast_ns_from_link, _HETHER_nut2tn,
	{
	 _SRC(nutv6());
	 _DST(tnv6());
	 HopLimit=255;
	},
	{
	 TargetAddress=tnv6();
	}
)

//----------------------------------------------------------------------
// unicast NS
//	NUT(link-local) ==> TN(link-local)
//	target= TN(link-local)
//	w/ SLLA
//----------------------------------------------------------------------
FEM_icmp6_ns(unicast_ns_from_link_sll, _HETHER_nut2tn,
	{
	 _SRC(nutv6());
	 _DST(tnv6());
	 HopLimit=255;
	},
	{
	 TargetAddress=tnv6();
	 option=_SLLOPT_nut;
	}
)

//----------------------------------------------------------------------
_HETHER_define(hether_x2allnode, ether(A0N_MAC_ADDR),
	v62ethermulti(v6(_ALLNODES_MCAST_ADDR)))
_SLLOPT_define(sllopt_x, ether(A0N_MAC_ADDR))

//----------------------------------------------------------------------
// multicast RA
//	X(link-local) ==> all-node
//	m=0, o=0
//	lifetime=600, reachableTime=0, retransTimer=0
//	w/ SLLA
//	w/ prefix
//		l=1, a=1
//		ValidLifetime=2592000, PreferredLifetime=604800,
//----------------------------------------------------------------------
FEM_icmp6_ra(unsol_ra, hether_x2allnode,
	{
	 _SRC(v6ether(A0N_MAC_ADDR));
	 _DST(v6(_ALLNODES_MCAST_ADDR));
	 HopLimit=255;
	},
	{
	 CurHopLimit=0;
	 MFlag=0;
	 OFlag=0;
	 LifeTime=600;
	 ReachableTime=0;
	 RetransTimer=0;
         option=sllopt_x;
	 option=prefixopt_a;
	}
)

//----------------------------------------------------------------------
Opt_ICMPv6_Prefix prefixopt_a {
//      Type=3;
//      Length=4;
//      PrefixLength=_GLOBAL0_UCAST_PRFXLEN;
        LFlag=1;
        AFlag=1;        
//      Reserved1=ZERO; 
        ValidLifetime=2592000;
        PreferredLifetime=604800;
//      Reserved2=ZERO; 
        Prefix=v6(_GLOBAL0_UCAST_PRFX);
}

//----------------------------------------------------------------------
// multicast RA
//	X(link-local) ==> all-node
//	m=0, o=0
//	lifetime=0, reachableTime=0, retransTimer=0
//	w/ SLLA
//	w/o prefix
//----------------------------------------------------------------------
FEM_icmp6_ra(unsol_ra_clrrtr, hether_x2allnode,
	{
	 _SRC(v6ether(A0N_MAC_ADDR));
	 _DST(v6(_ALLNODES_MCAST_ADDR));
	 HopLimit=255;
	},
	{
	 CurHopLimit=0;
	 MFlag=0;
	 OFlag=0;
	 LifeTime=0;
	 ReachableTime=0;
	 RetransTimer=0;
         option=sllopt_x;
	}
)

//----------------------------------------------------------------------

