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       * @param payload
84       */
85      public void setPayload(IpmiPayload payload) {
86          setPayloadLength(payload.getPayloadLength());
87          this.payload = payload;
88      }
89  
90      public IpmiPayload getPayload() {
91          return payload;
92      }
93  
94      public void setPayloadLength(int payloadLength) {
95          this.payloadLength = payloadLength;
96      }
97  
98      /**
99       * @return Length of the UNENCRYPTED payload.
100      */
101     public int getPayloadLength() {
102         return payloadLength;
103     }
104 
105     public void setConfidentialityAlgorithm(ConfidentialityAlgorithm confidentialityAlgorithm) {
106         this.confidentialityAlgorithm = confidentialityAlgorithm;
107     }
108 
109     public ConfidentialityAlgorithm getConfidentialityAlgorithm() {
110         return confidentialityAlgorithm;
111     }
112 
113 }