javanetsim-cvs Mailing List for javaNetSim (Page 8)
Status: Beta
Brought to you by:
darkkey
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(120) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(1) |
Feb
(69) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(76) |
Oct
(28) |
Nov
(77) |
Dec
(186) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(36) |
Oct
(61) |
Nov
(23) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(17) |
Oct
(105) |
Nov
(5) |
Dec
(1) |
2009 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(9) |
Nov
|
Dec
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10516/core Modified Files: ApplicationLayerDevice.java CommandInterface.java CommandProcessor.java CommandsTree.java DeviceConfig.java Node.java Log Message: new mechanism for "no" processing was developed; some console commands was added & fixed Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DeviceConfig.java 18 Oct 2007 22:22:09 -0000 1.6 --- DeviceConfig.java 20 Oct 2007 22:54:40 -0000 1.7 *************** *** 15,18 **** --- 15,19 ---- import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; + import core.CommandInterface.Modes; /** *************** *** 31,35 **** private LinkedList running_config = new LinkedList(); private LinkedList startup_config = new LinkedList(); ! int device_type; /** Creates a new instance of DeviceConfig */ --- 32,36 ---- private LinkedList running_config = new LinkedList(); private LinkedList startup_config = new LinkedList(); ! Modes mode; /** Creates a new instance of DeviceConfig */ *************** *** 37,43 **** cmdproc = new CommandProcessor(dev); device = dev; - device_type = CommandsTree.NETWORK_LAYER; if(device instanceof ApplicationLayerDevice){ ! device_type = CommandsTree.APPLICATION_LAYER; } } --- 38,46 ---- cmdproc = new CommandProcessor(dev); device = dev; if(device instanceof ApplicationLayerDevice){ ! mode = new Modes(CommandInterface.ALL_MODES, CommandInterface.APPLICATION_LAYER, CommandInterface.CALLS); ! } ! else{ ! mode = new Modes(CommandInterface.ALL_MODES, CommandInterface.NETWORK_LAYER, CommandInterface.CALLS); } } *************** *** 187,191 **** public String executeCommand(String command){ ! return cmdproc.call(command, cmdproc.ALLMODE | device_type, ""); } --- 190,194 ---- public String executeCommand(String command){ ! return cmdproc.call(command, mode, ""); } Index: CommandsTree.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandsTree.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CommandsTree.java 16 Oct 2007 23:02:31 -0000 1.3 --- CommandsTree.java 20 Oct 2007 22:54:40 -0000 1.4 *************** *** 12,15 **** --- 12,16 ---- import java.util.LinkedList; import java.util.Vector; + import core.CommandInterface.Modes; /** *************** *** 19,33 **** public class CommandsTree { - public static final int NO_MODE = 0x01; - public static final int STD_MODE = 0x02; - public static final int CONF_MODE = 0x04; - public static final int STD_CONF_MODE = STD_MODE | CONF_MODE; - public static final int MODES = NO_MODE | STD_MODE | CONF_MODE; - public static final int NO_LAYER = 0x10; - public static final int NETWORK_LAYER = 0x20 | NO_LAYER; - public static final int TRANSPORT_LAYER = 0x40 | NETWORK_LAYER; - public static final int APPLICATION_LAYER = 0x80 | TRANSPORT_LAYER; - public static final int LAYERS = APPLICATION_LAYER; - public static final int ALLMODE = MODES | LAYERS; public static final String ANYWORD = "*"; --- 20,23 ---- *************** *** 39,44 **** private LinkedList tree; private CommandInterface function; ! private int modes; ! private String params; private String description; --- 29,33 ---- private LinkedList tree; private CommandInterface function; ! public Modes modes; private String description; *************** *** 47,64 **** */ public CommandNode(String name){ this.name = name; tree = null; function = null; - modes = NO_MODE | NO_LAYER; - params = ""; description = ""; } ! public CommandNode(String name, CommandInterface function, int modes, String params, String description){ this.name = name; tree = null; this.function = function; - this.modes = modes; - this.params = params; this.description = description; } --- 36,56 ---- */ public CommandNode(String name){ + modes = new Modes(); this.name = name; tree = null; function = null; description = ""; } ! public CommandNode(String name, CommandInterface function, String description){ ! if(function != null){ ! this.modes = function.modes; ! } ! else{ ! this.modes = new Modes(); ! } this.name = name; tree = null; this.function = function; this.description = description; } *************** *** 68,72 **** } ! private Vector<CommandNode> getNodes(String command, int mode){ Vector<CommandNode> nodes = new Vector<CommandNode>(0); --- 60,64 ---- } ! private Vector<CommandNode> getNodes(String command, Modes mode){ Vector<CommandNode> nodes = new Vector<CommandNode>(0); *************** *** 81,85 **** if(nodename.length()>cmdsize) nodename = nodename.substring(0,cmdsize); int cmp = command.compareToIgnoreCase(nodename); ! if(cmp == 0 && (node.getModes() & mode & MODES)!=0 && (node.getModes() & mode & LAYERS)!=0){ nodes.add((CommandNode)tree.get(i)); } --- 73,77 ---- if(nodename.length()>cmdsize) nodename = nodename.substring(0,cmdsize); int cmp = command.compareToIgnoreCase(nodename); ! if(cmp == 0 && modes.isContain(mode)){ nodes.add((CommandNode)tree.get(i)); } *************** *** 99,103 **** } ! public Vector<String> getCommands(String command, int mode){ Vector<CommandNode> nodes = getNodes(command, mode); Vector<String> nodenames = new Vector<String>(nodes.size()); --- 91,95 ---- } ! public Vector<String> getCommands(String command, Modes mode){ Vector<CommandNode> nodes = getNodes(command, mode); Vector<String> nodenames = new Vector<String>(nodes.size()); *************** *** 108,112 **** } ! public CommandNode getNode(String nodename, int mode){ Vector<CommandNode> nodes = getNodes(nodename, mode); CommandNode node = null; --- 100,104 ---- } ! public CommandNode getNode(String nodename, Modes mode){ Vector<CommandNode> nodes = getNodes(nodename, mode); CommandNode node = null; *************** *** 125,144 **** } - public int getModes(){ - return modes; - } - - public void setModes(int modes){ - this.modes = modes; - } - - public String getParameters(){ - return params; - } - - public void setParameters(String params){ - this.params = params; - } - public String getDescription(){ return description; --- 117,120 ---- *************** *** 199,202 **** --- 175,182 ---- } + private Modes allModes(){ + return new Modes(CommandInterface.ALL_MODES, CommandInterface.LAYERS, CommandInterface.CALLS); + } + /** Bind 'command' with 'params' to 'function' working in 'modes' * @param command full command line without parameters *************** *** 206,210 **** * @return true command was executed, false otherwise */ ! public boolean add(String command, CommandInterface function, int modes, String params, String description){ boolean result = false; String cmds[] = command.split(" "); --- 186,190 ---- * @return true command was executed, false otherwise */ ! public boolean add(String command, CommandInterface function, String description){ boolean result = false; String cmds[] = command.split(" "); *************** *** 213,222 **** boolean existed = false; for(int i=0; i<cmds.length && !existed ; i++){ ! CommandNode nextnode = node.getNode(cmds[i], ALLMODE); if(nextnode != null && nextnode.getName().compareTo(cmds[i])==0){ if(i == cmds.length-1){ if(nextnode.getFunction()==null){ ! nextnode.setModes(nextnode.getModes() | modes); ! nextnode.setParameters(params); nextnode.setFunction(function); if(nextnode.getDescription().equals("") && !description.equals("")){ --- 193,201 ---- boolean existed = false; for(int i=0; i<cmds.length && !existed ; i++){ ! CommandNode nextnode = node.getNode(cmds[i], allModes()); if(nextnode != null && nextnode.getName().compareTo(cmds[i])==0){ if(i == cmds.length-1){ if(nextnode.getFunction()==null){ ! nextnode.modes.or(function.modes); nextnode.setFunction(function); if(nextnode.getDescription().equals("") && !description.equals("")){ *************** *** 231,239 **** else{ if(i == cmds.length-1){ ! nextnode = new CommandNode(cmds[i], function, modes, params, description); } else{ nextnode = new CommandNode(cmds[i]); ! nextnode.setModes(modes); } node.add(nextnode); --- 210,218 ---- else{ if(i == cmds.length-1){ ! nextnode = new CommandNode(cmds[i], function, description); } else{ nextnode = new CommandNode(cmds[i]); ! nextnode.modes.set(function.modes); } node.add(nextnode); *************** *** 245,263 **** node = root; for(int i=0; i<cmds.length && node!=null ; i++){ ! node.setModes(node.getModes() | modes); ! node = node.getNode(cmds[i], ALLMODE); } result = true; } return result; } ! public boolean addDescription(String command, String description){ ! boolean result = false; String cmds[] = command.split(" "); CommandNode node = root; for(int i=0; i<cmds.length; i++){ ! CommandNode nextnode = node.getNode(cmds[i], ALLMODE); if(nextnode != null && nextnode.getName().compareTo(cmds[i])==0){ if(i == cmds.length-1){ --- 224,244 ---- node = root; for(int i=0; i<cmds.length && node!=null ; i++){ ! node.modes.or(function.modes); ! node = node.getNode(cmds[i], allModes()); } result = true; } + if(function.modes.cmd_mode==CommandInterface.NO_CALL && !cmds[0].equalsIgnoreCase("no")){ + result = result && add("no "+command, function, description); + } return result; } ! public void addDescription(String command, String description){ String cmds[] = command.split(" "); CommandNode node = root; for(int i=0; i<cmds.length; i++){ ! CommandNode nextnode = node.getNode(cmds[i], allModes()); if(nextnode != null && nextnode.getName().compareTo(cmds[i])==0){ if(i == cmds.length-1){ *************** *** 267,271 **** else{ if(i == cmds.length-1){ ! nextnode = new CommandNode(cmds[i], null, NO_MODE | NO_LAYER, "", description); } else{ --- 248,252 ---- else{ if(i == cmds.length-1){ ! nextnode = new CommandNode(cmds[i], null, description); } else{ *************** *** 276,280 **** node = nextnode; } ! return result; } --- 257,263 ---- node = nextnode; } ! if(!cmds[0].equalsIgnoreCase("no")){ ! addDescription("no "+command, description); ! } } *************** *** 284,293 **** * @return true if command was executed, false otherwise */ ! public String call(String command, int mode){ String result = null; String cmds[] = command.split(" "); CommandInterface func = null; ! int modes = 0; String params = ""; Vector<String> vprms = new Vector<String>(0); --- 267,276 ---- * @return true if command was executed, false otherwise */ ! public String call(String command, Modes mode){ String result = null; String cmds[] = command.split(" "); CommandInterface func = null; ! Modes modes = new Modes(0,0,0); String params = ""; Vector<String> vprms = new Vector<String>(0); *************** *** 295,299 **** CommandNode node = root; int i; ! for(i=0; i<cmds.length && node!=null && (node.getModes() & mode & MODES)!=0 && (node.getModes() & mode & LAYERS)!=0; i++){ node = node.getNode(cmds[i], mode); if(node != null){ --- 278,282 ---- CommandNode node = root; int i; ! for(i=0; i<cmds.length && node!=null && node.modes.isContain(mode); i++){ node = node.getNode(cmds[i], mode); if(node != null){ *************** *** 302,310 **** } func = node.getFunction(); ! modes = node.getModes(); ! params = node.getParameters(); } } ! if(func!=null && (modes & mode & MODES)!=0 && (modes & mode & LAYERS)!=0){ //String sprms[] = params.split(" "); if(node==null) i--; --- 285,303 ---- } func = node.getFunction(); ! modes = node.modes; ! if(func!=null){ ! if(cmds[0].equalsIgnoreCase("no")){ ! params = node.getFunction().no_call_params; ! } ! else{ ! params = node.getFunction().call_params; ! } ! } ! else{ ! params = ""; ! } } } ! if(func!=null && modes.isContain(mode)){ //String sprms[] = params.split(" "); if(node==null) i--; *************** *** 312,316 **** vprms.add(cmds[i]); } ! result = func.call(vprms); } return result; --- 305,314 ---- vprms.add(cmds[i]); } ! if(cmds[0].equalsIgnoreCase("no")){ ! result = func.no_call(vprms); ! } ! else{ ! result = func.call(vprms); ! } } return result; *************** *** 322,326 **** * @return complete command, or "" if completing is impossible */ ! public String complete(String command, int mode){ String result = null; String cmds[] = command.split(" "); --- 320,324 ---- * @return complete command, or "" if completing is impossible */ ! public String complete(String command, Modes mode){ String result = null; String cmds[] = command.split(" "); *************** *** 331,335 **** else{ CommandNode node = root; ! for(int i=0; i<cmds.length && node!=null && (node.getModes() & mode & MODES)!=0 && (node.getModes() & mode & LAYERS)!=0; i++){ node = node.getNode(cmds[i], mode); if(node != null && i==cmds.length-1){ --- 329,333 ---- else{ CommandNode node = root; ! for(int i=0; i<cmds.length && node!=null && node.modes.isContain(mode); i++){ node = node.getNode(cmds[i], mode); if(node != null && i==cmds.length-1){ *************** *** 349,353 **** * @return complete command, or "" if helping is impossible */ ! public Vector<Pair> help(String command, int mode){ Vector<Pair> result = null; String cmds[] = command.split(" "); --- 347,351 ---- * @return complete command, or "" if helping is impossible */ ! public Vector<Pair> help(String command, Modes mode){ Vector<Pair> result = null; String cmds[] = command.split(" "); *************** *** 356,365 **** CommandInterface func = null; int modes = 0; ! for(int i=0; i<cmds.length && node!=null && (node.getModes() & mode & MODES)!=0 && (node.getModes() & mode & LAYERS)!=0; i++){ if(i<cmds.length-1){ CommandNode nextnode = node.getNode(cmds[i], mode); if(nextnode==null && node.getFunction()!=null){ result = new Vector<Pair>(1); ! result.add(new Pair(node.getParameters(), "")); } node = nextnode; --- 354,368 ---- CommandInterface func = null; int modes = 0; ! for(int i=0; i<cmds.length && node!=null && node.modes.isContain(mode); i++){ if(i<cmds.length-1){ CommandNode nextnode = node.getNode(cmds[i], mode); if(nextnode==null && node.getFunction()!=null){ result = new Vector<Pair>(1); ! if(cmds[0].equalsIgnoreCase("no")){ ! result.add(new Pair(node.getFunction().no_call_params, "")); ! } ! else{ ! result.add(new Pair(node.getFunction().call_params, "")); ! } } node = nextnode; *************** *** 376,380 **** } if(node.getFunction()!=null){ ! result.add(new Pair(node.getParameters(), "")); } } --- 379,388 ---- } if(node.getFunction()!=null){ ! if(cmds[0].equalsIgnoreCase("no")){ ! result.add(new Pair(node.getFunction().no_call_params, "")); ! } ! else{ ! result.add(new Pair(node.getFunction().call_params, "")); ! } } } Index: CommandInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandInterface.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CommandInterface.java 12 Oct 2007 21:06:39 -0000 1.1 --- CommandInterface.java 20 Oct 2007 22:54:40 -0000 1.2 *************** *** 15,23 **** * @author QweR */ ! public interface CommandInterface { ! /** Execute fucntion ! * @return true if command was executed, false otherwise ! */ ! public String call(Vector<String> params); } --- 15,80 ---- * @author QweR */ ! abstract public class CommandInterface { ! ! public static final int NO_MODE = 0x01; ! public static final int STD_MODE = 0x02; ! public static final int CONF_MODE = 0x04; ! public static final int STD_CONF_MODE = STD_MODE | CONF_MODE; ! public static final int ALL_MODES = NO_MODE | STD_MODE | CONF_MODE; ! public static final int NO_LAYER = 0x01; ! public static final int NETWORK_LAYER = 0x02 | NO_LAYER; ! public static final int TRANSPORT_LAYER = 0x04 | NETWORK_LAYER; ! public static final int APPLICATION_LAYER = 0x08 | TRANSPORT_LAYER; ! public static final int LAYERS = APPLICATION_LAYER; ! ! public static final int CALL_ONLY = 0x01; ! public static final int NO_CALL = 0x02; ! public static final int CALLS = CALL_ONLY | NO_CALL; ! ! ! static public class Modes{ ! public int conf_mode; ! public int layer_mode; ! public int cmd_mode; ! ! public Modes(){ ! conf_mode = NO_MODE; ! layer_mode = NO_LAYER; ! cmd_mode = CALL_ONLY; ! } ! public Modes(int conf, int layer, int cmd){ ! conf_mode = conf; ! layer_mode = layer; ! cmd_mode = cmd; ! } ! public void set(Modes mode){ ! conf_mode = mode.conf_mode; ! layer_mode = mode.layer_mode; ! cmd_mode = mode.cmd_mode; ! } ! public void or(Modes mode){ ! conf_mode |= mode.conf_mode; ! layer_mode |= mode.layer_mode; ! cmd_mode |= mode.cmd_mode; ! } ! public boolean isContain(Modes mode){ ! return ((conf_mode & mode.conf_mode)!=0 && (layer_mode & mode.layer_mode)!=0 && (cmd_mode & mode.cmd_mode)!=0); ! } ! } ! ! public Modes modes; ! public String call_params; ! public String no_call_params; ! ! ! public CommandInterface(){ ! modes = new Modes(NO_MODE, NO_LAYER, CALL_ONLY); ! } ! ! abstract public String call(Vector<String> params); ! ! public String no_call(Vector<String> params){ ! return "Function not implemented!!!"; ! } } Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CommandProcessor.java 18 Oct 2007 22:22:09 -0000 1.6 --- CommandProcessor.java 20 Oct 2007 22:54:40 -0000 1.7 *************** *** 25,28 **** --- 25,29 ---- import java.util.Iterator; import java.util.Vector; + import core.CommandInterface.Modes; /** *************** *** 32,45 **** public class CommandProcessor { [...2587 lines suppressed...] ! } public String call(Vector<String> params){ device.getConfig().clear(DeviceConfig.STARTUP_CONFIG); *************** *** 1506,1510 **** } }; ! class write_terminal_CommandClass implements CommandInterface{ public String call(Vector<String> params){ String out = ""; --- 2289,2297 ---- } }; ! class write_terminal_CommandClass extends CommandInterface{ ! public write_terminal_CommandClass(){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ String out = ""; Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Node.java 20 Oct 2007 13:27:20 -0000 1.18 --- Node.java 20 Oct 2007 22:54:40 -0000 1.19 *************** *** 129,132 **** --- 129,134 ---- public boolean On; + public String location = ""; + private int ProtocolStackLayers; Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ApplicationLayerDevice.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ApplicationLayerDevice.java 19 Oct 2007 08:52:24 -0000 1.6 --- ApplicationLayerDevice.java 20 Oct 2007 22:54:40 -0000 1.7 *************** *** 18,21 **** --- 18,22 ---- public class ApplicationLayerDevice extends NetworkLayerDevice{ protected Hashtable Apps = null; + protected Hashtable userlist = new Hashtable(); /** Creates a new instance of ApplicationLayerDevice */ public ApplicationLayerDevice(String inName, int inProtocolStackLayers, boolean inOn) { *************** *** 58,61 **** --- 59,81 ---- } + + public void addUser(String username, String password){ + if(userlist.containsKey(username)){ + userlist.remove(username); + } + userlist.put(username, password); + } + + public void delUser(String username){ + userlist.remove(username); + } + + public String getUserPassword(String username){ + return (String)userlist.get(username); + } + + public Enumeration<String> getUserList(){ + return userlist.keys(); + } } |
From: QweR <qw...@us...> - 2007-10-20 22:54:48
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10516/guiUI Modified Files: EthPortProperties.java MainScreen.java Terminal.java Log Message: new mechanism for "no" processing was developed; some console commands was added & fixed Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** MainScreen.java 20 Oct 2007 20:19:46 -0000 1.78 --- MainScreen.java 20 Oct 2007 22:54:40 -0000 1.79 *************** *** 4410,4414 **** public void RunCmd(String inNodeName){ try{ ! if(!(Sim.getNode(inNodeName) instanceof core.NetworkLayerDevice) && !(Sim.getNode(inNodeName) instanceof core.Printer)){ Terminal r = new Terminal(this, (core.NetworkLayerDevice)Sim.getNode(inNodeName)); r.pack(); --- 4410,4414 ---- public void RunCmd(String inNodeName){ try{ ! if(/*!(Sim.getNode(inNodeName) instanceof core.NetworkLayerDevice) &&*/ !(Sim.getNode(inNodeName) instanceof core.Printer)){ Terminal r = new Terminal(this, (core.NetworkLayerDevice)Sim.getNode(inNodeName)); r.pack(); Index: EthPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/EthPortProperties.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EthPortProperties.java 19 Oct 2007 15:57:01 -0000 1.2 --- EthPortProperties.java 20 Oct 2007 22:54:40 -0000 1.3 *************** *** 302,306 **** private void okButton(){ try { ! String SC = txtMAC.getText(); if(SC.matches("[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]")){ NetworkLayerDevice temp = (NetworkLayerDevice)Sim.getNode(NodeName); --- 302,306 ---- private void okButton(){ try { ! String SC = txtMAC.getText(); if(SC.matches("[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]")){ NetworkLayerDevice temp = (NetworkLayerDevice)Sim.getNode(NodeName); Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Terminal.java 16 Oct 2007 23:02:31 -0000 1.5 --- Terminal.java 20 Oct 2007 22:54:40 -0000 1.6 *************** *** 34,37 **** --- 34,38 ---- import core.CommandProcessor; import core.InvalidNetworkInterfaceNameException; + import core.CommandInterface.Modes; /** *************** *** 52,56 **** private final static int max_history = 128; CmdVerifier cmdverifier = new CmdVerifier(); ! private int current_mode; private int device_type; private CommandProcessor cmdproc; --- 53,57 ---- private final static int max_history = 128; CmdVerifier cmdverifier = new CmdVerifier(); ! private Modes current_mode; private int device_type; private CommandProcessor cmdproc; *************** *** 74,98 **** this.parent = parent; cmdproc = new CommandProcessor(dev); ! ! current_mode = CommandsTree.STD_MODE; if(device instanceof core.ApplicationLayerDevice){ ! device_type = CommandsTree.APPLICATION_LAYER; } else{ ! device_type = CommandsTree.NETWORK_LAYER; } ! cmdproc.add("clear terminal", clear_terminal_Command, cmdproc.STD_CONF_MODE | cmdproc.NETWORK_LAYER, "<cr>", "Clear screen"); cmdproc.addDescription("configure","Enter configuration mode"); ! cmdproc.add("configure replace", configure_replace_Command, cmdproc.STD_MODE | cmdproc.NO_LAYER, "<cr>", "Replace configure from the terminal"); ! cmdproc.add("configure memory", configure_memory_Command, cmdproc.STD_MODE | cmdproc.NO_LAYER, "<cr>", "Configure from memory"); ! cmdproc.add("configure terminal", configure_terminal_Command, cmdproc.STD_MODE | cmdproc.NO_LAYER, "<cr>", "Configure from the terminal"); ! cmdproc.add("exit", exit_Command, cmdproc.STD_CONF_MODE | cmdproc.NO_LAYER, "<cr>", "Exit from current mode"); ! cmdproc.add("interface", interface_Command, cmdproc.CONF_MODE | cmdproc.NETWORK_LAYER, "<interface>", ""); ! cmdproc.add("interface *", interface_Command, cmdproc.CONF_MODE | cmdproc.NETWORK_LAYER, "<cr>", ""); ! cmdproc.add("interface * exit", exit_Command, cmdproc.CONF_MODE | cmdproc.NETWORK_LAYER, "<cr>", ""); ! cmdproc.add("logout", logout_Command, cmdproc.STD_MODE | cmdproc.NO_LAYER, "<cr>", "Exit from the console"); ! cmdproc.add("ping", ping_Command, cmdproc.STD_CONF_MODE | cmdproc.NETWORK_LAYER, "<ip>", "Send echo messages"); ! cmdproc.add("show history", show_history_Command, cmdproc.STD_CONF_MODE | cmdproc.NO_LAYER, "<cr>", "Display the session command history"); panel = new JPanel(); --- 75,98 ---- this.parent = parent; cmdproc = new CommandProcessor(dev); ! if(device instanceof core.ApplicationLayerDevice){ ! current_mode = new Modes(CommandInterface.STD_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.CALLS); } else{ ! current_mode = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALLS); } ! cmdproc.add("clear terminal", clear_terminal_Command, "Clear screen"); cmdproc.addDescription("configure","Enter configuration mode"); ! cmdproc.add("configure replace", configure_replace_Command, "Replace configure from the terminal"); ! cmdproc.add("configure memory", configure_memory_Command, "Configure from memory"); ! cmdproc.add("configure terminal", configure_terminal_Command, "Configure from the terminal"); ! cmdproc.add("exit", exit_Command, "Exit from current mode"); ! cmdproc.add("interface", interface_Command, ""); ! cmdproc.add("interface *", interface_Command, ""); ! cmdproc.add("interface * exit", exit_Command, ""); ! cmdproc.add("logout", logout_Command, "Exit from the console"); ! cmdproc.add("ping", ping_Command, "Send echo messages"); ! cmdproc.add("show history", show_history_Command, "Display the session command history"); panel = new JPanel(); *************** *** 152,156 **** private void addToTerminal(String data){ text += data+"\n"+device.NodeProtocolStack.getParentNodeName(); ! if(current_mode == cmdproc.CONF_MODE){ text += "(config"; if(interface_mode){ --- 152,156 ---- private void addToTerminal(String data){ text += data+"\n"+device.NodeProtocolStack.getParentNodeName(); ! if(current_mode.conf_mode == CommandInterface.CONF_MODE){ text += "(config"; if(interface_mode){ *************** *** 185,189 **** } appendToTerminal(cmdline.getText() + "\n"); ! String tmptext = cmdproc.call(cmdline.getText(), current_mode | device_type, interface_name); if(tmptext==null){ tmptext = "% Incomplete command.\n"; --- 185,189 ---- } appendToTerminal(cmdline.getText() + "\n"); ! String tmptext = cmdproc.call(cmdline.getText(), current_mode, interface_name); if(tmptext==null){ tmptext = "% Incomplete command.\n"; *************** *** 205,209 **** addToTerminal(cmdline.getText()); int caretPos = cmdline.getCaretPosition(); ! String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode | device_type, interface_name); //String last_str = cmdline.getText().substring(caretPos); if(compl_str!=null && !compl_str.endsWith(" ")){ --- 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(" ")){ *************** *** 215,219 **** case '?': { String tmptext = cmdline.getText() + "?\n"; ! Vector<Pair> tmpv = cmdproc.help(cmdline.getText().substring(0,cmdline.getCaretPosition()), current_mode | device_type, interface_name); if(tmpv!=null){ for(int i=0; i<tmpv.size(); i++){ --- 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++){ *************** *** 305,309 **** } ! class clear_terminal_CommandClass implements CommandInterface{ public String call(Vector<String> params){ clearTerminal(); --- 305,313 ---- } ! class clear_terminal_CommandClass extends CommandInterface{ ! public clear_terminal_CommandClass (){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ clearTerminal(); *************** *** 311,338 **** } }; ! class configure_terminal_CommandClass implements CommandInterface{ public String call(Vector<String> params){ device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; ! current_mode = cmdproc.CONF_MODE; return "Enter configuration commands, one per line. End with 'exit'"; } }; ! class configure_replace_CommandClass implements CommandInterface{ public String call(Vector<String> params){ device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; ! current_mode = cmdproc.CONF_MODE; return "Running-config was erased\nEnter configuration commands, one per line. End with 'exit'"; } }; ! class configure_memory_CommandClass implements CommandInterface{ public String call(Vector<String> params){ device.getConfig().working_config = DeviceConfig.STARTUP_CONFIG; ! current_mode = cmdproc.CONF_MODE; return "Starting-config editing\nEnter configuration commands, one per line. End with 'exit'"; } }; ! class exit_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! if(current_mode == cmdproc.CONF_MODE){ if(interface_mode){ interface_mode = false; --- 315,359 ---- } }; ! class configure_terminal_CommandClass extends CommandInterface{ ! public configure_terminal_CommandClass (){ ! modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; ! current_mode.conf_mode = CommandInterface.CONF_MODE; return "Enter configuration commands, one per line. End with 'exit'"; } }; ! class configure_replace_CommandClass extends CommandInterface{ ! public configure_replace_CommandClass (){ ! modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; ! current_mode.conf_mode = CommandInterface.CONF_MODE; ! device.getConfig().clear(DeviceConfig.RUNNING_CONFIG); return "Running-config was erased\nEnter configuration commands, one per line. End with 'exit'"; } }; ! class configure_memory_CommandClass extends CommandInterface{ ! public configure_memory_CommandClass (){ ! modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ device.getConfig().working_config = DeviceConfig.STARTUP_CONFIG; ! current_mode.conf_mode = CommandInterface.CONF_MODE; return "Starting-config editing\nEnter configuration commands, one per line. End with 'exit'"; } }; ! class exit_CommandClass extends CommandInterface{ ! public exit_CommandClass (){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ ! if(current_mode.conf_mode == CommandInterface.CONF_MODE){ if(interface_mode){ interface_mode = false; *************** *** 340,348 **** } else{ ! current_mode = cmdproc.STD_MODE; device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; } } ! else if(current_mode == cmdproc.STD_MODE){ exitWindow(); } --- 361,369 ---- } else{ ! current_mode.conf_mode = CommandInterface.STD_MODE; device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; } } ! else if(current_mode.conf_mode == CommandInterface.STD_MODE){ exitWindow(); } *************** *** 350,354 **** } }; ! class interface_CommandClass implements CommandInterface{ public String call(Vector<String> params){ String out = ""; --- 371,379 ---- } }; ! class interface_CommandClass extends CommandInterface{ ! public interface_CommandClass (){ ! modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ String out = ""; *************** *** 370,374 **** } }; ! class logout_CommandClass implements CommandInterface{ public String call(Vector<String> params){ exitWindow(); --- 395,403 ---- } }; ! class logout_CommandClass extends CommandInterface{ ! public logout_CommandClass (){ ! modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ exitWindow(); *************** *** 376,380 **** } }; ! class ping_CommandClass implements CommandInterface{ public String call(Vector<String> params){ if(params.size()==1){ --- 405,413 ---- } }; ! class ping_CommandClass extends CommandInterface{ ! public ping_CommandClass (){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<ip>"; ! } public String call(Vector<String> params){ if(params.size()==1){ *************** *** 405,409 **** } }; ! class show_history_CommandClass implements CommandInterface{ public String call(Vector<String> params){ String out = ""; --- 438,446 ---- } }; ! class show_history_CommandClass extends CommandInterface{ ! public show_history_CommandClass (){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } public String call(Vector<String> params){ String out = ""; |
From: QweR <qw...@us...> - 2007-10-20 22:54:48
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10516/core/protocolsuite/tcp_ip Modified Files: DHCPD.java Telnet_server.java Log Message: new mechanism for "no" processing was developed; some console commands was added & fixed Index: DHCPD.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPD.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DHCPD.java 20 Oct 2007 13:27:20 -0000 1.4 --- DHCPD.java 20 Oct 2007 22:54:40 -0000 1.5 *************** *** 364,366 **** --- 364,374 ---- } + public void excludeAddress(String low_ip, String high_ip){ + + } + + public void no_excludeAddress(String low_ip, String high_ip){ + + } + } Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Telnet_server.java 20 Oct 2007 13:27:21 -0000 1.20 --- Telnet_server.java 20 Oct 2007 22:54:40 -0000 1.21 *************** *** 13,16 **** --- 13,18 ---- import java.util.regex.*; import core.Error; + import java.util.Enumeration; + import java.util.Hashtable; import java.util.Vector; *************** *** 22,25 **** --- 24,31 ---- public class Telnet_server extends Application{ + public class TSession{ + public String user; + } + private ApplicationLayerDevice mDevice; private String cmdline = ""; *************** *** 31,35 **** private String login = "root"; private String temp = ""; ! private Vector<Integer> connections = new Vector<Integer>(1); /** Creates a new instance of Telnet Server */ --- 37,41 ---- private String login = "root"; private String temp = ""; ! public Hashtable connections = new Hashtable(); /** Creates a new instance of Telnet Server */ *************** *** 62,66 **** public void Accept(int listenSock, int sessionSock){ ! connections.add(new Integer(sessionSock)); } --- 68,72 ---- public void Accept(int listenSock, int sessionSock){ ! connections.put(new Integer(sessionSock), new TSession()); } *************** *** 75,80 **** { mParentStack.SL().close(appSock); ! for(int i=0; i<connections.size(); i++){ ! mParentStack.SL().close(connections.get(i).intValue()); } islogin=false; --- 81,89 ---- { mParentStack.SL().close(appSock); ! Enumeration keys = connections.keys(); ! while(keys.hasMoreElements()){ ! Integer key = (Integer)keys.nextElement(); ! mParentStack.SL().close(key.intValue()); ! connections.remove(key); } islogin=false; *************** *** 85,90 **** { mParentStack.SL().free(appSock); ! for(int i=0; i<connections.size(); i++){ ! mParentStack.SL().free(connections.get(i).intValue()); } islogin=false; --- 94,102 ---- { mParentStack.SL().free(appSock); ! Enumeration keys = connections.keys(); ! while(keys.hasMoreElements()){ ! Integer key = (Integer)keys.nextElement(); ! mParentStack.SL().free(key.intValue()); ! connections.remove(key); } islogin=false; *************** *** 129,137 **** temp = ""; cmdline = ""; ! try{ ! connections.remove(new Integer(sock)); ! }catch(Exception e){ ! printLayerInfo("Cannot listen on port: " + e.toString()); ! } } --- 141,145 ---- temp = ""; cmdline = ""; ! connections.remove(new Integer(sock)); } *************** *** 195,199 **** else if(ispass) { ispass = false; ! if(temp.compareTo(login)==0 && cmdline.compareTo(password)==0) { outData += "\r\nWelcome to " + mParentStack.getParentNodeName() + "\r\n" + runcmd(""); } --- 203,208 ---- else if(ispass) { ispass = false; ! if(isAuth(temp, cmdline)) { ! ((TSession)connections.get(new Integer(sock))).user = temp; outData += "\r\nWelcome to " + mParentStack.getParentNodeName() + "\r\n" + runcmd(""); } *************** *** 436,439 **** return password; } ! } --- 445,455 ---- return password; } ! ! private boolean isAuth(String user, String pass){ ! boolean auth = false; ! if((user.equals(login) && pass.equals(password)) || pass.equals(mDevice.getUserPassword(user))){ ! auth = true; ! } ! return auth; ! } } |
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9138/guiUI Modified Files: ApplicationLayerDevice.java GuiPC.java MainScreen.java MenuBar.java SandBox.java SimulationToolBar.java Added Files: GuiPrinter.java Log Message: Added network printers. Index: MenuBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MenuBar.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** MenuBar.java 19 Oct 2007 08:52:27 -0000 1.17 --- MenuBar.java 20 Oct 2007 20:19:46 -0000 1.18 *************** *** 60,64 **** --- 60,66 ---- private JMenuItem mnuSwitch = new JMenuItem("Switch ..."); private JMenuItem mnuCSUDSU = new JMenuItem("CSU/DSU device..."); + private JMenuItem mnuPrinter = new JMenuItem("Printer..."); private JMenuItem mnuExternalNAT = new JMenuItem("Socks Proxy..."); + //help menu *************** *** 129,132 **** --- 131,135 ---- mnuAdd.add(mnuCSUDSU); mnuAdd.add(mnuExternalNAT); + mnuAdd.add(mnuPrinter); *************** *** 230,233 **** --- 233,245 ---- }); + + //Add action listener to new hub + mnuPrinter.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.setAllHighlightsOff(); + controller.addingNode(SandBox.PRINTER_CURSOR); + } + }); + mnuMsgLinkLayer.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ Index: SimulationToolBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SimulationToolBar.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SimulationToolBar.java 15 Oct 2007 18:25:54 -0000 1.3 --- SimulationToolBar.java 20 Oct 2007 20:19:46 -0000 1.4 *************** *** 102,105 **** --- 102,107 ---- private JButton btnNewCSUDSU = new JButton(new ImageIcon(cl.getResource("images/simulation/csudsu_small.png"))); + + private JButton btnNewPrinter = new JButton(new ImageIcon(cl.getResource("images/simulation/printer_small.png"))); private JButton btnNewLink = new JButton(new ImageIcon(cl.getResource("images/simulation/link.gif"))); *************** *** 172,175 **** --- 174,179 ---- btnNewCSUDSU.setToolTipText("Creates a new CSU/DSU device"); + + btnNewPrinter.setToolTipText("Creates a new CSU/DSU device"); *************** *** 188,191 **** --- 192,197 ---- btnNewCSUDSU.setBorderPainted(false); + + btnNewPrinter.setBorderPainted(false); *************** *** 208,211 **** --- 214,231 ---- + btnNewPrinter.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e){ + + setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. + + highlightButton(btnNewPrinter, true); + + controller.addingNode(SandBox.PRINTER_CURSOR); + + } + + }); + //Set action listener for Hub toolbar item *************** *** 303,306 **** --- 323,328 ---- this.add(btnNewPC); + + this.add(btnNewPrinter); this.add(btnNewRouter); *************** *** 407,410 **** --- 429,434 ---- btnNewPC.setBackground(deactivatedColor); + + btnNewPrinter.setBackground(deactivatedColor); btnNewRouter.setBackground(deactivatedColor); Index: GuiPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiPC.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GuiPC.java 15 Oct 2007 18:25:54 -0000 1.4 --- GuiPC.java 20 Oct 2007 20:19:46 -0000 1.5 *************** *** 55,59 **** --- 55,64 ---- package guiUI; + import java.awt.Dimension; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; + import javax.swing.JMenuItem; + import javax.swing.JMenu; /** *************** *** 85,93 **** */ public GuiPC(String inName, MainScreen inMainScreen){ ! super(inName, inMainScreen, "images/simulation/mymac.png"); } --- 90,185 ---- */ + + private JMenuItem mnuEchoListen = new JMenuItem("Start udp echo server to listen."); + private JMenuItem mnuEchoSend = new JMenuItem("Send data via udp echo client."); + private JMenuItem mnuEchotcpListen = new JMenuItem("Start tcp echo server to listen."); + private JMenuItem mnuEchotcpSend = new JMenuItem("Send data via tcp echo client."); + private JMenuItem mnuTelnetListen = new JMenuItem("Start telnet server to listen."); + private JMenuItem mnuTelnetNoListen = new JMenuItem("Stop telnet server."); + private JMenuItem mnuTelnetConnect = new JMenuItem("Telnet client."); + private JMenuItem mnuPosixTelnet = new JMenuItem("RFC(line) telnet client."); + private JMenuItem mnuSNMPManager = new JMenuItem("Send SNMP message"); + private JMenuItem mnuDHCPD = new JMenuItem("Start DHCP Server"); public GuiPC(String inName, MainScreen inMainScreen){ ! super(inName, inMainScreen, "images/simulation/mymac.png"); + + mnuEchoListen.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.EchoServerListen(lblNodeName.getText()); + + + } + }); + mnuEchoSend.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.EchoSend(lblNodeName.getText()); + } + }); + + mnuEchotcpListen.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.EchotcpServerListen(lblNodeName.getText()); + + + } + }); + mnuEchotcpSend.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.EchotcpSend(lblNodeName.getText()); + } + }); + + mnuSNMPManager.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.SNMPSendMessage(lblNodeName.getText()); + } + }); + + mnuTelnetListen.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.TelnetListen(lblNodeName.getText()); + } + }); + mnuTelnetNoListen.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.TelnetNoListen(lblNodeName.getText()); + } + }); + mnuTelnetConnect.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.TelnetConnect(lblNodeName.getText()); + } + }); + + mnuPosixTelnet.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.PosixTelnet(lblNodeName.getText()); + } + }); + + mnuDHCPD.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.DHCPD(lblNodeName.getText()); + } + }); + + mnuAppLayer.addSeparator(); + mnuAppLayer.add(mnuEchoListen); + mnuAppLayer.add(mnuEchoSend); + mnuAppLayer.addSeparator(); + mnuAppLayer.add(mnuEchotcpListen); + mnuAppLayer.add(mnuEchotcpSend); + mnuAppLayer.addSeparator(); + mnuAppLayer.add(mnuSNMPManager); + mnuAppLayer.addSeparator(); + mnuAppLayer.add(mnuTelnetListen); + mnuAppLayer.add(mnuTelnetNoListen); + mnuAppLayer.add(mnuTelnetConnect); + mnuAppLayer.add(mnuPosixTelnet); + mnuAppLayer.addSeparator(); + mnuAppLayer.add(mnuDHCPD); } --- NEW FILE: GuiPrinter.java --- package guiUI; public class GuiPrinter extends ApplicationLayerDevice { public GuiPrinter(String inName, MainScreen inMainScreen){ super(inName, inMainScreen, "images/simulation/printer.png"); } } Index: SandBox.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SandBox.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SandBox.java 15 Oct 2007 18:25:54 -0000 1.8 --- SandBox.java 20 Oct 2007 20:19:46 -0000 1.9 *************** *** 55,58 **** --- 55,59 ---- public static final int EXTERNALNAT_CURSOR = 4; public static final int CSUDSU_CURSOR = 5; + public static final int PRINTER_CURSOR = 6; private Cursor csrDefault = new Cursor(Cursor.DEFAULT_CURSOR); *************** *** 84,87 **** --- 85,91 ---- Image csudsuImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/csudsu2.png")); Cursor customCSUDSUCursor = Toolkit.getDefaultToolkit().createCustomCursor(csudsuImage, cursorLocation, "csudsuCursor"); + + Image printerImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/printer.png")); + Cursor customPrinterCursor = Toolkit.getDefaultToolkit().createCustomCursor(printerImage, cursorLocation, "printerCursor"); public SandBox(MainScreen inMainScreen){ *************** *** 216,219 **** --- 220,227 ---- Point NodeLocation = new Point(e.getX(), e.getY()); controller.addCSUDSU(NodeLocation); + }else if(this.getCursor() == customPrinterCursor){ + this.setCursor(csrDefault); + Point NodeLocation = new Point(e.getX(), e.getY()); + controller.addPrinter(NodeLocation); } } *************** *** 240,246 **** this.setCursor(customExternalNATCursor); }else if(cursorType == CSUDSU_CURSOR){ ! this.setCursor(customCSUDSUCursor); ! } ! } --- 248,255 ---- this.setCursor(customExternalNATCursor); }else if(cursorType == CSUDSU_CURSOR){ ! this.setCursor(customCSUDSUCursor); ! }else if(cursorType == PRINTER_CURSOR){ ! this.setCursor(customPrinterCursor); ! } } Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** MainScreen.java 20 Oct 2007 13:27:21 -0000 1.77 --- MainScreen.java 20 Oct 2007 20:19:46 -0000 1.78 *************** *** 739,742 **** --- 739,801 ---- + public void addPrinter(Point inPoint){ + + String result = JOptionPane.showInputDialog(this,"Please enter a Printer name:","Create New Printer", JOptionPane.PLAIN_MESSAGE); + + if(result != null){ + + result = result.trim(); + + if (!result.equalsIgnoreCase("")){ + + try { + + Sim.addPrinter(result, true); + + Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + "0", core.NetworkInterface.Ethernet10T, true); + + GuiPrinter tempPC = new GuiPrinter(result,this); + + tempPC.setNodeLocation(inPoint); + + Sandbox.add(tempPC); + + Sandbox.setLayer(tempPC,3,0); + + GUInodeTable.put(result,tempPC); + + isDirty = true; + + this.setAllHighlightsOff(); + + //pnlConsole.append("Added PC "+result+" to simulation\n"); + + //mConsole.insertRow(mConsole.getRowCount(), new Object[]{"1","2,"3","4"}); + + } catch (InvalidNodeNameException e) { + + JOptionPane.showMessageDialog(this, "Invalid Printer name entered. Node with name: '" + result+"' all ready exist within Simulation","Invalid Pc name", JOptionPane.ERROR_MESSAGE); + + } + + + + }else{ + + JOptionPane.showMessageDialog(this, "Printer name not entered","Printer name not entered",JOptionPane.WARNING_MESSAGE); + + + + } + + + + } + + this.setAllHighlightsOff(); + + this.refreshNodeInformationTab(); + + } /** *************** *** 4351,4357 **** public void RunCmd(String inNodeName){ try{ ! Terminal r = new Terminal(this, (core.NetworkLayerDevice)Sim.getNode(inNodeName)); ! r.pack(); ! r.setVisible(true); } catch(InvalidNodeNameException e) { --- 4410,4420 ---- public void RunCmd(String inNodeName){ try{ ! if(!(Sim.getNode(inNodeName) instanceof core.NetworkLayerDevice) && !(Sim.getNode(inNodeName) instanceof core.Printer)){ ! Terminal r = new Terminal(this, (core.NetworkLayerDevice)Sim.getNode(inNodeName)); ! r.pack(); ! r.setVisible(true); ! }else{ ! JOptionPane.showMessageDialog(this, "Feature isn't supported by this device type!","Error", JOptionPane.ERROR_MESSAGE); ! } } catch(InvalidNodeNameException e) { Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/ApplicationLayerDevice.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ApplicationLayerDevice.java 14 Oct 2007 17:19:07 -0000 1.10 --- ApplicationLayerDevice.java 20 Oct 2007 20:19:46 -0000 1.11 *************** *** 22,39 **** public class ApplicationLayerDevice extends NetworkLayerDevice { - private JMenuItem mnuEchoListen = new JMenuItem("Start udp echo server to listen."); - private JMenuItem mnuEchoSend = new JMenuItem("Send data via udp echo client."); - private JMenuItem mnuEchotcpListen = new JMenuItem("Start tcp echo server to listen."); - private JMenuItem mnuEchotcpSend = new JMenuItem("Send data via tcp echo client."); - private JMenuItem mnuTelnetListen = new JMenuItem("Start telnet server to listen."); - private JMenuItem mnuTelnetNoListen = new JMenuItem("Stop telnet server."); - private JMenuItem mnuTelnetConnect = new JMenuItem("Telnet client."); - private JMenuItem mnuPosixTelnet = new JMenuItem("RFC(line) telnet client."); protected JMenu mnuAppLayer = new JMenu("Applications"); private JMenuItem mnuSNMPStartAgent = new JMenuItem("Start SNMP agent"); private JMenuItem mnuSNMPStopAgent = new JMenuItem("Stop SNMP agent"); ! private JMenuItem mnuSNMPManager = new JMenuItem("Send SNMP message"); ! private JMenuItem mnuDHCPD = new JMenuItem("Start DHCP Server"); ! private JMenuItem mnuDHCPC = new JMenuItem("Run DHCP Client"); /** Creates a new instance of ApplicationLayerDevice */ --- 22,35 ---- public class ApplicationLayerDevice extends NetworkLayerDevice { protected JMenu mnuAppLayer = new JMenu("Applications"); + + private JMenuItem mnuDHCPC = new JMenuItem("Run DHCP Client"); + private JMenuItem mnuSNMPStartAgent = new JMenuItem("Start SNMP agent"); private JMenuItem mnuSNMPStopAgent = new JMenuItem("Stop SNMP agent"); ! ! ! ! /** Creates a new instance of ApplicationLayerDevice */ *************** *** 41,78 **** super(inName, inMainScreen, imageLocation); - - - mnuEchoListen.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - controller.EchoServerListen(lblNodeName.getText()); - - - } - }); - mnuEchoSend.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - controller.EchoSend(lblNodeName.getText()); - } - }); - - mnuEchotcpListen.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - controller.EchotcpServerListen(lblNodeName.getText()); - - - } - }); - mnuEchotcpSend.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - controller.EchotcpSend(lblNodeName.getText()); - } - }); - GuiNodePopMenu.add(mnuAppLayer); ! mnuAppLayer.add(mnuEchoListen); ! mnuAppLayer.add(mnuEchoSend); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuEchotcpListen); ! mnuAppLayer.add(mnuEchotcpSend); mnuSNMPStartAgent.addActionListener(new ActionListener(){ --- 37,43 ---- super(inName, inMainScreen, imageLocation); GuiNodePopMenu.add(mnuAppLayer); ! ! mnuSNMPStartAgent.addActionListener(new ActionListener(){ *************** *** 86,122 **** } }); ! mnuSNMPManager.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.SNMPSendMessage(lblNodeName.getText()); ! } ! }); ! ! mnuTelnetListen.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.TelnetListen(lblNodeName.getText()); ! } ! }); ! mnuTelnetNoListen.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.TelnetNoListen(lblNodeName.getText()); ! } ! }); ! mnuTelnetConnect.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.TelnetConnect(lblNodeName.getText()); ! } ! }); ! ! mnuPosixTelnet.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.PosixTelnet(lblNodeName.getText()); ! } ! }); ! ! mnuDHCPD.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.DHCPD(lblNodeName.getText()); ! } ! }); mnuDHCPC.addActionListener(new ActionListener(){ --- 51,55 ---- } }); ! mnuDHCPC.addActionListener(new ActionListener(){ *************** *** 126,142 **** }); - mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuSNMPStartAgent); mnuAppLayer.add(mnuSNMPStopAgent); ! mnuAppLayer.add(mnuSNMPManager); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuTelnetListen); ! mnuAppLayer.add(mnuTelnetNoListen); ! mnuAppLayer.add(mnuTelnetConnect); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuPosixTelnet); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuDHCPC); ! mnuAppLayer.add(mnuDHCPD); } } --- 59,66 ---- }); mnuAppLayer.add(mnuSNMPStartAgent); mnuAppLayer.add(mnuSNMPStopAgent); ! mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuDHCPC); } } |
From: Alexander B. <da...@us...> - 2007-10-20 20:19:50
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9138 Modified Files: TODO.txt Log Message: Added network printers. Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** TODO.txt 19 Oct 2007 15:57:00 -0000 1.26 --- TODO.txt 20 Oct 2007 20:19:46 -0000 1.27 *************** *** 4,13 **** *** Whole Project ! 2. Add (TCP sockets, RMI and Corba mechanisms) to CSU/DSU units + TCP packets transport ! 3. DHCP server/clients : retrying/repeating transactions, re-leasing. 4. Socks Proxy(old -- Nat Gateway) to external network. ! 5. Network Printers ! 6. Repeaters ! 7. Ethernet fiber Lines and converters 8. Firewalls (NAT, PAT, etc) 9. Second level Switches (VLAN, etc...) --- 4,11 ---- *** Whole Project ! 2. Add (UDP sockets, RMI and Corba mechanisms) to CSU/DSU units ! 3. DHCP server/clients : re-leasing, MAC-filter and excludes. 4. Socks Proxy(old -- Nat Gateway) to external network. ! 6. Repeaters and Ethernet fiber converters 8. Firewalls (NAT, PAT, etc) 9. Second level Switches (VLAN, etc...) *************** *** 15,18 **** --- 13,17 ---- 11. DNS server/clents. 12. Wi-Fi Access-Points and Wi-Fi adapters in PCs + 13. TokenRing *** Documentation/Comments |
From: Alexander B. <da...@us...> - 2007-10-20 20:19:50
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9138/core Modified Files: Simulation.java Added Files: Printer.java Log Message: Added network printers. Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Simulation.java 20 Oct 2007 13:27:20 -0000 1.24 --- Simulation.java 20 Oct 2007 20:19:46 -0000 1.25 *************** *** 1032,1035 **** --- 1032,1044 ---- } + public void addPrinter(String inPCName, boolean inOn) throws InvalidNodeNameException { + if (!nodeTable.containsKey(inPCName)) { + nodeTable.put(inPCName, new Printer(inPCName, inOn)); + } else { + throw new InvalidNodeNameException("Node already exists with same name"); + } + return; + } + /** * This method will check to see if the hub name is contained within the --- NEW FILE: Printer.java --- package core; import core.protocolsuite.tcp_ip.DHCPC; import core.protocolsuite.tcp_ip.SNMP; public class Printer extends ApplicationLayerDevice { public final static int SNMP_AGENT_ID = 161; public final static int SNMP_MANAGER_ID = 30161; public final static int DHCP_SERVER_ID = 67; public final static int DHCP_CLIENT_ID = 68; /** * Constructs a PC with the specified name. * @author tristan_veness * @param inName - A name to give the new PC Node. eg: PC1 * @version v0.10 */ protected Printer(String inName, boolean inOn) { super(inName,7, inOn); } public void initApplications(){ super.initApplications(); SNMP snmpAgent = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, 161, 0, core.ProtocolStack.UIDGen++); DHCPC dhcpc = new DHCPC(NodeProtocolStack, core.ProtocolStack.UIDGen++); addApp(snmpAgent, SNMP_AGENT_ID); addApp(dhcpc, DHCP_CLIENT_ID); } }//EOF |
From: Alexander B. <da...@us...> - 2007-10-20 20:19:50
|
Update of /cvsroot/javanetsim/javaNetSim/images/simulation In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9138/images/simulation Modified Files: csudsu2.png Added Files: printer.png printer_small.png Log Message: Added network printers. --- NEW FILE: printer.png --- (This appears to be a binary file; contents omitted.) Index: csudsu2.png =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/images/simulation/csudsu2.png,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsGKb1Bf and /tmp/cvsMqeVfI differ --- NEW FILE: printer_small.png --- (This appears to be a binary file; contents omitted.) |
From: Alexander B. <da...@us...> - 2007-10-20 13:27:27
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv20961/core/protocolsuite/tcp_ip Modified Files: Application.java DHCPC.java DHCPD.java Echo.java Echo_tcp.java ExternalProxyApp.java PosixTelnetClient.java SNMP.java TCP_packet.java Telnet_client.java Telnet_server.java Log Message: Node timers; DHCPC resendings; TCP to bytes packing. Index: TCP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/TCP_packet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TCP_packet.java 25 Sep 2007 22:34:09 -0000 1.5 --- TCP_packet.java 20 Oct 2007 13:27:21 -0000 1.6 *************** *** 420,424 **** return ( sequence_number - ((TCP_packet)o).sequence_number ); } ! }//EOF --- 420,463 ---- return ( sequence_number - ((TCP_packet)o).sequence_number ); } ! ! public String toBytes(){ ! return RawtoBytes() + IPtoBytes() + TCPtoBytes(); ! } ! ! public void fromBytes(String str){ ! RawfromBytes(str); ! IPfromBytes(str); ! TCPfromBytes(str); ! } ! ! public String TCPtoBytes(){ ! return "T|" + TCP_MessageLength + "|" + TCP_message + "|" + TCP_srcPort + "|" + TCP_destPort + "|" ! + TCP_window + "|" + get_acknowledgment_number() + "|" + get_sequence_number() + "|" ! + get_ACK_flag() + "|" + get_FIN_flag() + "|" + get_PSH_flag() + "|" + get_RST_flag() + "|" ! + get_SYN_flag() + "|" + get_URG_flag() + "|#"; ! } ! ! public void TCPfromBytes(String str){ ! String icmp = str.replaceAll(".*#T\\|", ""); ! ! System.out.println(icmp); ! ! String[] fields = icmp.split("\\|"); ! ! TCP_MessageLength = Integer.valueOf(fields[0]); ! TCP_message = fields[1]; ! TCP_srcPort = Integer.valueOf(fields[2]); ! TCP_destPort = Integer.valueOf(fields[3]); ! TCP_window = Integer.valueOf(fields[4]); ! set_acknowledgment_number(Integer.valueOf(fields[5])); ! set_sequence_number(Integer.valueOf(fields[6])); ! set_ACK_flag(Boolean.valueOf(fields[7])); ! set_FIN_flag(Boolean.valueOf(fields[8])); ! set_PSH_flag(Boolean.valueOf(fields[9])); ! set_RST_flag(Boolean.valueOf(fields[10])); ! set_SYN_flag(Boolean.valueOf(fields[11])); ! set_URG_flag(Boolean.valueOf(fields[12])); ! } ! }//EOF Index: Telnet_client.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_client.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Telnet_client.java 1 Oct 2007 04:58:12 -0000 1.15 --- Telnet_client.java 20 Oct 2007 13:27:21 -0000 1.16 *************** *** 36,39 **** --- 36,41 ---- appSock = mParentStack.SL().socket(jnSocket.TCP_socket, this); } + + public void Timer(int code){ } /** Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Telnet_server.java 15 Oct 2007 21:41:43 -0000 1.19 --- Telnet_server.java 20 Oct 2007 13:27:21 -0000 1.20 *************** *** 41,44 **** --- 41,46 ---- appSock = mParentStack.SL().socket(jnSocket.TCP_socket, this); } + + public void Timer(int code){ } /** Index: PosixTelnetClient.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/PosixTelnetClient.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PosixTelnetClient.java 1 Oct 2007 04:58:12 -0000 1.6 --- PosixTelnetClient.java 20 Oct 2007 13:27:21 -0000 1.7 *************** *** 26,29 **** --- 26,31 ---- appSock = mParentStack.SL().socket(jnSocket.TCP_socket, this); } + + public void Timer(int code){ } /** Index: DHCPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPC.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DHCPC.java 14 Oct 2007 17:19:07 -0000 1.2 --- DHCPC.java 20 Oct 2007 13:27:20 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- import core.LayerInfo; import core.Simulation; + import javax.lang.model.util.SimpleAnnotationValueVisitor6; /** *************** *** 26,29 **** --- 27,33 ---- int leaseTime; + String resend; + int resendings; + /** Creates a new instance of DHCPC */ *************** *** 33,36 **** --- 37,62 ---- running = false; completed = false; + resend = ""; + resendings = 0; + } + + public void Timer(int code){ + if(running){ + if(!completed){ + if(resend != "" && resendings++ < 5){ + LayerInfo protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP client"); + protInfo.setLayer("Application "); + protInfo.setDescription("Resening DHCP packet to 255.255.255.255 due to timer."); + Simulation.addLayerInfo(protInfo); + try{ + SendData(appSock, "255.255.255.255", 67, resend); + }catch(Exception e){} + } + }else{ + //re-lease + } + } } *************** *** 73,76 **** --- 99,103 ---- public void Free() throws TransportLayerException { + mParentStack.getParentNode().cancelTimerTask(this); printLayerInfo("DHCP Client", "DHCP Client application freed socket."); mParentStack.SL().free(appSock); *************** *** 174,179 **** r.chaddr + "' DHCP Server='" + r.DHCPServer + "' preferred IP='" + r.WantedIP + "'."); Simulation.addLayerInfo(protInfo); try{ ! SendData(appSock, "255.255.255.255", 67, r.toBytes()); }catch(CommunicationException e){ throw new TransportLayerException(e.toString()); --- 201,209 ---- r.chaddr + "' DHCP Server='" + r.DHCPServer + "' preferred IP='" + r.WantedIP + "'."); Simulation.addLayerInfo(protInfo); + + resend = r.toBytes(); + try{ ! SendData(appSock, "255.255.255.255", 67, resend); }catch(CommunicationException e){ throw new TransportLayerException(e.toString()); *************** *** 202,205 **** --- 232,238 ---- Simulation.addLayerInfo(protInfo); + resend = ""; + resendings = 0; + try{ mParentStack.setIPAddress(iface, p.yiaddr ); *************** *** 259,262 **** --- 292,298 ---- String Data = d.toBytes(); + resend = Data; + resendings = 0; + LayerInfo protInfo = new LayerInfo(getClass().getName()); protInfo.setObjectName(mParentStack.getParentNodeName()); *************** *** 274,277 **** --- 310,315 ---- Simulation.addLayerInfo(protInfo); + mParentStack.getParentNode().startTimerTask(this, 5000); + SendData(appSock, "255.255.255.255", 67, Data); } Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Echo_tcp.java 15 Oct 2007 12:04:33 -0000 1.39 --- Echo_tcp.java 20 Oct 2007 13:27:20 -0000 1.40 *************** *** 40,43 **** --- 40,45 ---- } + public void Timer(int code){ } + /** * This method start to listen on application port Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Echo.java 19 Oct 2007 08:52:26 -0000 1.30 --- Echo.java 20 Oct 2007 13:27:20 -0000 1.31 *************** *** 26,32 **** public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); ! appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); int fake = 0; } /** --- 26,34 ---- public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); ! appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); int fake = 0; } + + public void Timer(int code){ } /** Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Application.java 13 Oct 2007 12:57:00 -0000 1.24 --- Application.java 20 Oct 2007 13:27:20 -0000 1.25 *************** *** 17,21 **** * @author key */ ! public abstract class Application { protected String protocolName; --- 17,21 ---- * @author key */ ! public abstract class Application extends core.TimerApp{ protected String protocolName; *************** *** 25,41 **** protected int appType; ! protected int appSock; - protected int UID; /** Creates a new instance of ApplicationProtocol */ public Application(ProtocolStack inParentStack, int listenPort, int appType, int UID){ this.listenPort = listenPort; this.mParentStack = inParentStack; ! this.appType = appType; ! this.UID = UID; } - /** * This method start to listen on application port --- 25,39 ---- protected int appType; ! protected int appSock; /** Creates a new instance of ApplicationProtocol */ public Application(ProtocolStack inParentStack, int listenPort, int appType, int UID){ + super(UID); this.listenPort = listenPort; this.mParentStack = inParentStack; ! this.appType = appType; } /** * This method start to listen on application port *************** *** 120,127 **** } - public int getUID(){ - return this.UID; - } - protected void printLayerInfo(String DataType, String s) { LayerInfo protInfo = new LayerInfo(getClass().getName()); --- 118,121 ---- Index: ExternalProxyApp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ExternalProxyApp.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ExternalProxyApp.java 15 Oct 2007 12:04:33 -0000 1.7 --- ExternalProxyApp.java 20 Oct 2007 13:27:20 -0000 1.8 *************** *** 71,74 **** --- 71,76 ---- System.out.println("NAT step 1.5"); } + + public void Timer(int code){ } /** Index: DHCPD.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPD.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DHCPD.java 15 Oct 2007 12:04:33 -0000 1.3 --- DHCPD.java 20 Oct 2007 13:27:20 -0000 1.4 *************** *** 63,67 **** appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); } ! /** * This method start to listen on application port --- 63,69 ---- appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); } ! ! public void Timer(int code){ } ! /** * This method start to listen on application port Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** SNMP.java 15 Oct 2007 21:41:42 -0000 1.25 --- SNMP.java 20 Oct 2007 13:27:21 -0000 1.26 *************** *** 132,135 **** --- 132,138 ---- appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); } + + public void Timer(int code){ } + /** * This method start to listen on application port |
From: Alexander B. <da...@us...> - 2007-10-20 13:27:25
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv20961/guiUI Modified Files: MainScreen.java Log Message: Node timers; DHCPC resendings; TCP to bytes packing. Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** MainScreen.java 19 Oct 2007 19:38:06 -0000 1.76 --- MainScreen.java 20 Oct 2007 13:27:21 -0000 1.77 *************** *** 2115,2119 **** strSave += "|#"; }else{ ! strSave += "|" + Sim.getMacAddressForInterface(key, nics[i].toString()); } break; --- 2115,2119 ---- strSave += "|#"; }else{ ! strSave += "|" + ((core.EthernetNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).defaultMACAddress; } break; *************** *** 2378,2383 **** Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Ethernet100FX, true); try{ ! //FIXME!!!!!!! ! Sim.setMACAddress(strNodeName,iface[0], iface[4]); }catch(Exception e){ } }else{ --- 2378,2382 ---- Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Ethernet100FX, true); try{ ! ((core.EthernetNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).defaultMACAddress = iface[4]; }catch(Exception e){ } }else{ *************** *** 2390,2394 **** try{ //FIXME!!!!!!! ! Sim.setMACAddress(strNodeName,iface[0], iface[4]); }catch(Exception e){ } }else{ --- 2389,2393 ---- try{ //FIXME!!!!!!! ! ((core.EthernetNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).defaultMACAddress = iface[4]; }catch(Exception e){ } }else{ *************** *** 2403,2407 **** Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Serial, true); } ! ((core.SerialNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setClockRate(Integer.valueOf(iface[4])); break; --- 2402,2406 ---- Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Serial, true); } ! ((core.SerialNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setClockRate(Integer.valueOf(iface[4])); break; *************** *** 2764,2768 **** try{ ! Sim.setMACAddress(strNodeName,iface[0], iface[5]); sieve = iface[6]; --- 2763,2768 ---- try{ ! ((core.EthernetNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).defaultMACAddress = iface[5]; ! //Sim.setMACAddress(strNodeName,iface[0], iface[5]); sieve = iface[6]; *************** *** 3708,3712 **** GUInodeTable.clear(); ! Sim.removeAllObjects(); Sim = null; --- 3708,3712 ---- GUInodeTable.clear(); ! Sim.removeAllObjects(); Sim = null; |
From: Alexander B. <da...@us...> - 2007-10-20 13:27:25
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv20961/core Modified Files: EthernetNetworkInterface.java FiberEthernetNetworkInterface.java Node.java Simulation.java WANSocket.java Added Files: TimerApp.java Log Message: Node timers; DHCPC resendings; TCP to bytes packing. Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Node.java 19 Oct 2007 17:40:33 -0000 1.17 --- Node.java 20 Oct 2007 13:27:20 -0000 1.18 *************** *** 132,135 **** --- 132,203 ---- + class app_timer_task{ + core.TimerApp app; + int interval; + long lastcall; + Node n; + + public app_timer_task(Node inN, core.TimerApp inApp, int inInterval){ + interval = inInterval; + app = inApp; + n = inN; + } + + public void call(){ + try{ + if(n.On){ + if(System.currentTimeMillis() >= (lastcall+interval) ){ + lastcall = System.currentTimeMillis(); + app.Timer(0); + } + } + }catch(Exception e){ + + } + } + + } + + public class AppTasks extends TimerTask + { + private java.util.Hashtable timerTable; + + public AppTasks(java.util.Hashtable inTimerTable) + { + this.timerTable=inTimerTable; + + } + + + public void run() + { + java.util.Enumeration e = timerTable.keys(); + + for(;e.hasMoreElements();){ + Integer i = (Integer)e.nextElement(); + ((app_timer_task)timerTable.get(i)).call(); + } + } + } + + private java.util.Hashtable timerTable = null; + Timer appTimer = null; + + public void startTimerTask(core.TimerApp app, int interval){ + timerTable.put(Integer.valueOf(app.getUID()), new app_timer_task(this, app, interval)); + } + + public void cancelTimerTask(core.TimerApp app){ + if(timerTable.get(app.getUID())!=null){ + timerTable.remove(app.getUID()); + } + } + + public void stopTimers(){ + if(appTimer!=null){ + appTimer.cancel(); + } + appTimer = null; + } /** *************** *** 162,166 **** this.On = inOn; ! } --- 230,237 ---- this.On = inOn; ! ! timerTable = new Hashtable(); ! appTimer=new Timer(); ! appTimer.schedule(new AppTasks(timerTable),500,500); } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Simulation.java 19 Oct 2007 17:40:33 -0000 1.23 --- Simulation.java 20 Oct 2007 13:27:20 -0000 1.24 *************** *** 121,126 **** private static LayerInfoHandler Info = new LayerInfoHandler(); private static int PROTOCOL_TYPE; ! ! // A script is just a Vector containing Strings right now // Each String being a representation of a method to be run such as sendAppData() --- 121,125 ---- private static LayerInfoHandler Info = new LayerInfoHandler(); private static int PROTOCOL_TYPE; ! // A script is just a Vector containing Strings right now // Each String being a representation of a method to be run such as sendAppData() *************** *** 892,895 **** --- 891,901 ---- **/ public void removeAllObjects(){ + Enumeration e = nodeTable.elements(); + while(e.hasMoreElements()) + { + Node temp = (Node)e.nextElement(); + temp.stopTimers(); + } + // nodeTable.clear(); linkTable.clear(); *************** *** 908,911 **** --- 914,918 ---- Node deletedNode = (Node) nodeTable.get(inNodeName); + deletedNode.stopTimers(); deletedNode.removeAllLinks(); nodeTable.remove(inNodeName); //remove node from hashtable Index: WANSocket.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANSocket.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WANSocket.java 15 Oct 2007 18:25:54 -0000 1.2 --- WANSocket.java 20 Oct 2007 13:27:20 -0000 1.3 *************** *** 118,121 **** --- 118,124 ---- break; case 'T': + TCP_packet tcp = new TCP_packet("","",0,0); + tcp.fromBytes(inPacket); + parentInterface.receivePacket(tcp); break; case 'U': Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EthernetNetworkInterface.java 18 Oct 2007 22:22:09 -0000 1.9 --- EthernetNetworkInterface.java 20 Oct 2007 13:27:20 -0000 1.10 *************** *** 52,61 **** */ ! class EthernetNetworkInterface extends NetworkInterface{ /** * Stores The MAC address for each instance of this class * */ protected String MACAddress; ! protected String defaultMACAddress; /** --- 52,61 ---- */ ! public class EthernetNetworkInterface extends NetworkInterface{ /** * Stores The MAC address for each instance of this class * */ protected String MACAddress; ! public String defaultMACAddress; /** --- NEW FILE: TimerApp.java --- package core; /** * * @author key */ public abstract class TimerApp { protected int UID; public TimerApp(int UID){ this.UID = UID; } public int getUID(){ return this.UID; } public abstract void Timer(int code); } Index: FiberEthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/FiberEthernetNetworkInterface.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FiberEthernetNetworkInterface.java 19 Oct 2007 15:57:01 -0000 1.1 --- FiberEthernetNetworkInterface.java 20 Oct 2007 13:27:20 -0000 1.2 *************** *** 2,6 **** ! class FiberEthernetNetworkInterface extends EthernetNetworkInterface{ protected FiberEthernetNetworkInterface(String inName, Node parent) { --- 2,6 ---- ! public class FiberEthernetNetworkInterface extends EthernetNetworkInterface{ protected FiberEthernetNetworkInterface(String inName, Node parent) { |
From: Alexander B. <da...@us...> - 2007-10-19 19:38:11
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21162/guiUI Modified Files: MainScreen.java SerPortProperties.java Added Files: WANPortProperties.java Log Message: Added WAN NIC properties dialog. --- NEW FILE: WANPortProperties.java --- /* Java Network Simulator (javaNetSim) Copyright (c) 2007, 2006, 2005, Ice Team; All rights reserved. Copyright (c) 2004, jFirewallSim development team; All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Canberra Institute of Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package guiUI; import core.InvalidLinkNameException; import core.InvalidNetworkInterfaceNameException; import core.InvalidNodeNameException; import core.Node; import core.NetworkLayerDevice; import core.WANNetworkInterface; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.GridBagLayout; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JCheckBox; import javax.swing.JOptionPane; import java.awt.Insets; import java.awt.GridBagConstraints; import java.awt.BorderLayout; import javax.swing.JButton; import java.awt.Dimension; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JComboBox; import core.Simulation; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.Color; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.util.Arrays; import java.awt.Component; import javax.swing.SwingConstants; /** * * @author Key * * This class is a dialog that shows Serernet Port Props * */ public class WANPortProperties extends javax.swing.JDialog { private JPanel backpanel; private JLabel lblInterface, cmbInterface; private JLabel lblNodeName, cmbNodeName; private JLabel lblError; private JButton btnOk; private JLabel lblType; private JComboBox cmbType; private JLabel lblRole; private JComboBox cmbRole; private JLabel lblHost; private JTextField txtHost; private JLabel lblPort; private JTextField txtPort; private JLabel lblService; private JTextField txtService; private JLabel lblUP; private JCheckBox chkUP; private MainScreen controller; private Simulation Sim; private SandBox SBox; private String NodeName=""; private String NodeInt=""; private WANNetworkInterface wan; private boolean ErrorFlag = true; public WANPortProperties(JFrame frame, String inNodeName, String inNodeInt, Simulation Sim, SandBox SBox) { super(frame); this.NodeName = inNodeName; this.NodeInt = inNodeInt; try{ wan = (WANNetworkInterface)Sim.getNode(inNodeName).getNIC(inNodeInt); }catch(Exception e){ e.printStackTrace(); } setResizable(false); controller = (MainScreen)frame; this.Sim = Sim; this.SBox = SBox; setTitle("WAN Port Properties"); initGUI(inNodeName, inNodeInt); final JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.SOUTH); btnOk = new JButton(); btnOk.setEnabled(true); btnOk.setToolTipText("Set options!"); btnOk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButton(); } }); btnOk.setName("btnOK"); panel.add(btnOk); btnOk.setText("OK"); final JButton btnCancel = new JButton(); btnCancel.setToolTipText("Cancel changes"); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancelButton(); } }); btnCancel.setName("btnCancel"); panel.add(btnCancel); btnCancel.setText("Cancel"); this.pack(); this.getRootPane().setDefaultButton(btnOk); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); this.setModal(true); this.setVisible(true); } private void initGUI(String NodeName, String NodeInt) { try { setSize(350, 325); { backpanel = new JPanel(); backpanel.setMinimumSize(new Dimension(200, 10)); this.getContentPane().add(backpanel, BorderLayout.CENTER); GridBagLayout backpanelLayout = new GridBagLayout(); backpanel.setPreferredSize(new java.awt.Dimension(264, 213)); backpanelLayout.columnWeights = new double[] {}; backpanelLayout.columnWidths = new int[] {}; backpanelLayout.rowWeights = new double[] {0.0}; backpanelLayout.rowHeights = new int[] {5,5,5,5}; backpanel.setLayout(backpanelLayout); { lblNodeName = new JLabel(); backpanel.add(lblNodeName, new GridBagConstraints( 0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 21, 0)); lblNodeName.setText("Node Name:"); } { lblInterface = new JLabel(); backpanel.add(lblInterface, new GridBagConstraints( 0, 1, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 27), 0, 0)); lblInterface.setText("Interface:"); } { lblType = new JLabel(); backpanel.add(lblType, new GridBagConstraints( 0, 2, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblType.setText("Connection type:"); } { lblRole = new JLabel(); backpanel.add(lblRole, new GridBagConstraints( 0, 3, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblRole.setText("Connection role:"); } { lblHost = new JLabel(); backpanel.add(lblHost, new GridBagConstraints( 0, 4, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblHost.setText("Host/URL:"); } { lblPort = new JLabel(); backpanel.add(lblPort, new GridBagConstraints( 0, 5, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblPort.setText("Port:"); } { lblService = new JLabel(); backpanel.add(lblService, new GridBagConstraints( 0, 6, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblService.setText("Service:"); } { lblUP = new JLabel(); backpanel.add(lblUP, new GridBagConstraints( 0, 7, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblUP.setText("Administratively UP:"); } { cmbNodeName = new JLabel(); cmbNodeName.setMinimumSize(new Dimension(100, 0)); cmbNodeName.setText(NodeName); final GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.LINE_START; gridBagConstraints.gridy = 0; gridBagConstraints.gridx = 1; backpanel.add(cmbNodeName, gridBagConstraints); } { cmbInterface = new JLabel(); cmbInterface.setText(NodeInt); final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints(); gridBagConstraints_1.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_1.anchor = GridBagConstraints.LINE_START; gridBagConstraints_1.gridy = 1; gridBagConstraints_1.gridx = 1; backpanel.add(cmbInterface, gridBagConstraints_1); } cmbType = new JComboBox(); cmbType.setEnabled(true); final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints(); gridBagConstraints_3.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_3.anchor = GridBagConstraints.LINE_START; gridBagConstraints_3.gridy = 2; gridBagConstraints_3.gridx = 1; backpanel.add(cmbType, gridBagConstraints_3); cmbType.addItem("TCP Socket"); cmbType.addItem("UDP Socket"); cmbType.addItem("RMI"); cmbType.addItem("CORBA"); int sel = wan.getConnType() - 1; if(sel<0) sel = 0; cmbType.setSelectedIndex( sel ); cmbRole = new JComboBox(); /*cmbRole.addFocusListener(new FocusAdapter() { public void actionPerformed(ActionEvent e) { //lblError.setVisible(false); } });*/ cmbRole.setEnabled(true); final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints(); gridBagConstraints_4.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_4.anchor = GridBagConstraints.LINE_START; gridBagConstraints_4.gridy = 3; gridBagConstraints_4.gridx = 1; backpanel.add(cmbRole, gridBagConstraints_4); cmbRole.addItem("Client"); cmbRole.addItem("Server"); if(wan.getServer()){ cmbRole.setSelectedIndex(1); }else{ cmbRole.setSelectedIndex(0); } txtHost = new JTextField(); txtHost.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { lblError.setVisible(false); } }); txtHost.setEnabled(true); final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints(); gridBagConstraints_5.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_5.anchor = GridBagConstraints.LINE_START; gridBagConstraints_5.gridy = 4; gridBagConstraints_5.gridx = 1; backpanel.add(txtHost, gridBagConstraints_5); txtHost.setText(wan.getConnHost()); txtPort = new JTextField(); txtPort.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { lblError.setVisible(false); } }); txtPort.setEnabled(true); final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints(); gridBagConstraints_6.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_6.anchor = GridBagConstraints.LINE_START; gridBagConstraints_6.gridy = 5; gridBagConstraints_6.gridx = 1; backpanel.add(txtPort, gridBagConstraints_6); txtPort.setText(String.valueOf(wan.getConnPort())); txtService = new JTextField(); txtService.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { lblError.setVisible(false); } }); txtService.setEnabled(true); final GridBagConstraints gridBagConstraints_7 = new GridBagConstraints(); gridBagConstraints_7.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_7.anchor = GridBagConstraints.LINE_START; gridBagConstraints_7.gridy = 6; gridBagConstraints_7.gridx = 1; backpanel.add(txtService, gridBagConstraints_7); txtService.setText(wan.getConnService()); chkUP = new JCheckBox(); chkUP.setEnabled(true); final GridBagConstraints gridBagConstraints_8 = new GridBagConstraints(); gridBagConstraints_8.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_8.anchor = GridBagConstraints.LINE_START; gridBagConstraints_8.gridy = 7; gridBagConstraints_8.gridx = 1; backpanel.add(chkUP, gridBagConstraints_8); chkUP.setSelected(Sim.getNode(NodeName).getNIC(NodeInt).isUP()); lblError = new JLabel(); lblError.setHorizontalTextPosition(SwingConstants.CENTER); lblError.setHorizontalAlignment(SwingConstants.CENTER); lblError.setAlignmentX(Component.CENTER_ALIGNMENT); lblError.setMinimumSize(new Dimension(100, 20)); lblError.setMaximumSize(new Dimension(100, 20)); lblError.setPreferredSize(new Dimension(100, 20)); lblError.setVisible(false); final GridBagConstraints gridBagConstraints_9 = new GridBagConstraints(); gridBagConstraints_9.anchor = GridBagConstraints.WEST; gridBagConstraints_9.insets = new Insets(0, 1, 0, 0); gridBagConstraints_9.fill = GridBagConstraints.BOTH; gridBagConstraints_9.gridwidth = 2; gridBagConstraints_9.gridy = 5; gridBagConstraints_9.gridx = 0; backpanel.add(lblError, gridBagConstraints_9); lblError.setText("Invalid MAC!"); cmbType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectWANType(); lblError.setVisible(false); } }); selectWANType(); } } catch (Exception e) { e.printStackTrace(); } } private void selectWANType(){ switch(cmbType.getSelectedIndex() + 1){ case WANNetworkInterface.SocketTCP: case WANNetworkInterface.SocketUDP: cmbRole.setEnabled(true); txtHost.setEnabled(true); txtPort.setEnabled(true); txtService.setEnabled(false); txtService.setText(""); break; case WANNetworkInterface.RMI: cmbRole.setEnabled(false); txtHost.setEnabled(true); txtPort.setEnabled(true); txtPort.setText(""); txtService.setEnabled(true); break; case WANNetworkInterface.Corba: cmbRole.setEnabled(false); txtHost.setEnabled(true); txtPort.setEnabled(true); txtPort.setText(""); txtService.setEnabled(true); break; } } /** * This is executed when the user hit's the enter button. * @author Key * */ private void okButton(){ try { switch(cmbType.getSelectedIndex() + 1){ case WANNetworkInterface.SocketTCP: case WANNetworkInterface.SocketUDP: if(!txtPort.getText().matches("[0-9]+")){ JOptionPane.showMessageDialog(this,"Invalid Port", "Error!", JOptionPane.ERROR_MESSAGE); return; } wan.setConnType(cmbType.getSelectedIndex() + 1); wan.setConnHost(txtHost.getText()); wan.setConnPort(Integer.valueOf(txtPort.getText())); wan.setServer( cmbRole.getSelectedIndex() == 1 ); break; case WANNetworkInterface.RMI: case WANNetworkInterface.Corba: wan.setConnType(cmbType.getSelectedIndex() + 1); wan.setConnHost(txtHost.getText()); wan.setConnService(txtService.getText()); break; } if(wan.isUP()) wan.DOWN(); if(chkUP.isSelected()){ wan.UP(); } this.dispose(); } catch (Exception e) { e.printStackTrace(); } } /** * This is executed when the user hits the cancel button * @author Key * */ private void cancelButton(){ this.dispose(); } } Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** MainScreen.java 19 Oct 2007 17:40:33 -0000 1.75 --- MainScreen.java 19 Oct 2007 19:38:06 -0000 1.76 *************** *** 2413,2416 **** --- 2413,2421 ---- Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.WAN, false); ((core.CSUDSU)Sim.getNode(strNodeName)).setWAN(iface[0]); + ((core.WANNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setConnType(Integer.valueOf(iface[4])); + ((core.WANNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setServer(Boolean.valueOf(iface[5])); + ((core.WANNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setConnHost(iface[6]); + ((core.WANNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setConnPort(Integer.valueOf(iface[7])); + if(iface.length > 8) ((core.WANNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setConnService(iface[8]); break; } *************** *** 4478,4482 **** break; case core.NetworkInterface.WAN: ! String service = JOptionPane.showInputDialog(this, "Sevice name", "Service name.", JOptionPane.QUESTION_MESSAGE); if(service == null || service == "" || service.length() < 3){ ((core.WANNetworkInterface)(temp.getNIC(IntName))).setServer(true); --- 4483,4487 ---- break; case core.NetworkInterface.WAN: ! /*String service = JOptionPane.showInputDialog(this, "Sevice name", "Service name.", JOptionPane.QUESTION_MESSAGE); if(service == null || service == "" || service.length() < 3){ ((core.WANNetworkInterface)(temp.getNIC(IntName))).setServer(true); *************** *** 4485,4489 **** } ! ((core.WANNetworkInterface)(temp.getNIC(IntName))).UP(); break; default: --- 4490,4495 ---- } ! ((core.WANNetworkInterface)(temp.getNIC(IntName))).UP(); */ ! new WANPortProperties(this, NodeName, IntName, Sim, Sandbox); break; default: Index: SerPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SerPortProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SerPortProperties.java 19 Oct 2007 15:57:01 -0000 1.1 --- SerPortProperties.java 19 Oct 2007 19:38:06 -0000 1.2 *************** *** 102,106 **** this.Sim = Sim; this.SBox = SBox; ! setTitle("Serernet Port Properties"); initGUI(inNodeName, inNodeInt); --- 102,106 ---- this.Sim = Sim; this.SBox = SBox; ! setTitle("WAN Port Properties"); initGUI(inNodeName, inNodeInt); |
From: Alexander B. <da...@us...> - 2007-10-19 19:38:09
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21162/core Modified Files: README.txt WANNetworkInterface.java Log Message: Added WAN NIC properties dialog. Index: WANNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANNetworkInterface.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WANNetworkInterface.java 19 Oct 2007 08:52:26 -0000 1.3 --- WANNetworkInterface.java 19 Oct 2007 19:38:06 -0000 1.4 *************** *** 116,123 **** //temp debug values ! Host = "127.0.0.1"; ! port = 18008; ! type = this.SocketTCP; ! server = true; } --- 116,120 ---- //temp debug values ! up = false; } *************** *** 268,272 **** case SocketTCP: case SocketUDP: ! s.Close(); s = null; break; --- 265,269 ---- case SocketTCP: case SocketUDP: ! if(s!= null) s.Close(); s = null; break; Index: README.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/README.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README.txt 20 Nov 2005 20:30:53 -0000 1.2 --- README.txt 19 Oct 2007 19:38:06 -0000 1.3 *************** *** 1 **** ! This directory contains all the file for the core of the jfirewallsim --- 1 ---- ! This directory contains all the file for the core of the javaNetSim |
From: Alexander B. <da...@us...> - 2007-10-19 17:40:41
|
Update of /cvsroot/javanetsim/javaNetSim/textUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv532/textUI Modified Files: TextUI.java Log Message: Minor savefile changes and fixes; new device variations added. Index: TextUI.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/textUI/TextUI.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TextUI.java 19 Oct 2007 15:57:01 -0000 1.4 --- TextUI.java 19 Oct 2007 17:40:33 -0000 1.5 *************** *** 2331,2335 **** try { ! sim.addSwitch(args[1], true, 8, 0); System.out.println("Node '"+ args[1] + "' created.\n"); --- 2331,2335 ---- try { ! sim.addSwitch(args[1], true); System.out.println("Node '"+ args[1] + "' created.\n"); |
From: Alexander B. <da...@us...> - 2007-10-19 17:40:41
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv532/core Modified Files: CSUDSU.java Hub.java Node.java PC.java Router.java Simulation.java Switch.java Log Message: Minor savefile changes and fixes; new device variations added. Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PC.java 19 Oct 2007 08:52:26 -0000 1.16 --- PC.java 19 Oct 2007 17:40:33 -0000 1.17 *************** *** 105,114 **** */ protected PC(String inName, boolean inOn) { ! super(inName,7, inOn); ! //initApplications() have been called in ApplicaitonLayerDevice ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Console) + "0", NetworkInterface.Console, false); ! //addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Wireless) + "0", NetworkInterface.Wireless, true); ! //addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.WAN) + "0" + "_" + (int)(Math.random()*1000), NetworkInterface.WAN, true); } --- 105,109 ---- */ protected PC(String inName, boolean inOn) { ! super(inName,7, inOn); } Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Node.java 19 Oct 2007 15:57:00 -0000 1.16 --- Node.java 19 Oct 2007 17:40:33 -0000 1.17 *************** *** 270,274 **** * */ ! protected void addNetworkInterface(String interfaceName, int type, boolean active) { switch(type){ --- 270,274 ---- * */ ! public void addNetworkInterface(String interfaceName, int type, boolean active) { switch(type){ Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Simulation.java 19 Oct 2007 15:57:00 -0000 1.22 --- Simulation.java 19 Oct 2007 17:40:33 -0000 1.23 *************** *** 1058,1064 **** * @version v0.20 **/ ! public void addSwitch(String inNodeName, boolean inOn, int c, int p) throws InvalidNodeNameException { if(!nodeTable.containsKey(inNodeName)){ ! nodeTable.put(inNodeName, new Switch(inNodeName, inOn, c, p)); }else{ throw new InvalidNodeNameException("Node already exists with same name"); --- 1058,1064 ---- * @version v0.20 **/ ! public void addSwitch(String inNodeName, boolean inOn) throws InvalidNodeNameException { if(!nodeTable.containsKey(inNodeName)){ ! nodeTable.put(inNodeName, new Switch(inNodeName, inOn)); }else{ throw new InvalidNodeNameException("Node already exists with same name"); Index: Hub.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Hub.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Hub.java 19 Oct 2007 08:52:26 -0000 1.7 --- Hub.java 19 Oct 2007 17:40:33 -0000 1.8 *************** *** 56,65 **** public Hub(String inName, boolean inOn) { ! super(inName, 1, inOn); //pass name and protocolstack layer ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "2", NetworkInterface.Ethernet10T, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "3", NetworkInterface.Ethernet10T, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "4", NetworkInterface.Ethernet10T, false); } --- 56,60 ---- public Hub(String inName, boolean inOn) { ! super(inName, 1, inOn); //pass name and protocolstack layer } Index: Router.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Router.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Router.java 19 Oct 2007 15:57:00 -0000 1.7 --- Router.java 19 Oct 2007 17:40:33 -0000 1.8 *************** *** 46,55 **** **/ protected Router(String inName, boolean inOn) { ! super(inName,3, inOn); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Console) + "0", NetworkInterface.Console, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet100FX) + "0", NetworkInterface.Ethernet100FX, true); } --- 46,50 ---- **/ protected Router(String inName, boolean inOn) { ! super(inName,3, inOn); } Index: Switch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Switch.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Switch.java 19 Oct 2007 15:57:01 -0000 1.8 --- Switch.java 19 Oct 2007 17:40:33 -0000 1.9 *************** *** 56,86 **** Hashtable IntCaches; ! public int Copper_ports; ! public int Fiber_ports; ! ! ! public Switch(String inName, boolean inOn, int cports, int fports) { super(inName, 1, inOn); //pass name and protocolstack layer ! IntCaches = new Hashtable(); ! String name = NetworkInterface.getIntName(NetworkInterface.Ethernet10T); ! ! Copper_ports = cports; ! Fiber_ports = fports; ! ! for(int j = 0; j < cports; j++){ ! addNetworkInterface(name + j, NetworkInterface.Ethernet10T, false); ! IntCaches.put(name + j, new Hashtable()); ! } ! ! name = NetworkInterface.getIntName(NetworkInterface.Ethernet100FX); ! ! for(int j = 0; j < fports; j++){ ! addNetworkInterface(name + j, NetworkInterface.Ethernet100FX, false); ! IntCaches.put(name + j, new Hashtable()); ! } } public void Reset(){ sz = 0; --- 56,73 ---- Hashtable IntCaches; ! public Switch(String inName, boolean inOn) { super(inName, 1, inOn); //pass name and protocolstack layer ! IntCaches = new Hashtable(); } + public void addNetworkInterface(String name, int type, boolean active){ + if(!active){ + super.addNetworkInterface(name, type, false); + IntCaches.put(name, new Hashtable()); + } + } + public void Reset(){ sz = 0; Index: CSUDSU.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CSUDSU.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CSUDSU.java 19 Oct 2007 08:52:26 -0000 1.2 --- CSUDSU.java 19 Oct 2007 17:40:33 -0000 1.3 *************** *** 38,50 **** public CSUDSU(String inName, boolean inOn) { super(inName, 1, inOn); //pass name and protocolstack layer - - lanPort = "ser0"; - wanPort = "wan0" + "_" + (int)(Math.random()*1000); - - addNetworkInterface(lanPort, NetworkInterface.Serial, false); - addNetworkInterface(wanPort, NetworkInterface.WAN, false); - } public void Reset(){ --- 38,60 ---- public CSUDSU(String inName, boolean inOn) { super(inName, 1, inOn); //pass name and protocolstack layer } + public void addSerialInterface(){ + lanPort = "ser0"; + addNetworkInterface(lanPort, NetworkInterface.Serial, false); + } + + public void addWANInterface(){ + wanPort = "wan0" + "_" + (int)(Math.random()*1000); + addNetworkInterface(wanPort, NetworkInterface.WAN, false); + } + + public void setLAN(String lan){ + lanPort = lan; + } + + public void setWAN(String wan){ + wanPort = wan; + } public void Reset(){ |
From: Alexander B. <da...@us...> - 2007-10-19 17:40:41
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv532/guiUI Modified Files: MainScreen.java Log Message: Minor savefile changes and fixes; new device variations added. Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** MainScreen.java 19 Oct 2007 15:57:01 -0000 1.74 --- MainScreen.java 19 Oct 2007 17:40:33 -0000 1.75 *************** *** 87,90 **** --- 87,91 ---- import core.Simulation; import core.Node; + import core.NetworkInterface; import core.protocolsuite.tcp_ip.Route_entry; import java.util.Timer; *************** *** 688,691 **** --- 689,696 ---- Sim.addPC(result, true); + + Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + "0", core.NetworkInterface.Ethernet10T, true); + Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Console) + "0", core.NetworkInterface.Console, false); + GuiPC tempPC = new GuiPC(result,this); *************** *** 771,775 **** String result = JOptionPane.showInputDialog(this,"Please enter a Router name:","Create New Router", JOptionPane.PLAIN_MESSAGE); ! if(result != null){ result = result.trim(); --- 776,791 ---- String result = JOptionPane.showInputDialog(this,"Please enter a Router name:","Create New Router", JOptionPane.PLAIN_MESSAGE); ! String[] choices = {"Simple router with 2 Ethernet-TX ports.", ! "Router with 3 Ethernet-TX ports", ! "Router with 2 Ethernet-TX ports and 1 Ethernet-FX port.", ! "Router with 3 Ethernet-FX ports.", ! "Multi-enviroment router with 1 Ethernet-TX, 2 Serial and 1 Ethernet-FX ports.", ! }; ! ! String choice = (String)JOptionPane.showInputDialog(this,"Please choose Switch type", "Create New Switch", ! JOptionPane.PLAIN_MESSAGE, null, ! choices,choices[0]); ! ! if(result != null && choice !=null){ result = result.trim(); *************** *** 780,783 **** --- 796,826 ---- Sim.addRouter(result, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Console) + "0", NetworkInterface.Console, false); + + if(choice.contains(choices[0])){ + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, true); + }else if(choice.contains(choices[1])){ + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "2", NetworkInterface.Ethernet10T, true); + }else if(choice.contains(choices[2])){ + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet100FX) + "0", NetworkInterface.Ethernet100FX, true); + }else if(choice.contains(choices[3])){ + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet100FX) + "0", NetworkInterface.Ethernet100FX, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet100FX) + "1", NetworkInterface.Ethernet100FX, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet100FX) + "2", NetworkInterface.Ethernet100FX, true); + }else if(choice.contains(choices[4])){ + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "1", NetworkInterface.Serial, true); + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet100FX) + "0", NetworkInterface.Ethernet100FX, true); + } + + + + GuiRouter tempRouter = new GuiRouter(result,this); *************** *** 834,839 **** String result = JOptionPane.showInputDialog(this,"Please enter a Hub name:","Create New Hub", JOptionPane.PLAIN_MESSAGE); ! if(result != null){ result = result.trim(); --- 877,890 ---- String result = JOptionPane.showInputDialog(this,"Please enter a Hub name:","Create New Hub", JOptionPane.PLAIN_MESSAGE); + + String[] choises = {"5-ports simple hub.", + "8-ports hub." + }; + + String choice = (String)JOptionPane.showInputDialog(this,"Please choose Hub type", "Create New Hub", + JOptionPane.PLAIN_MESSAGE, null, + choises,choises[0]); ! if(result != null && choice != null){ result = result.trim(); *************** *** 842,847 **** try { ! Sim.addHub(result, true); GuiHub tempHub = new GuiHub(result,this); --- 893,905 ---- try { ! int portCount = 5; ! ! if(choice.contains(choises[1])) portCount = 8; ! Sim.addHub(result, true); + for(int i = 0; i < portCount; i++){ + Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + String.valueOf(i), core.NetworkInterface.Ethernet10T, false); + } + GuiHub tempHub = new GuiHub(result,this); *************** *** 896,899 **** --- 954,960 ---- Sim.addCSUDSU(result, true); + + ((core.CSUDSU)Sim.getNode(result)).addSerialInterface(); + ((core.CSUDSU)Sim.getNode(result)).addWANInterface(); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(result,this); *************** *** 1010,1014 **** String result = JOptionPane.showInputDialog(this,"Please enter a Switch name:","Create New Switch", JOptionPane.PLAIN_MESSAGE); ! if(result != null){ result = result.trim(); --- 1071,1090 ---- String result = JOptionPane.showInputDialog(this,"Please enter a Switch name:","Create New Switch", JOptionPane.PLAIN_MESSAGE); ! String[] choices = {"5 Ethernet-TX ports simple switch.", ! "8 Ethernet-TX ports switch.", ! "12 Ethernet-TX ports switch.", ! "24 Ethernet-TX ports switch.", ! "12 Ethernet-TX ports with 2 Ethernet-FX switch.", ! "24 Ethernet-TX ports with 2 Ethernet-FX switch.", ! "12 Ethernet-FX ports with 2 Ethernet-TX switch.", ! "24 Ethernet-FX ports with 2 Ethernet-TX switch." ! }; ! ! String choice = (String)JOptionPane.showInputDialog(this,"Please choose Switch type", "Create New Switch", ! JOptionPane.PLAIN_MESSAGE, null, ! choices,choices[0]); ! ! ! if(result != null && choice != null){ result = result.trim(); *************** *** 1017,1022 **** try { ! Sim.addSwitch(result, true, 12, 2); GuiSwitch tempSwitch = new GuiSwitch(result,this); --- 1093,1125 ---- try { + int tx=0, fx=0; + + if(choice.contains(choices[0])){ + tx = 5; fx = 0; + }else if(choice.contains(choices[1])){ + tx = 8; fx = 0; + }else if(choice.contains(choices[2])){ + tx = 12; fx = 0; + }else if(choice.contains(choices[3])){ + tx = 24; fx = 0; + }else if(choice.contains(choices[4])){ + tx = 12; fx = 2; + }else if(choice.contains(choices[5])){ + tx = 24; fx = 2; + }else if(choice.contains(choices[6])){ + tx = 2; fx = 12; + }else if(choice.contains(choices[7])){ + tx = 2; fx = 24; + } ! Sim.addSwitch(result, true); ! ! for(int i = 0; i < tx; i++){ ! Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + String.valueOf(i), core.NetworkInterface.Ethernet10T, false); ! } ! ! for(int i = 0; i < fx; i++){ ! Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet100FX) + String.valueOf(i), core.NetworkInterface.Ethernet100FX, false); ! } GuiSwitch tempSwitch = new GuiSwitch(result,this); *************** *** 1978,1986 **** strType = strType.replaceFirst("class guiUI\\.",""); - if(Sim.getNode(key) instanceof core.Switch){ - strType += "_" + ((core.Switch)Sim.getNode(key)).Copper_ports; - strType += "_" + ((core.Switch)Sim.getNode(key)).Fiber_ports; - } - Point pnt1 = tempNode.getLocation(); --- 2081,2084 ---- *************** *** 2209,2212 **** --- 2307,2311 ---- Vector DevicesTurnedOn = new Vector(); Hashtable links = new Hashtable(); + Vector connections = new Vector(); while (( line = input.readLine()) != null){ *************** *** 2240,2294 **** if(strClassName.contains("GuiHub")){ deviceType = 1; ! Sim.addHub(strNodeName, false); ! GuiHub tempHub = new GuiHub(strNodeName,this); ! tempHub.setNodeLocation(pnt); ! Sandbox.add(tempHub); ! Sandbox.setLayer((Component) tempHub,3,0); ! GUInodeTable.put(strNodeName,tempHub); }else if(strClassName.contains("GuiSwitch")){ ! String[] params = strClassName.split("_"); ! deviceType = 1; ! if(params.length < 2){ ! Sim.addSwitch(strNodeName, false, 12, 2); ! }else{ ! Sim.addSwitch(strNodeName, false, Integer.valueOf(params[1]), Integer.valueOf(params[2])); ! } ! GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); ! tempSwitch.setNodeLocation(pnt); ! Sandbox.add(tempSwitch); ! Sandbox.setLayer(tempSwitch,3,0); ! GUInodeTable.put(strNodeName,tempSwitch); }else if(strClassName.contains("GuiCSUDSU")){ deviceType = 1; ! Sim.addCSUDSU(strNodeName, false); ! GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); ! tempCSUDSU.setNodeLocation(pnt); ! Sandbox.add(tempCSUDSU); ! Sandbox.setLayer(tempCSUDSU,3,0); ! GUInodeTable.put(strNodeName,tempCSUDSU); }else if(strClassName.contains("GuiPC")){ deviceType = 2; ! Sim.addPC(strNodeName, false); ! GuiPC tempPC = new GuiPC(strNodeName,this); ! tempPC.setNodeLocation(pnt); ! Sandbox.add(tempPC); ! Sandbox.setLayer(tempPC,3,0); ! GUInodeTable.put(strNodeName,tempPC); }else if(strClassName.contains("GuiRouter")){ deviceType = 2; ! Sim.addRouter(strNodeName, false); ! GuiRouter tempRouter = new GuiRouter(strNodeName,this); ! tempRouter.setNodeLocation(pnt); ! Sandbox.add(tempRouter); ! Sandbox.setLayer(tempRouter,3,0); ! GUInodeTable.put(strNodeName,tempRouter); }else if(strClassName.contains("GuiExternalProxy")){ deviceType = 2; ! Sim.addExternalNAT(strNodeName, false); ! GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); ! tempRouter.setNodeLocation(pnt); ! Sandbox.add(tempRouter); ! Sandbox.setLayer(tempRouter,3,0); ! GUInodeTable.put(strNodeName,tempRouter); } --- 2339,2358 ---- if(strClassName.contains("GuiHub")){ deviceType = 1; ! Sim.addHub(strNodeName, false); }else if(strClassName.contains("GuiSwitch")){ ! deviceType = 1; ! Sim.addSwitch(strNodeName, false); }else if(strClassName.contains("GuiCSUDSU")){ deviceType = 1; ! Sim.addCSUDSU(strNodeName, false); }else if(strClassName.contains("GuiPC")){ deviceType = 2; ! Sim.addPC(strNodeName, false); }else if(strClassName.contains("GuiRouter")){ deviceType = 2; ! Sim.addRouter(strNodeName, false); }else if(strClassName.contains("GuiExternalProxy")){ deviceType = 2; ! Sim.addExternalNAT(strNodeName, false); } *************** *** 2307,2325 **** sieve = iface[3]; ! switch(LinkType){ - case core.NetworkInterface.Ethernet10T: case core.NetworkInterface.Ethernet100FX: ! if(!iface[4].contains("#")) ! try{ //FIXME!!!!!!! ! Sim.setMACAddress(strNodeName,iface[0], iface[4]); ! }catch(Exception e){ } break; case core.NetworkInterface.Serial: ((core.SerialNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setClockRate(Integer.valueOf(iface[4])); break; } ! if(!strLinkName.contains("null")){ --- 2371,2420 ---- sieve = iface[3]; ! ! // sim nodes switch(LinkType){ case core.NetworkInterface.Ethernet100FX: ! if(!iface[4].contains("#")){ ! Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Ethernet100FX, true); ! try{ //FIXME!!!!!!! ! Sim.setMACAddress(strNodeName,iface[0], iface[4]); ! }catch(Exception e){ } ! }else{ ! Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Ethernet100FX, false); ! } ! break; ! case core.NetworkInterface.Ethernet10T: ! if(!iface[4].contains("#")){ ! Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Ethernet10T, true); ! try{ ! //FIXME!!!!!!! ! Sim.setMACAddress(strNodeName,iface[0], iface[4]); ! }catch(Exception e){ } ! }else{ ! Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Ethernet10T, false); ! } break; case core.NetworkInterface.Serial: + if(Sim.getNode(strNodeName) instanceof core.CSUDSU){ + Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Serial, false); + ((core.CSUDSU)Sim.getNode(strNodeName)).setLAN(iface[0]); + }else{ + Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Serial, true); + } ((core.SerialNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setClockRate(Integer.valueOf(iface[4])); break; + + case core.NetworkInterface.Console: + Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.Console, false); + break; + + case core.NetworkInterface.WAN: + Sim.getNode(strNodeName).addNetworkInterface(iface[0], core.NetworkInterface.WAN, false); + ((core.CSUDSU)Sim.getNode(strNodeName)).setWAN(iface[0]); + break; } ! ! // interfaces if(!strLinkName.contains("null")){ *************** *** 2335,2359 **** case core.NetworkInterface.Ethernet10T: Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); - this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Ethernet10T); break; case core.NetworkInterface.Ethernet100FX: ! Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Ethernet100FX); break; case core.NetworkInterface.Console: ! Sim.addConsoleLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Console); ! break; case core.NetworkInterface.Serial: ! Sim.addSerialLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Serial); break; } } } ! } ! line = input.readLine(); if(line.contains("#config")){ --- 2430,2492 ---- case core.NetworkInterface.Ethernet10T: Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); break; case core.NetworkInterface.Ethernet100FX: ! Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); break; case core.NetworkInterface.Console: ! Sim.addConsoleLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! break; case core.NetworkInterface.Serial: ! Sim.addSerialLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); break; } + + connections.add(strLinkName + "|" + ln[0] + "|" + strNodeName + "|" + LinkType); } } ! } ! ! // add gui nodes ! if(strClassName.contains("GuiHub")){ ! GuiHub tempHub = new GuiHub(strNodeName,this); ! tempHub.setNodeLocation(pnt); ! Sandbox.add(tempHub); ! Sandbox.setLayer((Component) tempHub,3,0); ! GUInodeTable.put(strNodeName,tempHub); ! }else if(strClassName.contains("GuiSwitch")){ ! GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); ! tempSwitch.setNodeLocation(pnt); ! Sandbox.add(tempSwitch); ! Sandbox.setLayer(tempSwitch,3,0); ! GUInodeTable.put(strNodeName,tempSwitch); ! }else if(strClassName.contains("GuiCSUDSU")){ ! GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); ! tempCSUDSU.setNodeLocation(pnt); ! Sandbox.add(tempCSUDSU); ! Sandbox.setLayer(tempCSUDSU,3,0); ! GUInodeTable.put(strNodeName,tempCSUDSU); ! }else if(strClassName.contains("GuiPC")){ ! GuiPC tempPC = new GuiPC(strNodeName,this); ! tempPC.setNodeLocation(pnt); ! Sandbox.add(tempPC); ! Sandbox.setLayer(tempPC,3,0); ! GUInodeTable.put(strNodeName,tempPC); ! }else if(strClassName.contains("GuiRouter")){ ! GuiRouter tempRouter = new GuiRouter(strNodeName,this); ! tempRouter.setNodeLocation(pnt); ! Sandbox.add(tempRouter); ! Sandbox.setLayer(tempRouter,3,0); ! GUInodeTable.put(strNodeName,tempRouter); ! }else if(strClassName.contains("GuiExternalProxy")){ ! GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); ! tempRouter.setNodeLocation(pnt); ! Sandbox.add(tempRouter); ! Sandbox.setLayer(tempRouter,3,0); ! GUInodeTable.put(strNodeName,tempRouter); ! } ! ! //config line = input.readLine(); if(line.contains("#config")){ *************** *** 2365,2368 **** --- 2498,2502 ---- } + //data line = input.readLine(); if(line.contains("#data")){ *************** *** 2378,2381 **** --- 2512,2522 ---- }//while + // add graphical connections + for(int i =0; i< connections.size(); i++){ + String[] gc = ((String)connections.get(i)).split("\\|"); + this.createLink(gc[0], gc[1], gc[2], Integer.valueOf(gc[3])); + } + + // turn on devices for(int i =0; i<DevicesTurnedOn.size() ;i++){ String nodeName = (String) DevicesTurnedOn.get(i); *************** *** 2519,2522 **** --- 2660,2667 ---- Sim.addHub(strNodeName, true); + for(int i = 0; i < 5; i++){ + Sim.getNode(strNodeName).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + String.valueOf(i), core.NetworkInterface.Ethernet10T, false); + } + GuiHub tempHub = new GuiHub(strNodeName,this); *************** *** 2535,2539 **** deviceType = 1; ! Sim.addSwitch(strNodeName, true, 8, 0); GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); --- 2680,2687 ---- deviceType = 1; ! Sim.addSwitch(strNodeName, true); ! for(int i = 0; i < 8; i++){ ! Sim.getNode(strNodeName).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + String.valueOf(i), core.NetworkInterface.Ethernet10T, false); ! } GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); *************** *** 2547,2567 **** GUInodeTable.put(strNodeName,tempSwitch); - }else if(strClassName.contains("GuiCSUDSU")){ - - deviceType = 1; - - Sim.addCSUDSU(strNodeName, true); - - GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); - - tempCSUDSU.setNodeLocation(pnt); - - Sandbox.add(tempCSUDSU); - - Sandbox.setLayer(tempCSUDSU,3,0); - - GUInodeTable.put(strNodeName,tempCSUDSU); - - }else if(strClassName.contains("GuiPC")){ --- 2695,2698 ---- *************** *** 2569,2573 **** Sim.addPC(strNodeName, true); ! GuiPC tempPC = new GuiPC(strNodeName,this); --- 2700,2706 ---- Sim.addPC(strNodeName, true); ! Sim.getNode(strNodeName).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + "0", core.NetworkInterface.Ethernet10T, true); ! Sim.getNode(strNodeName).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Console) + "0", core.NetworkInterface.Console, true); ! GuiPC tempPC = new GuiPC(strNodeName,this); *************** *** 2585,2589 **** --- 2718,2727 ---- Sim.addRouter(strNodeName, true); + Sim.getNode(strNodeName).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + "0", core.NetworkInterface.Ethernet10T, true); + Sim.getNode(strNodeName).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + "1", core.NetworkInterface.Ethernet10T, true); + Sim.getNode(strNodeName).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Serial) + "0", core.NetworkInterface.Serial, true); + Sim.getNode(strNodeName).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Console) + "0", core.NetworkInterface.Console, true); + GuiRouter tempRouter = new GuiRouter(strNodeName,this); *************** *** 2596,2618 **** GUInodeTable.put(strNodeName,tempRouter); - }else if(strClassName.contains("GuiExternalProxy")){ - - deviceType = 2; - - Sim.addExternalNAT(strNodeName, true); - - GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); - - tempRouter.setNodeLocation(pnt); - - Sandbox.add(tempRouter); - - Sandbox.setLayer(tempRouter,3,0); - - GUInodeTable.put(strNodeName,tempRouter); - } - String sieve = "100.00"; --- 2734,2739 ---- |
From: Alexander B. <da...@us...> - 2007-10-19 15:57:14
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22802/guiUI Modified Files: EthPortProperties.java LinkLayerPanel.java MainScreen.java SetTCPIPPropertiesDialog.java Added Files: SerPortProperties.java Log Message: New link type -- FX, Fiber Ethernet. Small changes in interface properties dialogs; added serial network interface properties dialog. Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** MainScreen.java 19 Oct 2007 08:52:27 -0000 1.73 --- MainScreen.java 19 Oct 2007 15:57:01 -0000 1.74 *************** *** 1018,1022 **** try { ! Sim.addSwitch(result, true); GuiSwitch tempSwitch = new GuiSwitch(result,this); --- 1018,1022 ---- try { ! Sim.addSwitch(result, true, 12, 2); GuiSwitch tempSwitch = new GuiSwitch(result,this); *************** *** 1216,1219 **** --- 1216,1220 ---- switch(Sim.getNode(inNode1).getIntType(strFirstNodeInterface)){ case core.NetworkInterface.Ethernet10T: + case core.NetworkInterface.Ethernet100FX: Sim.addEthernetLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); break; *************** *** 1976,1979 **** --- 1977,1985 ---- String strType = tempNode.getClass().toString(); strType = strType.replaceFirst("class guiUI\\.",""); + + if(Sim.getNode(key) instanceof core.Switch){ + strType += "_" + ((core.Switch)Sim.getNode(key)).Copper_ports; + strType += "_" + ((core.Switch)Sim.getNode(key)).Fiber_ports; + } Point pnt1 = tempNode.getLocation(); *************** *** 2007,2011 **** switch(type){ case core.NetworkInterface.Ethernet10T: ! if((Sim.getNode(key).getNIC(nics[i].toString())) instanceof core.NetworkInterfacePort ){ strSave += "|#"; }else{ --- 2013,2018 ---- switch(type){ case core.NetworkInterface.Ethernet10T: ! case core.NetworkInterface.Ethernet100FX: ! if(!Sim.getNode(key).getNIC(nics[i].toString()).isActive()){ strSave += "|#"; }else{ *************** *** 2240,2245 **** GUInodeTable.put(strNodeName,tempHub); }else if(strClassName.contains("GuiSwitch")){ deviceType = 1; ! Sim.addSwitch(strNodeName, false); GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); tempSwitch.setNodeLocation(pnt); --- 2247,2257 ---- GUInodeTable.put(strNodeName,tempHub); }else if(strClassName.contains("GuiSwitch")){ + String[] params = strClassName.split("_"); deviceType = 1; ! if(params.length < 2){ ! Sim.addSwitch(strNodeName, false, 12, 2); ! }else{ ! Sim.addSwitch(strNodeName, false, Integer.valueOf(params[1]), Integer.valueOf(params[2])); ! } GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); tempSwitch.setNodeLocation(pnt); *************** *** 2298,2301 **** --- 2310,2314 ---- switch(LinkType){ case core.NetworkInterface.Ethernet10T: + case core.NetworkInterface.Ethernet100FX: if(!iface[4].contains("#")) try{ *************** *** 2324,2327 **** --- 2337,2344 ---- this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Ethernet10T); break; + case core.NetworkInterface.Ethernet100FX: + Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); + this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Ethernet100FX); + break; case core.NetworkInterface.Console: Sim.addConsoleLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); *************** *** 2518,2522 **** deviceType = 1; ! Sim.addSwitch(strNodeName, true); GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); --- 2535,2539 ---- deviceType = 1; ! Sim.addSwitch(strNodeName, true, 8, 0); GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); *************** *** 4331,4336 **** switch(itype){ case core.NetworkInterface.Ethernet10T: ! new EthPortProperties(this,NodeName, IntName,Sim,Sandbox); break; case core.NetworkInterface.WAN: String service = JOptionPane.showInputDialog(this, "Sevice name", "Service name.", JOptionPane.QUESTION_MESSAGE); --- 4348,4359 ---- switch(itype){ case core.NetworkInterface.Ethernet10T: ! case core.NetworkInterface.Ethernet100FX: ! if(temp.getNIC(IntName).isActive()){ ! new EthPortProperties(this,NodeName, IntName,Sim,Sandbox); ! } break; + case core.NetworkInterface.Serial: + new SerPortProperties(this,NodeName, IntName,Sim,Sandbox); + break; case core.NetworkInterface.WAN: String service = JOptionPane.showInputDialog(this, "Sevice name", "Service name.", JOptionPane.QUESTION_MESSAGE); Index: SetTCPIPPropertiesDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SetTCPIPPropertiesDialog.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SetTCPIPPropertiesDialog.java 15 Oct 2007 12:04:33 -0000 1.9 --- SetTCPIPPropertiesDialog.java 19 Oct 2007 15:57:01 -0000 1.10 *************** *** 389,393 **** ! if(NodeName != null){ Sim.setDefaultGateway(NodeName,DefaultGWAddress); controller.addToConsole(NodeName +"'s Default Gateway Address has been set to " + DefaultGWAddress +"\n"); --- 389,393 ---- ! if(NodeName != null && DefaultGWAddress!=null){ Sim.setDefaultGateway(NodeName,DefaultGWAddress); controller.addToConsole(NodeName +"'s Default Gateway Address has been set to " + DefaultGWAddress +"\n"); Index: EthPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/EthPortProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EthPortProperties.java 13 Oct 2007 12:57:01 -0000 1.1 --- EthPortProperties.java 19 Oct 2007 15:57:01 -0000 1.2 *************** *** 42,45 **** --- 42,46 ---- import javax.swing.JLabel; import javax.swing.JTextField; + import javax.swing.JCheckBox; import java.awt.Insets; import java.awt.GridBagConstraints; *************** *** 79,82 **** --- 80,85 ---- private JTextField txtMAC; private JLabel lblMAC; + private JLabel lblUP; + private JCheckBox chkUP; private MainScreen controller; *************** *** 199,202 **** --- 202,222 ---- lblMAC.setText("MAC Address:"); } + + { + lblUP = new JLabel(); + backpanel.add(lblUP, new GridBagConstraints( + 0, + 3, + 1, + 1, + 0.0, + 1.0, + GridBagConstraints.LINE_END, + GridBagConstraints.HORIZONTAL, + new Insets(0, 0, 0, 16), + 0, + 0)); + lblUP.setText("Administratively UP:"); + } { *************** *** 238,242 **** backpanel.add(txtMAC, gridBagConstraints_3); txtMAC.setText(Sim.getNode(NodeName).getMACAddress(NodeInt)); ! lblError = new JLabel(); --- 258,271 ---- backpanel.add(txtMAC, gridBagConstraints_3); txtMAC.setText(Sim.getNode(NodeName).getMACAddress(NodeInt)); ! ! chkUP = new JCheckBox(); ! chkUP.setEnabled(true); ! final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints(); ! gridBagConstraints_4.fill = GridBagConstraints.HORIZONTAL; ! gridBagConstraints_4.anchor = GridBagConstraints.LINE_START; ! gridBagConstraints_4.gridy = 3; ! gridBagConstraints_4.gridx = 1; ! backpanel.add(chkUP, gridBagConstraints_4); ! chkUP.setSelected(Sim.getNode(NodeName).getNIC(NodeInt).isUP()); lblError = new JLabel(); *************** *** 276,280 **** if(SC.matches("[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]")){ NetworkLayerDevice temp = (NetworkLayerDevice)Sim.getNode(NodeName); ! temp.setMACAddress(NodeInt, SC); this.dispose(); }else{ --- 305,321 ---- if(SC.matches("[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]")){ NetworkLayerDevice temp = (NetworkLayerDevice)Sim.getNode(NodeName); ! temp.getConfig().executeCommand("int " + NodeInt + " mac-address " + SC); ! ! if(chkUP.isSelected()){ ! 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"); ! } ! this.dispose(); }else{ --- NEW FILE: SerPortProperties.java --- /* Java Network Simulator (javaNetSim) Copyright (c) 2007, 2006, 2005, Ice Team; All rights reserved. Copyright (c) 2004, jFirewallSim development team; All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Canberra Institute of Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package guiUI; import core.InvalidLinkNameException; import core.InvalidNetworkInterfaceNameException; import core.InvalidNodeNameException; import core.Node; import core.NetworkLayerDevice; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.GridBagLayout; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JCheckBox; import java.awt.Insets; import java.awt.GridBagConstraints; import java.awt.BorderLayout; import javax.swing.JButton; import java.awt.Dimension; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JComboBox; import core.Simulation; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.Color; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.util.Arrays; import java.awt.Component; import javax.swing.SwingConstants; /** * * @author Key * * This class is a dialog that shows Serernet Port Props * */ public class SerPortProperties extends javax.swing.JDialog { private JPanel backpanel; private JLabel lblInterface, cmbInterface; private JLabel lblNodeName, cmbNodeName; private JLabel lblError; private JButton btnOk; private JTextField txtCR; private JLabel lblCR; private JLabel lblUP; private JCheckBox chkUP; private MainScreen controller; private Simulation Sim; private SandBox SBox; private String NodeName=""; private String NodeInt=""; private boolean ErrorFlag = true; public SerPortProperties(JFrame frame, String inNodeName, String inNodeInt, Simulation Sim, SandBox SBox) { super(frame); this.NodeName = inNodeName; this.NodeInt = inNodeInt; setResizable(false); controller = (MainScreen)frame; this.Sim = Sim; this.SBox = SBox; setTitle("Serernet Port Properties"); initGUI(inNodeName, inNodeInt); final JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.SOUTH); btnOk = new JButton(); btnOk.setEnabled(true); btnOk.setToolTipText("Set options!"); btnOk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButton(); } }); btnOk.setName("btnOK"); panel.add(btnOk); btnOk.setText("OK"); final JButton btnCancel = new JButton(); btnCancel.setToolTipText("Cancel changes"); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancelButton(); } }); btnCancel.setName("btnCancel"); panel.add(btnCancel); btnCancel.setText("Cancel"); this.getRootPane().setDefaultButton(btnOk); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); this.setModal(true); this.setVisible(true); } private void initGUI(String NodeName, String NodeInt) { try { setSize(350, 225); { backpanel = new JPanel(); backpanel.setMinimumSize(new Dimension(200, 10)); this.getContentPane().add(backpanel, BorderLayout.CENTER); GridBagLayout backpanelLayout = new GridBagLayout(); backpanel.setPreferredSize(new java.awt.Dimension(264, 213)); backpanelLayout.columnWeights = new double[] {}; backpanelLayout.columnWidths = new int[] {}; backpanelLayout.rowWeights = new double[] {0.0}; backpanelLayout.rowHeights = new int[] {5,5,5,5}; backpanel.setLayout(backpanelLayout); { lblNodeName = new JLabel(); backpanel.add(lblNodeName, new GridBagConstraints( 0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 21, 0)); lblNodeName.setText("Node Name:"); } { lblInterface = new JLabel(); backpanel.add(lblInterface, new GridBagConstraints( 0, 1, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 27), 0, 0)); lblInterface.setText("Interface:"); } { lblCR = new JLabel(); backpanel.add(lblCR, new GridBagConstraints( 0, 2, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblCR.setText("Clock Rate:"); } { lblUP = new JLabel(); backpanel.add(lblUP, new GridBagConstraints( 0, 3, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblUP.setText("Administratively UP:"); } { cmbNodeName = new JLabel(); cmbNodeName.setMinimumSize(new Dimension(100, 0)); cmbNodeName.setText(NodeName); final GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.LINE_START; gridBagConstraints.gridy = 0; gridBagConstraints.gridx = 1; backpanel.add(cmbNodeName, gridBagConstraints); } { cmbInterface = new JLabel(); cmbInterface.setText(NodeInt); final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints(); gridBagConstraints_1.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_1.anchor = GridBagConstraints.LINE_START; gridBagConstraints_1.gridy = 1; gridBagConstraints_1.gridx = 1; backpanel.add(cmbInterface, gridBagConstraints_1); } txtCR = new JTextField(); txtCR.addFocusListener(new FocusAdapter() { public void actionPerformed(ActionEvent e) { lblError.setVisible(false); } }); txtCR.setEnabled(true); final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints(); gridBagConstraints_3.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_3.anchor = GridBagConstraints.LINE_START; gridBagConstraints_3.gridy = 2; gridBagConstraints_3.gridx = 1; backpanel.add(txtCR, gridBagConstraints_3); txtCR.setText(String.valueOf(((core.SerialNetworkInterface)Sim.getNode(NodeName).getNIC(NodeInt)).getClockRate())); chkUP = new JCheckBox(); chkUP.setEnabled(true); final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints(); gridBagConstraints_4.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_4.anchor = GridBagConstraints.LINE_START; gridBagConstraints_4.gridy = 3; gridBagConstraints_4.gridx = 1; backpanel.add(chkUP, gridBagConstraints_4); chkUP.setSelected(Sim.getNode(NodeName).getNIC(NodeInt).isUP()); lblError = new JLabel(); lblError.setHorizontalTextPosition(SwingConstants.CENTER); lblError.setHorizontalAlignment(SwingConstants.CENTER); lblError.setAlignmentX(Component.CENTER_ALIGNMENT); lblError.setMinimumSize(new Dimension(100, 20)); lblError.setMaximumSize(new Dimension(100, 20)); lblError.setPreferredSize(new Dimension(100, 20)); lblError.setVisible(false); final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints(); gridBagConstraints_5.anchor = GridBagConstraints.WEST; gridBagConstraints_5.insets = new Insets(0, 1, 0, 0); gridBagConstraints_5.fill = GridBagConstraints.BOTH; gridBagConstraints_5.gridwidth = 2; gridBagConstraints_5.gridy = 5; gridBagConstraints_5.gridx = 0; backpanel.add(lblError, gridBagConstraints_5); lblError.setText("Invalid MAC!"); } } catch (Exception e) { e.printStackTrace(); } } /** * This mSerod is executed when the user hit's the enter button. * It will delete the link on selected interface. * * @author Key * */ private void okButton(){ try { String CR = txtCR.getText(); if(CR.matches("[0-9]+")){ if(Sim.getNode(NodeName) instanceof NetworkLayerDevice){ NetworkLayerDevice temp = (NetworkLayerDevice)Sim.getNode(NodeName); temp.getConfig().executeCommand("int " + NodeInt + " clock-rate " + CR); if(chkUP.isSelected()){ 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{ ((core.SerialNetworkInterface)Sim.getNode(NodeName).getNIC(NodeInt)).setClockRate(Integer.valueOf(CR)); Sim.getNode(NodeName).getNIC(NodeInt).DOWN(); if(chkUP.isSelected()){ Sim.getNode(NodeName).getNIC(NodeInt).UP(); } } this.dispose(); }else{ lblError.setText("Invalid MAC Address!"); lblError.setForeground(Color.RED); lblError.setVisible(true); controller.shakeDiaLog(this); ErrorFlag = true; } } catch (Exception e) { e.printStackTrace(); } } /** * This mSerod is executed when the user hits the cancel button * @author luke_hamilton * @author Key * */ private void cancelButton(){ this.dispose(); } } Index: LinkLayerPanel.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkLayerPanel.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LinkLayerPanel.java 15 Oct 2007 12:04:33 -0000 1.5 --- LinkLayerPanel.java 19 Oct 2007 15:57:01 -0000 1.6 *************** *** 156,164 **** break; case core.NetworkInterface.Console: ! LineTable.put(inName,new LinkLine(new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y), new BasicStroke(3.0f), Color.BLUE)); break; case core.NetworkInterface.Serial: LineTable.put(inName,new LinkLine(new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y), new BasicStroke(3.0f), Color.RED)); break; } --- 156,167 ---- break; case core.NetworkInterface.Console: ! LineTable.put(inName,new LinkLine(new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y), new BasicStroke(3.0f), Color.CYAN )); break; case core.NetworkInterface.Serial: LineTable.put(inName,new LinkLine(new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y), new BasicStroke(3.0f), Color.RED)); break; + case core.NetworkInterface.Ethernet100FX: + LineTable.put(inName,new LinkLine(new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y), new BasicStroke(3.0f), Color.ORANGE)); + break; } |
From: Alexander B. <da...@us...> - 2007-10-19 15:57:10
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22802/core Modified Files: NetworkInterface.java Node.java Router.java Simulation.java Switch.java Added Files: AccessListEngine.java FiberEthernetLink.java FiberEthernetNetworkInterface.java FiberNetworkInterfacePort.java Log Message: New link type -- FX, Fiber Ethernet. Small changes in interface properties dialogs; added serial network interface properties dialog. Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Node.java 19 Oct 2007 08:52:26 -0000 1.15 --- Node.java 19 Oct 2007 15:57:00 -0000 1.16 *************** *** 280,283 **** --- 280,290 ---- } break; + case NetworkInterface.Ethernet100FX: + if(active){ + NetworkInterfacetable.put(interfaceName,new FiberEthernetNetworkInterface(interfaceName,this)); + }else{ + NetworkInterfacetable.put(interfaceName,new FiberNetworkInterfacePort(interfaceName,this)); + } + break; case NetworkInterface.Console: NetworkInterfacetable.put(interfaceName,new ConsoleNetworkInterface(interfaceName,this)); *************** *** 467,471 **** //"Not Applicable" ! if(((NetworkInterface)(NetworkInterfacetable.get(inInterfaceName))).getType() == NetworkInterface.Ethernet10T){ EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); return temp.getMACAddress(); --- 474,479 ---- //"Not Applicable" ! if(((NetworkInterface)(NetworkInterfacetable.get(inInterfaceName))).getType() == NetworkInterface.Ethernet10T || ! ((NetworkInterface)(NetworkInterfacetable.get(inInterfaceName))).getType() == NetworkInterface.Ethernet100FX){ EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); return temp.getMACAddress(); *************** *** 518,526 **** switch(temp.getType()){ case NetworkInterface.Ethernet10T: ! return "Ethernet"; case NetworkInterface.Console: return "Console"; case NetworkInterface.Wireless: return "Wireless"; default: return "Unknown"; --- 526,538 ---- switch(temp.getType()){ case NetworkInterface.Ethernet10T: ! return "Copper Ethernet"; case NetworkInterface.Console: return "Console"; case NetworkInterface.Wireless: return "Wireless"; + case NetworkInterface.Ethernet100FX: + return "Fiber Ethernet"; + case NetworkInterface.Serial: + return "Serial"; default: return "Unknown"; Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Simulation.java 19 Oct 2007 08:52:26 -0000 1.21 --- Simulation.java 19 Oct 2007 15:57:00 -0000 1.22 *************** *** 696,700 **** //Create link and add it to hashtable ! linkTable.put(inLinkName,new EthernetLink(inLinkName, interface1, interface2, Double.valueOf(sieveCoeff).doubleValue())); }else{ throw new InvalidNodeNameException("Invalid node name"); --- 696,704 ---- //Create link and add it to hashtable ! if(interface1 instanceof FiberEthernetNetworkInterface){ ! linkTable.put(inLinkName,new FiberEthernetLink(inLinkName, interface1, interface2, Double.valueOf(sieveCoeff).doubleValue())); ! }else{ ! linkTable.put(inLinkName,new EthernetLink(inLinkName, interface1, interface2, Double.valueOf(sieveCoeff).doubleValue())); ! } }else{ throw new InvalidNodeNameException("Invalid node name"); *************** *** 719,723 **** //Create link and add it to hashtable ! linkTable.put(inLinkName,new EthernetLink(inLinkName, interface1, interface2)); }else{ throw new InvalidNodeNameException("Invalid node name"); --- 723,731 ---- //Create link and add it to hashtable ! if(interface1 instanceof FiberEthernetNetworkInterface){ ! linkTable.put(inLinkName,new FiberEthernetLink(inLinkName, interface1, interface2)); ! }else{ ! linkTable.put(inLinkName,new EthernetLink(inLinkName, interface1, interface2)); ! } }else{ throw new InvalidNodeNameException("Invalid node name"); *************** *** 1050,1056 **** * @version v0.20 **/ ! public void addSwitch(String inNodeName, boolean inOn) throws InvalidNodeNameException { if(!nodeTable.containsKey(inNodeName)){ ! nodeTable.put(inNodeName, new Switch(inNodeName, inOn)); }else{ throw new InvalidNodeNameException("Node already exists with same name"); --- 1058,1064 ---- * @version v0.20 **/ ! public void addSwitch(String inNodeName, boolean inOn, int c, int p) throws InvalidNodeNameException { if(!nodeTable.containsKey(inNodeName)){ ! nodeTable.put(inNodeName, new Switch(inNodeName, inOn, c, p)); }else{ throw new InvalidNodeNameException("Node already exists with same name"); Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NetworkInterface.java 19 Oct 2007 08:52:26 -0000 1.10 --- NetworkInterface.java 19 Oct 2007 15:57:00 -0000 1.11 *************** *** 162,165 **** --- 162,166 ---- public final static int WAN = 3; public final static int Serial = 4; + public final static int Ethernet100FX = 5; public static String getIntName(int type){ *************** *** 175,178 **** --- 176,181 ---- case 4: return "ser"; + case 5: + return "fib"; default: return "unk"; Index: Router.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Router.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Router.java 19 Oct 2007 08:52:26 -0000 1.6 --- Router.java 19 Oct 2007 15:57:00 -0000 1.7 *************** *** 51,54 **** --- 51,55 ---- addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Console) + "0", NetworkInterface.Console, false); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, true); + addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet100FX) + "0", NetworkInterface.Ethernet100FX, true); } Index: Switch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Switch.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Switch.java 19 Oct 2007 08:52:26 -0000 1.7 --- Switch.java 19 Oct 2007 15:57:01 -0000 1.8 *************** *** 55,61 **** Hashtable IntCaches; ! public Switch(String inName, boolean inOn) { super(inName, 1, inOn); //pass name and protocolstack layer --- 55,64 ---- Hashtable IntCaches; + + public int Copper_ports; + public int Fiber_ports; ! public Switch(String inName, boolean inOn, int cports, int fports) { super(inName, 1, inOn); //pass name and protocolstack layer *************** *** 63,98 **** String name = NetworkInterface.getIntName(NetworkInterface.Ethernet10T); ! addNetworkInterface(name + "0", NetworkInterface.Ethernet10T, false); ! Hashtable iceth0 = new Hashtable(); ! IntCaches.put(name, iceth0); ! ! addNetworkInterface(name + "1", NetworkInterface.Ethernet10T, false); ! Hashtable iceth1 = new Hashtable(); ! IntCaches.put(name + "1", iceth1); ! ! addNetworkInterface(name + "2", NetworkInterface.Ethernet10T, false); ! Hashtable iceth2 = new Hashtable(); ! IntCaches.put(name + "2", iceth2); ! ! addNetworkInterface(name + "3", NetworkInterface.Ethernet10T, false); ! Hashtable iceth3 = new Hashtable(); ! IntCaches.put(name + "3", iceth3); ! ! addNetworkInterface(name + "4", NetworkInterface.Ethernet10T, false); ! Hashtable iceth4 = new Hashtable(); ! IntCaches.put(name + "4", iceth4); ! ! addNetworkInterface(name + "5", NetworkInterface.Ethernet10T, false); ! Hashtable iceth5 = new Hashtable(); ! IntCaches.put(name + "5", iceth5); ! addNetworkInterface(name + "6", NetworkInterface.Ethernet10T, false); ! Hashtable iceth6 = new Hashtable(); ! IntCaches.put(name + "6", iceth6); ! addNetworkInterface(name + "7", NetworkInterface.Ethernet10T, false); ! Hashtable iceth7 = new Hashtable(); ! IntCaches.put(name + "7", iceth7); } --- 66,83 ---- String name = NetworkInterface.getIntName(NetworkInterface.Ethernet10T); ! Copper_ports = cports; ! Fiber_ports = fports; ! for(int j = 0; j < cports; j++){ ! addNetworkInterface(name + j, NetworkInterface.Ethernet10T, false); ! IntCaches.put(name + j, new Hashtable()); ! } ! name = NetworkInterface.getIntName(NetworkInterface.Ethernet100FX); + for(int j = 0; j < fports; j++){ + addNetworkInterface(name + j, NetworkInterface.Ethernet100FX, false); + IntCaches.put(name + j, new Hashtable()); + } } --- NEW FILE: FiberEthernetNetworkInterface.java --- package core; class FiberEthernetNetworkInterface extends EthernetNetworkInterface{ protected FiberEthernetNetworkInterface(String inName, Node parent) { super(inName,parent); } public int getType(){ return NetworkInterface.Ethernet100FX; } } --- NEW FILE: FiberEthernetLink.java --- package core; import java.util.*; public class FiberEthernetLink extends EthernetLink { public FiberEthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName, inFirstNodeInterface, inSecondNodeInterface); } public FiberEthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface, double sieveCoeff)throws InvalidLinkConnectionException { super(inName, inFirstNodeInterface, inSecondNodeInterface, sieveCoeff); } } --- NEW FILE: FiberNetworkInterfacePort.java --- package core; import java.io.Serializable; public class FiberNetworkInterfacePort extends NetworkInterfacePort{ protected FiberNetworkInterfacePort(String inName, Node inParent) { super(inName,inParent); } public int getType(){ return NetworkInterface.Ethernet100FX; } }//EOF --- NEW FILE: AccessListEngine.java --- package core; import java.util.Enumeration; import java.util.Hashtable; import core.protocolsuite.tcp_ip.IPV4Address; /** * * @author key */ public class AccessListEngine { public class access_list{ public final static int PERMIT = 1; public final static int DENY = 2; public final static int REMARK = 0; public final static int IP = 0; public final static int ICMP = 1; public final static int UDP = 2; public final static int TCP = 3; public int number; public int line; public short action; public String IP1; public String SubnetMask1; public int Port1; public String IP2; public String SubnetMask2; public int Port2; public short protocol; } Node parentNode; Hashtable ACLs; public AccessListEngine(Node inParentNode){ parentNode = inParentNode; } public boolean addACL(int number, int line, short action, String IP1, String SubnetMask1){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); boolean new_acl = false; if(ACLl == null){ ACLl = new Hashtable(); new_acl = true; } if(ACLl.get(Integer.valueOf(line)) == null) return false; if(line < 0){ line = 0; Integer temp; Enumeration e = ACLl.keys(); while(e.hasMoreElements()){ temp = (Integer)e.nextElement(); if(line < Integer.valueOf(temp)){ line = Integer.valueOf(temp); } } line += 10; } access_list al = new access_list(); al.number = number; al.line = line; al.action = action; al.IP1 = IP1; al.SubnetMask1 = SubnetMask1; ACLl.put(Integer.valueOf(line), al); if(new_acl) ACLs.put(Integer.valueOf(number), ACLl); return true; } public boolean removeACL(int number, int line){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); if(ACLl == null) return false; if(ACLl.get(Integer.valueOf(line)) == null) return false; ACLl.remove(Integer.valueOf(line)); if(ACLl.size() < 1) ACLs.remove(Integer.valueOf(number)); return true; } public boolean removeACL(int number, int action, String IP1, String SubnetMask1){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); boolean found = false; if(ACLl == null) return false; access_list temp_acl = null; Enumeration e = ACLl.keys(); while(e.hasMoreElements()){ temp_acl = (access_list)ACLl.get((Integer)e.nextElement()); if(temp_acl.action == action && temp_acl.IP1.equals(IP1) && temp_acl.SubnetMask1.equals(SubnetMask1)){ found = true; break; } } if(found) ACLl.remove(Integer.valueOf(temp_acl.line)); if(ACLl.size() < 1) ACLs.remove(Integer.valueOf(number)); return found; } public boolean passStandartACL(int number, String IP){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); if(ACLl == null) return false; try{ String binIP = IPV4Address.toBinaryString(IP); String binNetwork = ""; String binMask = ""; access_list temp_acl = null; Enumeration e = ACLl.keys(); while(e.hasMoreElements()){ temp_acl = (access_list)ACLl.get((Integer)e.nextElement()); if(temp_acl.action>0){ binNetwork = IPV4Address.toBinaryString(temp_acl.IP1); binMask = IPV4Address.toBinaryString(temp_acl.SubnetMask1); if(IPV4Address.IPandMask(binNetwork, binMask).equals(IPV4Address.IPandMask(binIP,binMask))){ if(temp_acl.action == access_list.PERMIT) return true; else return false; } } } }catch(Exception ex){ ex.printStackTrace(); } return false; } } |
From: Alexander B. <da...@us...> - 2007-10-19 15:57:09
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22802 Modified Files: README.txt TODO.txt Log Message: New link type -- FX, Fiber Ethernet. Small changes in interface properties dialogs; added serial network interface properties dialog. Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** TODO.txt 14 Oct 2007 17:19:06 -0000 1.25 --- TODO.txt 19 Oct 2007 15:57:00 -0000 1.26 *************** *** 4,11 **** *** Whole Project ! 1. ReNew Console(IOS-similar command line) and normal config files. ! 1.1 Rebooting devices. ! 1.2 Up/down interfaces. ! 2. VPN-client/VPN-gateway (sockets, RMI and Corba mechanisms) (or PPP Client/PPP Gateway -- ??) 3. DHCP server/clients : retrying/repeating transactions, re-leasing. 4. Socks Proxy(old -- Nat Gateway) to external network. --- 4,8 ---- *** Whole Project ! 2. Add (TCP sockets, RMI and Corba mechanisms) to CSU/DSU units + TCP packets transport 3. DHCP server/clients : retrying/repeating transactions, re-leasing. 4. Socks Proxy(old -- Nat Gateway) to external network. *************** *** 27,35 **** 1. Check changing/saving netmask in SET TCP/IP Properties dialog. - 2. Create _normal_ route table edit form (instead of route command). Use as template EditRoutesDialog.java. Note, - that "route" command is only for ugly testing purposes! 7. Fix LinkProperties Dialog: safe using (check for correct input values) (!!!, Gift!). ! 8. Add show switch cache dialog. ! 9. Device config save/load. *** Simulation Related --- 24,29 ---- 1. Check changing/saving netmask in SET TCP/IP Properties dialog. 7. Fix LinkProperties Dialog: safe using (check for correct input values) (!!!, Gift!). ! 10. Optimize File Open/Save dialog calling... *** Simulation Related Index: README.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/README.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** README.txt 13 Oct 2007 12:57:00 -0000 1.13 --- README.txt 19 Oct 2007 15:57:00 -0000 1.14 *************** *** 32,35 **** --- 32,46 ---- ********************* + ***** Release Version 0.38 3rd November 2007 ***** + + New Features + ------------ + + 1. New command line (console). + 2. Added new link types (Console, Serial). + 3. New savefile format. + 4. New protocols: DHCP + 5. New devices: CSU/DSU unit + ***** Release Version 0.34 1th October 2007 ***** |
From: Alexander B. <da...@us...> - 2007-10-19 15:57:05
|
Update of /cvsroot/javanetsim/javaNetSim/textUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22802/textUI Modified Files: TextUI.java Log Message: New link type -- FX, Fiber Ethernet. Small changes in interface properties dialogs; added serial network interface properties dialog. Index: TextUI.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/textUI/TextUI.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TextUI.java 19 Oct 2007 08:52:27 -0000 1.3 --- TextUI.java 19 Oct 2007 15:57:01 -0000 1.4 *************** *** 2331,2335 **** try { ! sim.addSwitch(args[1], true); System.out.println("Node '"+ args[1] + "' created.\n"); --- 2331,2335 ---- try { ! sim.addSwitch(args[1], true, 8, 0); System.out.println("Node '"+ args[1] + "' created.\n"); |
From: Alexander B. <da...@us...> - 2007-10-19 08:52:42
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11211/guiUI Modified Files: MainScreen.java MenuBar.java Log Message: New save file format; import. Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** MainScreen.java 15 Oct 2007 18:25:54 -0000 1.72 --- MainScreen.java 19 Oct 2007 08:52:27 -0000 1.73 *************** *** 129,135 **** //Prefix for file extension ! private static final String GUI_PREFIX = "jfst"; ! private static final String SIM_PREFIX = "jfst"; private static final String HTM_PREFIX = "htm"; --- 129,135 ---- //Prefix for file extension ! private static final String OLD_PREFIX = "jfst"; ! private static final String SIM_PREFIX = "jnst"; private static final String HTM_PREFIX = "htm"; *************** *** 197,202 **** //The File chooser class - private JFileChooser chooser = new JFileChooser(); - private JScrollPane scroller = new JScrollPane(); --- 197,200 ---- *************** *** 689,693 **** try { ! Sim.addPC(result); GuiPC tempPC = new GuiPC(result,this); --- 687,691 ---- try { ! Sim.addPC(result, true); GuiPC tempPC = new GuiPC(result,this); *************** *** 781,785 **** try { ! Sim.addRouter(result); GuiRouter tempRouter = new GuiRouter(result,this); --- 779,783 ---- try { ! Sim.addRouter(result, true); GuiRouter tempRouter = new GuiRouter(result,this); *************** *** 845,849 **** try { ! Sim.addHub(result); GuiHub tempHub = new GuiHub(result,this); --- 843,847 ---- try { ! Sim.addHub(result, true); GuiHub tempHub = new GuiHub(result,this); *************** *** 897,901 **** try { ! Sim.addCSUDSU(result); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(result,this); --- 895,899 ---- try { ! Sim.addCSUDSU(result, true); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(result,this); *************** *** 958,962 **** try { ! Sim.addExternalNAT(result); GuiExternalProxy tempEN = new GuiExternalProxy(result,this); --- 956,960 ---- try { ! Sim.addExternalNAT(result, true); GuiExternalProxy tempEN = new GuiExternalProxy(result,this); *************** *** 1020,1024 **** try { ! Sim.addSwitch(result); GuiSwitch tempSwitch = new GuiSwitch(result,this); --- 1018,1022 ---- try { ! Sim.addSwitch(result, true); GuiSwitch tempSwitch = new GuiSwitch(result,this); *************** *** 1927,2032 **** - /** - - * Currently not implements but will eventually save the Simulation and GUI Nodes. - - * - - */ - public void Save(){ - if(simSaveFile!=null) SaveAs(simSaveFile.getPath()); - else SaveAs(null); - } - - - /** - - * Currently not implements but will eventually save the Simulation and GUI Nodes. - - * - - */ - - public void SaveAs(String saveas){ chooser.setDialogTitle("Save As ..."); - chooser.setAcceptAllFileFilterUsed(false); ! ! chooser.addChoosableFileFilter(new GraphicFilter()); ! ! int returnVal; - - if(saveas == null){ - returnVal = chooser.showSaveDialog(this); - }else{ - returnVal = JFileChooser.APPROVE_OPTION; - } - if(returnVal == JFileChooser.APPROVE_OPTION){ - //Get Selected file for saving GUI information - File tempFile = chooser.getSelectedFile(); ! ! ! ! ! //TODO Test if prefix isnt already added!!!!! ! ! ! ! //Set the Sim save file ! ! if(saveas == null){ ! if(tempFile.getPath().contains("."+SIM_PREFIX)) simSaveFile = new File(tempFile.getPath()); - else simSaveFile = new File(tempFile.getPath()+"."+SIM_PREFIX); - } - - - //TODO Remove me!!! - - //System.out.println(simSaveFile.getPath()); - - - //Save Simulation. - try{ ! Enumeration enum1 = GUInodeTable.keys(); ! String strSave = ""; - - while(enum1.hasMoreElements()){ String key = (String)enum1.nextElement(); - GuiNode tempNode = (GuiNode)GUInodeTable.get(key); - String lnk; --- 1925,1970 ---- public void Save(){ if(simSaveFile!=null) SaveAs(simSaveFile.getPath()); else SaveAs(null); } public void SaveAs(String saveas){ + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("Save As ..."); chooser.setAcceptAllFileFilterUsed(false); ! chooser.addChoosableFileFilter(new JNSTFilter()); int returnVal; if(saveas == null){ returnVal = chooser.showSaveDialog(this); }else{ returnVal = JFileChooser.APPROVE_OPTION; } if(returnVal == JFileChooser.APPROVE_OPTION){ //Get Selected file for saving GUI information File tempFile = chooser.getSelectedFile(); ! if(saveas == null){ if(tempFile.getPath().contains("."+SIM_PREFIX)) simSaveFile = new File(tempFile.getPath()); else simSaveFile = new File(tempFile.getPath()+"."+SIM_PREFIX); } //Save Simulation. try{ ! Enumeration enum1 = GUInodeTable.keys(); String strSave = ""; while(enum1.hasMoreElements()){ String key = (String)enum1.nextElement(); GuiNode tempNode = (GuiNode)GUInodeTable.get(key); String lnk; *************** *** 2034,2054 **** Object nics[] = Sim.getAllInterfaces(key); - - - Arrays.sort(nics); - - String strType = tempNode.getClass().toString(); - strType = strType.replaceFirst("class guiUI\\.",""); - - Point pnt1 = tempNode.getLocation(); - - strSave = strSave + key + "\n" --- 1972,1982 ---- *************** *** 2056,2131 **** + pnt1.x + "," + pnt1.y + "\n" + nics.length + "\n"; - - for (int i = 0; i < nics.length; i++) { String linkName = Sim.getLinkName(key, nics[i].toString()); ! strSave = strSave + nics[i] + "|" + linkName; ! ! if(tempNode instanceof NetworkLayerDevice){ ! ! String lP = "100.00"; ! ! try{ ! lnk = Sim.getLinkName(key, nics[i].toString()); ! lP = Double.valueOf(Sim.GetLinkProb(lnk)).toString(); ! }catch(Exception e){} ! ! ! strSave = strSave + "|" + Sim.getIpAddressForInterface(key,nics[i].toString()) ! ! + "|" + Sim.getSubnetMask(key,nics[i].toString()) ! ! + "|" + Sim.getDefaultGateway(key) + "|" + Sim.getMacAddressForInterface(key, nics[i].toString()) ! + "|" + lP; ! ! }else{ ! ! strSave = strSave + "|||"; ! } - - strSave = strSave + "\n"; - ! } ! try{ ! String routes[] = Sim.getRouteTableEntries(key); ! strSave = strSave + (routes.length-1) + "\n"; ! ! Route_entry r; ! ! for(int i=0; i<routes.length-1; i++){ ! ! r = Sim.getRouteEntry(key, routes[i]); ! ! strSave = strSave + routes[i] + "|" + r.gateway + "|" + r.genMask + "|" + r.Type + "|" + r.iFace + "\n"; ! ! } ! ! }catch(Exception e){ ! strSave = strSave + "0\n"; ! } } catch (Exception e) { //This should never happen - e.printStackTrace(); - } - - - - - - } --- 1984,2058 ---- + pnt1.x + "," + pnt1.y + "\n" + + + Sim.getNode(key).On + "\n" + nics.length + "\n"; for (int i = 0; i < nics.length; i++) { String linkName = Sim.getLinkName(key, nics[i].toString()); + int type = Sim.getNode(key).getIntType(nics[i].toString()); ! strSave = strSave + nics[i] + "|" + type + "|" + linkName; ! ! String lP = "100.00"; ! try{ ! lnk = Sim.getLinkName(key, nics[i].toString()); ! lP = Double.valueOf(Sim.GetLinkProb(lnk)).toString(); ! }catch(Exception e){} ! ! strSave += "|" + lP; ! ! switch(type){ ! case core.NetworkInterface.Ethernet10T: ! if((Sim.getNode(key).getNIC(nics[i].toString())) instanceof core.NetworkInterfacePort ){ ! strSave += "|#"; ! }else{ ! strSave += "|" + Sim.getMacAddressForInterface(key, nics[i].toString()); ! } ! break; ! case core.NetworkInterface.Console: ! break; ! case core.NetworkInterface.WAN: ! strSave += "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getConnType() ! + "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getServer() ! + "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getConnHost() ! + "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getConnPort() ! + "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getConnService(); ! break; ! case core.NetworkInterface.Serial: ! strSave += "|" + ! ((core.SerialNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getClockRate(); ! break; } ! strSave += "\n"; } + strSave += "#config\n"; ! if(Sim.getNode(key) instanceof core.NetworkLayerDevice){ ! Iterator<String> cnf = ((core.NetworkLayerDevice)Sim.getNode(key)).getConfig().getConfig(core.DeviceConfig.STARTUP_CONFIG).iterator(); ! while(cnf.hasNext()){ ! strSave += cnf.next() + "\n"; ! } ! } ! ! strSave += "#endconfig\n"; ! ! strSave += "#data\n"; + strSave += "#enddata\n"; + } catch (Exception e) { //This should never happen e.printStackTrace(); } } *************** *** 2152,2182 **** } - - - //FileOutputStream out = new FileOutputStream(simSaveFile); - - //ObjectOutputStream objStream = new ObjectOutputStream(out); - - - - //objStream.writeBytes("\n"); - - - - - - //objStream.flush(); - - - System.out.println("Writing Simulation file"); ! ! ! ! ! ! ! System.out.println("Simulation was saved succesfully."); System.out.println("File "+ simSaveFile.getName() + " has been saved to " + simSaveFile.getAbsolutePath()); --- 2079,2085 ---- } System.out.println("Writing Simulation file"); ! System.out.println("Simulation was saved succesfully."); System.out.println("File "+ simSaveFile.getName() + " has been saved to " + simSaveFile.getAbsolutePath()); *************** *** 2205,2208 **** --- 2108,2113 ---- public void save_html_rep(String saveas){ + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("Save HTML report..."); chooser.setAcceptAllFileFilterUsed(false); *************** *** 2267,2279 **** printLayerInfo(false); chooser.setDialogTitle("Open File ..."); ! //chooser.setMultiSelectionEnabled(true); ! //chooser.setAcceptAllFileFilterUsed(false); //TODO this needs to be false ! ! chooser.addChoosableFileFilter(new GraphicFilter()); int returnVal = chooser.showOpenDialog(this); --- 2172,2408 ---- printLayerInfo(false); + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("Open File ..."); + chooser.setMultiSelectionEnabled(false); + chooser.setAcceptAllFileFilterUsed(false); + chooser.addChoosableFileFilter(new JNSTFilter()); ! int returnVal = chooser.showOpenDialog(this); ! if(returnVal == JFileChooser.APPROVE_OPTION){ ! try { ! File inFile = chooser.getSelectedFile(); ! File simFile; ! if(inFile.getPath().contains("."+SIM_PREFIX)) simFile = new File(inFile.getPath()); ! else simFile = new File(inFile.getPath()+"."+SIM_PREFIX); ! ! this.refreshMainScreen(); ! ! ! BufferedReader input = null; ! ! try { ! ! input = new BufferedReader( new FileReader(simFile) ); ! String line = null; //not declared within while loop ! ! Vector DevicesTurnedOn = new Vector(); ! Hashtable links = new Hashtable(); ! ! while (( line = input.readLine()) != null){ ! ! String strNodeName; ! String strClassName; ! String coords; ! int intCount; ! int x; ! int y; ! int j; ! int deviceType = 0; ! boolean on = false; ! ! ! strNodeName = line; ! strClassName = input.readLine().trim(); ! coords = input.readLine(); ! on = Boolean.valueOf(input.readLine().trim()); ! intCount = Integer.valueOf(input.readLine()).intValue(); ! ! if(on) DevicesTurnedOn.add(strNodeName); ! ! String xy[] = coords.split(","); ! ! x = Integer.valueOf(xy[0]).intValue(); ! y = Integer.valueOf(xy[1]).intValue(); ! ! Point pnt = new Point(x,y); ! ! if(strClassName.contains("GuiHub")){ ! deviceType = 1; ! Sim.addHub(strNodeName, false); ! GuiHub tempHub = new GuiHub(strNodeName,this); ! tempHub.setNodeLocation(pnt); ! Sandbox.add(tempHub); ! Sandbox.setLayer((Component) tempHub,3,0); ! GUInodeTable.put(strNodeName,tempHub); ! }else if(strClassName.contains("GuiSwitch")){ ! deviceType = 1; ! Sim.addSwitch(strNodeName, false); ! GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); ! tempSwitch.setNodeLocation(pnt); ! Sandbox.add(tempSwitch); ! Sandbox.setLayer(tempSwitch,3,0); ! GUInodeTable.put(strNodeName,tempSwitch); ! }else if(strClassName.contains("GuiCSUDSU")){ ! deviceType = 1; ! Sim.addCSUDSU(strNodeName, false); ! GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); ! tempCSUDSU.setNodeLocation(pnt); ! Sandbox.add(tempCSUDSU); ! Sandbox.setLayer(tempCSUDSU,3,0); ! GUInodeTable.put(strNodeName,tempCSUDSU); ! }else if(strClassName.contains("GuiPC")){ ! deviceType = 2; ! Sim.addPC(strNodeName, false); ! GuiPC tempPC = new GuiPC(strNodeName,this); ! tempPC.setNodeLocation(pnt); ! Sandbox.add(tempPC); ! Sandbox.setLayer(tempPC,3,0); ! GUInodeTable.put(strNodeName,tempPC); ! }else if(strClassName.contains("GuiRouter")){ ! deviceType = 2; ! Sim.addRouter(strNodeName, false); ! GuiRouter tempRouter = new GuiRouter(strNodeName,this); ! tempRouter.setNodeLocation(pnt); ! Sandbox.add(tempRouter); ! Sandbox.setLayer(tempRouter,3,0); ! GUInodeTable.put(strNodeName,tempRouter); ! }else if(strClassName.contains("GuiExternalProxy")){ ! deviceType = 2; ! Sim.addExternalNAT(strNodeName, false); ! GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); ! tempRouter.setNodeLocation(pnt); ! Sandbox.add(tempRouter); ! Sandbox.setLayer(tempRouter,3,0); ! GUInodeTable.put(strNodeName,tempRouter); ! } ! ! ! String sieve = "100.00"; ! ! for(j = 1; j<=intCount; j++){ ! ! line = input.readLine(); ! ! String iface[] = line.split("\\|"); ! ! int LinkType = Integer.valueOf(iface[1]); ! ! String strLinkName = iface[2]; ! ! sieve = iface[3]; ! ! switch(LinkType){ ! case core.NetworkInterface.Ethernet10T: ! if(!iface[4].contains("#")) ! try{ ! //FIXME!!!!!!! ! Sim.setMACAddress(strNodeName,iface[0], iface[4]); ! }catch(Exception e){ } ! break; ! case core.NetworkInterface.Serial: ! ((core.SerialNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setClockRate(Integer.valueOf(iface[4])); ! break; ! } ! ! if(!strLinkName.contains("null")){ ! ! if(((String)links.get(strLinkName)) == null){ ! ! links.put(strLinkName, strNodeName + "|" + iface[0] + "|" + sieve); ! ! }else{ ! ! String ln[] = ((String) links.get(strLinkName)).split("\\|"); ! ! switch(LinkType){ ! case core.NetworkInterface.Ethernet10T: ! Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Ethernet10T); ! break; ! case core.NetworkInterface.Console: ! Sim.addConsoleLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Console); ! break; ! case core.NetworkInterface.Serial: ! Sim.addSerialLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Serial); ! break; ! } ! } ! ! } ! ! } ! ! line = input.readLine(); ! if(line.contains("#config")){ ! line = input.readLine(); ! while(!line.contains("#endconfig")){ ! ((core.NetworkLayerDevice)Sim.getNode(strNodeName)).getConfig().add(line,core.DeviceConfig.STARTUP_CONFIG); ! line = input.readLine(); ! } ! } ! ! line = input.readLine(); ! if(line.contains("#data")){ ! line = input.readLine(); ! while(!line.contains("#enddata")){ ! line = input.readLine(); ! if(line == null) break; ! } ! } ! ! /// ! ! }//while ! ! for(int i =0; i<DevicesTurnedOn.size() ;i++){ ! String nodeName = (String) DevicesTurnedOn.get(i); ! Sim.getNode(nodeName).turnOn(); ! } ! ! this.refreshNodeInformationTab(); ! simSaveFile = simFile; ! ! ! }finally { ! try { ! if (input!= null) { ! //flush and close both "input" and its underlying FileReader ! input.close(); ! } ! } catch (IOException ex) { ! ex.printStackTrace(); ! } ! } ! ! } catch (FileNotFoundException e) { ! e.printStackTrace(); ! } catch (IOException e){ ! e.printStackTrace(); ! } catch (Exception e){ ! e.printStackTrace(); ! } ! } ! } ! ! ! public void Import(){ ! ! printLayerInfo(false); ! ! JFileChooser chooser = new JFileChooser(); ! ! chooser.setDialogTitle("Import simulation from previous versions ..."); ! ! chooser.setMultiSelectionEnabled(false); ! ! chooser.setAcceptAllFileFilterUsed(false); ! ! chooser.addChoosableFileFilter(new JFSTFilter()); int returnVal = chooser.showOpenDialog(this); *************** *** 2291,2297 **** File simFile; ! if(inFile.getPath().contains("."+SIM_PREFIX)) simFile = new File(inFile.getPath()); ! else simFile = new File(inFile.getPath()+"."+SIM_PREFIX); --- 2420,2426 ---- File simFile; ! if(inFile.getPath().contains("."+OLD_PREFIX)) simFile = new File(inFile.getPath()); ! else simFile = new File(inFile.getPath()+"."+OLD_PREFIX); *************** *** 2372,2376 **** deviceType = 1; ! Sim.addHub(strNodeName); GuiHub tempHub = new GuiHub(strNodeName,this); --- 2501,2505 ---- deviceType = 1; ! Sim.addHub(strNodeName, true); GuiHub tempHub = new GuiHub(strNodeName,this); *************** *** 2389,2393 **** deviceType = 1; ! Sim.addSwitch(strNodeName); GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); --- 2518,2522 ---- deviceType = 1; ! Sim.addSwitch(strNodeName, true); GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); *************** *** 2405,2409 **** deviceType = 1; ! Sim.addCSUDSU(strNodeName); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); --- 2534,2538 ---- deviceType = 1; ! Sim.addCSUDSU(strNodeName, true); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); *************** *** 2422,2426 **** deviceType = 2; ! Sim.addPC(strNodeName); GuiPC tempPC = new GuiPC(strNodeName,this); --- 2551,2555 ---- deviceType = 2; ! Sim.addPC(strNodeName, true); GuiPC tempPC = new GuiPC(strNodeName,this); *************** *** 2438,2442 **** deviceType = 2; ! Sim.addRouter(strNodeName); GuiRouter tempRouter = new GuiRouter(strNodeName,this); --- 2567,2571 ---- deviceType = 2; ! Sim.addRouter(strNodeName, true); GuiRouter tempRouter = new GuiRouter(strNodeName,this); *************** *** 2454,2458 **** deviceType = 2; ! Sim.addExternalNAT(strNodeName); GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); --- 2583,2587 ---- deviceType = 2; ! Sim.addExternalNAT(strNodeName, true); GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); *************** *** 2599,2603 **** //save the file for later use with the saveSim method ! simSaveFile = simFile; --- 2728,2732 ---- //save the file for later use with the saveSim method ! //simSaveFile = simFile; *************** *** 2627,2633 **** } - - - /** --- 2756,2759 ---- *************** *** 3089,3128 **** ! class GraphicFilter extends FileFilter{ ! ! ! ! /** ! ! * This method returns the Description that is in the File choosers Dialog ! ! */ ! public String getDescription(){ ! ! return "Simulation File (*."+GUI_PREFIX+")"; ! } - - - - /** - - * This method returns true or false if a file has the prefix - - */ - public boolean accept(File f) { ! ! if(f.isDirectory() || f.getName().endsWith(GUI_PREFIX)){ ! return true; - } return false; ! ! } --- 3215,3241 ---- ! class JFSTFilter extends FileFilter{ public String getDescription(){ ! return "Old Simulation File (*."+OLD_PREFIX+")"; } public boolean accept(File f) { ! if(f.isDirectory() || f.getName().endsWith(OLD_PREFIX)){ return true; } return false; + } + } + + class JNSTFilter extends FileFilter{ + public String getDescription(){ + return "Simulation File (*."+SIM_PREFIX+")"; + } ! public boolean accept(File f) { ! if(f.isDirectory() || f.getName().endsWith(SIM_PREFIX)){ ! return true; ! } ! return false; } Index: MenuBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MenuBar.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** MenuBar.java 15 Oct 2007 18:25:54 -0000 1.16 --- MenuBar.java 19 Oct 2007 08:52:27 -0000 1.17 *************** *** 25,30 **** --- 25,35 ---- private JMenuItem mnuOpen = new JMenuItem("Open ..."); //Open a old simulation + private JMenuItem mnuSave = new JMenuItem("Save ..."); //Save a simulation private JMenuItem mnuSaveAs = new JMenuItem("Save As..."); //Save a simulation + //HTML report generator menu + + private JMenuItem mnuImport = new JMenuItem("Import ..."); //Open a old simulation + private JMenuItem mnuGenRep = new JMenuItem("Export to HTML ..."); private JMenuItem mnuExit = new JMenuItem("Exit"); //Exit appliction //private JMenuItem mnuClose = new JMenuItem("Close"); //Close *************** *** 48,54 **** private JCheckBoxMenuItem mnuMsgApplication = new JCheckBoxMenuItem("Application Layer",true); ! //HTML report generator menu ! private JMenuItem mnuGenRep = new JMenuItem("Generate HTML report..."); ! //Add submenu private JMenu mnuAdd = new JMenu("Add"); //For Adding objects to simulation private JMenuItem mnuPC = new JMenuItem("PC ..."); --- 53,57 ---- private JCheckBoxMenuItem mnuMsgApplication = new JCheckBoxMenuItem("Application Layer",true); ! //Add submenu private JMenu mnuAdd = new JMenu("Add"); //For Adding objects to simulation private JMenuItem mnuPC = new JMenuItem("PC ..."); *************** *** 59,73 **** private JMenuItem mnuExternalNAT = new JMenuItem("Socks Proxy..."); - //Tools submenu - private JMenu mnuTools = new JMenu("Tools"); - private JMenuItem mnuSetTCPIPProperties = new JMenuItem("Set TCP/IP Properties ..."); - - /* - private JMenu mnuScenario = new JMenu("Scenario's"); - private JMenuItem mnuTest1 = new JMenuItem("Test 1"); - private JMenuItem mnuTest2 = new JMenuItem("Test 2"); - private JMenuItem mnuTest3 = new JMenuItem("Test 3"); - private JMenuItem mnuTest4 = new JMenuItem("Test 4"); - */ //help menu private JMenu mnuHelp = new JMenu("Help"); --- 62,65 ---- *************** *** 119,128 **** mnuFile.add(mnuNew); mnuFile.add(mnuOpen); mnuFile.add(mnuSave); mnuFile.add(mnuSaveAs); mnuFile.add(mnuExit); //Add items to simulation menu ! mnuSimulation.add(mnuGenRep); mnuSimulation.add(mnuAdd); mnuAdd.add(mnuPC); --- 111,125 ---- mnuFile.add(mnuNew); mnuFile.add(mnuOpen); + mnuFile.add(mnuSave); mnuFile.add(mnuSaveAs); + mnuFile.addSeparator(); + mnuFile.add(mnuImport); + mnuFile.add(mnuGenRep); + mnuFile.addSeparator(); mnuFile.add(mnuExit); //Add items to simulation menu ! mnuSimulation.add(mnuAdd); mnuAdd.add(mnuPC); *************** *** 133,138 **** mnuAdd.add(mnuExternalNAT); - mnuSimulation.add(mnuTools); - mnuTools.add(mnuSetTCPIPProperties); //mnuSimulation.add(mnuScenario); --- 130,133 ---- *************** *** 178,191 **** //mnuSwitch.setMnemonic('S'); - mnuTools.setMnemonic('T'); - mnuSetTCPIPProperties.setMnemonic('I'); - - /*mnuScenario.setMnemonic('S'); - mnuTest1.setMnemonic('1'); - mnuTest2.setMnemonic('2'); - mnuTest3.setMnemonic('3'); - mnuTest4.setMnemonic('4'); - */ - mnuEnvironment.setMnemonic('E'); mnuClearConsole.setMnemonic('C'); --- 173,176 ---- *************** *** 337,340 **** --- 322,332 ---- } }); + + //Add action listener to Save menu item + mnuImport.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.Import(); + } + }); //Add action listener to New menu item *************** *** 346,355 **** }); - mnuSetTCPIPProperties.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - controller.setTCPIPProperties(null); - } - }); - mnuAbout.addActionListener(new ActionListener() { --- 338,341 ---- |
From: Alexander B. <da...@us...> - 2007-10-19 08:52:42
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11211/core Modified Files: ApplicationLayerDevice.java CSUDSU.java DataLinkLayerDevice.java ExternalProxy.java Hub.java NetworkInterface.java NetworkLayerDevice.java Node.java PC.java ProtocolStack.java Router.java SerialNetworkInterface.java Simulation.java Switch.java WANNetworkInterface.java Log Message: New save file format; import. Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PC.java 15 Oct 2007 21:41:42 -0000 1.15 --- PC.java 19 Oct 2007 08:52:26 -0000 1.16 *************** *** 104,119 **** * @version v0.10 */ ! protected PC(String inName) { ! super(inName,7); //initApplications() have been called in ApplicaitonLayerDevice addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Console) + "0", NetworkInterface.Console, false); //addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Wireless) + "0", NetworkInterface.Wireless, true); ! //addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.WAN) + "0" + "_" + (int)(Math.random()*1000), NetworkInterface.WAN, true); ! } public void initApplications(){ ! super.initApplications(); Echo echoServer = new Echo(NodeProtocolStack, 7, 1, core.ProtocolStack.UIDGen++); --- 104,118 ---- * @version v0.10 */ ! protected PC(String inName, boolean inOn) { ! super(inName,7, inOn); //initApplications() have been called in ApplicaitonLayerDevice addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Console) + "0", NetworkInterface.Console, false); //addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Wireless) + "0", NetworkInterface.Wireless, true); ! //addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.WAN) + "0" + "_" + (int)(Math.random()*1000), NetworkInterface.WAN, true); } public void initApplications(){ ! super.initApplications(); Echo echoServer = new Echo(NodeProtocolStack, 7, 1, core.ProtocolStack.UIDGen++); Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Node.java 16 Oct 2007 23:02:31 -0000 1.14 --- Node.java 19 Oct 2007 08:52:26 -0000 1.15 *************** *** 151,163 **** */ ! protected Node(String inName, int inProtocolStackLayers) { ! NetworkInterfacetable = new Hashtable(); ! name=inName; ! ProtocolStackLayers = inProtocolStackLayers; ! init(inProtocolStackLayers); } --- 151,165 ---- */ ! protected Node(String inName, int inProtocolStackLayers, boolean inOn) { ! NetworkInterfacetable = new Hashtable(); ! name=inName; ! ProtocolStackLayers = inProtocolStackLayers; ! init(inProtocolStackLayers); ! ! this.On = inOn; } Index: SerialNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/SerialNetworkInterface.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SerialNetworkInterface.java 15 Oct 2007 12:04:32 -0000 1.3 --- SerialNetworkInterface.java 19 Oct 2007 08:52:26 -0000 1.4 *************** *** 29,33 **** package core; ! class SerialNetworkInterface extends NetworkInterface{ /** * FrameRelay ClockRate --- 29,33 ---- package core; ! public class SerialNetworkInterface extends NetworkInterface{ /** * FrameRelay ClockRate *************** *** 47,51 **** LayerInfo pingInfo = new LayerInfo(getClass().getName()); pingInfo.setObjectName(parentNode.getName()); ! pingInfo.setDataType("FrameRelay Packet"); pingInfo.setLayer("Link"); pingInfo.setDescription("Recieved and accepted packet at interface " + name); --- 47,51 ---- LayerInfo pingInfo = new LayerInfo(getClass().getName()); pingInfo.setObjectName(parentNode.getName()); ! pingInfo.setDataType("HDLC Packet"); pingInfo.setLayer("Link"); pingInfo.setDescription("Recieved and accepted packet at interface " + name); *************** *** 57,61 **** LayerInfo pingInfo = new LayerInfo(getClass().getName()); pingInfo.setObjectName(parentNode.getName()); ! pingInfo.setDataType("FrameRelay Packet"); pingInfo.setLayer("Link"); pingInfo.setDescription("Recieved signal at interface " + name + " dropped due to invalid Clock rate."); --- 57,61 ---- LayerInfo pingInfo = new LayerInfo(getClass().getName()); pingInfo.setObjectName(parentNode.getName()); ! pingInfo.setDataType("HDLC Packet"); pingInfo.setLayer("Link"); pingInfo.setDescription("Recieved signal at interface " + name + " dropped due to invalid Clock rate."); *************** *** 77,81 **** LayerInfo pingInfo = new LayerInfo(getClass().getName()); pingInfo.setObjectName(parentNode.getName()); ! pingInfo.setDataType("FrameRelay Packet"); pingInfo.setLayer("Link"); pingInfo.setDescription("Sending packet from interface "+ name); --- 77,81 ---- LayerInfo pingInfo = new LayerInfo(getClass().getName()); pingInfo.setObjectName(parentNode.getName()); ! pingInfo.setDataType("HDLC Packet"); pingInfo.setLayer("Link"); pingInfo.setDescription("Sending packet from interface "+ name); *************** *** 88,92 **** LayerInfo frameErrInfo = new LayerInfo(getClass().getName()); frameErrInfo.setObjectName(parentNode.getName()); ! frameErrInfo.setDataType("FrameRelay Packet"); frameErrInfo.setLayer("Link"); frameErrInfo.setDescription(ex.toString()); --- 88,92 ---- LayerInfo frameErrInfo = new LayerInfo(getClass().getName()); frameErrInfo.setObjectName(parentNode.getName()); ! frameErrInfo.setDataType("HDLC Packet"); frameErrInfo.setLayer("Link"); frameErrInfo.setDescription(ex.toString()); *************** *** 103,107 **** * @version v0.20 */ ! protected int getClockRate() { return ClockRate; } --- 103,107 ---- * @version v0.20 */ ! public int getClockRate() { return ClockRate; } *************** *** 111,115 **** } ! protected final void setClockRate(int ClockRate){ this.ClockRate = ClockRate; } --- 111,115 ---- } ! public final void setClockRate(int ClockRate){ this.ClockRate = ClockRate; } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Simulation.java 18 Oct 2007 22:22:09 -0000 1.20 --- Simulation.java 19 Oct 2007 08:52:26 -0000 1.21 *************** *** 934,938 **** modifiedInterface.removeConnectedLink(); ! //Remove any disconnected links from the simulation Enumeration keys = linkTable.keys(); --- 934,938 ---- modifiedInterface.removeConnectedLink(); ! //Remove any disconnected links from the simulation Enumeration keys = linkTable.keys(); *************** *** 982,988 **** * @version v0.20 **/ ! public void addRouter(String inRouterName)throws InvalidNodeNameException { if (!nodeTable.containsKey(inRouterName)) { ! nodeTable.put(inRouterName, new Router(inRouterName)); } else { throw new InvalidNodeNameException("Node already exists with same name"); --- 982,988 ---- * @version v0.20 **/ ! public void addRouter(String inRouterName, boolean inOn)throws InvalidNodeNameException { if (!nodeTable.containsKey(inRouterName)) { ! nodeTable.put(inRouterName, new Router(inRouterName, inOn)); } else { throw new InvalidNodeNameException("Node already exists with same name"); *************** *** 991,997 **** } ! public void addExternalNAT(String inRouterName)throws InvalidNodeNameException { if (!nodeTable.containsKey(inRouterName)) { ! nodeTable.put(inRouterName, new ExternalProxy(inRouterName)); } else { throw new InvalidNodeNameException("Node already exists with same name"); --- 991,997 ---- } ! public void addExternalNAT(String inRouterName, boolean inOn)throws InvalidNodeNameException { if (!nodeTable.containsKey(inRouterName)) { ! nodeTable.put(inRouterName, new ExternalProxy(inRouterName, inOn)); } else { throw new InvalidNodeNameException("Node already exists with same name"); *************** *** 1008,1014 **** * @version v0.20 **/ ! public void addPC(String inPCName) throws InvalidNodeNameException { if (!nodeTable.containsKey(inPCName)) { ! nodeTable.put(inPCName, new PC(inPCName)); } else { throw new InvalidNodeNameException("Node already exists with same name"); --- 1008,1014 ---- * @version v0.20 **/ ! public void addPC(String inPCName, boolean inOn) throws InvalidNodeNameException { if (!nodeTable.containsKey(inPCName)) { ! nodeTable.put(inPCName, new PC(inPCName, inOn)); } else { throw new InvalidNodeNameException("Node already exists with same name"); *************** *** 1026,1032 **** * @version v0.20 **/ ! public void addHub(String inNodeName) throws InvalidNodeNameException { if (!nodeTable.containsKey(inNodeName)) { ! nodeTable.put(inNodeName, new Hub(inNodeName)); } else { throw new InvalidNodeNameException("Node already exists with same name"); --- 1026,1032 ---- * @version v0.20 **/ ! public void addHub(String inNodeName, boolean inOn) throws InvalidNodeNameException { if (!nodeTable.containsKey(inNodeName)) { ! nodeTable.put(inNodeName, new Hub(inNodeName, inOn)); } else { throw new InvalidNodeNameException("Node already exists with same name"); *************** *** 1034,1040 **** } ! public void addCSUDSU(String inNodeName) throws InvalidNodeNameException { if (!nodeTable.containsKey(inNodeName)) { ! nodeTable.put(inNodeName, new CSUDSU(inNodeName)); } else { throw new InvalidNodeNameException("Node already exists with same name"); --- 1034,1040 ---- } ! public void addCSUDSU(String inNodeName, boolean inOn) throws InvalidNodeNameException { if (!nodeTable.containsKey(inNodeName)) { ! nodeTable.put(inNodeName, new CSUDSU(inNodeName, inOn)); } else { throw new InvalidNodeNameException("Node already exists with same name"); *************** *** 1050,1056 **** * @version v0.20 **/ ! public void addSwitch(String inNodeName) throws InvalidNodeNameException { if(!nodeTable.containsKey(inNodeName)){ ! nodeTable.put(inNodeName, new Switch(inNodeName)); }else{ throw new InvalidNodeNameException("Node already exists with same name"); --- 1050,1056 ---- * @version v0.20 **/ ! public void addSwitch(String inNodeName, boolean inOn) throws InvalidNodeNameException { if(!nodeTable.containsKey(inNodeName)){ ! nodeTable.put(inNodeName, new Switch(inNodeName, inOn)); }else{ throw new InvalidNodeNameException("Node already exists with same name"); Index: Hub.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Hub.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Hub.java 13 Oct 2007 12:57:00 -0000 1.6 --- Hub.java 19 Oct 2007 08:52:26 -0000 1.7 *************** *** 55,60 **** ! public Hub(String inName) { ! super(inName, 1); //pass name and protocolstack layer addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, false); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, false); --- 55,60 ---- ! public Hub(String inName, boolean inOn) { ! super(inName, 1, inOn); //pass name and protocolstack layer addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, false); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, false); Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ProtocolStack.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ProtocolStack.java 13 Oct 2007 12:57:00 -0000 1.7 --- ProtocolStack.java 19 Oct 2007 08:52:26 -0000 1.8 *************** *** 150,153 **** --- 150,154 ---- + public abstract void intUP(String iface); }//EOF Index: DataLinkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DataLinkLayerDevice.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DataLinkLayerDevice.java 13 Oct 2007 12:57:00 -0000 1.3 --- DataLinkLayerDevice.java 19 Oct 2007 08:52:26 -0000 1.4 *************** *** 43,48 **** * @version v0.20 */ ! public DataLinkLayerDevice(String inName, int inProtocolStackLayers) { ! super(inName, inProtocolStackLayers); } --- 43,48 ---- * @version v0.20 */ ! public DataLinkLayerDevice(String inName, int inProtocolStackLayers, boolean inOn) { ! super(inName, inProtocolStackLayers, inOn); } Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NetworkInterface.java 16 Oct 2007 23:02:31 -0000 1.9 --- NetworkInterface.java 19 Oct 2007 08:52:26 -0000 1.10 *************** *** 115,118 **** --- 115,128 ---- protected boolean up; + protected boolean dhcp; + + public boolean getDHCP(){ + return dhcp; + } + + public void setDHCP(boolean inDHÑP){ + dhcp = inDHÑP; + } + protected String description = ""; *************** *** 124,128 **** pingInfo.setLayer("Link"); pingInfo.setDescription("Interface " + name + " state set to up!"); ! Simulation.addLayerInfo(pingInfo); } --- 134,141 ---- pingInfo.setLayer("Link"); pingInfo.setDescription("Interface " + name + " state set to up!"); ! Simulation.addLayerInfo(pingInfo); ! if( parentNode.NodeProtocolStack != null){ ! parentNode.NodeProtocolStack.intUP(name); ! } } Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** NetworkLayerDevice.java 15 Oct 2007 12:04:32 -0000 1.11 --- NetworkLayerDevice.java 19 Oct 2007 08:52:26 -0000 1.12 *************** *** 58,63 **** * @version v0.20 */ ! public NetworkLayerDevice(String inName, int inProtocolStackLayers) { ! super(inName, inProtocolStackLayers); //set default startup-config config.working_config = DeviceConfig.STARTUP_CONFIG; --- 58,63 ---- * @version v0.20 */ ! public NetworkLayerDevice(String inName, int inProtocolStackLayers, boolean inOn) { ! super(inName, inProtocolStackLayers, inOn); //set default startup-config config.working_config = DeviceConfig.STARTUP_CONFIG; Index: Router.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Router.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Router.java 15 Oct 2007 12:04:32 -0000 1.5 --- Router.java 19 Oct 2007 08:52:26 -0000 1.6 *************** *** 45,50 **** * @version v0.10 **/ ! protected Router(String inName) { ! super(inName,3); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, true); --- 45,50 ---- * @version v0.10 **/ ! protected Router(String inName, boolean inOn) { ! super(inName,3, inOn); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, true); Index: Switch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Switch.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Switch.java 13 Oct 2007 12:57:00 -0000 1.6 --- Switch.java 19 Oct 2007 08:52:26 -0000 1.7 *************** *** 57,62 **** ! public Switch(String inName) { ! super(inName, 1); //pass name and protocolstack layer IntCaches = new Hashtable(); --- 57,62 ---- ! public Switch(String inName, boolean inOn) { ! super(inName, 1, inOn); //pass name and protocolstack layer IntCaches = new Hashtable(); Index: CSUDSU.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CSUDSU.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CSUDSU.java 15 Oct 2007 18:25:54 -0000 1.1 --- CSUDSU.java 19 Oct 2007 08:52:26 -0000 1.2 *************** *** 36,41 **** int sz = 0; ! public CSUDSU(String inName) { ! super(inName, 1); //pass name and protocolstack layer lanPort = "ser0"; --- 36,41 ---- int sz = 0; ! public CSUDSU(String inName, boolean inOn) { ! super(inName, 1, inOn); //pass name and protocolstack layer lanPort = "ser0"; Index: WANNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANNetworkInterface.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WANNetworkInterface.java 15 Oct 2007 18:25:54 -0000 1.2 --- WANNetworkInterface.java 19 Oct 2007 08:52:26 -0000 1.3 *************** *** 95,102 **** } ! public void UP(){ ! super.UP(); up = listen(); up &= connect(); } --- 95,102 ---- } ! public void UP(){ up = listen(); up &= connect(); + super.UP(); } Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ApplicationLayerDevice.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ApplicationLayerDevice.java 15 Oct 2007 21:41:42 -0000 1.5 --- ApplicationLayerDevice.java 19 Oct 2007 08:52:24 -0000 1.6 *************** *** 19,26 **** protected Hashtable Apps = null; /** Creates a new instance of ApplicationLayerDevice */ ! public ApplicationLayerDevice(String inName, int inProtocolStackLayers) { ! super(inName, inProtocolStackLayers); Apps = new Hashtable(); ! initApplications(); } --- 19,26 ---- protected Hashtable Apps = null; /** Creates a new instance of ApplicationLayerDevice */ ! public ApplicationLayerDevice(String inName, int inProtocolStackLayers, boolean inOn) { ! super(inName, inProtocolStackLayers, inOn); Apps = new Hashtable(); ! if(inOn) initApplications(); } Index: ExternalProxy.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ExternalProxy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExternalProxy.java 13 Oct 2007 12:57:00 -0000 1.2 --- ExternalProxy.java 19 Oct 2007 08:52:26 -0000 1.3 *************** *** 66,71 **** * @version v0.10 **/ ! protected ExternalProxy(String inName) { ! super(inName,3); NodeProtocolStack.initNAT(); addNetworkInterface("eth0", NetworkInterface.Ethernet10T, true ); --- 66,71 ---- * @version v0.10 **/ ! protected ExternalProxy(String inName, boolean inOn) { ! super(inName,3, inOn); NodeProtocolStack.initNAT(); addNetworkInterface("eth0", NetworkInterface.Ethernet10T, true ); |
From: Alexander B. <da...@us...> - 2007-10-19 08:52:34
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11211/core/protocolsuite/tcp_ip Modified Files: Echo.java ProtocolStack.java Log Message: New save file format; import. Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** ProtocolStack.java 15 Oct 2007 12:04:33 -0000 1.61 --- ProtocolStack.java 19 Oct 2007 08:52:27 -0000 1.62 *************** *** 737,740 **** --- 737,747 ---- Simulation.addLayerInfo(UDP_Info); // throw tpe; + }catch(NullPointerException e){ + LayerInfo UDP_Info = new LayerInfo(getClass().getName()); + UDP_Info.setObjectName(getParentNodeName()); + UDP_Info.setDataType("UDP Packet"); + UDP_Info.setLayer("Transport"); + UDP_Info.setDescription("Transport level doesn't dupport on this device."); + Simulation.addLayerInfo(UDP_Info); } *************** *** 746,751 **** }catch(TransportLayerException te){} catch(NullPointerException e){ ! System.out.println("ProtocolStack.java: receivePacket" + e.toString()); ! e.printStackTrace(); } catch (CommunicationException ce) {} --- 753,762 ---- }catch(TransportLayerException te){} catch(NullPointerException e){ ! LayerInfo UDP_Info = new LayerInfo(getClass().getName()); ! UDP_Info.setObjectName(getParentNodeName()); ! UDP_Info.setDataType("TCP Packet"); ! UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Transport level doesn't dupport on this device."); ! Simulation.addLayerInfo(UDP_Info); } catch (CommunicationException ce) {} *************** *** 1245,1249 **** } return ""; ! } --- 1256,1264 ---- } return ""; ! } ! ! public void intUP(String iface){ ! ! } Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Echo.java 15 Oct 2007 21:41:42 -0000 1.29 --- Echo.java 19 Oct 2007 08:52:26 -0000 1.30 *************** *** 219,223 **** Simulation.addLayerInfo(protInfo); ! SendData(Data); } else { LayerInfo protInfo = new LayerInfo(getClass().getName()); --- 219,226 ---- Simulation.addLayerInfo(protInfo); ! SendData(Data); ! //try{ ! //Thread.sleep(5); ! //}catch(Exception e){} } else { LayerInfo protInfo = new LayerInfo(getClass().getName()); |
From: Alexander B. <da...@us...> - 2007-10-19 08:52:32
|
Update of /cvsroot/javanetsim/javaNetSim/textUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11211/textUI Modified Files: TextUI.java Log Message: New save file format; import. Index: TextUI.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/textUI/TextUI.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TextUI.java 13 Sep 2007 13:38:53 -0000 1.2 --- TextUI.java 19 Oct 2007 08:52:27 -0000 1.3 *************** *** 1,1598 **** /* Java Firewall Simulator (jFirewallSim) Copyright (c) 2004, jFirewallSim development team All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. [...4766 lines suppressed...] }else{ + System.out.println(); + } + } + + + }//EOF + + + \ No newline at end of file |
From: Alexander B. <da...@us...> - 2007-10-19 08:52:31
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/ipx_spx In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11211/core/protocolsuite/ipx_spx Modified Files: ProtocolStack.java Log Message: New save file format; import. Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/ipx_spx/ProtocolStack.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProtocolStack.java 13 Oct 2007 12:57:00 -0000 1.3 --- ProtocolStack.java 19 Oct 2007 08:52:26 -0000 1.4 *************** *** 46,49 **** --- 46,52 ---- public void receivePacket(Packet inPacket, String inInterface){ } + public void intUP(String iface){ + + } }//EOF |
From: QweR <qw...@us...> - 2007-10-18 22:22:15
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17909/core Modified Files: CommandProcessor.java DeviceConfig.java EthernetNetworkInterface.java Simulation.java Log Message: some console command was corrected Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CommandProcessor.java 16 Oct 2007 23:02:31 -0000 1.5 --- CommandProcessor.java 18 Oct 2007 22:22:09 -0000 1.6 *************** *** 10,13 **** --- 10,16 ---- package core; + import core.protocolsuite.tcp_ip.DHCPC; + import core.protocolsuite.tcp_ip.DHCPD; + import core.protocolsuite.tcp_ip.IPV4Address; import core.protocolsuite.tcp_ip.InvalidIPAddressException; import core.protocolsuite.tcp_ip.InvalidSubnetMaskException; *************** *** 19,22 **** --- 22,26 ---- import core.protocolsuite.tcp_ip.jnSocket; import java.util.Enumeration; + import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; *************** *** 40,43 **** --- 44,48 ---- private NetworkLayerDevice device; private CommandsTree commands = new CommandsTree(); + private Hashtable pools = new Hashtable(); private NoCommandClass noCommand = new NoCommandClass(); *************** *** 77,80 **** --- 82,89 ---- private no_interface__mac_address_CommandClass no_interface__mac_address_Command = new no_interface__mac_address_CommandClass(); private no_interface__shutdown_CommandClass no_interface__shutdown_Command = new no_interface__shutdown_CommandClass(); + private ip_dhcp_pool_CommandClass ip_dhcp_pool_Command = new ip_dhcp_pool_CommandClass(); + private no_ip_dhcp_pool_CommandClass no_ip_dhcp_pool_Command = new no_ip_dhcp_pool_CommandClass(); + private ip_local_pool_CommandClass ip_local_pool_Command = new ip_local_pool_CommandClass(); + private no_ip_local_pool_CommandClass no_ip_local_pool_Command = new no_ip_local_pool_CommandClass(); private ip_route_CommandClass ip_route_Command = new ip_route_CommandClass(); private no_ip_route_CommandClass no_ip_route_Command = new no_ip_route_CommandClass(); *************** *** 154,158 **** commands.add("interface * mac-address", interface__mac_address_Command, CONF_MODE | NETWORK_LAYER, "<MAC>", "Manually set interface MAC address"); commands.add("interface * shutdown", interface__shutdown_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Shutdown the selected interface"); - commands.addDescription("no interface","Select an interface to configure"); commands.addDescription("no interface *","Any available interface name"); --- 163,166 ---- *************** *** 172,181 **** commands.add("no interface * shutdown", no_interface__shutdown_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Up the selected interface"); commands.addDescription("ip","Global IP configuration subcommands"); ! commands.addDescription("no ip","Global IP configuration subcommands"); ! commands.add("ip route", ip_route_Command, CONF_MODE | NETWORK_LAYER, "(<host ip>|<network ip>) <netmask> <gateway> <target interface>", "Add route record"); commands.add("no ip route", no_ip_route_Command, CONF_MODE | NETWORK_LAYER, "(<host ip>|<network ip>)", "Delete route record"); commands.addDescription("ip tcp","Global TCP parameters"); commands.add("ip tcp window-size", ip_tcp_window_size_Command, CONF_MODE | TRANSPORT_LAYER, "<window-size>", "TCP window size"); commands.addDescription("show","Show running system information"); commands.add("show access-lists", show_access_lists_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<1-2699 | WORD>", "List access lists"); --- 180,198 ---- commands.add("no interface * shutdown", no_interface__shutdown_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Up the selected interface"); + commands.addDescription("ip dhcp","Configure DHCP server"); + commands.addDescription("no ip dhcp","Configure DHCP server"); + commands.add("ip dhcp pool", ip_dhcp_pool_Command, CONF_MODE | APPLICATION_LAYER, "<pool>", "Configure DHCP address pools"); + commands.add("no ip dhcp pool", no_ip_dhcp_pool_Command, CONF_MODE | APPLICATION_LAYER, "<pool>", "Configure DHCP address pools"); + commands.addDescription("ip local","Specify local options"); + commands.addDescription("no ip local","Specify local options"); + commands.add("ip local pool", ip_local_pool_Command, CONF_MODE | NETWORK_LAYER, "<pool> <first ip> <last ip>", "IP Local address pool lists"); + commands.add("no ip local pool", no_ip_local_pool_Command, CONF_MODE | NETWORK_LAYER, "<pool>", "IP Local address pool lists"); commands.addDescription("ip","Global IP configuration subcommands"); ! commands.addDescription("no ip","Negative global IP configuration subcommands"); ! commands.add("ip route", ip_route_Command, CONF_MODE | NETWORK_LAYER, "(<host ip>|<network ip>) <netmask> <gateway> [<target interface>]", "Add route record"); commands.add("no ip route", no_ip_route_Command, CONF_MODE | NETWORK_LAYER, "(<host ip>|<network ip>)", "Delete route record"); commands.addDescription("ip tcp","Global TCP parameters"); commands.add("ip tcp window-size", ip_tcp_window_size_Command, CONF_MODE | TRANSPORT_LAYER, "<window-size>", "TCP window size"); + commands.addDescription("show","Show running system information"); commands.add("show access-lists", show_access_lists_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<1-2699 | WORD>", "List access lists"); *************** *** 210,213 **** --- 227,231 ---- commands.add("show udp statistics", show_udp_statistics_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "UDP statistics"); commands.add("show version", show_version_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "System hardware and software status"); + commands.addDescription("snmp-server","Modify SNMP engine parameters"); commands.add("snmp-server community", snmp_server_community_Command, CONF_MODE | APPLICATION_LAYER, "<community>", "Enable SNMP; set community string"); *************** *** 298,302 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 316,320 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 312,316 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 330,334 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 324,328 **** device.removeARP(ArpTable.get(i).get(0)); } ! out += "ARP table have been cleared\n"; return out; } --- 342,346 ---- device.removeARP(ArpTable.get(i).get(0)); } ! out += "ARP table has been cleared\n"; return out; } *************** *** 389,393 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 407,411 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 417,421 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 435,439 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 448,452 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 466,470 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 483,487 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 501,505 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 528,532 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! } else{ --- 546,576 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(PC.DHCP_CLIENT_ID); ! if(dhcpc!=null){ ! if(params.size()==1){ ! try { ! if(device.getNetworkInterface(params.get(0))!=null){ ! dhcpc.StartDHCPC(params.get(0), "169.254.0.1"); ! } ! } catch (InvalidNetworkInterfaceNameException ex) { ! out += "Invalid interface name\n"; ! } catch (CommunicationException ex) { ! //ex.printStackTrace(); ! } catch (LowLinkException ex) { ! //ex.printStackTrace(); ! } catch (TransportLayerException ex) { ! //ex.printStackTrace(); ! } catch (InvalidNetworkLayerDeviceException ex) { ! out += "internal error: Invalid network layer device\n"; ! //ex.printStackTrace(); ! } ! } ! else{ ! out += "error: invalid parameters\n"; ! } ! } ! else{ ! out += "This instruction not supported by device\n"; ! } } else{ *************** *** 549,553 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 593,597 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 567,571 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 611,615 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 584,588 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 628,632 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 606,610 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 650,654 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 640,644 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 684,688 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 685,689 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! } else{ --- 729,752 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(PC.DHCP_CLIENT_ID); ! if(dhcpc!=null){ ! if(params.size()==1){ ! try { ! if(device.getNetworkInterface(params.get(0))!=null){ ! dhcpc.Close(); ! } ! } catch (InvalidNetworkInterfaceNameException ex) { ! out += "Invalid interface name\n"; ! } catch (TransportLayerException ex) { ! //ex.printStackTrace(); ! } ! } ! else{ ! out += "error: invalid parameters\n"; ! } ! } ! else{ ! out += "This instruction not supported by device\n"; ! } } else{ *************** *** 698,702 **** if(params.size()==1){ try { ! device.setMACAddress(params.get(0), params.get(1)); device.getConfig().remove("^interface "+params.get(0)+" mac-address "); } catch (InvalidNetworkInterfaceNameException ex) { --- 761,765 ---- if(params.size()==1){ try { ! device.setMACAddress(params.get(0), null); device.getConfig().remove("^interface "+params.get(0)+" mac-address "); } catch (InvalidNetworkInterfaceNameException ex) { *************** *** 705,709 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 768,772 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 723,727 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 786,879 ---- } else{ ! out += "error: invalid parameters\n"; ! } ! return out; ! } ! }; ! class ip_dhcp_pool_CommandClass implements CommandInterface{ ! public String call(Vector<String> params){ ! String out = ""; ! if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); ! if(dhcpd!=null){ ! if(params.size()==1){ ! String poolname = params.get(0); ! Pair ipmask = (Pair) pools.get(poolname); ! if(ipmask!=null){ ! DHCPD.pool pool = dhcpd.new_pool(); ! pool.IP = (String) ipmask.getFirst(); ! pool.Genmask = (String) ipmask.getSecond(); ! pool.Gateway = "???.???.???.???";; ! pool.MAC = "??:??:??:??:??:??"; ! dhcpd.pools.put(poolname, pool); ! try { ! dhcpd.Listen(); ! } catch (TransportLayerException ex) { ! out += "error: dhcp server has not started to listen"; ! } ! device.getConfig().remove("^ip dhcp pool "+poolname+"$"); ! device.getConfig().add("ip dhcp pool "+poolname); ! } ! else{ ! out += "error: pool "+poolname+" not exists\n"; ! } ! } ! else{ ! out += "error: invalid parameters\n"; ! } ! } ! else{ ! out += "This instruction not supported by device\n"; ! } ! } ! else{ ! out += "This instruction not supported by device\n"; ! } ! return out; ! } ! }; ! class no_ip_dhcp_pool_CommandClass implements CommandInterface{ ! public String call(Vector<String> params){ ! return ""; ! } ! }; ! class ip_local_pool_CommandClass implements CommandInterface{ ! public String call(Vector<String> params){ ! String out = ""; ! if(params.size()==3){ ! String poolname = params.get(0); ! if(IPV4Address.validateDecIP(params.get(1)) && IPV4Address.validateDecSubnetMask(params.get(2), params.get(1))){ ! if(pools.containsKey(poolname)){ ! ((Pair)pools.get(poolname)).setFirst(params.get(1)); ! ((Pair)pools.get(poolname)).setSecond(params.get(2)); ! } ! else{ ! pools.put(poolname, new Pair(params.get(1), params.get(2))); ! } ! device.getConfig().remove("^ip local pool "+poolname+" "); ! device.getConfig().addBefore("ip local pool "+poolname+" "+params.get(1)+" "+params.get(2), device.getConfig().working_config, " pool "+poolname+"($| ?)"); ! } ! else{ ! out += "error: invalid ip address or net mask\n"; ! } ! } ! else{ ! out += "error: invalid parameters\n"; ! } ! return out; ! } ! }; ! class no_ip_local_pool_CommandClass implements CommandInterface{ ! public String call(Vector<String> params){ ! String out = ""; ! if(params.size()==1){ ! String poolname = params.get(0); ! if(pools.containsKey(poolname)){ ! pools.remove(poolname); ! } ! device.getConfig().remove("^ip local pool "+poolname+" "); ! } ! else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 731,742 **** public String call(Vector<String> params){ String out = ""; ! if(params.size()==4){ ! device.getConfig().remove("^ip route "+params.get(0)+" "+params.get(1)); ! device.getConfig().add("ip route "+params.get(0)+" "+params.get(1)+" "+params.get(2)+" "+params.get(3)); ! device.addRoute(new Route_entry(params.get(0), params.get(2), params.get(1), params.get(3), 0)); ! out+="Route added.\n"; } else{ ! out += "Invalid parameters\n"; } return out; --- 883,914 ---- public String call(Vector<String> params){ String out = ""; ! if(params.size()==4 || params.size()==3){ ! String dest = params.get(0); ! String mask = params.get(1); ! device.getConfig().remove("^ip route "+dest+" "+mask); ! if(params.size()==4){ ! device.getConfig().add("ip route "+dest+" "+mask+" "+params.get(2)+" "+params.get(3)); ! } ! else{ ! device.getConfig().add("ip route "+dest+" "+mask+" "+params.get(2)+" eth0"); ! } ! if((dest.compareToIgnoreCase("default")==0 || dest.equals("0.0.0.0")) && mask.equals("0.0.0.0")){ ! try { ! device.setDefaultGateway(params.get(2)); ! out+="Default gateway added.\n"; ! } catch (InvalidNodeNameException ex) { ! out+="internal error: invalid node name!\n"; ! ex.printStackTrace(); ! } catch (InvalidDefaultGatewayException ex) { ! out+="error: invalid default gateway.\n"; ! } ! } ! else{ ! device.addRoute(new Route_entry(params.get(0), params.get(2), params.get(1), params.get(3), 0)); ! out+="Route added.\n"; ! } } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 747,756 **** String out = ""; if(params.size()==1){ ! device.getConfig().remove("^ip route "+params.get(0)); ! device.removeRoute(params.get(0)); ! out+="Route to " + params.get(0) + " removed.\n"; } else{ ! out += "Invalid parameters\n"; } return out; --- 919,942 ---- String out = ""; if(params.size()==1){ ! String dest = params.get(0); ! device.getConfig().remove("^ip route "+dest); ! if(dest.compareToIgnoreCase("default")==0 || dest.equals("0.0.0.0")){ ! try { ! device.setDefaultGateway(null); ! out+="Default gateway removed.\n"; ! } catch (InvalidNodeNameException ex) { ! out+="internal error: invalid node name!\n"; ! ex.printStackTrace(); ! } catch (InvalidDefaultGatewayException ex) { ! out+="internal error: invalid default gateway.\n"; ! } ! } ! else{ ! device.removeRoute(dest); ! out+="Route to " + params.get(0) + " removed.\n"; ! } } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 772,776 **** } else{ ! out += "Invalid parameters\n"; } } --- 958,962 ---- } else{ ! out += "error: invalid parameters\n"; } } *************** *** 911,915 **** } else{ ! out += "Invalid parameters\n"; } return out; --- 1097,1101 ---- } else{ ! out += "error: invalid parameters\n"; } return out; *************** *** 1149,1153 **** } else{ ! out += "Invalid parameters\n"; } } --- 1335,1339 ---- } else{ ! out += "error: invalid parameters\n"; } } *************** *** 1175,1179 **** } else{ ! out += "Invalid parameters\n"; } } --- 1361,1365 ---- } else{ ! out += "error: invalid parameters\n"; } } *************** *** 1210,1218 **** device.getConfig().add("snmp server port "+params.get(0)); }catch(NumberFormatException e){ ! out += "Invalid parameters\n"; } } else{ ! out += "Invalid parameters\n"; } } --- 1396,1404 ---- device.getConfig().add("snmp server port "+params.get(0)); }catch(NumberFormatException e){ ! out += "error: invalid parameters\n"; } } else{ ! out += "error: invalid parameters\n"; } } *************** *** 1261,1269 **** device.getConfig().add("telnet server "+params.get(0)); }catch(NumberFormatException e){ ! out += "Invalid parameters\n"; } } else{ ! out += "Invalid parameters\n"; } } --- 1447,1455 ---- device.getConfig().add("telnet server "+params.get(0)); }catch(NumberFormatException e){ ! out += "error: invalid parameters\n"; } } else{ ! out += "error: invalid parameters\n"; } } *************** *** 1291,1295 **** } else{ ! out += "Invalid parameters\n"; } } --- 1477,1481 ---- } else{ ! out += "error: invalid parameters\n"; } } Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** EthernetNetworkInterface.java 13 Oct 2007 12:57:00 -0000 1.8 --- EthernetNetworkInterface.java 18 Oct 2007 22:22:09 -0000 1.9 *************** *** 56,60 **** * Stores The MAC address for each instance of this class * */ ! protected String MACAddress; /** --- 56,61 ---- * Stores The MAC address for each instance of this class * */ ! protected String MACAddress; ! protected String defaultMACAddress; /** *************** *** 73,77 **** //set MAC address to null, as hub dont have MAC address. }else{ ! MACAddress = setMacAddress(); } --- 74,79 ---- //set MAC address to null, as hub dont have MAC address. }else{ ! MACAddress = setMacAddress(); ! defaultMACAddress = MACAddress; } *************** *** 212,216 **** protected final void setMacAddress(String macAddress){ ! this.MACAddress = macAddress; } --- 214,223 ---- protected final void setMacAddress(String macAddress){ ! if(macAddress==null){ ! this.MACAddress = defaultMACAddress; ! } ! else{ ! this.MACAddress = macAddress; ! } } Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DeviceConfig.java 16 Oct 2007 23:02:31 -0000 1.5 --- DeviceConfig.java 18 Oct 2007 22:22:09 -0000 1.6 *************** *** 92,101 **** */ public boolean add(String command){ ! return addBefore(command, null); } ! public boolean addBefore(String command, String beforeCommand){ boolean result = false; ! LinkedList config = getConfig(working_config); boolean found = false; int index = -1; --- 92,105 ---- */ public boolean add(String command){ ! return add(command, working_config); } ! public boolean add(String command, int config_name){ ! return addBefore(command, config_name, null); ! } ! ! public boolean addBefore(String command, int config_name, String beforeCommand){ boolean result = false; ! LinkedList config = getConfig(config_name); boolean found = false; int index = -1; *************** *** 133,141 **** */ public boolean remove(String command){ boolean result = false; try{ Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(working_config); Iterator<String> it = config.iterator(); while(it.hasNext()){ --- 137,149 ---- */ public boolean remove(String command){ + return remove(command, working_config); + } + + public boolean remove(String command, int config_name){ boolean result = false; try{ Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext()){ *************** *** 156,164 **** */ public boolean isExists(String command){ boolean result = false; try{ Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(working_config); Iterator<String> it = config.iterator(); while(it.hasNext() && !result){ --- 164,176 ---- */ public boolean isExists(String command){ + return isExists(command, working_config); + } + + public boolean isExists(String command, int config_name){ boolean result = false; try{ Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext() && !result){ Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Simulation.java 16 Oct 2007 23:02:31 -0000 1.19 --- Simulation.java 18 Oct 2007 22:22:09 -0000 1.20 *************** *** 350,353 **** --- 350,355 ---- //nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); nld.getConfig().executeCommand("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask); + nld.getConfig().remove("interface "+inInterface+" ip address ", DeviceConfig.STARTUP_CONFIG); + nld.getConfig().add("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask, DeviceConfig.STARTUP_CONFIG); } else *************** *** 385,390 **** { //test if device is a network layer device NetworkLayerDevice t = (NetworkLayerDevice)temp; ! t.setDefaultGateway(inGatewayIPAddress); ! //t.getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0"); //t.getConfig().executeCommand("ip route default 0.0.0.0 "+inGatewayIPAddress+" eth0"); } --- 387,394 ---- { //test if device is a network layer device NetworkLayerDevice t = (NetworkLayerDevice)temp; ! //t.setDefaultGateway(inGatewayIPAddress); ! t.getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0"); ! t.getConfig().remove("^ip route 0.0.0.0 0.0.0.0 ", DeviceConfig.STARTUP_CONFIG); ! t.getConfig().add("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0", DeviceConfig.STARTUP_CONFIG); //t.getConfig().executeCommand("ip route default 0.0.0.0 "+inGatewayIPAddress+" eth0"); } *************** *** 447,450 **** --- 451,456 ---- //t.setIPAddress(inNodeInterface,inIPAddress); t.getConfig().executeCommand("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface)); + t.getConfig().remove("^interface "+inNodeInterface+" ip address ", DeviceConfig.STARTUP_CONFIG); + t.getConfig().add("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface), DeviceConfig.STARTUP_CONFIG); macAddress = t.getMACAddress(inNodeInterface); updateARP(inIPAddress, macAddress, inNodeName); *************** *** 531,534 **** --- 537,542 ---- //tempNet.addToARPStatic(inIPAddress, inMACAddress); tempNet.getConfig().executeCommand("arp "+inIPAddress+" "+inMACAddress); + tempNet.getConfig().remove("^arp "+inIPAddress+" ", DeviceConfig.STARTUP_CONFIG); + tempNet.getConfig().add("arp "+inIPAddress+" "+inMACAddress, DeviceConfig.STARTUP_CONFIG); } *************** *** 551,554 **** --- 559,563 ---- //tempNet.removeARP(inIPAddress); tempNet.getConfig().executeCommand("no arp "+inIPAddress); + tempNet.getConfig().add("no arp "+inIPAddress, DeviceConfig.STARTUP_CONFIG); } |