package com.lumaserv.bgp.protocol.message; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @Getter @Setter public class BGPNotification { byte majorErrorCode; byte minorErrorCode; /** Major error codes */ @Getter public enum Error { MESSAGE_HEADER_ERROR(1), OPEN_MESSAGE_ERROR(2), UPDATE_MESSAGE_ERROR(3), HOLD_TIMER_ERROR(4), FSM_ERROR(5), CEASE(6); byte code; Error(int code) { this.code = (byte)code; } } /** Minor error codes for OPEN_MESSAGE_ERROR */ @Getter public enum OpenMessageError { UNSUPPORTED_VERSION_NUMBER(1), BAD_PEER_AS(2), BAD_BGP_IDENTIFIER(3), UNSUPPORTED_OPTION_PARAMETER(4), UNACCEPTABLE_HOLD_TIME(5); byte code; OpenMessageError(int code) { this.code = (byte)code; } } public BGPNotification(byte[] message) { this.majorErrorCode = message[0]; this.minorErrorCode = message[1]; } @Override public String toString() { return "" + majorErrorCode + ":" + minorErrorCode; } }