package org.opendaylight.lispflowmapping.lisp.serializer.address;
import java.nio.ByteBuffer;
-
import org.opendaylight.lispflowmapping.lisp.serializer.address.factory.LispAddressSerializerFactory;
import org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException;
import org.opendaylight.lispflowmapping.lisp.util.AddressTypeMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc;
public class LcafSerializer extends LispAddressSerializer {
-
private static final LcafSerializer INSTANCE = new LcafSerializer();
private static final byte DEFAULT_IID_MASK_LENGTH = (byte) 32;
return Length.LCAF_HEADER;
}
+ @Override
protected short getLcafLength(LispAddress lispAddress) {
throw new LispSerializationException("Unimplemented method");
}
LispAddressSerializer lcafSerializer = InstanceIdSerializer.getInstance();
serializeLCAFAddressHeader(buffer, lispAddress, lcafSerializer);
buffer.put(buffer.position() - 1, DEFAULT_IID_MASK_LENGTH);
- buffer.putShort((short) (lcafSerializer.getLcafLength(lispAddress) -
- LispAddressSerializer.getInstance().getInstanceIdExtraSize()));
+ buffer.putShort((short) (lcafSerializer.getLcafLength(lispAddress)
+ - LispAddressSerializer.getInstance().getInstanceIdExtraSize()));
}
- private void serializeLCAFAddressHeader(ByteBuffer buffer, LispAddress lispAddress,
+ private static void serializeLCAFAddressHeader(ByteBuffer buffer, LispAddress lispAddress,
LispAddressSerializer serializer) {
- buffer.putShort((short) 0); // RES + Flags.
+ // RES + Flags
+ buffer.putShort((short) 0);
buffer.put(serializer.getLcafType());
buffer.put((byte) 0);
}
protected Eid deserializeEidData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
buffer.position(buffer.position() + Length.RES + Length.FLAGS);
byte lcafType = (byte) ByteUtil.getUnsignedByte(buffer);
- Class <? extends LispAddressFamily> addressType = AddressTypeMap.getLcafType(lcafType);
+ LispAddressFamily addressType = AddressTypeMap.getLcafType(lcafType);
// TODO move these to ctx to shorten the list of arguments
byte res2 = buffer.get();
short length = buffer.getShort();
}
// Reset the mask context here, since the general mask length field in mapping records doesn't apply to LCAF
// address types; except for Instance ID, since we don't store it as an LCAF
- if (ctx != null && addressType != InstanceIdLcaf.class) {
+ if (ctx != null && !InstanceIdLcaf.VALUE.equals(addressType)) {
ctx.setMaskLen(LispAddressSerializerContext.MASK_LEN_MISSING);
}
return serializer.deserializeLcafEidData(buffer, res2, length, ctx);
protected Rloc deserializeRlocData(ByteBuffer buffer) {
buffer.position(buffer.position() + Length.RES + Length.FLAGS);
byte lcafType = (byte) ByteUtil.getUnsignedByte(buffer);
- Class <? extends LispAddressFamily> addressType = AddressTypeMap.getLcafType(lcafType);
+ LispAddressFamily addressType = AddressTypeMap.getLcafType(lcafType);
byte res2 = buffer.get();
short length = buffer.getShort();