public int addTunnel(String vipa, String ifName, String ANAddress, int AnTsa) { int port = realPortManager.getport(ifName + ANAddress); String[] par = new String[] { "-a", "tun", "-S", vipa, "-D", Module.getVipaFix(), "-i", ifName, "-d", ANAddress, "-l", "" + port, "-r", "" + AnTsa }; // System.err.println("YYYYYY__" + "-a"+ " " +"tun"+ " " +"-S" + " " + vipa+ " " +"-D"+ " " // +Module.getVipaFix()+ " " +"-i"+ " " +ifName+ " " +"-d"+ " " +ANAddress+ " " +"-l"+ " " // +""+port+ " " +"-r"+ " " +""+AnTsa); // TODO PROVA // par[0] = "upmtconf " + par[0]; // result = Shell.executeRootCommand(par); // result = Module.upmtconf(par); // chiamata tramite JNI result = Module.upmtconf( par, false); // se impostata a true chiamata a JNI altrimenti chiamata di sistema // System.err.println(result); int localTid = Module.getUpmtParameter(result, "TID"); if (localTid == 0) { printLog("TUNNEL NON CREATO", Log.LEVEL_HIGH); return 0; } localTidTable.put(ifName + ":" + ANAddress, new Integer(localTid)); UPMTClient.addRMETunnelsToGUI(ANAddress); tidToANTable.put(new Integer(localTid), ANAddress); return localTid; }
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 }
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; }