import static org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathSegmentParser.SegmentType.AS_SEQUENCE;
import static org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathSegmentParser.SegmentType.AS_SET;
-import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
-
import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ShortAsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.AListCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.ASetCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.list._case.AList;
*/
public final class AsPathSegmentParser {
- public static final int AS_NUMBER_LENGTH = 2;
+ public static final int AS_NUMBER_LENGTH = 4;
/**
* Possible types of AS Path segments.
static List<AsSequence> parseAsSequence(final ReferenceCache refCache, final int count, final ByteBuf buffer) {
final List<AsSequence> coll = new ArrayList<>();
for (int i = 0; i < count; i++) {
- long asValue = buffer.readUnsignedShort();
coll.add(
- refCache.getSharedReference(new AsSequenceBuilder().setAs(refCache.getSharedReference(new AsNumber(asValue))).build()));
+ refCache.getSharedReference(new AsSequenceBuilder().setAs(refCache.getSharedReference(new AsNumber(buffer.readUnsignedInt()))).build()));
}
return coll;
}
static List<AsNumber> parseAsSet(final ReferenceCache refCache, final int count, final ByteBuf buffer) {
final List<AsNumber> coll = new ArrayList<>();
for (int i = 0; i < count; i++) {
- long asValue = buffer.readUnsignedShort();
coll.add(refCache.getSharedReference(
- new AsNumber(asValue)));
+ new AsNumber(buffer.readUnsignedInt())));
}
return coll;
}
- static void serializeAsSet(final ASetCase aSetCase, final ByteBuf byteAggregator) {
+ static void serializeAsSet(ASetCase aSetCase, ByteBuf byteAggregator) {
ASet aset = aSetCase.getASet();
if (aset == null || aset.getAsSet() == null) {
return;
byteAggregator.writeByte(serializeType(AS_SET));
byteAggregator.writeByte(aset.getAsSet().size());
for (AsNumber asNumber : aset.getAsSet()) {
- byteAggregator.writeShort(new ShortAsNumber(asNumber).getValue().shortValue());
+ byteAggregator.writeInt(asNumber.getValue().intValue());
}
}
- static void serializeAsSequence(final AListCase aListCase, final ByteBuf byteAggregator) {
- final AList alist = aListCase.getAList();
+ static void serializeAsSequence(AListCase aListCase, ByteBuf byteAggregator) {
+ AList alist = aListCase.getAList();
if (alist == null || alist.getAsSequence() == null) {
return;
}
byteAggregator.writeByte(serializeType(AS_SEQUENCE));
byteAggregator.writeByte(alist.getAsSequence().size());
for (AsSequence value : alist.getAsSequence()) {
- byteAggregator.writeShort(new ShortAsNumber(value.getAs()).getValue().shortValue());
+ byteAggregator.writeInt(value.getAs().getValue().intValue());
}
}
}
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
* Tests IPv4 NEXT_HOP, ATOMIC_AGGREGATE, COMMUNITY, NLRI
*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
- * 00 52 <- length (82) - including header
+ * 00 54 <- length (84) - including header
* 02 <- message type
* 00 00 <- withdrawn routes length
- * 00 2f <- total path attribute length (47)
+ * 00 31 <- total path attribute length (49)
* 40 <- attribute flags
* 01 <- attribute type code (origin)
* 01 <- attribute length
* 06 <- attribute length
* 02 <- AS_SEQUENCE
* 01 <- path segment count
- * fd ea <- path segment value (65002)
+ * 00 00 fd ea <- path segment value (65002)
* 40 <- attribute flags
* 03 <- attribute type code (Next Hop)
* 04 <- attribute length
* 60 <- attribute flags
* 06 <- attribute type code (atomic aggregate)
* 00 <- attribute length
- * 64 <- attribute flags
+ * 40 <- attribute flags
* 08 <- attribute type code (community)
* 10 <- attribute length FF FF FF
* 01 <- value (NO_EXPORT)
* Tests IPv6 NEXT_HOP, NLRI, ORIGIN.IGP, MULTI_EXIT_DISC, ORIGINATOR-ID, CLUSTER_LIST.
*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
- * 00 7e <- length (126) - including header
+ * 00 80 <- length (128) - including header
* 02 <- message type
* 00 00 <- withdrawn routes length
- * 00 67 <- total path attribute length (103)
+ * 00 69 <- total path attribute length (105)
* 40 <- attribute flags
* 01 <- attribute type code (origin)
* 01 <- attribute length
* 00 <- Origin value (IGP)
* 40 <- attribute flags
* 02 <- attribute type code (as path)
- * 04 <- attribute length
+ * 06 <- attribute length
* 02 <- AS_SEQUENCE
* 01 <- path segment count
- * fd e9 <- path segment value (65001)
+ * 00 00 fd e9 <- path segment value (65001)
* 40 <- attribute flags
* 03 <- attribute type code (next hop)
* 04 <- attribute length
* Tests more AS Numbers in AS_PATH, AGGREGATOR, ORIGIN.INCOMPLETE
*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
- * 00 45 <- length (69) - including header
+ * 00 4b <- length (75) - including header
* 02 <- message type
* 00 00 <- withdrawn routes length
- * 00 30 <- total path attribute length (42)
+ * 00 30 <- total path attribute length (48)
* 40 <- attribute flags
* 01 <- attribute type code (origin)
* 01 <- attribute length
* 10 <- attribute length
* 02 <- AS_SEQUENCE
* 01 <- path segment count
- * 00 1e <- path segment value (30)
+ * 00 00 00 1e <- path segment value (30)
* 01 <- AS_SET
* 02 <- path segment count
- * 00 0a <- path segment value (10)
- * 00 14 <- path segment value (20)
+ * 00 00 00 0a <- path segment value (10)
+ * 00 00 00 14 <- path segment value (20)
* 40 <- attribute flags
* 03 <- attribute type (Next hop)
* 04 <- attribute length