Esempio n. 1
0
  @Test
  public void testOneAS4Configuration() throws Exception {
    Capabilities caps = parser.parseConfig(config.configurationAt("Capabilities(1)"));
    Iterator<Capability> capIt = caps.getRequiredCapabilities().iterator();

    Assert.assertTrue(capIt.hasNext());
    AutonomousSystem4Capability cap = (AutonomousSystem4Capability) capIt.next();
    Assert.assertEquals(256, cap.getAutonomousSystem());
    Assert.assertFalse(capIt.hasNext());
  }
Esempio n. 2
0
  @Test
  public void testDecodeUnsupportedCapabilityNotificationPacket() {
    CapabilityListUnsupportedCapabilityNotificationPacket packet =
        safeDowncast(
            decoder.decodePacket(
                buildProtocolPacket(
                    new byte[] {
                      (byte) 0x03, // type code NOTIFICATION
                      (byte) 0x02, // error code: BGP Open
                      (byte) 0x07, // suberror code: Unsupported capability
                      (byte) 0x41, // Capability code 65: 4-octet AS numbers
                      (byte) 0x04, // Capability length: 4 octets
                      (byte) 0x00,
                      (byte) 0x00,
                      (byte) 0xfc,
                      (byte) 0x00, // AS number 64512
                      0x02, // Capability code 2: Route refresh
                      0x00, // Capability length: 0 octets
                      0x01, // Capability code 1: Multi-Protocol
                      0x04, // Capability length: 4 octets
                      0x00,
                      0x01, // Address Family 1: IPv4
                      0x00, // reserved
                      0x01, // Subsequent address family 1: Unicast forwarding
                    })),
            CapabilityListUnsupportedCapabilityNotificationPacket.class);

    Iterator<Capability> capIt = packet.getCapabilities().iterator();

    Assert.assertTrue(capIt.hasNext());
    AutonomousSystem4Capability as4cap = (AutonomousSystem4Capability) capIt.next();
    Assert.assertEquals(64512, as4cap.getAutonomousSystem());

    Assert.assertTrue(capIt.hasNext());
    Assert.assertEquals(RouteRefreshCapability.class, capIt.next().getClass());

    Assert.assertTrue(capIt.hasNext());
    MultiProtocolCapability mpCap = (MultiProtocolCapability) capIt.next();
    Assert.assertEquals(AddressFamily.IPv4, mpCap.getAfi());
    Assert.assertEquals(SubsequentAddressFamily.NLRI_UNICAST_FORWARDING, mpCap.getSafi());

    Assert.assertFalse(capIt.hasNext());
  }
Esempio n. 3
0
  @Test
  public void testOneAS4TwoMultiProtoclConfiguration() throws Exception {
    Capabilities caps = parser.parseConfig(config.configurationAt("Capabilities(8)"));
    Iterator<Capability> capIt = caps.getRequiredCapabilities().iterator();

    Assert.assertTrue(capIt.hasNext());
    AutonomousSystem4Capability as4cap = (AutonomousSystem4Capability) capIt.next();
    Assert.assertEquals(256, as4cap.getAutonomousSystem());

    Assert.assertTrue(capIt.hasNext());
    MultiProtocolCapability cap = (MultiProtocolCapability) capIt.next();
    Assert.assertEquals(AddressFamily.IPv4, cap.getAfi());
    Assert.assertEquals(SubsequentAddressFamily.NLRI_UNICAST_FORWARDING, cap.getSafi());

    Assert.assertTrue(capIt.hasNext());
    cap = (MultiProtocolCapability) capIt.next();
    Assert.assertEquals(AddressFamily.IPv6, cap.getAfi());
    Assert.assertEquals(SubsequentAddressFamily.NLRI_UNICAST_FORWARDING, cap.getSafi());

    Assert.assertFalse(capIt.hasNext());
  }