TagRewriteOperation(final int popTags) { this.code = this.ordinal(); this.popTags = UnsignedBytes.checkedCast(popTags); }
private void setPopTags(final RewriteBuilder builder, final TagRewriteOperation operation) { final byte numberOfTagsToPop = operation.getPopTags(); if (numberOfTagsToPop != 0) { builder.setPopTags(Short.valueOf(numberOfTagsToPop)); } }
/** * Returns VPP tag rewrite operation for given operation code. * @param code VPP tag rewrite operation code * @return vpp tag rewrite operation for given input parameter */ @Nullable public static TagRewriteOperation get(@Nonnegative final int code) { for (TagRewriteOperation operation : TagRewriteOperation.values()) { if (code == operation.code){ return operation; } } return null; }
private L2InterfaceVlanTagRewrite getTagRewriteRequest(final int swIfIndex, final Rewrite rewrite) { final L2InterfaceVlanTagRewrite request = new L2InterfaceVlanTagRewrite(); request.swIfIndex = swIfIndex; request.pushDot1Q = booleanToByte(_802dot1q.class == rewrite.getVlanType()); final List<PushTags> pushTags = rewrite.getPushTags(); final Short popTags = rewrite.getPopTags(); final int numberOfTagsToPop = popTags == null ? 0 : popTags.intValue(); final int numberOfTagsToPush = pushTags == null ? 0 : pushTags.size(); request.vtrOp = TagRewriteOperation.get(numberOfTagsToPop, numberOfTagsToPush).ordinal(); if (numberOfTagsToPush > 0) { for (final PushTags tag : pushTags) { if (tag.getIndex() == 0) { request.tag1 = tag.getDot1qTag().getVlanId().getValue(); } else { request.tag2 = tag.getDot1qTag().getVlanId().getValue(); } } } LOG.debug("Generated tag rewrite request: {}", ReflectionToStringBuilder.toString(request)); return request; }
@Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Rewrite> id, @Nonnull final RewriteBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { final String subInterfaceName = getSubInterfaceName(id); LOG.debug("Reading attributes for sub interface: {}", subInterfaceName); final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName, interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache()); LOG.debug("VPP sub-interface details: {}", ReflectionToStringBuilder.toString(iface)); checkState(iface.subId != 0, "Interface returned by the VPP is not a sub-interface"); final TagRewriteOperation operation = TagRewriteOperation.get(iface.vtrOp); if (TagRewriteOperation.disabled == operation) { LOG.debug("Tag rewrite operation is disabled for "); return; } builder.setVlanType(iface.vtrPushDot1Q == 1 ? _802dot1q.class : _802dot1ad.class); setPushTags(builder, iface); setPopTags(builder, operation); }