import static com.google.common.base.Preconditions.checkArgument;
import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.extractAS;
import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.extractLD;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
public ByteBuf serializeBody(final Esi esi, final ByteBuf body) {
checkArgument(esi instanceof AsGeneratedCase, "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi);
final AsGenerated asGen = ((AsGeneratedCase) esi).getAsGenerated();
- writeUnsignedInt(asGen.getAs().getValue(), body);
- writeUnsignedInt(asGen.getLocalDiscriminator(), body);
+ ByteBufUtils.write(body, asGen.getAs().getValue());
+ ByteBufUtils.writeOrZero(body, asGen.getLocalDiscriminator());
return body.writeByte(0);
}
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EsiType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.Esi;
checkArgument(esi instanceof LacpAutoGeneratedCase,
"Unknown esi instance. Passed %s. Needed LacpAutoGeneratedCase.", esi);
final LacpAutoGenerated lacp = ((LacpAutoGeneratedCase) esi).getLacpAutoGenerated();
- body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lacp.getCeLacpMacAddress()));
- ByteBufWriteUtil.writeUnsignedShort(lacp.getCeLacpPortKey(), body);
+ body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(lacp.getCeLacpMacAddress()));
+ ByteBufUtils.writeOrZero(body, lacp.getCeLacpPortKey());
return body.writeByte(0);
}
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EsiType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.Esi;
checkArgument(esi instanceof LanAutoGeneratedCase,
"Unknown esi instance. Passed %s. Needed LanAutoGeneratedCase.", esi);
final LanAutoGenerated lan = ((LanAutoGeneratedCase) esi).getLanAutoGenerated();
- body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lan.getRootBridgeMacAddress()));
- ByteBufWriteUtil.writeUnsignedShort(lan.getRootBridgePriority(), body);
+ body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(lan.getRootBridgeMacAddress()));
+ ByteBufUtils.writeOrZero(body, lan.getRootBridgePriority());
return body.writeByte(0);
}
Preconditions.checkArgument(esi instanceof MacAutoGeneratedCase,
"Unknown esi instance. Passed %s. Needed MacAutoGeneratedCase.", esi.getClass());
final MacAutoGenerated macAuto = ((MacAutoGeneratedCase) esi).getMacAutoGenerated();
- body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(macAuto.getSystemMacAddress()));
+ body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(macAuto.getSystemMacAddress()));
ByteBufWriteUtil.writeMedium(macAuto.getLocalDiscriminator().getValue().intValue(), body);
return body;
}
"Unknown esi instance. Passed %s. Needed RouterIdGeneratedCase.", esi);
final RouterIdGenerated routerID = ((RouterIdGeneratedCase) esi).getRouterIdGenerated();
ByteBufWriteUtil.writeIpv4Address(routerID.getRouterId(), body);
- ByteBufWriteUtil.writeUnsignedInt(routerID.getLocalDiscriminator(), body);
+ ByteBufUtils.writeOrZero(body, routerID.getLocalDiscriminator());
return body.writeByte(0);
}
extendedCommunity);
final EsImportRouteExtendedCommunity extCom = ((EsImportRouteExtendedCommunityCase) extendedCommunity)
.getEsImportRouteExtendedCommunity();
- byteAggregator.writeBytes(IetfYangUtil.INSTANCE.bytesFor(extCom.getEsImport()));
+ byteAggregator.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(extCom.getEsImport()));
}
@Override
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.util.BitArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.NormalizationType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.OperationalMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.Layer2AttributesExtendedCommunityCase;
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) {
- final Layer2AttributesExtendedCommunityBuilder builder = new Layer2AttributesExtendedCommunityBuilder();
final BitArray flags = BitArray.valueOf(body, FLAGS_SIZE);
- builder.setBackupPe(flags.get(BACKUP_PE_OFFSET));
- builder.setPrimaryPe(flags.get(PRIMARY_PE_OFFSET));
- builder.setControlWord(flags.get(CONTROL_WORD_OFFSET));
- builder.setModeOfOperation(OperationalMode.forValue(getFlagShort(flags, MODE_OF_OPERATION)));
- builder.setOperatingPer(NormalizationType.forValue(getFlagShort(flags, NORMALIZATION_TYPE)));
+ final Layer2AttributesExtendedCommunityBuilder builder = new Layer2AttributesExtendedCommunityBuilder()
+ .setBackupPe(flags.get(BACKUP_PE_OFFSET))
+ .setPrimaryPe(flags.get(PRIMARY_PE_OFFSET))
+ .setControlWord(flags.get(CONTROL_WORD_OFFSET))
- builder.setL2Mtu(ByteBufUtils.readUint16(body));
+ .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();
aux = (byte) (aux << FIVE_BITS_SHIFT);
res[res.length - 1] = (byte) (res[res.length - 1] | aux);
}
- ByteBufWriteUtil.writeUnsignedShort((int) res[res.length - 1], body);
- ByteBufWriteUtil.writeUnsignedShort(extCom.getL2Mtu(), body);
+ body.writeShort(res[res.length - 1]);
+ ByteBufUtils.writeOrZero(body, extCom.getL2Mtu());
body.writeZero(RESERVED);
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.evpn.spi.pojo.SimpleEsiTypeRegistry;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.NlriType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.Esi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.ethernet.a.d.route.EthernetADRoute;
final EthernetADRoute evpn = ((EthernetADRouteCase) evpnChoice).getEthernetADRoute();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
- ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
+ ByteBufUtils.writeOrZero(body, evpn.getEthernetTagId().getVlanId());
final MplsLabel mpls = evpn.getMplsLabel();
if (mpls != null) {
}
private static EthernetADRouteBuilder serializeKeyModel(final ContainerNode evpn) {
- final EthernetADRouteBuilder builder = new EthernetADRouteBuilder();
- builder.setEsi(serializeEsi(evpn));
- builder.setEthernetTagId(extractETI(evpn));
- return builder;
+ return new EthernetADRouteBuilder()
+ .setEsi(serializeEsi(evpn))
+ .setEthernetTagId(extractETI(evpn));
}
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.bgp.concepts.IpAddressUtil;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.NlriType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.ethernet.tag.id.EthernetTagId;
final IncMultiEthernetTagRes evpn = ((IncMultiEthernetTagResCase) evpnChoice).getIncMultiEthernetTagRes();
final ByteBuf body = Unpooled.buffer();
- ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
+ ByteBufUtils.writeOrZero(body, evpn.getEthernetTagId().getVlanId());
final ByteBuf orig = IpAddressUtil.bytesFor(evpn.getOrigRouteIp());
Preconditions.checkArgument(orig.readableBytes() > 0);
body.writeBytes(orig);
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.evpn.spi.pojo.SimpleEsiTypeRegistry;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.protocol.util.Ipv4Util;
import org.opendaylight.protocol.util.Ipv6Util;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
if (esi != null) {
SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
}
- ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
+ ByteBufUtils.writeOrZero(body, evpn.getEthernetTagId().getVlanId());
final MacAddress mac = evpn.getMacAddress();
body.writeByte(MAC_ADDRESS_LENGTH * BITS_SIZE);
- body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(mac));
+ body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(mac));
final ByteBuf ipAddress = serializeIp(evpn.getIpAddress());
Preconditions.checkArgument(ipAddress.readableBytes() > 0);
body.writeBytes(ipAddress);