Priyanka B
Committed by Gerrit Code Review

[ONOS-2599] Implement BGP Notification protocol Messgae parsing, Decode and encoding]

Change-Id: Ibf1515f6cd0aebaf1070785b420ec0f89bb37aca
......@@ -16,36 +16,34 @@
package org.onosproject.bgpio.protocol;
import org.onosproject.bgpio.exceptions.BGPParseException;
import org.onosproject.bgpio.types.BGPHeader;
/**
* Abstraction of an entity providing BGP Notification Message.
* Abstraction of an entity providing BGP notification message.
*/
public interface BGPNotificationMsg extends BGPMessage {
/**
* Returns errorCode in Notification message.
* Returns errorCode in notification message.
*
* @return errorCode in Notification message
* @return errorCode in notification message
*/
byte getErrorCode();
/**
* Returns error SubCode in Notification message.
* Returns error subCode in notification message.
*
* @return error SubCode in Notification message
* @return error subCode in notification message
*/
byte getErrorSubCode();
/**
* Returns error data in Notification message.
* Returns error data in notification message.
*
* @return error data in Notification message
* @return error data in notification message
*/
byte[] getData();
/**
* Builder interface with get and set functions to build Notification
* message.
* Builder interface with get and set functions to build notification message.
*/
public interface Builder extends BGPMessage.Builder {
......@@ -53,26 +51,18 @@ public interface BGPNotificationMsg extends BGPMessage {
BGPNotificationMsg build() throws BGPParseException;
/**
* Sets notification message header and returns its builder.
*
* @param header of notification message
* @return Builder by setting notification message header
*/
Builder setNotificationMsgHeader(BGPHeader header);
/**
* Sets errorCode in notification message and return its builder.
*
* @param errorCode in notification message
* @return builder by setting ErrorCode in notification message
* @return builder by setting errorCode in notification message
*/
Builder setErrorCode(byte errorCode);
/**
* Sets error SubCode in notification message and return its builder.
* Sets error subCode in notification message and return its builder.
*
* @param errorSubCode in notification Message
* @return builder by setting ErrorSubCode in notification Message
* @param errorSubCode in notification message
* @return builder by setting error subCode in notification message
*/
Builder setErrorSubCode(byte errorSubCode);
......
......@@ -44,7 +44,7 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
REFERENCE : RFC 4271
*/
protected static final Logger log = LoggerFactory.getLogger(BGPNotificationMsgVer4.class);
private static final Logger log = LoggerFactory.getLogger(BGPNotificationMsgVer4.class);
static final byte PACKET_VERSION = 4;
//BGPHeader(19) + Error code(1) + Error subcode(1)
......@@ -52,8 +52,10 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
static final int PACKET_MINIMUM_LENGTH = 2;
static final BGPType MSG_TYPE = BGPType.NOTIFICATION;
static final byte DEFAULT_ERRORSUBCODE = 0;
static final byte[] MARKER = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01};
static final byte[] MARKER = {(byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff };
static final byte MESSAGE_TYPE = 3;
static final BGPHeader DEFAULT_MESSAGE_HEADER = new BGPHeader(MARKER, BGPHeader.DEFAULT_HEADER_LENGTH,
MESSAGE_TYPE);
......@@ -65,7 +67,7 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
public static final BGPNotificationMsgVer4.Reader READER = new Reader();
/**
* Resets fields.
* Initialize fields.
*/
public BGPNotificationMsgVer4() {
this.bgpHeader = null;
......@@ -154,13 +156,6 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
}
@Override
public Builder setNotificationMsgHeader(BGPHeader header) {
this.bgpHeader = header;
this.isBGPHeaderSet = true;
return this;
}
@Override
public Builder setHeader(BGPHeader bgpMsgHeader) {
this.bgpHeader = bgpMsgHeader;
return this;
......