//
// Copyright (C) 2003, 2004, 2005 Yokogawa Electric Corporation, 
// INTAP(Interoperability Technology Association
// for Information Processing, Japan).  All rights reserved.
// 
// Redistribution and use of this software in source and binary forms, with 
// or without modification, are permitted provided that the following 
// conditions and disclaimer are agreed and accepted by the user:
// 
// 1. Redistributions of source code must retain the above copyright 
// notice, this list of conditions and the following disclaimer.
// 
// 2. Redistributions in binary form must reproduce the above copyright 
// notice, this list of conditions and the following disclaimer in the 
// documentation and/or other materials provided with the distribution.
// 
// 3. Neither the names of the copyrighters, the name of the project which 
// is related to this software (hereinafter referred to as "project") nor 
// the names of the contributors may be used to endorse or promote products 
// derived from this software without specific prior written permission.
// 
// 4. No merchantable use may be permitted without prior written 
// notification to the copyrighters. However, using this software for the 
// purpose of testing or evaluating any products including merchantable 
// products may be permitted without any notification to the copyrighters.
// 
// 
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHTERS, THE PROJECT AND 
// CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING 
// BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
// FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.  IN NO EVENT SHALL THE 
// COPYRIGHTERS, THE PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
// CONTRACT,STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
// THE POSSIBILITY OF SUCH DAMAGE.
//
// $TAHI: ct/pd/BEGIN.def,v 1.3 2003/04/22 04:09:18 akisada Exp $
//

#define PING_ID 0xffff
#define PING_SN 0x0001

#define TNMACADDR "00:00:00:00:a0:a0"
#define TNMACADDR1 "00:00:00:00:a1:a1",
#define TNMACADDR2 "00:00:00:00:a2:a2"
#define TNMACADDR3 "00:00:00:00:a3:a3"

//======================================================================

_HETHER_define(hether_pe2nut,
        ether(TNMACADDR),
        nutether()
)

_HETHER_define(hether_nut2pe,
        nutether(),
        ether(TNMACADDR)
)

_HETHER_define(hether_nut2pesolnode,
        nutether(),
        oneof(_ETHER_SOLNODE_MCAST(v6ether(TNMACADDR)),
              ether(TNMACADDR) )
)

_TLLOPT_define(tllopt_pe, ether(TNMACADDR))
_TLLOPT_define(tllopt_host, tnether())



//
// NS
//

FEM_icmp6_ns(
        ns_to_pe,
        hether_nut2pesolnode,
        {
                _SRC(nutv6());
                _DST(oneof(v6ether(TNMACADDR), _IPV6_SOLNODE_MCAST(v6ether(TNMACADDR))));
                HopLimit = 255;
        },
        {
                TargetAddress = v6ether(TNMACADDR);
                option = _SLLOPT_nut;
        }
)

//
// NA
//

FEM_icmp6_na(
        na_from_pe,
        hether_pe2nut,
        {
                _SRC(v6ether(TNMACADDR));
                _DST(nutv6());
                HopLimit = 255;
        },
        {
                RFlag = 1;
                SFlag = 1;
                OFlag = 1;
                TargetAddress = v6ether(TNMACADDR);
                option = tllopt_pe;
        }
)


//
// NS
//

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

//
// NA
//

FEM_icmp6_na(
        na_from_host,
        _HETHER_tn2nut,
        {
                _SRC(tnv6());
                _DST(nutv6());
                HopLimit = 255;
        },
        {
                RFlag = 1;
                SFlag = 1;
                OFlag = 1;
                TargetAddress = tnv6();
                option = tllopt_host;
        }
)


//
// ICMP echo request
//

FEM_icmp6_echo_request(
        echo_request_from_pe,
        hether_pe2nut,
        {
                Version = 6;
                TrafficClass = 0;
                FlowLabel = 0;
                _SRC(v6ether(TNMACADDR));
                _DST(nutv6());
        },
        {
                Identifier = PING_ID;
                SequenceNumber = PING_SN;
                payload = echo_data8;
        }
)

//
// ICMP echo reply
//

FEM_icmp6_echo_reply(
        echo_reply_to_pe,
        hether_nut2pe,
        {
                Version = 6;
                _SRC(nutv6());
                _DST(v6ether(TNMACADDR));
        },
        {
                Identifier = PING_ID;
                SequenceNumber = PING_SN;
                payload = echo_data8;
        }
)


//
// ICMP echo request
//

FEM_icmp6_echo_request(
        echo_request_from_host,
        _HETHER_tn2nut,
        {
                Version = 6;
                TrafficClass = 0;
                FlowLabel = 0;
                _SRC(tnv6());
                _DST(nutv6());
        },
        {
                Identifier = PING_ID;
                SequenceNumber = PING_SN;
                payload = echo_data8;
        }
)

//
// ICMP echo reply
//

FEM_icmp6_echo_reply(
        echo_reply_to_host,
        _HETHER_nut2tn,
        {
                Version = 6;
                _SRC(nutv6());
                _DST(tnv6());
        },
        {
                Identifier = PING_ID;
                SequenceNumber = PING_SN;
                payload = echo_data8;
        }
)

//
//

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


