use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project genius by opendaylight.
the class ActionLearn method buildAction.
@Override
public Action buildAction(int newActionKey) {
NxLearnBuilder learnBuilder = new NxLearnBuilder();
learnBuilder.setIdleTimeout(idleTimeout).setHardTimeout(hardTimeout).setPriority(priority).setCookie(cookie).setFlags(flags).setTableId(tableId).setFinIdleTimeout(finIdleTimeout).setFinHardTimeout(finHardTimeout);
learnBuilder.setFlowMods(this.flowMods.stream().map(FlowMod::buildFlowMod).collect(Collectors.toList()));
return new ActionBuilder().setKey(new ActionKey(newActionKey)).setAction(new NxActionLearnNodesNodeTableFlowApplyActionsCaseBuilder().setNxLearn(learnBuilder.build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class PCEPOverloadObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final OverloadBuilder builder = new OverloadBuilder();
buffer.readBytes(RESERVED + FLAGS);
builder.setDuration(buffer.readUnsignedShort());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class Layer2AttributesExtCom method parseExtendedCommunity.
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) {
final BitArray flags = BitArray.valueOf(body, FLAGS_SIZE);
final Layer2AttributesExtendedCommunityBuilder builder = new Layer2AttributesExtendedCommunityBuilder().setBackupPe(flags.get(BACKUP_PE_OFFSET)).setPrimaryPe(flags.get(PRIMARY_PE_OFFSET)).setControlWord(flags.get(CONTROL_WORD_OFFSET)).setModeOfOperation(OperationalMode.forValue(getFlagShort(flags, MODE_OF_OPERATION))).setOperatingPer(NormalizationType.forValue(getFlagShort(flags, NORMALIZATION_TYPE))).setL2Mtu(ByteBufUtils.readUint16(body));
body.skipBytes(RESERVED);
return new Layer2AttributesExtendedCommunityCaseBuilder().setLayer2AttributesExtendedCommunity(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class Layer2AttributesExtCom method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
Preconditions.checkArgument(extendedCommunity instanceof Layer2AttributesExtendedCommunityCase, "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", extendedCommunity);
final Layer2AttributesExtendedCommunity extCom = ((Layer2AttributesExtendedCommunityCase) extendedCommunity).getLayer2AttributesExtendedCommunity();
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(PRIMARY_PE_OFFSET, extCom.getPrimaryPe());
flags.set(BACKUP_PE_OFFSET, extCom.getBackupPe());
flags.set(CONTROL_WORD_OFFSET, extCom.getControlWord());
final byte[] res = flags.array();
byte aux = 0;
final OperationalMode modeOfOperation = extCom.getModeOfOperation();
if (modeOfOperation != null) {
aux = UnsignedBytes.checkedCast(modeOfOperation.getIntValue());
aux = (byte) (aux << THREE_BITS_SHIFT);
res[res.length - 1] = (byte) (res[res.length - 1] | aux);
}
final NormalizationType normalizationType = extCom.getOperatingPer();
if (normalizationType != null) {
aux = UnsignedBytes.checkedCast(normalizationType.getIntValue());
aux = (byte) (aux << FIVE_BITS_SHIFT);
res[res.length - 1] = (byte) (res[res.length - 1] | aux);
}
body.writeShort(res[res.length - 1]);
ByteBufUtils.writeOrZero(body, extCom.getL2Mtu());
body.writeZero(RESERVED);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv4NlriParserTest method testParseMpUnreachNlriConstraint.
@Test
public void testParseMpUnreachNlriConstraint() throws BGPParsingException {
final List<Flowspec> fs = new ArrayList<>();
final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder();
final FlowspecBuilder builder = new FlowspecBuilder();
final FlowspecType icmpType = createIcmpType();
builder.setFlowspecType(icmpType);
fs.add(builder.build());
final FlowspecType icmpCode = createIcmpCode();
builder.setFlowspecType(icmpCode);
fs.add(builder.build());
final TcpFlagsCase tcp = createTcp();
builder.setFlowspecType(tcp);
fs.add(builder.build());
final PacketLengthCase packet = createPackets();
builder.setFlowspecType(packet);
fs.add(builder.build());
final FlowspecType dscp = createDscp();
builder.setFlowspecType(dscp);
fs.add(builder.build());
final FlowspecType fragment = createFragment();
builder.setFlowspecType(fragment);
fs.add(builder.build());
final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(SAFI.FLOWSPEC_VPN);
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv4Case) result.getWithdrawnRoutes().getDestinationType()).getDestinationFlowspecL3vpnIpv4();
final List<Flowspec> flows = flowspecDst.getFlowspec();
checkUnreachFlows(flows, icmpType, icmpCode, tcp, packet, dscp, fragment);
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
mp.setAfi(Ipv4AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder().setDestinationFlowspecL3vpnIpv4(new DestinationFlowspecL3vpnIpv4Builder().setRouteDistinguisher(rd).setPathId(PATH_ID).setFlowspec(fs).build()).build()).build());
final ByteBuf buffer = Unpooled.buffer();
parser.serializeNlri(new Object[] { rd, flows }, PATH_ID, buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
parser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 " + "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 " + "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ", this.fsParser.stringNlri(flows));
}
Aggregations