Merge "Bug 6297: Change subscriber's RLOC selection algo"
authorLori Jakab <lorand.jakab@gmail.com>
Fri, 5 Aug 2016 13:24:47 +0000 (13:24 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 5 Aug 2016 13:24:47 +0000 (13:24 +0000)
1  2 
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundHandler.java
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/LispXtrSouthboundHandler.java

index 31dfa40cddaabeb25e192fafbaf6f5b3c6327bb8,38793b5b6adcf6523c115b181fe09e0ef088cb60..dba899a532b299af0db0a43e37ec82151807d430
@@@ -94,6 -94,7 +94,6 @@@ public class LispSouthboundHandler exte
      private SimpleMapCache smc;
      private AuthenticationKeyDataListener authenticationKeyDataListener;
      private DataStoreBackEnd dsbe;
 -    private boolean isReadFromChannelEnabled = true;
  
      public LispSouthboundHandler(LispSouthboundPlugin lispSbPlugin) {
          this.lispSbPlugin = lispSbPlugin;
              handleEncapsulatedControlMessage(inBuffer, msg.sender().getAddress());
          } else if (lispType == MessageType.MapRequest) {
              LOG.trace("Received packet of type Map-Request");
-             handleMapRequest(inBuffer, msg.sender().getPort());
+             handleMapRequest(inBuffer, msg.sender().getAddress(), msg.sender().getPort());
          } else if (lispType == MessageType.MapRegister) {
              LOG.trace("Received packet of type Map-Register");
              handleMapRegister(inBuffer, msg.sender().getAddress(), msg.sender().getPort());
  
      private void handleEncapsulatedControlMessage(ByteBuffer inBuffer, InetAddress sourceAddress) {
          try {
-             handleMapRequest(inBuffer, extractEncapsulatedSourcePort(inBuffer));
+             handleMapRequest(inBuffer, sourceAddress, extractEncapsulatedSourcePort(inBuffer));
          } catch (RuntimeException re) {
              throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len="
                      + inBuffer.capacity() + ")", re);
          }
      }
  
-     private void handleMapRequest(ByteBuffer inBuffer, int port) {
+     private void handleMapRequest(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
          try {
-             MapRequest request = MapRequestSerializer.getInstance().deserialize(inBuffer);
+             MapRequest request = MapRequestSerializer.getInstance().deserialize(inBuffer, sourceAddress);
              InetAddress finalSourceAddress = MapRequestUtil.selectItrRloc(request);
              if (finalSourceAddress == null) {
                  throw new LispMalformedPacketException("Couldn't deserialize Map-Request, no ITR Rloc found!");
  
      @Override
      protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
 -        if (isReadFromChannelEnabled) {
 -            if (LOG.isTraceEnabled()) {
 -                LOG.trace("Received UDP packet from {}:{} with content:\n{}", msg.sender().getHostString(),
 -                        msg.sender().getPort(), ByteBufUtil.prettyHexDump(msg.content()));
 -            }
 -            handlePacket(msg);
 +        if (LOG.isTraceEnabled()) {
 +            LOG.trace("Received UDP packet from {}:{} with content:\n{}", msg.sender().getHostString(),
 +                    msg.sender().getPort(), ByteBufUtil.prettyHexDump(msg.content()));
          }
 +        handlePacket(msg);
      }
  
      @Override
          dsbe = new DataStoreBackEnd(dataBroker);
      }
  
 -    public void setIsReadFromChannelEnabled(boolean isReadFromChannelEnabled) {
 -        this.isReadFromChannelEnabled = isReadFromChannelEnabled;
 -    }
 -
      public void setMapRegisterCacheTimeout(long mapRegisterCacheTimeout) {
          this.mapRegisterCacheTimeout = mapRegisterCacheTimeout;
      }
index 2e330fb94046a411af2d1a30ba1b1b8996c3ae09,668c116752f283375c71550084cb396bb063e950..eaff645ee968fc2a72c6813dc04c3ea4eda64f3b
@@@ -48,7 -48,7 +48,7 @@@ public class LispXtrSouthboundHandler e
          Object lispType = MessageType.forValue((int) (ByteUtil.getUnsignedByte(inBuffer, LispMessage.Pos.TYPE) >> 4));
          if (lispType == MessageType.MapRequest) {
              LOG.trace("Received packet of type MapRequest for xTR");
-             handleMapRequest(inBuffer);
+             handleMapRequest(inBuffer, packet.sender().getAddress());
          } else if (lispType ==  MessageType.MapReply){
              LOG.trace("Received packet of type MapReply for xTR");
              handleMapReply(inBuffer);
@@@ -57,9 -57,9 +57,9 @@@
          }
      }
  
-     private void handleMapRequest(ByteBuffer inBuffer) {
+     private void handleMapRequest(ByteBuffer inBuffer, InetAddress sourceAddress) {
          try {
-             MapRequest request = MapRequestSerializer.getInstance().deserialize(inBuffer);
+             MapRequest request = MapRequestSerializer.getInstance().deserialize(inBuffer, sourceAddress);
              InetAddress finalSourceAddress = MapRequestUtil.selectItrRloc(request);
              if (finalSourceAddress == null) {
                  throw new LispMalformedPacketException("Couldn't deserialize Map-Request, no ITR Rloc found!");
      @Override
      protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
          if (LOG.isTraceEnabled()) {
 -            LOG.trace("Received UDP packet from {}:{} with content:\n{}", msg.sender().getHostString(),
 +            LOG.trace("Received xTR UDP packet from {}:{} with content:\n{}", msg.sender().getHostString(),
                      msg.sender().getPort(), ByteBufUtil.prettyHexDump(msg.content()));
          }
          handlePacket(msg);