blob: 75c13589a4706667254ef348fc686bf4fca3f942 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
package org.openslx.dnbd3;
import java.nio.ByteBuffer;
public class DNBD3Header {
public static final int ERROR_IMAGE_NOT_FOUND = 1;
public static final int ERROR_IMAGE_ALREADY_EXISTS = 2;
public static final int ERROR_CONFIG_FILE_PERMISSIONS = 3;
public static final int ERROR_UNKNOWN = 10;
private int cmd;
private int size;
private int error;
public DNBD3Header(int cmd, int size, int error) {
this.cmd = cmd;
this.size = size;
this.error = error;
}
public DNBD3Header(byte[] bytes) {
ByteBuffer bb = ByteBuffer.wrap(bytes);
this.cmd = bb.getInt();
this.size = bb.getInt();
this.error = bb.getInt();
}
public DNBD3Header() {
}
public byte[] toByteArray() {
ByteBuffer bb = ByteBuffer.allocate(12);
bb.putInt(cmd);
bb.putInt(size);
bb.putInt(error);
return bb.array();
}
public void fromByteArray(byte[] bytes) {
ByteBuffer bb = ByteBuffer.wrap(bytes);
this.cmd = bb.getInt();
this.size = bb.getInt();
this.error = bb.getInt();
}
public int getCmd() {
return cmd;
}
public void setCmd(int cmd) {
this.cmd = cmd;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public int getError() {
return error;
}
public void setError(int error) {
this.error = error;
}
}
|