1 package org.metricshub.ipmi.core.coding.payload.lan;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import org.metricshub.ipmi.core.coding.payload.CompletionCode;
26 import org.metricshub.ipmi.core.common.TypeConverter;
27
28
29
30
31 public class IpmiLanResponse extends IpmiLanMessage {
32
33 private CompletionCode completionCode;
34
35 public void setCompletionCode(byte completionCode) {
36 this.completionCode = CompletionCode.parseInt(TypeConverter
37 .byteToInt(completionCode));
38 }
39
40 public CompletionCode getCompletionCode() {
41 return completionCode;
42 }
43
44
45
46
47
48
49
50
51 public IpmiLanResponse(byte[] rawData) {
52 setRequesterAddress(rawData[0]);
53 networkFunction = TypeConverter.intToByte((TypeConverter
54 .byteToInt(rawData[1]) & 0xfC) >> 2);
55 setRequesterLogicalUnitNumber(TypeConverter.intToByte(TypeConverter
56 .byteToInt(rawData[1]) & 0x03));
57 if (rawData[2] != getChecksum1(rawData)) {
58 throw new IllegalArgumentException("Checksum 1 failed");
59 }
60 setResponderAddress(rawData[3]);
61 setSequenceNumber(TypeConverter.intToByte((TypeConverter
62 .byteToInt(rawData[4]) & 0xfC) >> 2));
63 setResponderLogicalUnitNumber(TypeConverter.intToByte(TypeConverter
64 .byteToInt(rawData[4]) & 0x03));
65 setCommand(rawData[5]);
66 setCompletionCode(rawData[6]);
67
68 if (rawData.length > 8) {
69 byte[] data = new byte[rawData.length - 8];
70
71 System.arraycopy(rawData, 7, data, 0, rawData.length - 8);
72
73 setData(data);
74 }
75
76 if (rawData[rawData.length - 1] != getChecksum2(rawData)) {
77 throw new IllegalArgumentException("Checksum 2 failed");
78 }
79 }
80
81 @Override
82 public int getPayloadLength() {
83 int length = 8;
84 if (getData() != null) {
85 length += getData().length;
86 }
87 return length;
88 }
89
90
91
92
93 @Override
94 @Deprecated
95 public byte[] getPayloadData() {
96 return null;
97 }
98
99 }