Move to kernel style SPDX license identifiers
[lttng-ust.git] / liblttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / client / SessiondCommandHeader.java
CommitLineData
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
9package org.lttng.ust.agent.client;
10
11import java.nio.ByteBuffer;
12import java.nio.ByteOrder;
13
1d193914 14import 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 */
22class 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}
This page took 0.027358 seconds and 4 git commands to generate.