use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project bgpcep by opendaylight.
the class IPAddressesAndPrefixesTest method testByteBufForAddress.
@Test
public void testByteBufForAddress() {
final ByteBuf bb4 = Unpooled.wrappedBuffer(new byte[] { 123, 122, 4, 5 });
final ByteBuf bb6 = Unpooled.wrappedBuffer(new byte[] { 0x20, (byte) 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 });
assertEquals(bb4, Ipv4Util.byteBufForAddress(new Ipv4Address("123.122.4.5")));
assertEquals(bb6, Ipv6Util.byteBufForAddress(new Ipv6Address("2001::1")));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project bgpcep by opendaylight.
the class IPAddressesAndPrefixesTest method testToInetSocketAddress.
@Test
public void testToInetSocketAddress() {
final InetSocketAddress isa = Ipv4Util.toInetSocketAddress(new IpAddress(new Ipv4Address("123.42.13.8")), new PortNumber(10));
Assert.assertEquals(10, isa.getPort());
Assert.assertEquals("123.42.13.8", InetAddresses.toAddrString(isa.getAddress()));
final InetSocketAddress isa2 = Ipv4Util.toInetSocketAddress(new IpAddress(new Ipv6Address("2001:db8:1:2::")), new PortNumber(10));
Assert.assertEquals(10, isa2.getPort());
Assert.assertEquals("2001:db8:1:2::", InetAddresses.toAddrString(isa2.getAddress()));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project bgpcep by opendaylight.
the class IPAddressesAndPrefixesTest method testAddressForByteBuf.
@Test
public void testAddressForByteBuf() {
final ByteBuf bb = Unpooled.wrappedBuffer(new byte[] { 123, 122, 4, 5, 0x20, (byte) 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 });
assertEquals(new Ipv4Address("123.122.4.5"), Ipv4Util.addressForByteBuf(bb));
assertEquals(new Ipv6Address("2001::1"), Ipv6Util.addressForByteBuf(bb));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testredirectIpv6NhSerializer.
@Test
public void testredirectIpv6NhSerializer() throws BGPDocumentedException, BGPParsingException {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddress(new Ipv6Address("2001::1"))).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
final ByteBuf output = Unpooled.buffer(REDIRECT_NH_IPV6.length);
this.registry.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(REDIRECT_NH_IPV6, output.array());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testRedirectIpv6Parser.
@Test
public void testRedirectIpv6Parser() throws BGPDocumentedException, BGPParsingException {
final RedirectIpv6ExtendedCommunityCase redirect = new RedirectIpv6ExtendedCommunityCaseBuilder().setRedirectIpv6(new RedirectIpv6Builder().setGlobalAdministrator(new Ipv6Address("102:304:506:708:90a:b0c:d0e:f10")).setLocalAdministrator(258).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_IPV6));
Assert.assertEquals(expected, parsed);
}
Aggregations