Commit | Line | Data |
---|---|---|
d60dfbe4 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: LGPL-2.1-only |
d60dfbe4 | 3 | * |
c0c0989a MJ |
4 | * Copyright (C) 2015 EfficiOS Inc. |
5 | * Copyright (C) 2015 Alexandre Montplaisir <alexmonthy@efficios.com> | |
6 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> | |
d60dfbe4 AM |
7 | */ |
8 | ||
9 | package org.lttng.ust.agent.client; | |
10 | ||
11 | import java.nio.ByteBuffer; | |
12 | import java.nio.ByteOrder; | |
13 | ||
1d193914 | 14 | import org.lttng.ust.agent.client.SessiondCommand.CommandType; |
301a3ddb AM |
15 | |
16 | /** | |
17 | * Header of session daemon commands. | |
18 | * | |
19 | * @author Alexandre Montplaisir | |
20 | * @author David Goulet | |
21 | */ | |
22 | class SessiondCommandHeader { | |
d60dfbe4 AM |
23 | |
24 | /** ABI size of command header. */ | |
25 | public static final int HEADER_SIZE = 16; | |
26 | ||
27 | /** Payload size in bytes following this header. */ | |
301a3ddb AM |
28 | private final long dataSize; |
29 | ||
d60dfbe4 | 30 | /** Command type. */ |
301a3ddb | 31 | private final CommandType cmd; |
d60dfbe4 | 32 | |
301a3ddb | 33 | public SessiondCommandHeader(byte[] data) { |
d60dfbe4 AM |
34 | ByteBuffer buf = ByteBuffer.wrap(data); |
35 | buf.order(ByteOrder.BIG_ENDIAN); | |
36 | ||
37 | dataSize = buf.getLong(); | |
301a3ddb | 38 | cmd = CommandType.values()[buf.getInt() - 1]; |
d60dfbe4 AM |
39 | buf.getInt(); // command version, currently unused |
40 | } | |
41 | ||
42 | public long getDataSize() { | |
43 | return dataSize; | |
44 | } | |
45 | ||
301a3ddb | 46 | public CommandType getCommandType() { |
d60dfbe4 AM |
47 | return cmd; |
48 | } | |
49 | } |