use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.
the class AbstractBmpPerPeerMessageParser method parsePerPeerHeader.
protected static PeerHeader parsePerPeerHeader(final ByteBuf bytes) {
Preconditions.checkArgument(bytes.readableBytes() >= PER_PEER_HEADER_SIZE);
final PeerHeaderBuilder phBuilder = new PeerHeaderBuilder();
final PeerType peerType = PeerType.forValue(bytes.readByte());
phBuilder.setType(peerType);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
phBuilder.setAdjRibInType(AdjRibInType.forValue(flags.get(L_FLAG_POS) ? 1 : 0));
phBuilder.setIpv4(!flags.get(V_FLAG_POS));
switch(peerType) {
case L3vpn:
phBuilder.setPeerDistinguisher(new PeerDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(bytes)));
break;
case Local:
phBuilder.setPeerDistinguisher(new PeerDistinguisher(ByteArray.readBytes(bytes, PEER_DISTINGUISHER_SIZE)));
break;
case Global:
default:
bytes.skipBytes(PEER_DISTINGUISHER_SIZE);
break;
}
if (phBuilder.isIpv4()) {
bytes.skipBytes(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
phBuilder.setAddress(new IpAddress(Ipv4Util.addressForByteBuf(bytes)));
} else {
phBuilder.setAddress(new IpAddress(Ipv6Util.addressForByteBuf(bytes)));
}
phBuilder.setAs(new AsNumber(bytes.readUnsignedInt()));
phBuilder.setBgpId(Ipv4Util.addressForByteBuf(bytes));
phBuilder.setTimestampSec(new Timestamp(bytes.readUnsignedInt()));
phBuilder.setTimestampMicro(new Timestamp(bytes.readUnsignedInt()));
return phBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.
the class PCEPValidatorTest method setUp.
@Before
public void setUp() throws Exception {
this.ctx = new SimplePCEPExtensionProviderContext();
this.act = new BaseParserExtensionActivator();
this.viObjAct = new TestVendorInformationActivator();
this.act.start(this.ctx);
this.viObjAct.start(this.ctx);
this.objectRegistry = this.ctx.getObjectHandlerRegistry();
final RpBuilder rpBuilder = new RpBuilder();
rpBuilder.setProcessingRule(true);
rpBuilder.setIgnore(false);
rpBuilder.setReoptimization(false);
rpBuilder.setBiDirectional(false);
rpBuilder.setLoose(true);
rpBuilder.setMakeBeforeBreak(false);
rpBuilder.setOrder(false);
rpBuilder.setPathKey(false);
rpBuilder.setSupplyOf(false);
rpBuilder.setFragmentation(false);
rpBuilder.setP2mp(false);
rpBuilder.setEroCompression(false);
rpBuilder.setPriority((short) 1);
rpBuilder.setRequestId(new RequestId(10L));
rpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().build());
this.rpTrue = rpBuilder.build();
rpBuilder.setProcessingRule(false);
this.rpFalse = rpBuilder.build();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder openBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
openBuilder.setProcessingRule(false);
openBuilder.setIgnore(false);
openBuilder.setDeadTimer((short) 1);
openBuilder.setKeepalive((short) 1);
openBuilder.setSessionId((short) 0);
openBuilder.setVersion(new ProtocolVersion((short) 1));
openBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().build());
this.open = openBuilder.build();
final NoPathBuilder npbuilder = new NoPathBuilder();
npbuilder.setProcessingRule(false);
npbuilder.setIgnore(false);
npbuilder.setNatureOfIssue((short) 0);
npbuilder.setUnsatisfiedConstraints(false);
npbuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build());
this.noPath = npbuilder.build();
final LspaBuilder lspaBuilder = new LspaBuilder();
lspaBuilder.setProcessingRule(false);
lspaBuilder.setIgnore(false);
lspaBuilder.setLocalProtectionDesired(false);
lspaBuilder.setHoldPriority((short) 0);
lspaBuilder.setSetupPriority((short) 0);
lspaBuilder.setExcludeAny(new AttributeFilter(0L));
lspaBuilder.setIncludeAll(new AttributeFilter(0L));
lspaBuilder.setIncludeAny(new AttributeFilter(0L));
lspaBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder().build());
this.lspa = lspaBuilder.build();
final MetricBuilder mBuilder = new MetricBuilder();
mBuilder.setIgnore(false);
mBuilder.setProcessingRule(false);
mBuilder.setComputed(false);
mBuilder.setBound(false);
mBuilder.setMetricType((short) 1);
mBuilder.setValue(new Float32(new byte[4]));
this.metrics = new MetricsBuilder().setMetric(mBuilder.build()).build();
this.eroASSubobject = new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber(0xFFFFL)).build()).build();
final IroBuilder iroBuilder = new IroBuilder();
iroBuilder.setIgnore(false);
iroBuilder.setProcessingRule(false);
final List<Subobject> iroSubs = Lists.newArrayList();
iroSubs.add(new SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
iroBuilder.setSubobject(iroSubs);
this.iro = iroBuilder.build();
final EroBuilder eroBuilder = new EroBuilder();
eroBuilder.setIgnore(false);
eroBuilder.setProcessingRule(false);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject> eroSubs = Lists.newArrayList();
eroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
eroBuilder.setSubobject(eroSubs);
this.ero = eroBuilder.build();
final OfBuilder ofBuilder = new OfBuilder();
ofBuilder.setIgnore(false);
ofBuilder.setProcessingRule(false);
ofBuilder.setCode(new OfId(0));
ofBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.of.TlvsBuilder().build());
this.of = ofBuilder.build();
final Ipv4Builder afi = new Ipv4Builder();
afi.setSourceIpv4Address(new Ipv4Address("255.255.255.255"));
afi.setDestinationIpv4Address(new Ipv4Address("255.255.255.255"));
final EndpointsObjBuilder epBuilder = new EndpointsObjBuilder();
epBuilder.setIgnore(false);
epBuilder.setProcessingRule(true);
epBuilder.setAddressFamily(new Ipv4CaseBuilder().setIpv4(afi.build()).build());
this.endpoints = epBuilder.build();
final SvecBuilder sBuilder = new SvecBuilder();
sBuilder.setIgnore(false);
sBuilder.setProcessingRule(false);
sBuilder.setLinkDiverse(false);
sBuilder.setNodeDiverse(false);
sBuilder.setSrlgDiverse(false);
sBuilder.setRequestsIds(Lists.newArrayList(new RequestId(1L)));
this.svec = sBuilder.build();
this.viObjects = Lists.newArrayList();
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
this.viObjects.add(viObj);
this.monitoring = new MonitoringBuilder().setMonitoringId(100L).setFlags(new Flags(false, false, false, false, false)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.monitoring.TlvsBuilder().build()).build();
this.pccIdReq = new PccIdReqBuilder().setIpAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build();
this.pceId = new PceIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build();
final ProcTimeBuilder procTimeBuilder = new ProcTimeBuilder();
procTimeBuilder.setEstimated(false);
procTimeBuilder.setCurrentProcTime(1L);
procTimeBuilder.setMinProcTime(2L);
procTimeBuilder.setMaxProcTime(3L);
procTimeBuilder.setAverageProcTime(4L);
procTimeBuilder.setVarianceProcTime(5L);
this.procTime = procTimeBuilder.build();
this.overload = new OverloadBuilder().setDuration(120).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.
the class AbstractMessageParser method parseObjects.
private List<Object> parseObjects(final ByteBuf bytes) throws PCEPDeserializerException {
final List<Object> objs = new ArrayList<>();
while (bytes.isReadable()) {
if (bytes.readableBytes() < COMMON_OBJECT_HEADER_LENGTH) {
throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + bytes.readableBytes() + " Expected: >= " + COMMON_OBJECT_HEADER_LENGTH + ".");
}
final int objClass = bytes.readUnsignedByte();
final byte flagsByte = bytes.readByte();
final BitArray flags = BitArray.valueOf(flagsByte);
final int objType = UnsignedBytes.toInt(ByteArray.copyBitsRange(flagsByte, OT_SF_OFFSET, OT_SF_LENGTH));
final int objLength = bytes.readUnsignedShort();
if (bytes.readableBytes() < objLength - COMMON_OBJECT_HEADER_LENGTH) {
throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + bytes.readableBytes() + " Expected: >= " + objLength + ".");
}
// copy bytes for deeper parsing
final ByteBuf bytesToPass = bytes.readSlice(objLength - COMMON_OBJECT_HEADER_LENGTH);
final ObjectHeader header = new ObjectHeaderImpl(flags.get(PROCESSED), flags.get(IGNORED));
if (VendorInformationUtil.isVendorInformationObject(objClass, objType)) {
final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(bytesToPass.readUnsignedInt());
final Optional<? extends Object> obj = this.registry.parseVendorInformationObject(enterpriseNumber, header, bytesToPass);
if (obj.isPresent()) {
objs.add(obj.get());
}
} else {
// parseObject is required to return null for P=0 errored objects
final Object o = this.registry.parseObject(objClass, objType, header, bytesToPass);
if (o != null) {
objs.add(o);
}
}
}
return objs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.
the class RROIpv6PrefixSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
final IpPrefix prefix = specObj.getIpPrefix();
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory.");
writeIpv6Prefix(prefix.getIpv6Prefix(), body);
flags.toByteBuf(body);
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; " + "Expected: " + CONTENT_LENGTH + ".");
}
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
builder.setProtectionAvailable(flags.get(LPA_F_OFFSET));
builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
buffer.skipBytes(RESERVED);
ubuilder.setRouterId(buffer.readUnsignedInt());
ubuilder.setInterfaceId(buffer.readUnsignedInt());
builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build());
return builder.build();
}
Aggregations