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 SrEroSubobjectParserTest method testSrEroSubobjectIpv6NodeIdNAI.
@Test
public void testSrEroSubobjectIpv6NodeIdNAI() throws PCEPDeserializerException {
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
builder.setSidType(SidType.Ipv6NodeId);
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv6NodeID, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(srEroSubobjectWithIpv6NodeID, ByteArray.getAllBytes(buffer));
}
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 SrEroSubobjectParserTest method testSrEroSubobjectIpv6AdjacencyNAI.
@Test
public void testSrEroSubobjectIpv6AdjacencyNAI() throws PCEPDeserializerException {
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
builder.setSidType(SidType.Ipv6Adjacency);
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c"))).setRemoteIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729d"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv6Adjacency, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(srEroSubobjectWithIpv6Adjacency, ByteArray.getAllBytes(buffer));
}
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 SrRroSubobjectParserTest method testSrRroSubobjectIpv6NodeIdNAI.
@Test
public void testSrRroSubobjectIpv6NodeIdNAI() throws PCEPDeserializerException {
final SrRroTypeBuilder builder = new SrRroTypeBuilder();
builder.setSidType(SidType.Ipv6NodeId);
builder.setCFlag(false);
builder.setMFlag(false);
builder.setSid(123456L);
builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv6NodeID, 2))));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(srRroSubobjectWithIpv6NodeID, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project netvirt by opendaylight.
the class Ipv6ServiceUtils method getIpv6SolicitedNodeMcastAddress.
public static Ipv6Address getIpv6SolicitedNodeMcastAddress(Ipv6Address ipv6Address) {
/* According to RFC 4291, a Solicited Node Multicast Address is derived by adding the 24
lower order bits with the Solicited Node multicast prefix (i.e., FF02::1:FF00:0/104).
Example: For IPv6Address of FE80::2AA:FF:FE28:9C5A, the corresponding solicited node
multicast address would be FF02::1:FF28:9C5A
*/
byte[] octets;
try {
octets = InetAddress.getByName(ipv6Address.getValue()).getAddress();
} catch (UnknownHostException e) {
LOG.error("getIpv6SolicitedNodeMcastAddress: Failed to serialize ipv6Address ", e);
return null;
}
// Return the address in its fully expanded format.
Ipv6Address solictedV6Address = new Ipv6Address(InetAddresses.forString("ff02::1:ff" + StringUtils.leftPad(Integer.toHexString(0xFF & octets[13]), 2, "0") + ":" + StringUtils.leftPad(Integer.toHexString(0xFF & octets[14]), 2, "0") + StringUtils.leftPad(Integer.toHexString(0xFF & octets[15]), 2, "0")).getHostAddress());
return solictedV6Address;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project netvirt by opendaylight.
the class Ipv6ServiceUtils method getIpv6LinkLocalAddressFromMac.
public static Ipv6Address getIpv6LinkLocalAddressFromMac(MacAddress mac) {
byte[] octets = bytesFromHexString(mac.getValue());
/* As per the RFC2373, steps involved to generate a LLA include
1. Convert the 48 bit MAC address to 64 bit value by inserting 0xFFFE
between OUI and NIC Specific part.
2. Invert the Universal/Local flag in the OUI portion of the address.
3. Use the prefix "FE80::/10" along with the above 64 bit Interface
identifier to generate the IPv6 LLA. */
StringBuffer interfaceID = new StringBuffer();
short u8byte = (short) (octets[0] & 0xff);
u8byte ^= 1 << 1;
interfaceID.append(Integer.toHexString(0xFF & u8byte));
interfaceID.append(StringUtils.leftPad(Integer.toHexString(0xFF & octets[1]), 2, "0"));
interfaceID.append(":");
interfaceID.append(Integer.toHexString(0xFF & octets[2]));
interfaceID.append("ff:fe");
interfaceID.append(StringUtils.leftPad(Integer.toHexString(0xFF & octets[3]), 2, "0"));
interfaceID.append(":");
interfaceID.append(Integer.toHexString(0xFF & octets[4]));
interfaceID.append(StringUtils.leftPad(Integer.toHexString(0xFF & octets[5]), 2, "0"));
// Return the address in its fully expanded format.
Ipv6Address ipv6LLA = new Ipv6Address(InetAddresses.forString("fe80:0:0:0:" + interfaceID.toString()).getHostAddress());
return ipv6LLA;
}
Aggregations