aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4')
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPFactoryVer4.java58
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpFactoryVer4.java58
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPKeepaliveMsgVer4.java)56
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpMessageVer4.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPMessageVer4.java)56
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java)76
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java)130
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java36
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java72
8 files changed, 273 insertions, 269 deletions
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPFactoryVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPFactoryVer4.java
deleted file mode 100755
index 32af3854..00000000
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPFactoryVer4.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol.ver4;
-
-import org.onosproject.bgpio.protocol.BGPFactory;
-import org.onosproject.bgpio.protocol.BGPKeepaliveMsg;
-import org.onosproject.bgpio.protocol.BGPMessage;
-import org.onosproject.bgpio.protocol.BGPMessageReader;
-import org.onosproject.bgpio.protocol.BGPNotificationMsg;
-import org.onosproject.bgpio.protocol.BGPOpenMsg;
-import org.onosproject.bgpio.protocol.BGPVersion;
-
-/**
- * Provides BGP Factory and returns builder classes for all objects and messages.
- */
-public class BGPFactoryVer4 implements BGPFactory {
-
- public static final BGPFactoryVer4 INSTANCE = new BGPFactoryVer4();
-
- @Override
- public BGPOpenMsg.Builder openMessageBuilder() {
- return new BGPOpenMsgVer4.Builder();
- }
-
- @Override
- public BGPKeepaliveMsg.Builder keepaliveMessageBuilder() {
- return new BGPKeepaliveMsgVer4.Builder();
- }
-
- @Override
- public BGPNotificationMsg.Builder notificationMessageBuilder() {
- return new BGPNotificationMsgVer4.Builder();
- }
-
- @Override
- public BGPMessageReader<BGPMessage> getReader() {
- return BGPMessageVer4.READER;
- }
-
- @Override
- public BGPVersion getVersion() {
- return BGPVersion.BGP_4;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpFactoryVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpFactoryVer4.java
new file mode 100755
index 00000000..c57832b6
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpFactoryVer4.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.bgpio.protocol.ver4;
+
+import org.onosproject.bgpio.protocol.BgpFactory;
+import org.onosproject.bgpio.protocol.BgpKeepaliveMsg;
+import org.onosproject.bgpio.protocol.BgpMessage;
+import org.onosproject.bgpio.protocol.BgpMessageReader;
+import org.onosproject.bgpio.protocol.BgpNotificationMsg;
+import org.onosproject.bgpio.protocol.BgpOpenMsg;
+import org.onosproject.bgpio.protocol.BgpVersion;
+
+/**
+ * Provides BGP Factory and returns builder classes for all objects and messages.
+ */
+public class BgpFactoryVer4 implements BgpFactory {
+
+ public static final BgpFactoryVer4 INSTANCE = new BgpFactoryVer4();
+
+ @Override
+ public BgpOpenMsg.Builder openMessageBuilder() {
+ return new BgpOpenMsgVer4.Builder();
+ }
+
+ @Override
+ public BgpKeepaliveMsg.Builder keepaliveMessageBuilder() {
+ return new BgpKeepaliveMsgVer4.Builder();
+ }
+
+ @Override
+ public BgpNotificationMsg.Builder notificationMessageBuilder() {
+ return new BgpNotificationMsgVer4.Builder();
+ }
+
+ @Override
+ public BgpMessageReader<BgpMessage> getReader() {
+ return BgpMessageVer4.READER;
+ }
+
+ @Override
+ public BgpVersion getVersion() {
+ return BgpVersion.BGP_4;
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPKeepaliveMsgVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
index 10e6bb95..2c141586 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPKeepaliveMsgVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
@@ -16,13 +16,13 @@
package org.onosproject.bgpio.protocol.ver4;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.protocol.BGPKeepaliveMsg;
-import org.onosproject.bgpio.protocol.BGPMessageReader;
-import org.onosproject.bgpio.protocol.BGPMessageWriter;
-import org.onosproject.bgpio.types.BGPHeader;
-import org.onosproject.bgpio.protocol.BGPType;
-import org.onosproject.bgpio.protocol.BGPVersion;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpKeepaliveMsg;
+import org.onosproject.bgpio.protocol.BgpMessageReader;
+import org.onosproject.bgpio.protocol.BgpMessageWriter;
+import org.onosproject.bgpio.types.BgpHeader;
+import org.onosproject.bgpio.protocol.BgpType;
+import org.onosproject.bgpio.protocol.BgpVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,7 +31,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides BGP keep alive message.
*/
-class BGPKeepaliveMsgVer4 implements BGPKeepaliveMsg {
+public class BgpKeepaliveMsgVer4 implements BgpKeepaliveMsg {
/*
<Keepalive Message>::= <Common Header>
@@ -56,56 +56,56 @@ class BGPKeepaliveMsgVer4 implements BGPKeepaliveMsg {
*/
protected static final Logger log = LoggerFactory
- .getLogger(BGPKeepaliveMsgVer4.class);
+ .getLogger(BgpKeepaliveMsgVer4.class);
- private BGPHeader bgpMsgHeader;
+ private BgpHeader bgpMsgHeader;
public static final byte PACKET_VERSION = 4;
public static final int PACKET_MINIMUM_LENGTH = 19;
public static final int MARKER_LENGTH = 16;
- public static final BGPType MSG_TYPE = BGPType.KEEP_ALIVE;
+ public static final BgpType MSG_TYPE = BgpType.KEEP_ALIVE;
public static byte[] marker = new byte[] {(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};
- public static final BGPKeepaliveMsgVer4.Reader READER = new Reader();
+ public static final BgpKeepaliveMsgVer4.Reader READER = new Reader();
/**
* Reader class for reading BGP keepalive message from channel buffer.
*/
- static class Reader implements BGPMessageReader<BGPKeepaliveMsg> {
+ static class Reader implements BgpMessageReader<BgpKeepaliveMsg> {
@Override
- public BGPKeepaliveMsg readFrom(ChannelBuffer cb, BGPHeader bgpHeader)
- throws BGPParseException {
+ public BgpKeepaliveMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
+ throws BgpParseException {
/* bgpHeader is not required in case of keepalive message and
Header is already read and no other fields except header in keepalive message.*/
- return new BGPKeepaliveMsgVer4();
+ return new BgpKeepaliveMsgVer4();
}
}
/**
* Default constructor.
*/
- BGPKeepaliveMsgVer4() {
+ public BgpKeepaliveMsgVer4() {
}
/**
* Builder class for BGP keepalive message.
*/
- static class Builder implements BGPKeepaliveMsg.Builder {
- BGPHeader bgpMsgHeader;
+ static class Builder implements BgpKeepaliveMsg.Builder {
+ BgpHeader bgpMsgHeader;
@Override
- public Builder setHeader(BGPHeader bgpMsgHeader) {
+ public Builder setHeader(BgpHeader bgpMsgHeader) {
this.bgpMsgHeader = bgpMsgHeader;
return this;
}
@Override
- public BGPKeepaliveMsg build() {
- return new BGPKeepaliveMsgVer4();
+ public BgpKeepaliveMsg build() {
+ return new BgpKeepaliveMsgVer4();
}
}
@@ -119,10 +119,10 @@ class BGPKeepaliveMsgVer4 implements BGPKeepaliveMsg {
/**
* Writer class for writing the BGP keepalive message to channel buffer.
*/
- static class Writer implements BGPMessageWriter<BGPKeepaliveMsgVer4> {
+ static class Writer implements BgpMessageWriter<BgpKeepaliveMsgVer4> {
@Override
- public void write(ChannelBuffer cb, BGPKeepaliveMsgVer4 message) {
+ public void write(ChannelBuffer cb, BgpKeepaliveMsgVer4 message) {
// write marker
cb.writeBytes(marker, 0, MARKER_LENGTH);
@@ -136,17 +136,17 @@ class BGPKeepaliveMsgVer4 implements BGPKeepaliveMsg {
}
@Override
- public BGPVersion getVersion() {
- return BGPVersion.BGP_4;
+ public BgpVersion getVersion() {
+ return BgpVersion.BGP_4;
}
@Override
- public BGPType getType() {
+ public BgpType getType() {
return MSG_TYPE;
}
@Override
- public BGPHeader getHeader() {
+ public BgpHeader getHeader() {
return this.bgpMsgHeader;
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPMessageVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpMessageVer4.java
index d45e3de1..1c05dae4 100755
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPMessageVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpMessageVer4.java
@@ -17,12 +17,12 @@
package org.onosproject.bgpio.protocol.ver4;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.protocol.BGPFactories;
-import org.onosproject.bgpio.protocol.BGPMessage;
-import org.onosproject.bgpio.protocol.BGPMessageReader;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPHeader;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpFactories;
+import org.onosproject.bgpio.protocol.BgpMessage;
+import org.onosproject.bgpio.protocol.BgpMessageReader;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpHeader;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,9 +30,9 @@ import org.slf4j.LoggerFactory;
/**
* Provides BGP messages.
*/
-public abstract class BGPMessageVer4 {
+public abstract class BgpMessageVer4 {
- protected static final Logger log = LoggerFactory.getLogger(BGPFactories.class);
+ protected static final Logger log = LoggerFactory.getLogger(BgpFactories.class);
static final byte OPEN_MSG_TYPE = 0x1;
static final byte KEEPALIVE_MSG_TYPE = 0x4;
@@ -42,41 +42,42 @@ public abstract class BGPMessageVer4 {
static final int HEADER_AND_MSG_LEN = 18;
static final int MAXIMUM_PACKET_LENGTH = 4096;
- public static final BGPMessageVer4.Reader READER = new Reader();
+ public static final BgpMessageVer4.Reader READER = new Reader();
/**
* Reader class for reading BGP messages from channel buffer.
*
*/
- static class Reader implements BGPMessageReader<BGPMessage> {
+ static class Reader implements BgpMessageReader<BgpMessage> {
@Override
- public BGPMessage readFrom(ChannelBuffer cb, BGPHeader bgpHeader)
- throws BGPParseException {
+ public BgpMessage readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
+ throws BgpParseException {
if (cb.readableBytes() < MINIMUM_COMMON_HEADER_LENGTH) {
log.error("Packet should have minimum length.");
- Validation.validateLen(BGPErrorType.MESSAGE_HEADER_ERROR, BGPErrorType.BAD_MESSAGE_LENGTH,
+ Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_LENGTH,
cb.readableBytes());
}
if (cb.readableBytes() > MAXIMUM_PACKET_LENGTH) {
log.error("Packet length should not exceed {}.", MAXIMUM_PACKET_LENGTH);
- Validation.validateLen(BGPErrorType.MESSAGE_HEADER_ERROR, BGPErrorType.BAD_MESSAGE_LENGTH,
+ Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_LENGTH,
cb.readableBytes());
}
try {
// fixed value property version == 4
- byte[] marker = new byte[BGPHeader.MARKER_LENGTH];
- cb.readBytes(marker, 0, BGPHeader.MARKER_LENGTH);
+ byte[] marker = new byte[BgpHeader.MARKER_LENGTH];
+ cb.readBytes(marker, 0, BgpHeader.MARKER_LENGTH);
bgpHeader.setMarker(marker);
- for (int i = 0; i < BGPHeader.MARKER_LENGTH; i++) {
+ for (int i = 0; i < BgpHeader.MARKER_LENGTH; i++) {
if (marker[i] != (byte) 0xff) {
- throw new BGPParseException(BGPErrorType.MESSAGE_HEADER_ERROR,
- BGPErrorType.CONNECTION_NOT_SYNCHRONIZED, null);
+ throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR,
+ BgpErrorType.CONNECTION_NOT_SYNCHRONIZED, null);
}
}
short length = cb.readShort();
- if (length != (cb.readableBytes() + HEADER_AND_MSG_LEN)) {
- Validation.validateLen(BGPErrorType.MESSAGE_HEADER_ERROR, BGPErrorType.BAD_MESSAGE_LENGTH, length);
+ if (length > cb.readableBytes() + HEADER_AND_MSG_LEN) {
+ Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR,
+ BgpErrorType.BAD_MESSAGE_LENGTH, length);
}
bgpHeader.setLength(length);
byte type = cb.readByte();
@@ -87,22 +88,23 @@ public abstract class BGPMessageVer4 {
switch (type) {
case OPEN_MSG_TYPE:
log.debug("OPEN MESSAGE is received");
- return BGPOpenMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
+ return BgpOpenMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
case KEEPALIVE_MSG_TYPE:
log.debug("KEEPALIVE MESSAGE is received");
- return BGPKeepaliveMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
+ return BgpKeepaliveMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
case UPDATE_MSG_TYPE:
log.debug("UPDATE MESSAGE is received");
- // TODO: Update message version 4
+ return BgpUpdateMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
case NOTIFICATION_MSG_TYPE:
log.debug("NOTIFICATION MESSAGE is received");
- return BGPNotificationMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
+ return BgpNotificationMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
default:
- Validation.validateType(BGPErrorType.MESSAGE_HEADER_ERROR, BGPErrorType.BAD_MESSAGE_TYPE, type);
+ Validation.validateType(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_TYPE, type);
return null;
}
} catch (IndexOutOfBoundsException e) {
- throw new BGPParseException(BGPErrorType.MESSAGE_HEADER_ERROR, BGPErrorType.BAD_MESSAGE_LENGTH, null);
+ throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR,
+ BgpErrorType.BAD_MESSAGE_LENGTH, null);
}
}
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
index 3bddd375..d25db24e 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
@@ -16,14 +16,14 @@
package org.onosproject.bgpio.protocol.ver4;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.protocol.BGPMessageReader;
-import org.onosproject.bgpio.protocol.BGPMessageWriter;
-import org.onosproject.bgpio.protocol.BGPNotificationMsg;
-import org.onosproject.bgpio.protocol.BGPType;
-import org.onosproject.bgpio.protocol.BGPVersion;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPHeader;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpMessageReader;
+import org.onosproject.bgpio.protocol.BgpMessageWriter;
+import org.onosproject.bgpio.protocol.BgpNotificationMsg;
+import org.onosproject.bgpio.protocol.BgpType;
+import org.onosproject.bgpio.protocol.BgpVersion;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,7 +33,7 @@ import com.google.common.base.MoreObjects;
* A NOTIFICATION message is sent when an error condition is detected. The BGP connection is closed immediately after it
* is sent.
*/
-class BGPNotificationMsgVer4 implements BGPNotificationMsg {
+class BgpNotificationMsgVer4 implements BgpNotificationMsg {
/*
0 1 2 3
@@ -44,32 +44,32 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
REFERENCE : RFC 4271
*/
- private 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)
static final int TOTAL_MESSAGE_MIN_LENGTH = 21;
static final int PACKET_MINIMUM_LENGTH = 2;
- static final BGPType MSG_TYPE = BGPType.NOTIFICATION;
+ static final BgpType MSG_TYPE = BgpType.NOTIFICATION;
static final byte DEFAULT_ERRORSUBCODE = 0;
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,
+ static final BgpHeader DEFAULT_MESSAGE_HEADER = new BgpHeader(MARKER, BgpHeader.DEFAULT_HEADER_LENGTH,
MESSAGE_TYPE);
private byte errorCode;
private byte errorSubCode;
private byte[] data;
- private BGPHeader bgpHeader;
- public static final BGPNotificationMsgVer4.Reader READER = new Reader();
+ private BgpHeader bgpHeader;
+ public static final BgpNotificationMsgVer4.Reader READER = new Reader();
/**
* Initialize fields.
*/
- public BGPNotificationMsgVer4() {
+ public BgpNotificationMsgVer4() {
this.bgpHeader = null;
this.data = null;
this.errorCode = 0;
@@ -84,7 +84,7 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
* @param errorSubCode error subcode
* @param data field
*/
- public BGPNotificationMsgVer4(BGPHeader bgpHeader, byte errorCode, byte errorSubCode, byte[] data) {
+ public BgpNotificationMsgVer4(BgpHeader bgpHeader, byte errorCode, byte errorSubCode, byte[] data) {
this.bgpHeader = bgpHeader;
this.data = data;
this.errorCode = errorCode;
@@ -94,13 +94,13 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
/**
* Reader reads BGP Notification Message from the channel buffer.
*/
- static class Reader implements BGPMessageReader<BGPNotificationMsg> {
+ static class Reader implements BgpMessageReader<BgpNotificationMsg> {
@Override
- public BGPNotificationMsg readFrom(ChannelBuffer cb, BGPHeader bgpHeader) throws BGPParseException {
+ public BgpNotificationMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader) throws BgpParseException {
byte errorCode;
byte errorSubCode;
if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new BGPParseException("Not enough readable bytes");
+ throw new BgpParseException("Not enough readable bytes");
}
errorCode = cb.readByte();
errorSubCode = cb.readByte();
@@ -108,31 +108,31 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
int dataLength = bgpHeader.getLength() - TOTAL_MESSAGE_MIN_LENGTH;
byte[] data = new byte[dataLength];
cb.readBytes(data, 0, dataLength);
- return new BGPNotificationMsgVer4(bgpHeader, errorCode, errorSubCode, data);
+ return new BgpNotificationMsgVer4(bgpHeader, errorCode, errorSubCode, data);
}
}
/**
* Builder class for BGP notification message.
*/
- static class Builder implements BGPNotificationMsg.Builder {
+ static class Builder implements BgpNotificationMsg.Builder {
private byte errorCode;
private byte errorSubCode;
private byte[] data;
- private BGPHeader bgpHeader;
+ private BgpHeader bgpHeader;
private boolean isErrorCodeSet = false;
private boolean isErrorSubCodeSet = false;
private boolean isBGPHeaderSet = false;
@Override
- public BGPNotificationMsg build() throws BGPParseException {
- BGPHeader bgpHeader = this.isBGPHeaderSet ? this.bgpHeader : DEFAULT_MESSAGE_HEADER;
+ public BgpNotificationMsg build() throws BgpParseException {
+ BgpHeader bgpHeader = this.isBGPHeaderSet ? this.bgpHeader : DEFAULT_MESSAGE_HEADER;
if (!this.isErrorCodeSet) {
- throw new BGPParseException("Error code must be present");
+ throw new BgpParseException("Error code must be present");
}
byte errorSubCode = this.isErrorSubCodeSet ? this.errorSubCode : DEFAULT_ERRORSUBCODE;
- return new BGPNotificationMsgVer4(bgpHeader, this.errorCode, errorSubCode, this.data);
+ return new BgpNotificationMsgVer4(bgpHeader, this.errorCode, errorSubCode, this.data);
}
@Override
@@ -151,29 +151,31 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
@Override
public Builder setData(byte[] data) {
- this.data = data;
+ if (data != null) {
+ this.data = data;
+ }
return this;
}
@Override
- public Builder setHeader(BGPHeader bgpMsgHeader) {
+ public Builder setHeader(BgpHeader bgpMsgHeader) {
this.bgpHeader = bgpMsgHeader;
return this;
}
}
@Override
- public BGPVersion getVersion() {
- return BGPVersion.BGP_4;
+ public BgpVersion getVersion() {
+ return BgpVersion.BGP_4;
}
@Override
- public BGPType getType() {
- return BGPType.NOTIFICATION;
+ public BgpType getType() {
+ return BgpType.NOTIFICATION;
}
@Override
- public void writeTo(ChannelBuffer cb) throws BGPParseException {
+ public void writeTo(ChannelBuffer cb) throws BgpParseException {
WRITER.write(cb, this);
}
@@ -182,13 +184,13 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
/**
* Writer writes BGP notification message to channel buffer.
*/
- static class Writer implements BGPMessageWriter<BGPNotificationMsgVer4> {
+ static class Writer implements BgpMessageWriter<BgpNotificationMsgVer4> {
@Override
- public void write(ChannelBuffer cb, BGPNotificationMsgVer4 message) throws BGPParseException {
+ public void write(ChannelBuffer cb, BgpNotificationMsgVer4 message) throws BgpParseException {
int msgStartIndex = cb.writerIndex();
int headerLenIndex = message.bgpHeader.write(cb);
if (headerLenIndex <= 0) {
- throw new BGPParseException(BGPErrorType.MESSAGE_HEADER_ERROR, (byte) 0, null);
+ throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR, (byte) 0, null);
}
cb.writeByte(message.errorCode);
cb.writeByte(message.errorSubCode);
@@ -244,7 +246,7 @@ class BGPNotificationMsgVer4 implements BGPNotificationMsg {
}
@Override
- public BGPHeader getHeader() {
+ public BgpHeader getHeader() {
return this.bgpHeader;
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
index fccbf5f7..359eec25 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
@@ -19,15 +19,15 @@ import java.util.LinkedList;
import java.util.ListIterator;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.protocol.BGPMessageReader;
-import org.onosproject.bgpio.protocol.BGPMessageWriter;
-import org.onosproject.bgpio.protocol.BGPOpenMsg;
-import org.onosproject.bgpio.protocol.BGPType;
-import org.onosproject.bgpio.protocol.BGPVersion;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPHeader;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpMessageReader;
+import org.onosproject.bgpio.protocol.BgpMessageWriter;
+import org.onosproject.bgpio.protocol.BgpOpenMsg;
+import org.onosproject.bgpio.protocol.BgpType;
+import org.onosproject.bgpio.protocol.BgpVersion;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpHeader;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv;
import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv;
import org.onosproject.bgpio.util.Validation;
@@ -39,7 +39,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides BGP open message.
*/
-public class BGPOpenMsgVer4 implements BGPOpenMsg {
+public class BgpOpenMsgVer4 implements BgpOpenMsg {
/*
0 1 2 3
@@ -61,7 +61,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
REFERENCE : RFC 4271
*/
- protected static final Logger log = LoggerFactory.getLogger(BGPOpenMsgVer4.class);
+ protected static final Logger log = LoggerFactory.getLogger(BgpOpenMsgVer4.class);
public static final byte PACKET_VERSION = 4;
public static final int OPEN_MSG_MINIMUM_LENGTH = 10;
@@ -70,7 +70,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
public static final int DEFAULT_HOLD_TIME = 120;
public static final short AS_TRANS = 23456;
public static final int OPT_PARA_TYPE_CAPABILITY = 2;
- public static final BGPType MSG_TYPE = BGPType.OPEN;
+ public static final BgpType MSG_TYPE = BgpType.OPEN;
public static final short AFI = 16388;
public static final byte SAFI = 71;
public static final byte RES = 0;
@@ -78,22 +78,22 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
public static final byte[] MARKER = new byte[]{(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};
- public static final BGPHeader DEFAULT_OPEN_HEADER = new BGPHeader(MARKER,
+ public static final BgpHeader DEFAULT_OPEN_HEADER = new BgpHeader(MARKER,
(short) OPEN_MSG_MINIMUM_LENGTH, (byte) 0X01);
- private BGPHeader bgpMsgHeader;
+ private BgpHeader bgpMsgHeader;
private byte version;
private short asNumber;
private short holdTime;
private int bgpId;
private boolean isLargeAsCapabilitySet;
- private LinkedList<BGPValueType> capabilityTlv;
+ private LinkedList<BgpValueType> capabilityTlv;
- public static final BGPOpenMsgVer4.Reader READER = new Reader();
+ public static final BgpOpenMsgVer4.Reader READER = new Reader();
/**
* reset variables.
*/
- public BGPOpenMsgVer4() {
+ public BgpOpenMsgVer4() {
this.bgpMsgHeader = null;
this.version = 0;
this.holdTime = 0;
@@ -112,8 +112,8 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
* @param bgpId BGP identifier in open message
* @param capabilityTlv capabilities in open message
*/
- public BGPOpenMsgVer4(BGPHeader bgpMsgHeader, byte version, short asNumber, short holdTime,
- int bgpId, LinkedList<BGPValueType> capabilityTlv) {
+ public BgpOpenMsgVer4(BgpHeader bgpMsgHeader, byte version, short asNumber, short holdTime,
+ int bgpId, LinkedList<BgpValueType> capabilityTlv) {
this.bgpMsgHeader = bgpMsgHeader;
this.version = version;
this.asNumber = asNumber;
@@ -123,17 +123,17 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
}
@Override
- public BGPHeader getHeader() {
+ public BgpHeader getHeader() {
return this.bgpMsgHeader;
}
@Override
- public BGPVersion getVersion() {
- return BGPVersion.BGP_4;
+ public BgpVersion getVersion() {
+ return BgpVersion.BGP_4;
}
@Override
- public BGPType getType() {
+ public BgpType getType() {
return MSG_TYPE;
}
@@ -153,17 +153,17 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
}
@Override
- public LinkedList<BGPValueType> getCapabilityTlv() {
+ public LinkedList<BgpValueType> getCapabilityTlv() {
return this.capabilityTlv;
}
/**
* Reader class for reading BGP open message from channel buffer.
*/
- public static class Reader implements BGPMessageReader<BGPOpenMsg> {
+ public static class Reader implements BgpMessageReader<BgpOpenMsg> {
@Override
- public BGPOpenMsg readFrom(ChannelBuffer cb, BGPHeader bgpHeader) throws BGPParseException {
+ public BgpOpenMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader) throws BgpParseException {
byte version;
short holdTime;
@@ -172,11 +172,11 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
byte optParaLen = 0;
byte optParaType;
byte capParaLen = 0;
- LinkedList<BGPValueType> capabilityTlv = new LinkedList<>();
+ LinkedList<BgpValueType> capabilityTlv = new LinkedList<>();
if (cb.readableBytes() < OPEN_MSG_MINIMUM_LENGTH) {
log.error("[readFrom] Invalid length: Packet size is less than the minimum length ");
- Validation.validateLen(BGPErrorType.OPEN_MESSAGE_ERROR, BGPErrorType.BAD_MESSAGE_LENGTH,
+ Validation.validateLen(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.BAD_MESSAGE_LENGTH,
cb.readableBytes());
}
@@ -184,8 +184,8 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
version = cb.readByte();
if (version != PACKET_VERSION) {
log.error("[readFrom] Invalid version: " + version);
- throw new BGPParseException(BGPErrorType.OPEN_MESSAGE_ERROR,
- BGPErrorType.UNSUPPORTED_VERSION_NUMBER, null);
+ throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR,
+ BgpErrorType.UNSUPPORTED_VERSION_NUMBER, null);
}
// Read AS number
@@ -209,7 +209,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
capParaLen = cb.readByte();
if (cb.readableBytes() < capParaLen) {
- throw new BGPParseException(BGPErrorType.OPEN_MESSAGE_ERROR, (byte) 0, null);
+ throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, (byte) 0, null);
}
ChannelBuffer capaCb = cb.readBytes(capParaLen);
@@ -218,11 +218,11 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
if ((optParaType == OPT_PARA_TYPE_CAPABILITY) && (capParaLen != 0)) {
capabilityTlv = parseCapabilityTlv(capaCb);
} else {
- throw new BGPParseException(BGPErrorType.OPEN_MESSAGE_ERROR,
- BGPErrorType.UNSUPPORTED_OPTIONAL_PARAMETER, null);
+ throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR,
+ BgpErrorType.UNSUPPORTED_OPTIONAL_PARAMETER, null);
}
}
- return new BGPOpenMsgVer4(bgpHeader, version, asNumber, holdTime, bgpId, capabilityTlv);
+ return new BgpOpenMsgVer4(bgpHeader, version, asNumber, holdTime, bgpId, capabilityTlv);
}
}
@@ -231,14 +231,14 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
*
* @param cb of type channel buffer
* @return capabilityTlv of open message
- * @throws BGPParseException while parsing capabilities
+ * @throws BgpParseException while parsing capabilities
*/
- protected static LinkedList<BGPValueType> parseCapabilityTlv(ChannelBuffer cb) throws BGPParseException {
+ protected static LinkedList<BgpValueType> parseCapabilityTlv(ChannelBuffer cb) throws BgpParseException {
- LinkedList<BGPValueType> capabilityTlv = new LinkedList<>();
+ LinkedList<BgpValueType> capabilityTlv = new LinkedList<>();
while (cb.readableBytes() > 0) {
- BGPValueType tlv;
+ BgpValueType tlv;
short type = cb.readByte();
short length = cb.readByte();
@@ -246,10 +246,10 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
case FourOctetAsNumCapabilityTlv.TYPE:
log.debug("FourOctetAsNumCapabilityTlv");
if (FourOctetAsNumCapabilityTlv.LENGTH != length) {
- throw new BGPParseException("Invalid length received for FourOctetAsNumCapabilityTlv.");
+ throw new BgpParseException("Invalid length received for FourOctetAsNumCapabilityTlv.");
}
if (length > cb.readableBytes()) {
- throw new BGPParseException("Four octet as num tlv length"
+ throw new BgpParseException("Four octet as num tlv length"
+ " is more than readableBytes.");
}
int as4Num = cb.readInt();
@@ -258,10 +258,10 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
case MultiProtocolExtnCapabilityTlv.TYPE:
log.debug("MultiProtocolExtnCapabilityTlv");
if (MultiProtocolExtnCapabilityTlv.LENGTH != length) {
- throw new BGPParseException("Invalid length received for MultiProtocolExtnCapabilityTlv.");
+ throw new BgpParseException("Invalid length received for MultiProtocolExtnCapabilityTlv.");
}
if (length > cb.readableBytes()) {
- throw new BGPParseException("BGP LS tlv length is more than readableBytes.");
+ throw new BgpParseException("BGP LS tlv length is more than readableBytes.");
}
short afi = cb.readShort();
byte res = cb.readByte();
@@ -281,10 +281,10 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
/**
* Builder class for BGP open message.
*/
- static class Builder implements BGPOpenMsg.Builder {
+ static class Builder implements BgpOpenMsg.Builder {
private boolean isHeaderSet = false;
- private BGPHeader bgpMsgHeader;
+ private BgpHeader bgpMsgHeader;
private boolean isHoldTimeSet = false;
private short holdTime;
private boolean isAsNumSet = false;
@@ -294,40 +294,40 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
private boolean isLargeAsCapabilityTlvSet = false;
private boolean isLsCapabilityTlvSet = false;
- LinkedList<BGPValueType> capabilityTlv = new LinkedList<>();
+ LinkedList<BgpValueType> capabilityTlv = new LinkedList<>();
@Override
- public BGPOpenMsg build() throws BGPParseException {
- BGPHeader bgpMsgHeader = this.isHeaderSet ? this.bgpMsgHeader : DEFAULT_OPEN_HEADER;
+ public BgpOpenMsg build() throws BgpParseException {
+ BgpHeader bgpMsgHeader = this.isHeaderSet ? this.bgpMsgHeader : DEFAULT_OPEN_HEADER;
short holdTime = this.isHoldTimeSet ? this.holdTime : DEFAULT_HOLD_TIME;
if (!this.isAsNumSet) {
- throw new BGPParseException("BGP AS number is not set (mandatory)");
+ throw new BgpParseException("BGP AS number is not set (mandatory)");
}
if (!this.isBgpIdSet) {
- throw new BGPParseException("BGPID is not set (mandatory)");
+ throw new BgpParseException("BGPID is not set (mandatory)");
}
if (this.isLargeAsCapabilityTlvSet) {
- BGPValueType tlv;
+ BgpValueType tlv;
int value = this.asNumber;
tlv = new FourOctetAsNumCapabilityTlv(value);
this.capabilityTlv.add(tlv);
}
if (this.isLsCapabilityTlvSet) {
- BGPValueType tlv;
+ BgpValueType tlv;
tlv = new MultiProtocolExtnCapabilityTlv(AFI, RES, SAFI);
this.capabilityTlv.add(tlv);
}
- return new BGPOpenMsgVer4(bgpMsgHeader, PACKET_VERSION, this.asNumber, holdTime, this.bgpId,
+ return new BgpOpenMsgVer4(bgpMsgHeader, PACKET_VERSION, this.asNumber, holdTime, this.bgpId,
this.capabilityTlv);
}
@Override
- public Builder setHeader(BGPHeader bgpMsgHeader) {
+ public Builder setHeader(BgpHeader bgpMsgHeader) {
this.bgpMsgHeader = bgpMsgHeader;
return this;
}
@@ -354,7 +354,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
}
@Override
- public Builder setCapabilityTlv(LinkedList<BGPValueType> capabilityTlv) {
+ public Builder setCapabilityTlv(LinkedList<BgpValueType> capabilityTlv) {
this.capabilityTlv = capabilityTlv;
return this;
}
@@ -376,7 +376,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
public void writeTo(ChannelBuffer cb) {
try {
WRITER.write(cb, this);
- } catch (BGPParseException e) {
+ } catch (BgpParseException e) {
log.debug("[writeTo] Error: " + e.toString());
}
}
@@ -386,10 +386,10 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
/**
* Writer class for writing BGP open message to channel buffer.
*/
- public static class Writer implements BGPMessageWriter<BGPOpenMsgVer4> {
+ public static class Writer implements BgpMessageWriter<BgpOpenMsgVer4> {
@Override
- public void write(ChannelBuffer cb, BGPOpenMsgVer4 message) throws BGPParseException {
+ public void write(ChannelBuffer cb, BgpOpenMsgVer4 message) throws BgpParseException {
int optParaLen = 0;
int as4num = 0;
@@ -400,7 +400,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
int msgLenIndex = message.bgpMsgHeader.write(cb);
if (msgLenIndex <= 0) {
- throw new BGPParseException("Unable to write message header.");
+ throw new BgpParseException("Unable to write message header.");
}
// write version in 1-octet
@@ -408,13 +408,13 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
// get as4num if LS Capability is set
if (message.isLargeAsCapabilitySet) {
- LinkedList<BGPValueType> capabilityTlv = message
+ LinkedList<BgpValueType> capabilityTlv = message
.getCapabilityTlv();
- ListIterator<BGPValueType> listIterator = capabilityTlv
+ ListIterator<BgpValueType> listIterator = capabilityTlv
.listIterator();
while (listIterator.hasNext()) {
- BGPValueType tlv = listIterator.next();
+ BgpValueType tlv = listIterator.next();
if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) {
as4num = ((FourOctetAsNumCapabilityTlv) tlv).getInt();
break;
@@ -464,13 +464,13 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
* @param message of type BGPOpenMsgVer4
* @return capParaLen of open message
*/
- protected int packCapabilityTlv(ChannelBuffer cb, BGPOpenMsgVer4 message) {
+ protected int packCapabilityTlv(ChannelBuffer cb, BgpOpenMsgVer4 message) {
int startIndex = cb.writerIndex();
int capParaLen = 0;
int capParaLenIndex = 0;
- LinkedList<BGPValueType> capabilityTlv = message.capabilityTlv;
- ListIterator<BGPValueType> listIterator = capabilityTlv.listIterator();
+ LinkedList<BgpValueType> capabilityTlv = message.capabilityTlv;
+ ListIterator<BgpValueType> listIterator = capabilityTlv.listIterator();
if (listIterator.hasNext()) {
// Set optional parameter type as 2
@@ -487,7 +487,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
}
while (listIterator.hasNext()) {
- BGPValueType tlv = listIterator.next();
+ BgpValueType tlv = listIterator.next();
if (tlv == null) {
log.debug("Warning: tlv is null from CapabilityTlv list");
continue;
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
index 20a7ba03..9ffddf68 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
@@ -19,11 +19,11 @@ import java.util.LinkedList;
import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.types.As4Path;
import org.onosproject.bgpio.types.AsPath;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.types.LocalPref;
import org.onosproject.bgpio.types.Med;
import org.onosproject.bgpio.types.NextHop;
@@ -58,7 +58,7 @@ public class BgpPathAttributes {
public static final int MPREACHNLRI_TYPE = 14;
public static final int MPUNREACHNLRI_TYPE = 15;
- private final List<BGPValueType> pathAttribute;
+ private final List<BgpValueType> pathAttribute;
/**
* Initialize parameter.
@@ -72,7 +72,7 @@ public class BgpPathAttributes {
*
* @param pathAttribute list of path attributes
*/
- public BgpPathAttributes(List<BGPValueType> pathAttribute) {
+ public BgpPathAttributes(List<BgpValueType> pathAttribute) {
this.pathAttribute = pathAttribute;
}
@@ -81,7 +81,7 @@ public class BgpPathAttributes {
*
* @return list of path attributes
*/
- public List<BGPValueType> pathAttributes() {
+ public List<BgpValueType> pathAttributes() {
return this.pathAttribute;
}
@@ -90,13 +90,13 @@ public class BgpPathAttributes {
*
* @param cb channelBuffer
* @return object of BgpPathAttributes
- * @throws BGPParseException while parsing BGP path attributes
+ * @throws BgpParseException while parsing BGP path attributes
*/
public static BgpPathAttributes read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
- BGPValueType pathAttribute = null;
- List<BGPValueType> pathAttributeList = new LinkedList<>();
+ BgpValueType pathAttribute = null;
+ List<BgpValueType> pathAttributeList = new LinkedList<>();
boolean isOrigin = false;
boolean isAsPath = false;
boolean isNextHop = false;
@@ -161,27 +161,27 @@ public class BgpPathAttributes {
* @param isNextHop say whether nexthop attribute is present
* @param isMpReach say whether mpreach attribute is present
* @param isMpUnReach say whether mpunreach attribute is present
- * @throws BGPParseException if mandatory path attribute is not present
+ * @throws BgpParseException if mandatory path attribute is not present
*/
public static void checkMandatoryAttr(boolean isOrigin, boolean isAsPath,
boolean isNextHop, boolean isMpReach, boolean isMpUnReach)
- throws BGPParseException {
+ throws BgpParseException {
if (!isOrigin) {
log.debug("Mandatory Attributes not Present");
- Validation.validateType(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
+ Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
Origin.ORIGIN_TYPE);
}
if (!isAsPath) {
log.debug("Mandatory Attributes not Present");
- Validation.validateType(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
+ Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
AsPath.ASPATH_TYPE);
}
if (!isMpUnReach && !isMpReach && !isNextHop) {
log.debug("Mandatory Attributes not Present");
- Validation.validateType(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
+ Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
NextHop.NEXTHOP_TYPE);
}
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
index 9f4cf9b9..4d6af594 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
@@ -20,14 +20,14 @@ import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.IpPrefix;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.protocol.BGPMessageReader;
-import org.onosproject.bgpio.protocol.BGPType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpMessageReader;
+import org.onosproject.bgpio.protocol.BgpType;
import org.onosproject.bgpio.protocol.BgpUpdateMsg;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPHeader;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpHeader;
import org.onosproject.bgpio.util.Validation;
-import org.onosproject.bgpio.protocol.BGPVersion;
+import org.onosproject.bgpio.protocol.BgpVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,12 +75,12 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
public static final int BYTE_IN_BITS = 8;
public static final int MIN_LEN_AFTER_WITHDRW_ROUTES = 2;
public static final int MINIMUM_COMMON_HEADER_LENGTH = 19;
- public static final BGPType MSG_TYPE = BGPType.UPDATE;
+ public static final BgpType MSG_TYPE = BgpType.UPDATE;
public static final BgpUpdateMsgVer4.Reader READER = new Reader();
private List<IpPrefix> withdrawnRoutes;
private BgpPathAttributes bgpPathAttributes;
- private BGPHeader bgpHeader;
+ private BgpHeader bgpHeader;
private List<IpPrefix> nlri;
/**
@@ -91,7 +91,7 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
* @param bgpPathAttributes BGP Path attributes
* @param nlri Network Layer Reachability Information
*/
- public BgpUpdateMsgVer4(BGPHeader bgpHeader, List<IpPrefix> withdrawnRoutes,
+ public BgpUpdateMsgVer4(BgpHeader bgpHeader, List<IpPrefix> withdrawnRoutes,
BgpPathAttributes bgpPathAttributes, List<IpPrefix> nlri) {
this.bgpHeader = bgpHeader;
this.withdrawnRoutes = withdrawnRoutes;
@@ -102,15 +102,15 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
/**
* Reader reads BGP Update Message from the channel buffer.
*/
- static class Reader implements BGPMessageReader<BgpUpdateMsg> {
+ static class Reader implements BgpMessageReader<BgpUpdateMsg> {
@Override
- public BgpUpdateMsg readFrom(ChannelBuffer cb, BGPHeader bgpHeader)
- throws BGPParseException {
+ public BgpUpdateMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
+ throws BgpParseException {
if (cb.readableBytes() != (bgpHeader.getLength() - MINIMUM_COMMON_HEADER_LENGTH)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.BAD_MESSAGE_LENGTH, bgpHeader.getLength());
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.BAD_MESSAGE_LENGTH, bgpHeader.getLength());
}
LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
@@ -120,8 +120,8 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
Short withDrwLen = cb.readShort();
if (cb.readableBytes() < withDrwLen) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MALFORMED_ATTRIBUTE_LIST,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
ChannelBuffer tempCb = cb.readBytes(withDrwLen);
@@ -131,23 +131,23 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
}
if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
log.debug("Bgp Path Attribute len field not present");
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MALFORMED_ATTRIBUTE_LIST, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
// Reading Total Path Attribute Length
short totPathAttrLen = cb.readShort();
int len = withDrwLen + totPathAttrLen + PACKET_MINIMUM_LENGTH;
if (len > bgpHeader.getLength()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MALFORMED_ATTRIBUTE_LIST, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
if (totPathAttrLen != 0) {
// Parsing BGPPathAttributes
if (cb.readableBytes() < totPathAttrLen) {
Validation
- .validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MALFORMED_ATTRIBUTE_LIST,
+ .validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
tempCb = cb.readBytes(totPathAttrLen);
@@ -167,10 +167,10 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
*
* @param cb channelBuffer
* @return list of IP Prefix
- * @throws BGPParseException while parsing NLRI
+ * @throws BgpParseException while parsing NLRI
*/
public static LinkedList<IpPrefix> parseNlri(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
LinkedList<IpPrefix> nlri = new LinkedList<>();
while (cb.readableBytes() > 0) {
int length = cb.readByte();
@@ -186,8 +186,8 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
len = len + 1;
}
if (cb.readableBytes() < len) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MALFORMED_ATTRIBUTE_LIST,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
byte[] prefix = new byte[len];
@@ -204,10 +204,10 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
*
* @param cb channelBuffer
* @return list of IP prefix
- * @throws BGPParseException while parsing withdrawn routes
+ * @throws BgpParseException while parsing withdrawn routes
*/
public static LinkedList<IpPrefix> parseWithdrawnRoutes(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
while (cb.readableBytes() > 0) {
int length = cb.readByte();
@@ -224,8 +224,8 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
}
if (cb.readableBytes() < len) {
Validation
- .validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MALFORMED_ATTRIBUTE_LIST,
+ .validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
byte[] prefix = new byte[len];
@@ -238,17 +238,17 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
}
@Override
- public BGPVersion getVersion() {
- return BGPVersion.BGP_4;
+ public BgpVersion getVersion() {
+ return BgpVersion.BGP_4;
}
@Override
- public BGPType getType() {
- return BGPType.UPDATE;
+ public BgpType getType() {
+ return BgpType.UPDATE;
}
@Override
- public void writeTo(ChannelBuffer channelBuffer) throws BGPParseException {
+ public void writeTo(ChannelBuffer channelBuffer) throws BgpParseException {
//Not to be implemented as of now
}
@@ -268,7 +268,7 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
}
@Override
- public BGPHeader getHeader() {
+ public BgpHeader getHeader() {
return this.bgpHeader;
}