コード例 #1
0
  public void removeInterface(String ifName, InterfaceInfo oldIf, Set<String> ANList) {
    // pcerqua
    if (oldIf == null) {
      System.out.println("NULL interface removal -> return;");
      return;
    }

    System.out.println("ip route del " + oldIf.prefix + "/" + oldIf.netmask + " dev " + ifName);
    // #ifndef ANDROID
    result =
        Shell.executeCommand(
            new String[] {"ip", "route", "del", oldIf.prefix + "/" + oldIf.netmask, "dev", ifName});
    // #else
    //				result = Shell.executeRootCommand(new String[]{"ip", "route", "del", oldIf.prefix +"/" +
    // oldIf.netmask, "dev", ifName});
    // #endif
    // System.out.println (result);

    String[] par = new String[] {"-x", "dev", "-i", ifName};
    for (String ANAddress : ANList) {
      System.out.println("DEBUG, (list) of AN addresse(s) :" + ANAddress);
    }
    // TODO PROVA
    //		par[0] = "upmtconf " + par[0];
    //		result = Shell.executeRootCommand(par);
    result = Module.upmtconf(par);

    for (String ANAddress : ANList) {
      int tid = localTidTable.remove(ifName + ":" + ANAddress);
      realPortManager.releaseport(ifName + ANAddress);
      tidToANTable.remove(new Integer(tid));
    }
    // remove ip rule. In this case I don't care about the return value
    // #ifndef ANDROID
    Shell.executeCommand(new String[] {"ip", "rule", "del", "table", ifName + "_table"});

    if (removeTable(ifName)) {
      this.markTable.remove(ifName);
    }
    // #else
    //				result = Shell.executeRootCommand(new String[]{"ip", "rule", "del", "table", ifName
    // +"_table"});
    // #endif
  }
コード例 #2
0
  public int removeTunnel(String ifName, String ANAddress) {

    Integer tid = localTidTable.remove(ifName + ":" + ANAddress);

    if (tid == null) return -1;

    printLog("removing local tunnel " + tid);

    String[] par = new String[] {"-x", "tun", "-n", "" + tid};
    // TODO PROVA
    //		par[0] = "upmtconf " + par[0];
    //		result = Shell.executeRootCommand(par);
    result = Module.upmtconf(par);

    tidToANTable.remove(new Integer(tid));

    realPortManager.releaseport(ifName + ANAddress);
    return 0;
  }