/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anarres.ipmi.protocol.packet.ipmi;

import com.google.common.primitives.UnsignedBytes;
import java.nio.ByteBuffer;
import org.anarres.ipmi.protocol.packet.common.AbstractWireable;
import org.anarres.ipmi.protocol.packet.common.Code;

/**
 * 
 * Section 13.6 page 133.
 *
 * @author shevek
 */
public class IpmiHeader extends AbstractWireable {

    public enum AuthenticationType implements Code.Wrapper {

        NONE(0),
        MD2(1),
        MD5(2),
        PASSWORD(4),
        OEM_PROPRIETARY(5),
        RMCP(6);
        private final byte code;

        private AuthenticationType(int code) {
            this.code = UnsignedBytes.checkedCast(code);
        }

        @Override
        public byte getCode() {
            return code;
        }
    }
    private AuthenticationType authenticationType;
    private IpmiPayloadType payloadType;
    private boolean encrypted;
    private boolean authenticated;
    private int oemIanaEnterpriseNumber;    // 3 byte oem iana; 1 byte zero
    private char oemPayloadId;
    private int ipmiSessionId;
    private int ipmiSessionSequenceNumber;

    // 2 byte payload length
    @Override
    protected void toWireUnchecked(ByteBuffer buffer) {
        buffer.put(authenticationType.getCode());
        byte payloadType = this.payloadType.getCode();
        if (encrypted)
            payloadType |= 0x80;
        if (authenticated)
            payloadType |= 0x40;
        buffer.put(payloadType);
        // if payloadType == OEM_EXPLICIT
    }
}

@@ -1207,16 +1207,141 @@
 umber;%0A%0A
+    @Override%0A    public int getWireLength() %7B%0A        throw new UnsupportedOperationException(%22Not supported yet.%22);%0A    %7D%0A%0A
     // 2
@@ -1732,11 +1732,161 @@
 IT%0A    %7D
+%0A%0A    @Override%0A    protected void fromWireUnchecked(ByteBuffer buffer) %7B%0A        throw new UnsupportedOperationException(%22Not supported yet.%22);%0A    %7D
 %0A%7D%0A

Fix to compile for now.