View Javadoc
1   package org.metricshub.ipmi.core.coding.commands.payload;
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.commands.IpmiVersion;
26  import org.metricshub.ipmi.core.coding.protocol.AuthenticationType;
27  import org.metricshub.ipmi.core.coding.protocol.PayloadType;
28  import org.metricshub.ipmi.core.coding.security.CipherSuite;
29  import org.metricshub.ipmi.core.coding.security.SecurityConstants;
30  import org.metricshub.ipmi.core.common.TypeConverter;
31  
32  /**
33   * Concrete implementation of {@link ActivatePayload} command for {@link PayloadType#SOL}.
34   */
35  public class ActivateSolPayload extends ActivatePayload {
36  
37  	/**
38  	 * Instantiate a new {@link ActivateSolPayload}
39  	 * @param cipherSuite     Provides cipher suite (authentication, confidentiality
40  	 *                        and integrity algorithms used during the session).
41  	 * @param payloadInstance Paylaod instance as int
42  	 */
43      public ActivateSolPayload(CipherSuite cipherSuite, int payloadInstance) {
44          super(IpmiVersion.V20, cipherSuite, AuthenticationType.RMCPPlus, payloadInstance);
45      }
46  
47      @Override
48      public PayloadType getPayloadType() {
49          return PayloadType.Sol;
50      }
51  
52      @Override
53      protected byte[] prepareAuxilaryRequestData() {
54          byte[] result = new byte[4];
55  
56          boolean isAuthenticationEnabled = getCipherSuite().getAuthenticationAlgorithm().getCode() != SecurityConstants.AA_RAKP_NONE;
57          boolean isEncryptionEnabled = getCipherSuite().getConfidentialityAlgorithm().getCode() != SecurityConstants.CA_NONE;
58  
59          if (isEncryptionEnabled) {
60              //encryption bit
61              result[0] = TypeConverter.setBitOnPosition(7, result[0]);
62          }
63  
64          if (isAuthenticationEnabled) {
65              //authentication bit
66              result[0] = TypeConverter.setBitOnPosition(6, result[0]);
67          }
68  
69          /*The following settings determine what happens to serial alerts
70          if IPMI over Serial and SOL are sharing the same baseboard serial controller.
71          Bit 2 set and bit 3 reset mean, that serial/modem alerts are deferred while SOL active*/
72          result[0] = TypeConverter.setBitOnPosition(2, result[0]);
73  
74          return result;
75      }
76  
77      @Override
78      protected ActivatePayloadResponseData createEmptyResponse() {
79          return new ActivateSolPayloadResponseData();
80      }
81  }