Committed by
Gerrit Code Review
[ONOS-2599] Implement BGP Notification protocol Messgae parsing, Decode and encoding]
Change-Id: Ibf1515f6cd0aebaf1070785b420ec0f89bb37aca
Showing
2 changed files
with
18 additions
and
33 deletions
| ... | @@ -16,36 +16,34 @@ | ... | @@ -16,36 +16,34 @@ |
| 16 | package org.onosproject.bgpio.protocol; | 16 | package org.onosproject.bgpio.protocol; |
| 17 | 17 | ||
| 18 | import org.onosproject.bgpio.exceptions.BGPParseException; | 18 | import org.onosproject.bgpio.exceptions.BGPParseException; |
| 19 | -import org.onosproject.bgpio.types.BGPHeader; | ||
| 20 | 19 | ||
| 21 | /** | 20 | /** |
| 22 | - * Abstraction of an entity providing BGP Notification Message. | 21 | + * Abstraction of an entity providing BGP notification message. |
| 23 | */ | 22 | */ |
| 24 | public interface BGPNotificationMsg extends BGPMessage { | 23 | public interface BGPNotificationMsg extends BGPMessage { |
| 25 | /** | 24 | /** |
| 26 | - * Returns errorCode in Notification message. | 25 | + * Returns errorCode in notification message. |
| 27 | * | 26 | * |
| 28 | - * @return errorCode in Notification message | 27 | + * @return errorCode in notification message |
| 29 | */ | 28 | */ |
| 30 | byte getErrorCode(); | 29 | byte getErrorCode(); |
| 31 | 30 | ||
| 32 | /** | 31 | /** |
| 33 | - * Returns error SubCode in Notification message. | 32 | + * Returns error subCode in notification message. |
| 34 | * | 33 | * |
| 35 | - * @return error SubCode in Notification message | 34 | + * @return error subCode in notification message |
| 36 | */ | 35 | */ |
| 37 | byte getErrorSubCode(); | 36 | byte getErrorSubCode(); |
| 38 | 37 | ||
| 39 | /** | 38 | /** |
| 40 | - * Returns error data in Notification message. | 39 | + * Returns error data in notification message. |
| 41 | * | 40 | * |
| 42 | - * @return error data in Notification message | 41 | + * @return error data in notification message |
| 43 | */ | 42 | */ |
| 44 | byte[] getData(); | 43 | byte[] getData(); |
| 45 | 44 | ||
| 46 | /** | 45 | /** |
| 47 | - * Builder interface with get and set functions to build Notification | 46 | + * Builder interface with get and set functions to build notification message. |
| 48 | - * message. | ||
| 49 | */ | 47 | */ |
| 50 | public interface Builder extends BGPMessage.Builder { | 48 | public interface Builder extends BGPMessage.Builder { |
| 51 | 49 | ||
| ... | @@ -53,26 +51,18 @@ public interface BGPNotificationMsg extends BGPMessage { | ... | @@ -53,26 +51,18 @@ public interface BGPNotificationMsg extends BGPMessage { |
| 53 | BGPNotificationMsg build() throws BGPParseException; | 51 | BGPNotificationMsg build() throws BGPParseException; |
| 54 | 52 | ||
| 55 | /** | 53 | /** |
| 56 | - * Sets notification message header and returns its builder. | ||
| 57 | - * | ||
| 58 | - * @param header of notification message | ||
| 59 | - * @return Builder by setting notification message header | ||
| 60 | - */ | ||
| 61 | - Builder setNotificationMsgHeader(BGPHeader header); | ||
| 62 | - | ||
| 63 | - /** | ||
| 64 | * Sets errorCode in notification message and return its builder. | 54 | * Sets errorCode in notification message and return its builder. |
| 65 | * | 55 | * |
| 66 | * @param errorCode in notification message | 56 | * @param errorCode in notification message |
| 67 | - * @return builder by setting ErrorCode in notification message | 57 | + * @return builder by setting errorCode in notification message |
| 68 | */ | 58 | */ |
| 69 | Builder setErrorCode(byte errorCode); | 59 | Builder setErrorCode(byte errorCode); |
| 70 | 60 | ||
| 71 | /** | 61 | /** |
| 72 | - * Sets error SubCode in notification message and return its builder. | 62 | + * Sets error subCode in notification message and return its builder. |
| 73 | * | 63 | * |
| 74 | - * @param errorSubCode in notification Message | 64 | + * @param errorSubCode in notification message |
| 75 | - * @return builder by setting ErrorSubCode in notification Message | 65 | + * @return builder by setting error subCode in notification message |
| 76 | */ | 66 | */ |
| 77 | Builder setErrorSubCode(byte errorSubCode); | 67 | Builder setErrorSubCode(byte errorSubCode); |
| 78 | 68 | ... | ... |
| ... | @@ -44,7 +44,7 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg { | ... | @@ -44,7 +44,7 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg { |
| 44 | REFERENCE : RFC 4271 | 44 | REFERENCE : RFC 4271 |
| 45 | */ | 45 | */ |
| 46 | 46 | ||
| 47 | - protected static final Logger log = LoggerFactory.getLogger(BGPNotificationMsgVer4.class); | 47 | + private static final Logger log = LoggerFactory.getLogger(BGPNotificationMsgVer4.class); |
| 48 | 48 | ||
| 49 | static final byte PACKET_VERSION = 4; | 49 | static final byte PACKET_VERSION = 4; |
| 50 | //BGPHeader(19) + Error code(1) + Error subcode(1) | 50 | //BGPHeader(19) + Error code(1) + Error subcode(1) |
| ... | @@ -52,8 +52,10 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg { | ... | @@ -52,8 +52,10 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg { |
| 52 | static final int PACKET_MINIMUM_LENGTH = 2; | 52 | static final int PACKET_MINIMUM_LENGTH = 2; |
| 53 | static final BGPType MSG_TYPE = BGPType.NOTIFICATION; | 53 | static final BGPType MSG_TYPE = BGPType.NOTIFICATION; |
| 54 | static final byte DEFAULT_ERRORSUBCODE = 0; | 54 | static final byte DEFAULT_ERRORSUBCODE = 0; |
| 55 | - static final byte[] MARKER = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, | 55 | + static final byte[] MARKER = {(byte) 0xff, (byte) 0xff, (byte) 0xff, |
| 56 | - 0x01, 0x01}; | 56 | + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, |
| 57 | + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, | ||
| 58 | + (byte) 0xff, (byte) 0xff, (byte) 0xff }; | ||
| 57 | static final byte MESSAGE_TYPE = 3; | 59 | static final byte MESSAGE_TYPE = 3; |
| 58 | static final BGPHeader DEFAULT_MESSAGE_HEADER = new BGPHeader(MARKER, BGPHeader.DEFAULT_HEADER_LENGTH, | 60 | static final BGPHeader DEFAULT_MESSAGE_HEADER = new BGPHeader(MARKER, BGPHeader.DEFAULT_HEADER_LENGTH, |
| 59 | MESSAGE_TYPE); | 61 | MESSAGE_TYPE); |
| ... | @@ -65,7 +67,7 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg { | ... | @@ -65,7 +67,7 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg { |
| 65 | public static final BGPNotificationMsgVer4.Reader READER = new Reader(); | 67 | public static final BGPNotificationMsgVer4.Reader READER = new Reader(); |
| 66 | 68 | ||
| 67 | /** | 69 | /** |
| 68 | - * Resets fields. | 70 | + * Initialize fields. |
| 69 | */ | 71 | */ |
| 70 | public BGPNotificationMsgVer4() { | 72 | public BGPNotificationMsgVer4() { |
| 71 | this.bgpHeader = null; | 73 | this.bgpHeader = null; |
| ... | @@ -154,13 +156,6 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg { | ... | @@ -154,13 +156,6 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg { |
| 154 | } | 156 | } |
| 155 | 157 | ||
| 156 | @Override | 158 | @Override |
| 157 | - public Builder setNotificationMsgHeader(BGPHeader header) { | ||
| 158 | - this.bgpHeader = header; | ||
| 159 | - this.isBGPHeaderSet = true; | ||
| 160 | - return this; | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - @Override | ||
| 164 | public Builder setHeader(BGPHeader bgpMsgHeader) { | 159 | public Builder setHeader(BGPHeader bgpMsgHeader) { |
| 165 | this.bgpHeader = bgpMsgHeader; | 160 | this.bgpHeader = bgpMsgHeader; |
| 166 | return this; | 161 | return this; | ... | ... |
-
Please register or login to post a comment