final NodeIdentifier id3 = this.f.identifierForRouter(new IPv4RouterIdentifier(IPv4.FAMILY.addressForString("192.168.1.5")));
final NodeIdentifier id4 = this.f.identifierForRouter(new IPv6RouterIdentifier(IPv6.FAMILY.addressForString("2001:db8:85a3::8a2e:370:7334")));
+ // FIXME BUG-103
// assertEquals("HashCodes should be equal", id1.hashCode(), id2.hashCode());
- // FIXME BUG-89
- // assertEquals("toString should be equal", id1.toString(), id2.toString());
+ assertEquals("toString should be equal", id1.toString(), id2.toString());
// assertEquals(id1, id2);
assertNotSame(id1, id3);
@Test
@Ignore
- // FIXME BUG-89
+ // FIXME BUG-103
public void testISISRouterIdentifier() {
final ISISRouterIdentifier is1 = new ISISRouterIdentifier(new IsoSystemIdentifier(new byte[] { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }));
final ISISRouterIdentifier is2 = new ISISRouterIdentifier(new IsoSystemIdentifier(new byte[] { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }));
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParametersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
byte[] value = null;
- if (param instanceof CParameters) {
- value = CapabilityParameterParser.put((CParameters) param);
- } else {
+ value = CapabilityParameterParser.put(param.getCParameters());
+
+ if (value == null) {
logger.debug("BGP Parameter not supported.");
return new byte[] {};
}
final int paramType = UnsignedBytes.toInt(bytes[byteOffset++]);
final int paramLength = UnsignedBytes.toInt(bytes[byteOffset++]);
if (paramType == CAPABILITIES_OPT_PARAM_TYPE) {
- final BgpParameters param = (BgpParameters) CapabilityParameterParser.parse(ByteArray.subByte(bytes, byteOffset,
- paramLength));
+ final CParameters cparam = CapabilityParameterParser.parse(ByteArray.subByte(bytes, byteOffset, paramLength));
+ if (cparam == null) {
+ byteOffset += paramLength;
+ continue;
+ }
+ final BgpParameters param = new BgpParametersBuilder().setCParameters(cparam).build();
if (param != null)
params.add(param);
} else
private static final int LENGTH_SIZE = 1; // bytes
private static final int AFI_SIZE = 2; // bytes
private static final int SAFI_SIZE = 1; // bytes
-
+
private static final int As4BytesCapability_CODE = 65;
private static final int Multiprotocol_CODE = 1;
value = putMultiProtocolParameterValue((CMultiprotocol) cap);
bytes = new byte[CODE_SIZE + LENGTH_SIZE + value.length];
bytes[0] = ByteArray.intToBytes(Multiprotocol_CODE)[Integer.SIZE / Byte.SIZE - 1];
- //} else if (cap instanceof GracefulCapability) {
- // value = putGracefulParameterValue((GracefulCapability) cap);
+ // } else if (cap instanceof GracefulCapability) {
+ // value = putGracefulParameterValue((GracefulCapability) cap);
} else if (cap instanceof CAs4Bytes) {
value = putAS4BytesParameterValue((CAs4Bytes) cap);
bytes = new byte[CODE_SIZE + LENGTH_SIZE + value.length];
bytes[0] = ByteArray.intToBytes(As4BytesCapability_CODE)[Integer.SIZE / Byte.SIZE - 1];
}
- bytes[1] = ByteArray.intToBytes(value.length)[Integer.SIZE / Byte.SIZE - 1];
- System.arraycopy(value, 0, bytes, CODE_SIZE + LENGTH_SIZE, value.length);
+ if (bytes != null) {
+ bytes[1] = ByteArray.intToBytes(value.length)[Integer.SIZE / Byte.SIZE - 1];
+ System.arraycopy(value, 0, bytes, CODE_SIZE + LENGTH_SIZE, value.length);
+ }
logger.trace("BGP Parameter serialized to: {}", Arrays.toString(bytes));
return bytes;
}
return null;
}
-// private static byte[] putGracefulParameterValue(final GracefulCapability param) {
-// final int RESTART_FLAGS_SIZE = 4; // bits
-// final int TIMER_SIZE = 12; // bits
-// final int AFI_SIZE = 2; // bytes
-// final int SAFI_SIZE = 1; // bytes
-// final int AF_FLAGS_SIZE = 1; // bytes
-// final byte[] bytes = new byte[(RESTART_FLAGS_SIZE + TIMER_SIZE + (AFI_SIZE * Byte.SIZE + SAFI_SIZE * Byte.SIZE + AF_FLAGS_SIZE
-// * Byte.SIZE)
-// * param.getTableTypes().size())
-// / Byte.SIZE];
-// if (param.isRestartFlag()) {
-// bytes[0] = (byte) 0x80;
-// }
-// int index = (RESTART_FLAGS_SIZE + TIMER_SIZE) / Byte.SIZE;
-// for (final Entry<BGPTableType, Boolean> entry : param.getTableTypes().entrySet()) {
-// final byte[] a = putAfi(entry.getKey().getAddressFamily());
-// final byte s = putSafi(entry.getKey().getSubsequentAddressFamily());
-// final byte f = (entry.getValue()) ? (byte) 0x80 : (byte) 0x00;
-// System.arraycopy(a, 0, bytes, index, AFI_SIZE);
-// index += AFI_SIZE;
-// bytes[index] = s;
-// index += SAFI_SIZE;
-// bytes[index] = f;
-// index += AF_FLAGS_SIZE;
-// }
-// return bytes;
-// }
+ // private static byte[] putGracefulParameterValue(final GracefulCapability param) {
+ // final int RESTART_FLAGS_SIZE = 4; // bits
+ // final int TIMER_SIZE = 12; // bits
+ // final int AFI_SIZE = 2; // bytes
+ // final int SAFI_SIZE = 1; // bytes
+ // final int AF_FLAGS_SIZE = 1; // bytes
+ // final byte[] bytes = new byte[(RESTART_FLAGS_SIZE + TIMER_SIZE + (AFI_SIZE * Byte.SIZE + SAFI_SIZE * Byte.SIZE +
+ // AF_FLAGS_SIZE
+ // * Byte.SIZE)
+ // * param.getTableTypes().size())
+ // / Byte.SIZE];
+ // if (param.isRestartFlag()) {
+ // bytes[0] = (byte) 0x80;
+ // }
+ // int index = (RESTART_FLAGS_SIZE + TIMER_SIZE) / Byte.SIZE;
+ // for (final Entry<BGPTableType, Boolean> entry : param.getTableTypes().entrySet()) {
+ // final byte[] a = putAfi(entry.getKey().getAddressFamily());
+ // final byte s = putSafi(entry.getKey().getSubsequentAddressFamily());
+ // final byte f = (entry.getValue()) ? (byte) 0x80 : (byte) 0x00;
+ // System.arraycopy(a, 0, bytes, index, AFI_SIZE);
+ // index += AFI_SIZE;
+ // bytes[index] = s;
+ // index += SAFI_SIZE;
+ // bytes[index] = f;
+ // index += AF_FLAGS_SIZE;
+ // }
+ // return bytes;
+ // }
private static byte[] putMultiProtocolParameterValue(final CMultiprotocol param) {
final byte[] a = putAfi(param.getMultiprotocolCapability().getAfi());
throw new BGPParsingException("Subsequent Address Family Identifier: '"
+ ByteArray.bytesToInt(ByteArray.subByte(bytes, AFI_SIZE + 1, SAFI_SIZE)) + "' not supported.");
}
-
- return new CMultiprotocolBuilder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(afi).setSafi(safi).build()).build();
+
+ return new CMultiprotocolBuilder().setMultiprotocolCapability(
+ new MultiprotocolCapabilityBuilder().setAfi(afi).setSafi(safi).build()).build();
}
private static CAs4Bytes parseAS4BParameterValue(final byte[] bytes) {
- return new CAs4BytesBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(ByteArray.bytesToLong(bytes))).build()).build();
+ return new CAs4BytesBuilder().setAs4BytesCapability(
+ new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(ByteArray.bytesToLong(bytes))).build()).build();
}
private static byte[] putAfi(final Class<? extends AddressFamily> afi) {
* 00 00 00 64 <- AS number
*/
@Test
- @Ignore
- // FIXME BUG-100
public void testOpenMessage() throws Exception {
final BGPMessageFactoryImpl msgFactory = new BGPMessageFactoryImpl();
final Open open = (Open) msgFactory.parse(inputBytes.get(13)).get(0);
final Set<BGPTableType> types = Sets.newHashSet();
for (final BgpParameters param : open.getBgpParameters()) {
- if (param instanceof CParameters) {
- final CParameters p = (CParameters) param;
+ final CParameters p = param.getCParameters();
+ if (p instanceof CMultiprotocol) {
final BGPTableType type = new BGPTableType(((CMultiprotocol) p).getMultiprotocolCapability().getAfi(), ((CMultiprotocol) p).getMultiprotocolCapability().getSafi());
types.add(type);
}
import java.util.Set;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.protocol.bgp.concepts.BGPObject;
import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.ProtocolVersion;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParametersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.as.path.SegmentsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.CMultiprotocol;
}
@Test
- @Ignore
- // FIXME BUG-100
public void testGetOpenMessage() throws DeserializerException, DocumentedException, IOException {
final Map<byte[], List<Notification>> openMap = Maps.newHashMap();
final CParameters par = new CMultiprotocolBuilder().setMultiprotocolCapability(
new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(MplsLabeledVpnSubsequentAddressFamily.class).build()).build();
- params.add((BgpParameters) par);
+ params.add(new BgpParametersBuilder().setCParameters(par).build());
final byte[] input = new byte[] { 5, 8, 13, 21 };
final Set<BGPTableType> result = Sets.newHashSet();
for (final BgpParameters p : ((Open) mockParser.parse(input).get(0)).getBgpParameters()) {
- if (p instanceof CParameters) {
- final CParameters cp = ((CParameters) p);
- final BGPTableType t = new BGPTableType(((CMultiprotocol) cp).getMultiprotocolCapability().getAfi(), ((CMultiprotocol) cp).getMultiprotocolCapability().getSafi());
- result.add(t);
- }
+ final CParameters cp = p.getCParameters();
+ final BGPTableType t = new BGPTableType(((CMultiprotocol) cp).getMultiprotocolCapability().getAfi(), ((CMultiprotocol) cp).getMultiprotocolCapability().getSafi());
+ result.add(t);
}
assertEquals(type, result);
switch (this.state) {
case Finished:
case Idle:
- throw new IllegalStateException("Unexpected state " + this.state);
+ final Notify fsm_error = new NotifyBuilder().setErrorCode(BGPError.FSM_ERROR.getCode()).setErrorSubcode(
+ BGPError.FSM_ERROR.getSubcode()).build();
+ this.channel.writeAndFlush(fsm_error);
case OpenConfirm:
if (msg instanceof Keepalive) {
negotiationSuccessful(this.session);
final List<BgpParameters> prefs = openObj.getBgpParameters();
if (prefs != null && !prefs.isEmpty()) {
for (final BgpParameters param : openObj.getBgpParameters()) {
- if (param instanceof CParameters) {
- if (((CParameters) param) instanceof CMultiprotocol) {
- final CParameters cap = (CParameters) param;
- if (((CMultiprotocol) cap).getMultiprotocolCapability().getAfi() == LinkstateAddressFamily.class
- && ((CMultiprotocol) cap).getMultiprotocolCapability().getSafi() == LinkstateSubsequentAddressFamily.class) {
- this.remotePref = openObj;
- this.channel.writeAndFlush(new KeepaliveBuilder().build());
- this.session = new BGPSessionImpl(this.timer, this.listener, this.channel, this.remotePref);
- this.state = State.OpenConfirm;
- logger.debug("Channel {} moved to OpenConfirm state with remote proposal {}", this.channel,
- this.remotePref);
- return;
- }
+ final CParameters cap = param.getCParameters();
+ if (cap instanceof CMultiprotocol) {
+ if (((CMultiprotocol) cap).getMultiprotocolCapability().getAfi() == LinkstateAddressFamily.class
+ && ((CMultiprotocol) cap).getMultiprotocolCapability().getSafi() == LinkstateSubsequentAddressFamily.class) {
+ this.remotePref = openObj;
+ this.channel.writeAndFlush(new KeepaliveBuilder().build());
+ this.session = new BGPSessionImpl(this.timer, this.listener, this.channel, this.remotePref);
+ this.state = State.OpenConfirm;
+ logger.debug("Channel {} moved to OpenConfirm state with remote proposal {}", this.channel, this.remotePref);
+ return;
}
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.ProtocolVersion;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParametersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.CMultiprotocolBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.c.multiprotocol.MultiprotocolCapabilityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
MockitoAnnotations.initMocks(this);
final List<BgpParameters> tlvs = Lists.newArrayList();
- tlvs.add((BgpParameters) new CMultiprotocolBuilder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(
- this.ipv4tt.getAddressFamily()).setSafi(this.ipv4tt.getSubsequentAddressFamily()).build()));
- tlvs.add((BgpParameters) new CMultiprotocolBuilder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(
- this.linkstatett.getAddressFamily()).setSafi(this.linkstatett.getSubsequentAddressFamily()).build()));
+ tlvs.add(new BgpParametersBuilder().setCParameters(
+ new CMultiprotocolBuilder().setMultiprotocolCapability(
+ new MultiprotocolCapabilityBuilder().setAfi(this.ipv4tt.getAddressFamily()).setSafi(
+ this.ipv4tt.getSubsequentAddressFamily()).build()).build()).build());
+ tlvs.add(new BgpParametersBuilder().setCParameters(
+ new CMultiprotocolBuilder().setMultiprotocolCapability(
+ new MultiprotocolCapabilityBuilder().setAfi(this.linkstatett.getAddressFamily()).setSafi(
+ this.linkstatett.getSubsequentAddressFamily()).build()).build()).build());
final BGPSessionPreferences prefs = new BGPSessionPreferences(30, (short) 3, null, tlvs);
this.clientSession = new BGPSessionNegotiator(new HashedWheelTimer(), new DefaultPromise<BGPSessionImpl>(GlobalEventExecutor.INSTANCE), this.speakerListener, prefs, new SimpleSessionListener());
doAnswer(new Answer<Object>() {
}
@Test
- @Ignore
- // FIXME BUG-100
public void testAccSessionChar() throws InterruptedException {
this.clientSession.channelActive(null);
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(1) instanceof Keepalive);
this.clientSession.handleMessage(new KeepaliveBuilder().build());
assertEquals(this.clientSession.getState(), BGPSessionNegotiator.State.Finished);
- // Thread.sleep(3 * 1000);
- // Thread.sleep(100);
- // assertEquals(3, this.receivedMsgs.size());
- // assertTrue(this.receivedMsgs.get(2) instanceof BGPKeepAliveMessage); // test of keepalive timer
- // this.clientSession.handleMessage(new BGPOpenMessage(new ASNumber(30), (short) 3, null, null));
- // assertEquals(4, this.receivedMsgs.size());
- // assertTrue(this.receivedMsgs.get(3) instanceof BGPNotificationMessage);
- // final BGPMessage m = this.clientListener.getListMsg().get(3);
- // assertEquals(BGPError.FSM_ERROR, ((BGPNotificationMessage) m).getError());
+ Thread.sleep(1000);
+ Thread.sleep(100);
+ assertEquals(3, this.receivedMsgs.size());
+ assertTrue(this.receivedMsgs.get(2) instanceof Keepalive); // test of keepalive timer
}
@Test
- @Ignore
- // FIXME BUG-100
public void testNotAccChars() throws InterruptedException {
this.clientSession.channelActive(null);
assertEquals(1, this.receivedMsgs.size());
}
@Test
- @Ignore
- // FIXME BUG-100
public void sendNotification() {
this.clientSession.channelActive(null);
this.clientSession.handleMessage(this.classicOpen);
this.clientSession.handleMessage(new KeepaliveBuilder().build());
assertEquals(this.clientSession.getState(), BGPSessionNegotiator.State.Finished);
- try {
- this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).build());
- fail("Exception should be thrown.");
- } catch (final IllegalStateException e) {
- assertEquals("Unexpected state Finished", e.getMessage());
- }
+ this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).build());
+ assertEquals(3, this.receivedMsgs.size());
+ assertTrue(this.receivedMsgs.get(2) instanceof Notify);
+ final Notification m = this.receivedMsgs.get(2);
+ assertEquals(BGPError.FSM_ERROR.getCode(), ((Notify) m).getErrorCode().shortValue());
+ assertEquals(BGPError.FSM_ERROR.getSubcode(), ((Notify) m).getErrorSubcode().shortValue());
}
@After
import static org.junit.matchers.JUnitMatchers.containsString;
import java.net.UnknownHostException;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.KeepaliveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Notify;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.ProtocolVersion;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParametersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.CMultiprotocolBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.c.multiprotocol.MultiprotocolCapabilityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x09 };
- public static final byte[] openWithCpblt = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ public static final byte[] openWithCpblt1 = 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, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4,
- (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
+ (byte) 0xff, (byte) 0x00, (byte) 0x2d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x48, (byte) 0x00, (byte) 0xb4,
+ (byte) 0xac, (byte) 0x14, (byte) 0xa0, (byte) 0xaa, (byte) 0x10, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04,
+ (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x40,
+ (byte) 0x04, (byte) 0x00, (byte) 0x47 };
+
+ public static final byte[] openWithCpblt2 = 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, (byte) 0x00, (byte) 0x2d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x48, (byte) 0x00, (byte) 0xb4,
+ (byte) 0xac, (byte) 0x14, (byte) 0xa0, (byte) 0xaa, (byte) 0x10, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04,
+ (byte) 0x40, (byte) 0x04, (byte) 0x00, (byte) 0x47, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x00,
+ (byte) 0x01, (byte) 0x00, (byte) 0x01 };
final ProtocolMessageFactory<Notification> factory = new BGPMessageFactoryImpl();
}
@Test
- @Ignore
- // FIXME BUG-100
public void testTLVParser() throws UnknownHostException {
final BGPTableType t1 = new BGPTableType(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
final List<BgpParameters> tlvs = Lists.newArrayList();
- tlvs.add((BgpParameters) new CMultiprotocolBuilder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(
- Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()));
- tlvs.add((BgpParameters) new CMultiprotocolBuilder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(
- LinkstateAddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()));
+ tlvs.add(new BgpParametersBuilder().setCParameters(
+ new CMultiprotocolBuilder().setMultiprotocolCapability(
+ new MultiprotocolCapabilityBuilder().setAfi(LinkstateAddressFamily.class).setSafi(
+ LinkstateSubsequentAddressFamily.class).build()).build()).build());
+ tlvs.add(new BgpParametersBuilder().setCParameters(
+ new CMultiprotocolBuilder().setMultiprotocolCapability(
+ new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()).build()).build());
final Map<BGPTableType, Boolean> tableTypes = Maps.newHashMap();
tableTypes.put(t1, true);
final Open open = new OpenBuilder().setMyAsNumber(72).setHoldTimer(180).setBgpIdentifier(new Ipv4Address("172.20.160.170")).setVersion(
new ProtocolVersion((short) 4)).setBgpParameters(tlvs).build();
- System.out.println(this.factory.put(open));
- assertArrayEquals(openWithCpblt, this.factory.put(open));
+ final byte[] result = this.factory.put(open);
+
+ // the capabilities can be swapped.
+ assertTrue(Arrays.equals(openWithCpblt1, result) || Arrays.equals(openWithCpblt2, result));
}
}