private static final Pattern RD_TWO_OCTET_AS =
Pattern.compile("0:"
+ + "([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|"
+ + "[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|"
+ + "65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])"
+ + ":"
+ "([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|"
+ "[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|"
+ "[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|"
+ "4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|"
+ "429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|"
+ "42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|"
- + "42949672[0-8][0-9]|429496729[0-5])"
- + ":"
- + "([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|"
- + "[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|"
- + "65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])");
+ + "42949672[0-8][0-9]|429496729[0-5])");
private static final Pattern RD_IPV4 =
Pattern.compile("((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}"
private static final String IP_PORT = "10";
private static final String ADMIN = "55";
private static final String ASSIGNED_NUMBER = "65535";
+ private static final String ASSIGNED_NUMBER_BIG = "4294967295";
private static final byte[] AS_2B_BYTES = { 0, 0, 0, 55, 0, 0, (byte)0xff, (byte)0xff};
+ private static final byte[] AS_2B_BYTES_BIG = { 0, 0, 0, 55, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff};
private static final byte[] IP_BYTES = { 0, 1, 1, 2, 3, 4, 0, 10 };
private static final byte[] AS_4B_BYTES = { 0, 2, 0, 0, 0, 55, (byte)0xff, (byte)0xff};
private static final byte[] INVALID_RD_TYPE_BYTES = { 0, 3, 0, 0, 0, 55, (byte)0xff, (byte)0xff};
assertEquals("0" + SEPARATOR + ADMIN + SEPARATOR + ASSIGNED_NUMBER, parsed.getRdTwoOctetAs().getValue());
}
+ @Test
+ public void testAs2BLongRouteDistinguisher() {
+ final RouteDistinguisher expected = createRouteDistinguisher(0, ADMIN, ASSIGNED_NUMBER_BIG);
+ final RouteDistinguisher parsed = RouteDistinguisherUtil.parseRouteDistinguisher(Unpooled.copiedBuffer(AS_2B_BYTES_BIG));
+ assertEquals(expected.getRdTwoOctetAs(), parsed.getRdTwoOctetAs());
+ final ByteBuf byteAggregator = Unpooled.buffer(AS_2B_BYTES_BIG.length);
+ RouteDistinguisherUtil.serializeRouteDistinquisher(expected, byteAggregator);
+ assertArrayEquals(AS_2B_BYTES_BIG, byteAggregator.array());
+ assertEquals("0" + SEPARATOR + ADMIN + SEPARATOR + ASSIGNED_NUMBER_BIG, parsed.getRdTwoOctetAs().getValue());
+ }
+
@Test
public void testIpv4RouteDistinguisher() {
final RouteDistinguisher expected = createRouteDistinguisher(1, IP_ADDRESS, IP_PORT);