Commit | Line | Data |
---|---|---|
d60dfbe4 | 1 | /* |
301a3ddb | 2 | * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com> |
d60dfbe4 AM |
3 | * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com> |
4 | * | |
5 | * This library is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License, version 2.1 only, | |
7 | * as published by the Free Software Foundation. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
12 | * for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Lesser General Public License | |
15 | * along with this library; if not, write to the Free Software Foundation, | |
16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | ||
19 | package org.lttng.ust.agent.client; | |
20 | ||
21 | import java.nio.ByteBuffer; | |
22 | import java.nio.ByteOrder; | |
23 | ||
1d193914 | 24 | import org.lttng.ust.agent.client.SessiondCommand.CommandType; |
301a3ddb AM |
25 | |
26 | /** | |
27 | * Header of session daemon commands. | |
28 | * | |
29 | * @author Alexandre Montplaisir | |
30 | * @author David Goulet | |
31 | */ | |
32 | class SessiondCommandHeader { | |
d60dfbe4 AM |
33 | |
34 | /** ABI size of command header. */ | |
35 | public static final int HEADER_SIZE = 16; | |
36 | ||
37 | /** Payload size in bytes following this header. */ | |
301a3ddb AM |
38 | private final long dataSize; |
39 | ||
d60dfbe4 | 40 | /** Command type. */ |
301a3ddb | 41 | private final CommandType cmd; |
d60dfbe4 | 42 | |
301a3ddb | 43 | public SessiondCommandHeader(byte[] data) { |
d60dfbe4 AM |
44 | ByteBuffer buf = ByteBuffer.wrap(data); |
45 | buf.order(ByteOrder.BIG_ENDIAN); | |
46 | ||
47 | dataSize = buf.getLong(); | |
301a3ddb | 48 | cmd = CommandType.values()[buf.getInt() - 1]; |
d60dfbe4 AM |
49 | buf.getInt(); // command version, currently unused |
50 | } | |
51 | ||
52 | public long getDataSize() { | |
53 | return dataSize; | |
54 | } | |
55 | ||
301a3ddb | 56 | public CommandType getCommandType() { |
d60dfbe4 AM |
57 | return cmd; |
58 | } | |
59 | } |