View Javadoc
1   package org.metricshub.ipmi.core.coding.protocol;
2   
3   /*-
4    * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
5    * IPMI Java Client
6    * ჻჻჻჻჻჻
7    * Copyright 2023 Verax Systems, MetricsHub
8    * ჻჻჻჻჻჻
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   *
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   *
19   * You should have received a copy of the GNU General Lesser Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
23   */
24  
25  import org.metricshub.ipmi.core.coding.payload.IpmiPayload;
26  import org.metricshub.ipmi.core.coding.security.ConfidentialityAlgorithm;
27  
28  /**
29   * Wrapper class for IPMI message
30   */
31  public abstract class IpmiMessage {
32  	private AuthenticationType authenticationType;
33  
34  	private int sessionSequenceNumber;
35  
36  	private int sessionID;
37  
38  	private byte[] authCode;
39  
40  	private IpmiPayload payload;
41  
42  	private int payloadLength;
43  
44  	/**
45  	 * Confidentiality Algorithm used for encryption and decryption.
46  	 */
47  	private ConfidentialityAlgorithm confidentialityAlgorithm;
48  
49  	public void setAuthenticationType(AuthenticationType authenticationType) {
50  		this.authenticationType = authenticationType;
51  	}
52  
53  	public AuthenticationType getAuthenticationType() {
54  		return authenticationType;
55  	}
56  
57  	public void setSessionSequenceNumber(int sessionSequenceNumber) {
58  		this.sessionSequenceNumber = sessionSequenceNumber;
59  	}
60  
61  	public int getSessionSequenceNumber() {
62  		return sessionSequenceNumber;
63  	}
64  
65  	public void setSessionID(int sessionID) {
66  		this.sessionID = sessionID;
67  	}
68  
69  	public int getSessionID() {
70  		return sessionID;
71  	}
72  
73  	public void setAuthCode(byte[] authCode) {
74  		this.authCode = authCode;
75  	}
76  
77  	public byte[] getAuthCode() {
78  		return authCode;
79  	}
80  
81  	/**
82  	 * Sets {@link #payload} and {@link #payloadLength}
83  	 *
84  	 * @param payload
85  	 */
86  	public void setPayload(IpmiPayload payload) {
87  		setPayloadLength(payload.getPayloadLength());
88  		this.payload = payload;
89  	}
90  
91  	public IpmiPayload getPayload() {
92  		return payload;
93  	}
94  
95  	public void setPayloadLength(int payloadLength) {
96  		this.payloadLength = payloadLength;
97  	}
98  
99  	/**
100 	 * @return Length of the UNENCRYPTED payload.
101 	 */
102 	public int getPayloadLength() {
103 		return payloadLength;
104 	}
105 
106 	public void setConfidentialityAlgorithm(ConfidentialityAlgorithm confidentialityAlgorithm) {
107 		this.confidentialityAlgorithm = confidentialityAlgorithm;
108 	}
109 
110 	public ConfidentialityAlgorithm getConfidentialityAlgorithm() {
111 		return confidentialityAlgorithm;
112 	}
113 
114 }