1 /**********************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Matthew Khouzam - Initial implementation and API
11 * Marc-Andre Laperle - Initial implementation and API
12 **********************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.relayd
.lttngviewerCommands
;
16 import java
.io
.DataInputStream
;
17 import java
.io
.IOException
;
18 import java
.nio
.ByteBuffer
;
19 import java
.nio
.ByteOrder
;
22 * Response to getpacket command
24 * @author Matthew Khouzam
27 public class TracePacketResponse
implements IRelayResponse
{
32 * fStatus + fData.length + fFlags
34 private static final int SIZE
= (Integer
.SIZE
+ Integer
.SIZE
+ Integer
.SIZE
) / 8;
35 /** Enum lttng_viewer_get_packet_return_code */
36 private final GetPacketReturnCode fStatus
;
37 /** flags: is there new metadata or new streams? */
38 private final int fFlags
;
40 private final byte[] fData
;
43 * Trace packet response network constructor
46 * network input stream
50 public TracePacketResponse(DataInputStream inNet
) throws IOException
{
51 byte[] data
= new byte[SIZE
];
52 inNet
.readFully(data
);
53 ByteBuffer bb
= ByteBuffer
.wrap(data
);
54 bb
.order(ByteOrder
.BIG_ENDIAN
);
55 fStatus
= GetPacketReturnCode
.values()[bb
.getInt() - 1];
56 int length
= bb
.getInt();
58 if (fStatus
.equals(GetPacketReturnCode
.VIEWER_GET_PACKET_OK
)) {
59 fData
= new byte[length
];
60 inNet
.readFully(fData
);
71 public GetPacketReturnCode
getStatus() {
80 public int getFlags() {
85 * Get the packet data, please do not modify the data
89 public byte[] getData() {