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.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.NlriType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.Esi;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.ethernet.tag.id.EthernetTagId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.ethernet.tag.id.EthernetTagIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.EvpnChoice;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.evpn.choice.MacIpAdvRouteCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.evpn.choice.MacIpAdvRouteCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.mac.ip.adv.route.MacIpAdvRoute;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.mac.ip.adv.route.MacIpAdvRouteBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+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.tag.id.EthernetTagId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.ethernet.tag.id.EthernetTagIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.EvpnChoice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.evpn.choice.MacIpAdvRouteCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.evpn.choice.MacIpAdvRouteCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.mac.ip.adv.route.MacIpAdvRoute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.mac.ip.adv.route.MacIpAdvRouteBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
} else {
label2 = null;
}
- final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder().setEsi(esi).setEthernetTagId(eti).setMacAddress(mac).setIpAddress(ip)
+ final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder().setEsi(esi).setEthernetTagId(eti)
+ .setMacAddress(mac).setIpAddress(ip)
.setMplsLabel1(label1).setMplsLabel2(label2);
return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
}
}
@Override
- public ByteBuf serializeBody(final EvpnChoice evpn) {
- Preconditions.checkArgument(evpn instanceof MacIpAdvRouteCase, "Unknown evpn instance. Passed %s. Needed MacIpAdvRouteCase.", evpn.getClass());
- return serializeBody((MacIpAdvRouteCase) evpn);
- }
-
- @Override
- public EvpnChoice serializeEvpnModel(final ContainerNode evpn) {
- final MacIpAdvRouteBuilder builder = serializeKeyModel(evpn);
- builder.setEsi(serializeEsi(evpn));
- builder.setMplsLabel1(extractMplsLabel(evpn, MPLS1_NID));
- builder.setMplsLabel2(extractMplsLabel(evpn, MPLS2_NID));
- return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
- }
-
- @Override
- public EvpnChoice createRouteKey(final ContainerNode evpn) {
- return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(serializeKeyModel(evpn).build()).build();
- }
-
- private static MacIpAdvRouteBuilder serializeKeyModel(final ContainerNode evpn) {
- final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder();
- builder.setEthernetTagId(extractETI(evpn));
- builder.setMacAddress(extractMAC(evpn));
- builder.setIpAddress(extractIp(evpn));
- return builder;
- }
+ public ByteBuf serializeBody(final EvpnChoice evpnChoice) {
+ Preconditions.checkArgument(evpnChoice instanceof MacIpAdvRouteCase,
+ "Unknown evpn instance. Passed %s. Needed MacIpAdvRouteCase.", evpnChoice.getClass());
- private static ByteBuf serializeBody(final MacIpAdvRouteCase evpnCase) {
final ByteBuf body = Unpooled.buffer();
- final MacIpAdvRoute evpn = evpnCase.getMacIpAdvRoute();
+ final MacIpAdvRoute evpn = ((MacIpAdvRouteCase) evpnChoice).getMacIpAdvRoute();
final Esi esi = evpn.getEsi();
if (esi != null) {
SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
return body;
}
+ @Override
+ public EvpnChoice serializeEvpnModel(final ContainerNode evpn) {
+ final MacIpAdvRouteBuilder builder = serializeKeyModel(evpn);
+ builder.setEsi(serializeEsi(evpn));
+ builder.setMplsLabel1(extractMplsLabel(evpn, MPLS1_NID));
+ builder.setMplsLabel2(extractMplsLabel(evpn, MPLS2_NID));
+ return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
+ }
+
+ @Override
+ public EvpnChoice createRouteKey(final ContainerNode evpn) {
+ return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(serializeKeyModel(evpn).build()).build();
+ }
+
+ private static MacIpAdvRouteBuilder serializeKeyModel(final ContainerNode evpn) {
+ final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder();
+ builder.setEthernetTagId(extractETI(evpn));
+ builder.setMacAddress(extractMAC(evpn));
+ builder.setIpAddress(extractIp(evpn));
+ return builder;
+ }
+
private static ByteBuf serializeIp(final IpAddress ipAddress) {
final ByteBuf body = Unpooled.buffer();
- if (ipAddress.getIpv4Address() != null) {
- body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
- body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address()));
- } else if (ipAddress.getIpv6Address() != null) {
- body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
- body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address()));
+ if (ipAddress != null) {
+ if (ipAddress.getIpv4Address() != null) {
+ body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
+ body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address()));
+ } else if (ipAddress.getIpv6Address() != null) {
+ body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
+ body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address()));
+ } else {
+ body.writeZero(ZERO_BYTE);
+ }
} else {
body.writeZero(ZERO_BYTE);
}