[ONOS-2599] Implement BGP Notification protocol Messgae parsing, Decode and encoding]
Change-Id: Ibf1515f6cd0aebaf1070785b420ec0f89bb37aca
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNotificationMsg.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNotificationMsg.java
index 56540dd..a1d9d57 100644
--- a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNotificationMsg.java
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNotificationMsg.java
@@ -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 @@
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);
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java
index 064dead..3bddd37 100644
--- a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java
@@ -44,7 +44,7 @@
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 @@
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 @@
public static final BGPNotificationMsgVer4.Reader READER = new Reader();
/**
- * Resets fields.
+ * Initialize fields.
*/
public BGPNotificationMsgVer4() {
this.bgpHeader = null;
@@ -154,13 +156,6 @@
}
@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;