private void generateFlow(ACLRule rule,String dpid,String flowName){
  if (rule == null || checkIfRuleWorksInSwitch(rule.getId(),dpid)) {
    return;
  }
  int priority=getPriorityBySwitch(dpid);
  if (rule.getNw_src() != null) {
    HashMap<String,Object> flow=new HashMap<String,Object>();
    flow.put(StaticFlowEntryPusher.COLUMN_SWITCH,dpid);
    flow.put(StaticFlowEntryPusher.COLUMN_NAME,flowName);
    flow.put(StaticFlowEntryPusher.COLUMN_ACTIVE,Boolean.toString(true));
    flow.put(StaticFlowEntryPusher.COLUMN_COOKIE,"0");
    flow.put(StaticFlowEntryPusher.COLUMN_PRIORITY,Integer.toString(priority));
    flow.put(StaticFlowEntryPusher.COLUMN_DL_TYPE,"2048");
    flow.put(StaticFlowEntryPusher.COLUMN_NW_SRC,rule.getNw_src());
    if (rule.getNw_dst() != null) {
      flow.put(StaticFlowEntryPusher.COLUMN_NW_DST,rule.getNw_dst());
    }
    if (rule.getNw_proto() != 0) {
      flow.put(StaticFlowEntryPusher.COLUMN_NW_PROTO,Integer.toString(rule.getNw_proto()));
    }
    if (rule.getAction() == Action.ALLOW) {
      flow.put(StaticFlowEntryPusher.COLUMN_ACTIONS,"output=controller");
    }
    if (rule.getTp_dst() != 0) {
      flow.put(StaticFlowEntryPusher.COLUMN_TP_DST,Integer.toString(rule.getTp_dst()));
    }
    storageSource.insertRowAsync(StaticFlowEntryPusher.TABLE_NAME,flow);
  }
 else {
    HashMap<String,Object> flow=new HashMap<String,Object>();
    flow.put(StaticFlowEntryPusher.COLUMN_SWITCH,dpid);
    flow.put(StaticFlowEntryPusher.COLUMN_NAME,flowName);
    flow.put(StaticFlowEntryPusher.COLUMN_ACTIVE,Boolean.toString(true));
    flow.put(StaticFlowEntryPusher.COLUMN_COOKIE,"0");
    flow.put(StaticFlowEntryPusher.COLUMN_PRIORITY,Integer.toString(priority));
    flow.put(StaticFlowEntryPusher.COLUMN_DL_TYPE,"2048");
    flow.put(StaticFlowEntryPusher.COLUMN_NW_DST,rule.getNw_dst());
    if (rule.getNw_proto() != 0) {
      flow.put(StaticFlowEntryPusher.COLUMN_NW_PROTO,Integer.toString(rule.getNw_proto()));
    }
    if (rule.getAction() == Action.ALLOW) {
      flow.put(StaticFlowEntryPusher.COLUMN_ACTIONS,"output=controller");
    }
    if (rule.getTp_dst() != 0) {
      flow.put(StaticFlowEntryPusher.COLUMN_TP_DST,Integer.toString(rule.getTp_dst()));
    }
    storageSource.insertRowAsync(StaticFlowEntryPusher.TABLE_NAME,flow);
  }
  addRuleToSwitchMapping(rule.getId(),dpid);
  addRuleToFlowMapping(rule.getId(),flowName);
  logger.debug("ACL flow(id:{}) is added in {}.",flowName,dpid);
}

private void generateFlow ( ACLRule rule , String dpid , String flowName ) { if ( rule == null || checkIfRuleWorksInSwitch ( rule . getId ( ) , dpid ) ) { return ; } int priority = getPriorityBySwitch ( dpid ) ; if ( rule . getNw_src ( ) != null ) { HashMap < String , Object > flow = new HashMap < String , Object > ( ) ; flow . put ( StaticFlowEntryPusher . COLUMN_SWITCH , dpid ) ; flow . put ( StaticFlowEntryPusher . COLUMN_NAME , flowName ) ; flow . put ( StaticFlowEntryPusher . COLUMN_ACTIVE , Boolean . toString ( true ) ) ; flow . put ( StaticFlowEntryPusher . COLUMN_COOKIE , "0" ) ; flow . put ( StaticFlowEntryPusher . COLUMN_PRIORITY , Integer . toString ( priority ) ) ; flow . put ( StaticFlowEntryPusher . COLUMN_DL_TYPE , "2048" ) ; flow . put ( StaticFlowEntryPusher . COLUMN_NW_SRC , rule . getNw_src ( ) ) ; if ( rule . getNw_dst ( ) != null ) { flow . put ( StaticFlowEntryPusher . COLUMN_NW_DST , rule . getNw_dst ( ) ) ; } if ( rule . getNw_proto ( ) != 0 ) { flow . put ( StaticFlowEntryPusher . COLUMN_NW_PROTO , Integer . toString ( rule . getNw_proto ( ) ) ) ; } if ( rule . getAction ( ) == Action . ALLOW ) { flow . put ( StaticFlowEntryPusher . COLUMN_ACTIONS , "output=controller" ) ; } if ( rule . getTp_dst ( ) != 0 ) { flow . put ( StaticFlowEntryPusher . COLUMN_TP_DST , Integer . toString ( rule . getTp_dst ( ) ) ) ; } storageSource . insertRowAsync ( StaticFlowEntryPusher . TABLE_NAME , flow ) ; } else { HashMap < String , Object > flow = new HashMap < String , Object > ( ) ; flow . put ( StaticFlowEntryPusher . COLUMN_SWITCH , dpid ) ; flow . put ( StaticFlowEntryPusher . COLUMN_NAME , flowName ) ; flow . put ( StaticFlowEntryPusher . COLUMN_ACTIVE , Boolean . toString ( true ) ) ; flow . put ( StaticFlowEntryPusher . COLUMN_COOKIE , "0" ) ; flow . put ( StaticFlowEntryPusher . COLUMN_PRIORITY , Integer . toString ( priority ) ) ; flow . put ( StaticFlowEntryPusher . COLUMN_DL_TYPE , "2048" ) ; flow . put ( StaticFlowEntryPusher . COLUMN_NW_DST , rule . getNw_dst ( ) ) ; if ( rule . getNw_proto ( ) != 0 ) { flow . put ( StaticFlowEntryPusher . COLUMN_NW_PROTO , Integer . toString ( rule . getNw_proto ( ) ) ) ; } if ( rule . getAction ( ) == Action . ALLOW ) { flow . put ( StaticFlowEntryPusher . COLUMN_ACTIONS , "output=controller" ) ; } if ( rule . getTp_dst ( ) != 0 ) { flow . put ( StaticFlowEntryPusher . COLUMN_TP_DST , Integer . toString ( rule . getTp_dst ( ) ) ) ; } storageSource . insertRowAsync ( StaticFlowEntryPusher . TABLE_NAME , flow ) ; } addRuleToSwitchMapping ( rule . getId ( ) , dpid ) ; addRuleToFlowMapping ( rule . getId ( ) , flowName ) ; logger . debug ( "ACL flow(id:{}) is added in {}." , flowName , dpid ) ; }
generates acl flow rule according to acl rule and installs it into switch .
