1 /*
2  * This file is part of the OpenNMS(R) Application.
3  *
4  * OpenNMS(R) is Copyright (C) 2011 The OpenNMS Group, Inc.  All rights reserved.
5  * OpenNMS(R) is a derivative work, containing both original code, included code and modified
6  * code that was published under the GNU General Public License. Copyrights for modified
7  * and included code are below.
8  *
9  * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24  *
25  * For more information contact:
26  * OpenNMS Licensing       <license@opennms.org>
27  *     http://www.opennms.org/
28  *     http://www.opennms.com/
29  */
30 package org.opennms.protocols.icmp6;
31 
32 import java.nio.ByteBuffer;
33 
34 
35 
36 /**
37  * ICMPEchoRequest
38  *
39  * @author brozow
40  */
41 public class ICMPv6EchoRequest extends ICMPv6EchoPacket {
42 
43     public static final int PACKET_LENGTH = 64;
44 
45 
ICMPv6EchoRequest()46     public ICMPv6EchoRequest() {
47         super(64);
48         setType(Type.EchoRequest);
49         setCode(0);
50     }
51 
52 
ICMPv6EchoRequest(int size)53     public ICMPv6EchoRequest(int size) {
54         super(size);
55         setType(Type.EchoRequest);
56         setCode(0);
57     }
58 
59 
ICMPv6EchoRequest(int id, int seqNum, long threadId)60     public ICMPv6EchoRequest(int id, int seqNum, long threadId) {
61         this();
62 
63         setIdentifier(id);
64         setSequenceNumber(seqNum);
65 
66         // data fields
67         setThreadId(threadId);
68         setCookie();
69         // timestamp is set later
70 
71         // fill buffer with 'interesting' data
72         ByteBuffer buf = getDataBuffer();
73         for(int b = DATA_LENGTH; b < buf.limit(); b++) {
74             buf.put(b, (byte)b);
75         }
76 
77     }
78 
79 
ICMPv6EchoRequest(int id, int seqNum, long threadId, int size)80     public ICMPv6EchoRequest(int id, int seqNum, long threadId, int size) {
81         this(size);
82 
83         setIdentifier(id);
84         setSequenceNumber(seqNum);
85 
86         // data fields
87         setThreadId(threadId);
88         setCookie();
89         // timestamp is set later
90 
91         // fill buffer with 'interesting' data
92         ByteBuffer buf = getDataBuffer();
93         for(int b = DATA_LENGTH; b < buf.limit(); b++) {
94             buf.put(b, (byte)b);
95         }
96 
97     }
98 
99 
100 }
101