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

#include "nd.def"

//----------------------------------------------------------------------
// multicast RA
//      TN(link-local) ==> all-node
//      M=0, O=0
//      lifetime=600 sec
//	ReachableTime=0 msec (not specified)
//	RetransTimer=0 msec (not specified)
//      w/ SLLA
//      w/ prefix
//              l=1, a=1
//              ValidLifetime=2592000
//		PreferredLifetime=604800;
//----------------------------------------------------------------------
FEM_icmp6_ra(ra_tn2allnode_sll_a, _HETHER_tn2allnodes,
        {
         _SRC(tnv6());
         _DST(v6(_ALLNODES_MCAST_ADDR));
         HopLimit=255;
        },
        {
         CurHopLimit=0;
         MFlag=0;
         OFlag=0;
         LifeTime=600;
         ReachableTime=0;
         RetransTimer=0;
         option=_SLLOPT_tn;
         option=prefixopt_a;
        }
)

//----------------------------------------------------------------------
FEM_icmp6_ra(ra_tn2allnode_sll_b, _HETHER_tn2allnodes,
        {
         _SRC(tnv6());
         _DST(v6(_ALLNODES_MCAST_ADDR));
         HopLimit=255;
        },
        {
         CurHopLimit=0;
         MFlag=0;
         OFlag=0;
         LifeTime=600;
         ReachableTime=0;
         RetransTimer=0;
         option=_SLLOPT_tn;
         option=prefixopt_b;
        }
)

//----------------------------------------------------------------------
FEM_icmp6_ra(ra_tn2allnode_sll_c, _HETHER_tn2allnodes,
        {
         _SRC(tnv6());
         _DST(v6(_ALLNODES_MCAST_ADDR));
         HopLimit=255;
        },
        {
         CurHopLimit=0;
         MFlag=0;
         OFlag=0;
         LifeTime=600;
         ReachableTime=0;
         RetransTimer=0;
         option=_SLLOPT_tn;
         option=prefixopt_c;
        }
)

//----------------------------------------------------------------------
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);
}

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

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

//----------------------------------------------------------------------
// multicast RA
//      TN(link-local) ==> all-node
//      M=0, O=0
//      lifetime=0 sec
//	ReachableTime=0 msec (not specified)
//	RetransTimer=0 msec (not specified)
//      w/o SLLA
//      w/o prefix
//----------------------------------------------------------------------
FEM_icmp6_ra(ra_tn2allnode_clrrtr, _HETHER_tn2allnodes,
        {
         _SRC(tnv6());
         _DST(v6(_ALLNODES_MCAST_ADDR));
         HopLimit=255;
        },
        {
         CurHopLimit=0;
         MFlag=0;
         OFlag=0;
         LifeTime=0;
         ReachableTime=0;
         RetransTimer=0;
        }
)

//----------------------------------------------------------------------
// multicast NS for DAD
//      unspecified ==> solnode[NUT's link-local]
//      target=NUT(global)
//      w/o SLLA
//----------------------------------------------------------------------
FEM_icmp6_ns(dad_ns_a, _HETHER_src2dstsolnode,
        {
         _SRC(v6(_UNSPEC_ADDR));
         _DST(_IPV6_SOLNODE_MCAST(nutv6()));
         HopLimit=255;
        },
        {
         TargetAddress=nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN);
        }
)

//----------------------------------------------------------------------
FEM_icmp6_ns(dad_ns_b, _HETHER_src2dstsolnode,
        {
         _SRC(v6(_UNSPEC_ADDR));
         _DST(_IPV6_SOLNODE_MCAST(nutv6()));
         HopLimit=255;
        },
        {
         TargetAddress=nut2v6(_GLOBAL8_UCAST_PRFX, _GLOBAL8_UCAST_PRFXLEN);
        }
)

//----------------------------------------------------------------------
FEM_icmp6_ns(dad_ns_c, _HETHER_src2dstsolnode,
        {
         _SRC(v6(_UNSPEC_ADDR));
         _DST(_IPV6_SOLNODE_MCAST(nutv6()));
         HopLimit=255;
        },
        {
         TargetAddress=nut2v6(_GLOBAL7_UCAST_PRFX, _GLOBAL7_UCAST_PRFXLEN);
        }
)

