org.opendaylight.lispflowmapping.lisp.serializer.address.NoAddressSerializer Maven / Gradle / Ivy
/*
* Copyright (c) 2014 Contextream, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.lispflowmapping.lisp.serializer.address;
import java.nio.ByteBuffer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.NoAddressAfi;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder;
import org.opendaylight.yangtools.yang.common.Empty;
public final class NoAddressSerializer extends LispAddressSerializer {
private static final NoAddressSerializer INSTANCE = new NoAddressSerializer();
// Private constructor prevents instantiation from other classes
private NoAddressSerializer() {
}
public static NoAddressSerializer getInstance() {
return INSTANCE;
}
@Override
public int getAddressSize(LispAddress lispAddress) {
return Length.NO;
}
@Override
protected short getAfi() {
return (short) 0;
}
@Override
protected void serializeData(ByteBuffer buffer, LispAddress lispAddress) {
}
@Override
protected Eid deserializeEidData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
EidBuilder eb = new EidBuilder();
eb.setAddressType(NoAddressAfi.VALUE);
eb.setVirtualNetworkId(getVni(ctx));
eb.setAddress(new NoAddressBuilder().setNoAddress(Empty.value()).build());
return eb.build();
}
@Override
protected Rloc deserializeRlocData(ByteBuffer buffer) {
RlocBuilder rb = new RlocBuilder();
rb.setAddressType(NoAddressAfi.VALUE);
rb.setVirtualNetworkId(null);
rb.setAddress(new NoAddressBuilder().setNoAddress(Empty.value()).build());
return rb.build();
}
private interface Length {
int NO = 0;
}
}