protected void pushBidirectionalVipRoutes(IOFSwitch sw,OFPacketIn pi,FloodlightContext cntx,IPClient client,LBMember member){
  IDevice srcDevice=null;
  IDevice dstDevice=null;
  Collection<? extends IDevice> allDevices=deviceManager.getAllDevices();
  for (  IDevice d : allDevices) {
    for (int j=0; j < d.getIPv4Addresses().length; j++) {
      if (srcDevice == null && client.ipAddress == d.getIPv4Addresses()[j])       srcDevice=d;
      if (dstDevice == null && member.address == d.getIPv4Addresses()[j]) {
        dstDevice=d;
        member.macString=dstDevice.getMACAddressString();
      }
      if (srcDevice != null && dstDevice != null)       break;
    }
  }
  if (srcDevice == null || dstDevice == null)   return;
  Long srcIsland=topology.getL2DomainId(sw.getId());
  if (srcIsland == null) {
    log.debug("No openflow island found for source {}/{}",sw.getStringId(),pi.getInPort());
    return;
  }
  boolean on_same_island=false;
  boolean on_same_if=false;
  for (  SwitchPort dstDap : dstDevice.getAttachmentPoints()) {
    long dstSwDpid=dstDap.getSwitchDPID();
    Long dstIsland=topology.getL2DomainId(dstSwDpid);
    if ((dstIsland != null) && dstIsland.equals(srcIsland)) {
      on_same_island=true;
      if ((sw.getId() == dstSwDpid) && (pi.getInPort() == dstDap.getPort())) {
        on_same_if=true;
      }
      break;
    }
  }
  if (!on_same_island) {
    if (log.isTraceEnabled()) {
      log.trace("No first hop island found for destination " + "device {}, Action = flooding",dstDevice);
    }
    return;
  }
  if (on_same_if) {
    if (log.isTraceEnabled()) {
      log.trace("Both source and destination are on the same " + "switch/port {}/{}, Action = NOP",sw.toString(),pi.getInPort());
    }
    return;
  }
  SwitchPort[] srcDaps=srcDevice.getAttachmentPoints();
  Arrays.sort(srcDaps,clusterIdComparator);
  SwitchPort[] dstDaps=dstDevice.getAttachmentPoints();
  Arrays.sort(dstDaps,clusterIdComparator);
  int iSrcDaps=0, iDstDaps=0;
  while ((iSrcDaps < srcDaps.length) && (iDstDaps < dstDaps.length)) {
    SwitchPort srcDap=srcDaps[iSrcDaps];
    SwitchPort dstDap=dstDaps[iDstDaps];
    Long srcCluster=topology.getL2DomainId(srcDap.getSwitchDPID());
    Long dstCluster=topology.getL2DomainId(dstDap.getSwitchDPID());
    int srcVsDest=srcCluster.compareTo(dstCluster);
    if (srcVsDest == 0) {
      if (!srcDap.equals(dstDap) && (srcCluster != null) && (dstCluster != null)) {
        Route routeIn=routingEngine.getRoute(srcDap.getSwitchDPID(),(short)srcDap.getPort(),dstDap.getSwitchDPID(),(short)dstDap.getPort(),0);
        Route routeOut=routingEngine.getRoute(dstDap.getSwitchDPID(),(short)dstDap.getPort(),srcDap.getSwitchDPID(),(short)srcDap.getPort(),0);
        if (routeIn != null) {
          pushStaticVipRoute(true,routeIn,client,member,sw.getId());
        }
        if (routeOut != null) {
          pushStaticVipRoute(false,routeOut,client,member,sw.getId());
        }
      }
      iSrcDaps++;
      iDstDaps++;
    }
 else     if (srcVsDest < 0) {
      iSrcDaps++;
    }
 else {
      iDstDaps++;
    }
  }
  return;
}