//----------------------------------------------------------------------
// unicast NA
//	TN(link-local) ==> NUT(link-local)
//	R=1, S=1, O=1
//	w/ TLLA
//----------------------------------------------------------------------
FEM_icmp6_na(unicast_na_tn2nut_RSO_tll, _HETHER_tn2nut,
        {
         _SRC(tnv6());
         _DST(nutv6());
         HopLimit=255;
        },
        {
         RFlag=1;
         SFlag=1;
         OFlag=1;
         TargetAddress=tnv6();
         option=_TLLOPT_tn;
        }
)

//----------------------------------------------------------------------
// echo-request
//      X(off-link global, but max:TN) ==> NUT(global)
//----------------------------------------------------------------------
FEM_icmp6_echo_request(echo_request_x2nut_a, _HETHER_tn2nut,
        {
         _SRC(v6merge(_GLOBAL9_UCAST_PRFX, _GLOBAL9_UCAST_PRFXLEN,
                        v6ether(A9N_MAC_ADDR)));
         _DST(nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN));
        },
        {
         payload=echo_data_a;
        }
)

//----------------------------------------------------------------------
FEM_icmp6_echo_request(echo_request_x2nut_b, _HETHER_tn2nut,
        {
         _SRC(v6merge(_GLOBAL9_UCAST_PRFX, _GLOBAL9_UCAST_PRFXLEN,
                        v6ether(A9N_MAC_ADDR)));
         _DST(nut2v6(_GLOBAL8_UCAST_PRFX, _GLOBAL8_UCAST_PRFXLEN));
        },
        {
         payload=echo_data_b;
        }
)

//----------------------------------------------------------------------
FEM_icmp6_echo_request(echo_request_x2nut_c, _HETHER_tn2nut,
        {
         _SRC(v6merge(_GLOBAL9_UCAST_PRFX, _GLOBAL9_UCAST_PRFXLEN,
                        v6ether(A9N_MAC_ADDR)));
         _DST(nut2v6(_GLOBAL7_UCAST_PRFX, _GLOBAL7_UCAST_PRFXLEN));
        },
        {
         payload=echo_data_c;
        }
)

//----------------------------------------------------------------------
// echo-reply
//      NUT(global) ==> X(off-link global, bug max:TN)
//----------------------------------------------------------------------
FEM_icmp6_echo_reply(echo_reply_nut2x_a, _HETHER_nut2tn,
        {
         _SRC(nut2v6(_GLOBAL0_UCAST_PRFX, _GLOBAL0_UCAST_PRFXLEN));
         _DST(v6merge(_GLOBAL9_UCAST_PRFX, _GLOBAL9_UCAST_PRFXLEN,
                        v6ether(A9N_MAC_ADDR)));
        },
        {
         payload=echo_data_a;
        }
)

//----------------------------------------------------------------------
FEM_icmp6_echo_reply(echo_reply_nut2x_b, _HETHER_nut2tn,
        {
         _SRC(nut2v6(_GLOBAL8_UCAST_PRFX, _GLOBAL8_UCAST_PRFXLEN));
         _DST(v6merge(_GLOBAL9_UCAST_PRFX, _GLOBAL9_UCAST_PRFXLEN,
                        v6ether(A9N_MAC_ADDR)));
        },
        {
         payload=echo_data_b;
        }
)

//----------------------------------------------------------------------
FEM_icmp6_echo_reply(echo_reply_nut2x_c, _HETHER_nut2tn,
        {
         _SRC(nut2v6(_GLOBAL7_UCAST_PRFX, _GLOBAL7_UCAST_PRFXLEN));
         _DST(v6merge(_GLOBAL9_UCAST_PRFX, _GLOBAL9_UCAST_PRFXLEN,
                        v6ether(A9N_MAC_ADDR)));
        },
        {
         payload=echo_data_c;
        }
)

//----------------------------------------------------------------------
Payload echo_data_a {
        data=repeat(0xaa,0x10);
}

//----------------------------------------------------------------------
Payload echo_data_b {
        data=repeat(0xbb,0x10);
}

//----------------------------------------------------------------------
Payload echo_data_c {
        data=repeat(0xcc,0x10);
}

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