@Test public void testCreateIpv6AddPrefix() throws Exception { List<IpPrefix> ipPrefixes = new ArrayList<>(); ipPrefixes.add(IpPrefixBuilder.getDefaultInstance("127.0.0.0/32")); Attribute attribute = AttributeFactory.createIpv6AddPrefix(ipPrefixes, AttributeFactory.COMPACT); assertEquals(AttributeType.Ipv6AddPrefix, attribute.getType()); assertEquals(AttributeVariant.Compact, attribute.getAttributeVariant()); Ipv6AddPrefixAttribute ipv6AddPrefixAttribute = (Ipv6AddPrefixAttribute) attribute.getAttributeOptionalFields(); assertNotNull(ipv6AddPrefixAttribute); assertEquals(ipPrefixes, ipv6AddPrefixAttribute.getIpv6AddPrefixAttributes().getIpPrefix()); for (int i = 1; i <= 256; i++) { String ip = "127.0." + ((i > 254) ? i - 254 : 0) + "." + i % 255 + "/32"; ipPrefixes.add(IpPrefixBuilder.getDefaultInstance(ip)); } attribute = AttributeFactory.createIpv6AddPrefix(ipPrefixes, AttributeFactory.COMPACT); assertEquals(AttributeType.Ipv6AddPrefix, attribute.getType()); assertEquals(AttributeVariant.CompactExtendedLength, attribute.getAttributeVariant()); ipv6AddPrefixAttribute = (Ipv6AddPrefixAttribute) attribute.getAttributeOptionalFields(); assertNotNull(ipv6AddPrefixAttribute); assertEquals(ipPrefixes, ipv6AddPrefixAttribute.getIpv6AddPrefixAttributes().getIpPrefix()); }
public static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags) { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setType(AttributeType.Ipv6AddPrefix); byte[] value = IpPrefixConv.toBytes(prefixes); if (value.length < 256) { attributeBuilder.setFlags(getFlags(flags)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); } else { attributeBuilder.setFlags(getFlags((byte) (flags + 8))); attributeBuilder.setAttributeVariant(AttributeVariant.CompactExtendedLength); } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); Ipv6AddPrefixAttributeBuilder _attributeBuilder = new Ipv6AddPrefixAttributeBuilder(); Ipv6AddPrefixAttributesBuilder _attributesBuilder = new Ipv6AddPrefixAttributesBuilder(); _attributesBuilder.setIpPrefix(prefixes); _attributeBuilder.setIpv6AddPrefixAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); }
AttributeFactory { public static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags) { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setType(AttributeType.Ipv6AddPrefix); byte[] value = IpPrefixConv.toBytes(prefixes); if (value.length < 256) { attributeBuilder.setFlags(getFlags(flags)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); } else { attributeBuilder.setFlags(getFlags((byte) (flags + 8))); attributeBuilder.setAttributeVariant(AttributeVariant.CompactExtendedLength); } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); Ipv6AddPrefixAttributeBuilder _attributeBuilder = new Ipv6AddPrefixAttributeBuilder(); Ipv6AddPrefixAttributesBuilder _attributesBuilder = new Ipv6AddPrefixAttributesBuilder(); _attributesBuilder.setIpPrefix(prefixes); _attributeBuilder.setIpv6AddPrefixAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); } }
AttributeFactory { public static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags) { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setType(AttributeType.Ipv6AddPrefix); byte[] value = IpPrefixConv.toBytes(prefixes); if (value.length < 256) { attributeBuilder.setFlags(getFlags(flags)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); } else { attributeBuilder.setFlags(getFlags((byte) (flags + 8))); attributeBuilder.setAttributeVariant(AttributeVariant.CompactExtendedLength); } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); Ipv6AddPrefixAttributeBuilder _attributeBuilder = new Ipv6AddPrefixAttributeBuilder(); Ipv6AddPrefixAttributesBuilder _attributesBuilder = new Ipv6AddPrefixAttributesBuilder(); _attributesBuilder.setIpPrefix(prefixes); _attributeBuilder.setIpv6AddPrefixAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); }  }
AttributeFactory { public static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags) { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setType(AttributeType.Ipv6AddPrefix); byte[] value = IpPrefixConv.toBytes(prefixes); if (value.length < 256) { attributeBuilder.setFlags(getFlags(flags)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); } else { attributeBuilder.setFlags(getFlags((byte) (flags + 8))); attributeBuilder.setAttributeVariant(AttributeVariant.CompactExtendedLength); } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); Ipv6AddPrefixAttributeBuilder _attributeBuilder = new Ipv6AddPrefixAttributeBuilder(); Ipv6AddPrefixAttributesBuilder _attributesBuilder = new Ipv6AddPrefixAttributesBuilder(); _attributesBuilder.setIpPrefix(prefixes); _attributeBuilder.setIpv6AddPrefixAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); }  static Attribute createCapabilities(Version version); static Attribute createHoldTime(int holdTimeMin); static Attribute createHoldTime(int holdTimeMin, int holdTimeMax); static Attribute createIpv4AddPrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv4DeletePrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv6DeletePrefix(List<IpPrefix> prefixes, byte flags); static Attribute createPeerSequence(List<NodeId> nodesIds); static Attribute createSourceGroupTag(int sgt); static Attribute createSxpNodeId(NodeId nodeId); static byte[] encodeCapability(Capabilities capability); }
AttributeFactory { public static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags) { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setType(AttributeType.Ipv6AddPrefix); byte[] value = IpPrefixConv.toBytes(prefixes); if (value.length < 256) { attributeBuilder.setFlags(getFlags(flags)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); } else { attributeBuilder.setFlags(getFlags((byte) (flags + 8))); attributeBuilder.setAttributeVariant(AttributeVariant.CompactExtendedLength); } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); Ipv6AddPrefixAttributeBuilder _attributeBuilder = new Ipv6AddPrefixAttributeBuilder(); Ipv6AddPrefixAttributesBuilder _attributesBuilder = new Ipv6AddPrefixAttributesBuilder(); _attributesBuilder.setIpPrefix(prefixes); _attributeBuilder.setIpv6AddPrefixAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); }  static Attribute createCapabilities(Version version); static Attribute createHoldTime(int holdTimeMin); static Attribute createHoldTime(int holdTimeMin, int holdTimeMax); static Attribute createIpv4AddPrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv4DeletePrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv6DeletePrefix(List<IpPrefix> prefixes, byte flags); static Attribute createPeerSequence(List<NodeId> nodesIds); static Attribute createSourceGroupTag(int sgt); static Attribute createSxpNodeId(NodeId nodeId); static byte[] encodeCapability(Capabilities capability); static final byte COMPACT; static final byte OPTIONAL_COMPACT; static final byte NONTRANSITIVE_COMPACT; }