package org.opendaylight.protocol.bgp.parser.impl.message.open;
import static java.util.Objects.requireNonNull;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
Preconditions.checkArgument(timeval >= 0 && timeval <= MAX_RESTART_TIME, "Restart time is " + time);
final GracefulRestartCapability.RestartFlags flags = grace.getRestartFlags();
if (flags != null && flags.isRestartState()) {
- writeUnsignedShort(RESTART_FLAG_STATE | timeval, bytes);
+ bytes.writeShort(RESTART_FLAG_STATE | timeval);
} else {
- writeUnsignedShort(timeval, bytes);
+ bytes.writeShort(timeval);
}
serializeTables(tables, bytes);
return bytes;
"The extended community %s is not RouteOriginIpv4Case type.", extendedCommunity);
final RouteOriginIpv4 routeTarget = ((RouteOriginIpv4Case) extendedCommunity).getRouteOriginIpv4();
ByteBufWriteUtil.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator);
- ByteBufWriteUtil.writeUnsignedShort(routeTarget.getLocalAdministrator(), byteAggregator);
+ ByteBufUtils.writeOrZero(byteAggregator, routeTarget.getLocalAdministrator());
}
@Override
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.bgp.parser.spi.extended.community.Abstract4OctetAsExtendedCommunity;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.SourceAs4ExtendedCommunityCase;
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) {
- final SourceAs4ExtendedCommunityBuilder builder = new SourceAs4ExtendedCommunityBuilder();
- builder.setGlobalAdministrator(new AsNumber(ByteBufUtils.readUint32(body)));
+ final SourceAs4ExtendedCommunityBuilder builder = new SourceAs4ExtendedCommunityBuilder()
+ .setGlobalAdministrator(new AsNumber(ByteBufUtils.readUint32(body)));
body.skipBytes(LOCAL_LENGTH);
- return new SourceAs4ExtendedCommunityCaseBuilder().setSourceAs4ExtendedCommunity(
- builder.build()).build();
+ return new SourceAs4ExtendedCommunityCaseBuilder()
+ .setSourceAs4ExtendedCommunity(builder.build())
+ .build();
}
@Override
"The extended community %s is not SourceAs4ExtendedCommunityCase type.",
extendedCommunity);
- body.writeInt(((SourceAs4ExtendedCommunityCase) extendedCommunity).getSourceAs4ExtendedCommunity()
- .getGlobalAdministrator().getValue().intValue());
- ByteBufWriteUtil.writeUnsignedShort(LOCAL_ADMIN, body);
+ ByteBufUtils.write(body, ((SourceAs4ExtendedCommunityCase) extendedCommunity).getSourceAs4ExtendedCommunity()
+ .getGlobalAdministrator().getValue());
+ body.writeShort(LOCAL_ADMIN);
}
@Override
package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
import io.netty.buffer.ByteBuf;
-import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.protocol.util.Ipv4Util;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4Builder;
+import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
/**
* Route Target Ipv4 Handler.
public static void serialize(final RouteTargetIpv4 routeTarget, final ByteBuf byteAggregator) {
ByteBufWriteUtil.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator);
- ByteBufWriteUtil.writeUnsignedShort(routeTarget.getLocalAdministrator(), byteAggregator);
+ ByteBufUtils.writeOrZero(byteAggregator, routeTarget.getLocalAdministrator());
}
public static RouteTargetIpv4 parse(final ByteBuf buffer) {