[Javanetsim-cvs] javaNetSim/guiUI EthPortProperties.java, 1.3, 1.4 SerPortProperties.java, 1.2, 1.3
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2007-11-17 21:39:08
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8566/guiUI Modified Files: EthPortProperties.java SerPortProperties.java Terminal.java Log Message: console, ACLs and TCP fixed Index: EthPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/EthPortProperties.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EthPortProperties.java 20 Oct 2007 22:54:40 -0000 1.3 --- EthPortProperties.java 17 Nov 2007 21:38:58 -0000 1.4 *************** *** 310,319 **** temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); temp.getConfig().executeCommand("no int " + NodeInt + " shutdown"); ! temp.getConfig().remove("int " + NodeInt + " shutdown"); ! temp.getConfig().add("no int " + NodeInt + " shutdown"); }else{ temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); ! temp.getConfig().remove("int " + NodeInt + " shutdown"); ! temp.getConfig().add("no int " + NodeInt + " shutdown"); } --- 310,319 ---- temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); temp.getConfig().executeCommand("no int " + NodeInt + " shutdown"); ! // temp.getConfig().remove("int " + NodeInt + " shutdown"); ! // temp.getConfig().add("no int " + NodeInt + " shutdown"); }else{ temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); ! // temp.getConfig().remove("int " + NodeInt + " shutdown"); ! // temp.getConfig().add("no int " + NodeInt + " shutdown"); } Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Terminal.java 23 Oct 2007 20:14:48 -0000 1.7 --- Terminal.java 17 Nov 2007 21:38:58 -0000 1.8 *************** *** 42,45 **** --- 42,49 ---- public class Terminal extends JFrame { + protected final static int DEF_MODE = 0; + protected final static int IF_MODE = 1; + protected final static int ACL_MODE = 2; + private JPanel panel; private JScrollPane scrollpane; *************** *** 56,61 **** private int device_type; private CommandProcessor cmdproc; ! private boolean interface_mode = false; ! private String interface_name = ""; private clear_terminal_CommandClass clear_terminal_Command = new clear_terminal_CommandClass(); --- 60,65 ---- private int device_type; private CommandProcessor cmdproc; ! private int interface_mode = DEF_MODE; ! private String command_prefix = ""; private clear_terminal_CommandClass clear_terminal_Command = new clear_terminal_CommandClass(); *************** *** 65,68 **** --- 69,74 ---- private exit_CommandClass exit_Command = new exit_CommandClass(); private interface_CommandClass interface_Command = new interface_CommandClass(); + private ip_access_list_standart_CommandClass ip_access_list_standart_Command = new ip_access_list_standart_CommandClass(); + private ip_access_list_extended_CommandClass ip_access_list_extended_Command = new ip_access_list_extended_CommandClass(); private logout_CommandClass logout_Command = new logout_CommandClass(); private ping_CommandClass ping_Command = new ping_CommandClass(); *************** *** 92,95 **** --- 98,103 ---- cmdproc.add("interface *", interface_Command, ""); cmdproc.add("interface * exit", exit_Command, ""); + // cmdproc.add("ip access-list standart *", ip_access_list_standart_Command, "Standard Access List"); + // cmdproc.add("ip access-list extended *", ip_access_list_extended_Command, "Extended Access List"); cmdproc.add("logout", logout_Command, "Exit from the console"); cmdproc.add("ping", ping_Command, "Send echo messages"); *************** *** 129,133 **** this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { ! printInfo(); } public void windowGainedFocus(WindowEvent e) { --- 137,141 ---- this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { ! //printInfo(); } public void windowGainedFocus(WindowEvent e) { *************** *** 138,142 **** public void exitWindow() { ! printInfo(); this.dispose(); } --- 146,150 ---- public void exitWindow() { ! //printInfo(); this.dispose(); } *************** *** 154,159 **** if(current_mode.conf_mode == CommandInterface.CONF_MODE){ text += "(config"; ! if(interface_mode){ ! text += "-if"; } text += ")"; --- 162,169 ---- if(current_mode.conf_mode == CommandInterface.CONF_MODE){ text += "(config"; ! switch(interface_mode){ ! case IF_MODE: text += "-if"; break; ! case ACL_MODE: text += "-ext-nacl"; break; ! default: } text += ")"; *************** *** 184,195 **** pos_history = history.size(); } ! appendToTerminal(cmdline.getText() + "\n"); ! String tmptext = cmdproc.call(cmdline.getText(), current_mode, interface_name); ! if(tmptext==null){ ! tmptext = "% Incomplete command.\n"; } addToTerminal(tmptext); cmdline.setText(""); ! printInfo(); break; } --- 194,208 ---- pos_history = history.size(); } ! String tmptext = ""; ! if(cmdline.getText().compareTo("")!=0){ ! appendToTerminal(cmdline.getText() + "\n"); ! tmptext = cmdproc.call(cmdline.getText(), current_mode, command_prefix); ! if(tmptext==null){ ! tmptext = "% Incomplete command.\n"; ! } } addToTerminal(tmptext); cmdline.setText(""); ! //printInfo(); break; } *************** *** 205,209 **** addToTerminal(cmdline.getText()); int caretPos = cmdline.getCaretPosition(); ! String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode, interface_name); //String last_str = cmdline.getText().substring(caretPos); if(compl_str!=null && !compl_str.endsWith(" ")){ --- 218,222 ---- addToTerminal(cmdline.getText()); int caretPos = cmdline.getCaretPosition(); ! String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode, command_prefix); //String last_str = cmdline.getText().substring(caretPos); if(compl_str!=null && !compl_str.endsWith(" ")){ *************** *** 215,219 **** case '?': { String tmptext = cmdline.getText() + "?\n"; ! Vector<Pair> tmpv = cmdproc.help(cmdline.getText().substring(0,cmdline.getCaretPosition()), current_mode, interface_name); if(tmpv!=null){ for(int i=0; i<tmpv.size(); i++){ --- 228,232 ---- case '?': { String tmptext = cmdline.getText() + "?\n"; ! Vector<Pair> tmpv = cmdproc.help(cmdline.getText().substring(0,cmdline.getCaretPosition()), current_mode, command_prefix); if(tmpv!=null){ for(int i=0; i<tmpv.size(); i++){ *************** *** 356,362 **** public String call(Vector<String> params){ if(current_mode.conf_mode == CommandInterface.CONF_MODE){ ! if(interface_mode){ ! interface_mode = false; ! interface_name = ""; } else{ --- 369,375 ---- public String call(Vector<String> params){ if(current_mode.conf_mode == CommandInterface.CONF_MODE){ ! if(interface_mode!=DEF_MODE){ ! interface_mode = DEF_MODE; ! command_prefix = ""; } else{ *************** *** 381,387 **** try { device.getNetworkInterface(params.get(0)); ! if(!interface_mode){ ! interface_mode = true; ! interface_name = "interface "+params.get(0); } } catch (InvalidNetworkInterfaceNameException ex) { --- 394,400 ---- try { device.getNetworkInterface(params.get(0)); ! if(interface_mode==DEF_MODE){ ! interface_mode = IF_MODE; ! command_prefix = "interface "+params.get(0); } } catch (InvalidNetworkInterfaceNameException ex) { *************** *** 395,398 **** --- 408,473 ---- } }; + class ip_access_list_standart_CommandClass extends CommandInterface{ + public ip_access_list_standart_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); + call_params = "<cr>"; + no_call_params = "<cr>"; + } + public String call(Vector<String> params){ + String out = ""; + if(params.size()==1){ + try{ + int iacl = Integer.parseInt(params.get(0)); + if(iacl>=1 && iacl<=99){ + if(interface_mode==DEF_MODE){ + interface_mode = ACL_MODE; + command_prefix = "ip access-list standart "+params.get(0); + } + } + else{ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 1 to 99\n"; + } + } + catch(NumberFormatException e){ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 1 to 99\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; + class ip_access_list_extended_CommandClass extends CommandInterface{ + public ip_access_list_extended_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.CALL_ONLY); + call_params = "<cr>"; + no_call_params = "<cr>"; + } + public String call(Vector<String> params){ + String out = ""; + if(params.size()==1){ + try{ + int iacl = Integer.parseInt(params.get(0)); + if(iacl>=100 && iacl<=2699){ + if(interface_mode==DEF_MODE){ + interface_mode = ACL_MODE; + command_prefix = "ip access-list standart "+params.get(0); + } + } + else{ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 100 to 2699\n"; + } + } + catch(NumberFormatException e){ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 100 to 2699\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; class logout_CommandClass extends CommandInterface{ public logout_CommandClass (){ Index: SerPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SerPortProperties.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SerPortProperties.java 19 Oct 2007 19:38:06 -0000 1.2 --- SerPortProperties.java 17 Nov 2007 21:38:58 -0000 1.3 *************** *** 311,320 **** temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); temp.getConfig().executeCommand("no int " + NodeInt + " shutdown"); ! temp.getConfig().remove("int " + NodeInt + " shutdown"); ! temp.getConfig().add("no int " + NodeInt + " shutdown"); }else{ temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); ! temp.getConfig().remove("int " + NodeInt + " shutdown"); ! temp.getConfig().add("no int " + NodeInt + " shutdown"); } }else{ --- 311,320 ---- temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); temp.getConfig().executeCommand("no int " + NodeInt + " shutdown"); ! // temp.getConfig().remove("int " + NodeInt + " shutdown"); ! // temp.getConfig().add("no int " + NodeInt + " shutdown"); }else{ temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); ! // temp.getConfig().remove("int " + NodeInt + " shutdown"); ! // temp.getConfig().add("no int " + NodeInt + " shutdown"); } }else{ |