protected void pushBidirectionalVipRoutes ( IOFSwitch sw , OFPacketIn pi , FloodlightContext cntx , IPClient client , LBMember member ) { IDevice srcDevice = null ; IDevice dstDevice = null ; Collection < ? extends IDevice > allDevices = deviceManager . getAllDevices ( ) ; for ( IDevice d : allDevices ) { for ( int j = 0 ; j < d . getIPv4Addresses ( ) . length ; j ++ ) { if ( srcDevice == null && client . ipAddress == d . getIPv4Addresses ( ) [ j ] ) srcDevice = d ; if ( dstDevice == null && member . address == d . getIPv4Addresses ( ) [ j ] ) { dstDevice = d ; member . macString = dstDevice . getMACAddressString ( ) ; } if ( srcDevice != null && dstDevice != null ) break ; } } if ( srcDevice == null || dstDevice == null ) return ; Long srcIsland = topology . getL2DomainId ( sw . getId ( ) ) ; if ( srcIsland == null ) { log . debug ( "No openflow island found for source {}/{}" , sw . getStringId ( ) , pi . getInPort ( ) ) ; return ; } boolean on_same_island = false ; boolean on_same_if = false ; for ( SwitchPort dstDap : dstDevice . getAttachmentPoints ( ) ) { long dstSwDpid = dstDap . getSwitchDPID ( ) ; Long dstIsland = topology . getL2DomainId ( dstSwDpid ) ; if ( ( dstIsland != null ) && dstIsland . equals ( srcIsland ) ) { on_same_island = true ; if ( ( sw . getId ( ) == dstSwDpid ) && ( pi . getInPort ( ) == dstDap . getPort ( ) ) ) { on_same_if = true ; } break ; } } if ( ! on_same_island ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "No first hop island found for destination " + "device {}, Action = flooding" , dstDevice ) ; } return ; } if ( on_same_if ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "Both source and destination are on the same " + "switch/port {}/{}, Action = NOP" , sw . toString ( ) , pi . getInPort ( ) ) ; } return ; } SwitchPort [ ] srcDaps = srcDevice . getAttachmentPoints ( ) ; Arrays . sort ( srcDaps , clusterIdComparator ) ; SwitchPort [ ] dstDaps = dstDevice . getAttachmentPoints ( ) ; Arrays . sort ( dstDaps , clusterIdComparator ) ; int iSrcDaps = 0 , iDstDaps = 0 ; while ( ( iSrcDaps < srcDaps . length ) && ( iDstDaps < dstDaps . length ) ) { SwitchPort srcDap = srcDaps [ iSrcDaps ] ; SwitchPort dstDap = dstDaps [ iDstDaps ] ; Long srcCluster = topology . getL2DomainId ( srcDap . getSwitchDPID ( ) ) ; Long dstCluster = topology . getL2DomainId ( dstDap . getSwitchDPID ( ) ) ; int srcVsDest = srcCluster . compareTo ( dstCluster ) ; if ( srcVsDest == 0 ) { if ( ! srcDap . equals ( dstDap ) && ( srcCluster != null ) && ( dstCluster != null ) ) { Route routeIn = routingEngine . getRoute ( srcDap . getSwitchDPID ( ) , ( short ) srcDap . getPort ( ) , dstDap . getSwitchDPID ( ) , ( short ) dstDap . getPort ( ) , 0 ) ; Route routeOut = routingEngine . getRoute ( dstDap . getSwitchDPID ( ) , ( short ) dstDap . getPort ( ) , srcDap . getSwitchDPID ( ) , ( short ) srcDap . getPort ( ) , 0 ) ; if ( routeIn != null ) { pushStaticVipRoute ( true , routeIn , client , member , sw . getId ( ) ) ; } if ( routeOut != null ) { pushStaticVipRoute ( false , routeOut , client , member , sw . getId ( ) ) ; } } iSrcDaps ++ ; iDstDaps ++ ; } else if ( srcVsDest < 0 ) { iSrcDaps ++ ; } else { iDstDaps ++ ; } } return ; }
used to find and push in - bound and out - bound routes using staticflowentrypusher
