use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createDscpsLengths.
private static List<Dscps> createDscpsLengths(final UnkeyedListNode dscpLengthsData) {
final List<Dscps> dscpsLengths = new ArrayList<>();
for (final UnkeyedListEntryNode node : dscpLengthsData.getValue()) {
final DscpsBuilder dscpsLengthsBuilder = new DscpsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
dscpsLengthsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
dscpsLengthsBuilder.setValue(new Dscp((Short) valueNode.get().getValue()));
}
dscpsLengths.add(dscpsLengthsBuilder.build());
}
return dscpsLengths;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method stringDscp.
private static String stringDscp(final List<Dscps> dscps) {
final StringBuilder buffer = new StringBuilder("where DSCP ");
boolean isFirst = true;
for (final Dscps item : dscps) {
buffer.append(NumericOneByteOperandParser.INSTANCE.toString(item.getOp(), isFirst));
buffer.append(item.getValue().getValue());
buffer.append(' ');
if (isFirst) {
isFirst = false;
}
}
return buffer.toString();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project bgpcep by opendaylight.
the class FSDscpHandler method serializeDscps.
private static void serializeDscps(final List<Dscps> dscps, final ByteBuf nlriByteBuf) {
for (final Iterator<Dscps> it = dscps.iterator(); it.hasNext(); ) {
final Dscps dscp = it.next();
NumericOneByteOperandParser.INSTANCE.serialize(dscp.getOp(), 1, !it.hasNext(), nlriByteBuf);
Util.writeShortest(dscp.getValue().getValue(), nlriByteBuf);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project bgpcep by opendaylight.
the class FSDscpHandler method parseDscps.
private static List<Dscps> parseDscps(final ByteBuf nlri) {
final List<Dscps> dscps = new ArrayList<>();
boolean end = false;
// we can do this as all fields will be rewritten in the cycle
final DscpsBuilder builder = new DscpsBuilder();
while (!end) {
final byte b = nlri.readByte();
// RFC does not specify operator
final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
builder.setOp(op);
builder.setValue(new Dscp(nlri.readUnsignedByte()));
end = op.isEndOfList();
dscps.add(builder.build());
}
return dscps;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project openflowplugin by opendaylight.
the class MatchResponseConvertorTest method testFromOFMatchV10ToSALMatch.
/**
* Test method for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testFromOFMatchV10ToSALMatch() {
int[] vids = { // Match untagged frame.
DL_VLAN_NONE, // Match packet with VLAN tag and VID equals the specified value.
1, 20, 4095 };
short[] dscps = { 0, 1, 20, 40, 62, 63 };
FlowWildcardsV10Builder wcBuilder = new FlowWildcardsV10Builder();
for (int vid : vids) {
for (short dscp : dscps) {
short tos = (short) (dscp << 2);
MatchV10Builder builder = new MatchV10Builder();
builder.setDlSrc(MAC_SRC).setDlDst(MAC_DST).setDlVlan(vid).setDlVlanPcp(VLAN_PCP).setDlType(ETHTYPE_IPV4).setInPort(IN_PORT.intValue()).setNwSrc(IPV4_SRC).setNwDst(IPV4_DST).setNwTos(tos);
wcBuilder.setAll(false).setNwProto(true).setTpSrc(true).setTpDst(true);
if (vid == DL_VLAN_NONE) {
wcBuilder.setDlVlanPcp(true);
}
FlowWildcardsV10 wc = wcBuilder.build();
MatchV10 ofMatch = builder.setWildcards(wc).build();
final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
data.setDatapathId(DPID);
Match match = convert(ofMatch, data).build();
checkDefaultV10(match, wc, vid);
IpMatch ipMatch = match.getIpMatch();
assertEquals(null, ipMatch.getIpProtocol());
assertEquals(dscp, ipMatch.getIpDscp().getValue().shortValue());
assertEquals(null, ipMatch.getIpEcn());
// Set all wildcard bits.
wc = wcBuilder.setAll(true).build();
ofMatch = builder.setWildcards(wc).build();
match = convert(ofMatch, data).build();
checkDefaultV10(match, wc, vid);
assertEquals(null, match.getIpMatch());
}
}
}
Aggregations