javanetsim-cvs Mailing List for javaNetSim (Page 9)
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-serv24483/core Modified Files: CommandProcessor.java CommandsTree.java DeviceConfig.java NetworkInterface.java Node.java Simulation.java Log Message: config saving partially works Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DeviceConfig.java 15 Oct 2007 21:41:42 -0000 1.4 --- DeviceConfig.java 16 Oct 2007 23:02:31 -0000 1.5 *************** *** 14,17 **** --- 14,18 ---- import java.util.Vector; import java.util.regex.Pattern; + import java.util.regex.PatternSyntaxException; /** *************** *** 30,37 **** --- 31,44 ---- private LinkedList running_config = new LinkedList(); private LinkedList startup_config = new LinkedList(); + int device_type; /** Creates a new instance of DeviceConfig */ public DeviceConfig(NetworkLayerDevice dev) { + cmdproc = new CommandProcessor(dev); device = dev; + device_type = CommandsTree.NETWORK_LAYER; + if(device instanceof ApplicationLayerDevice){ + device_type = CommandsTree.APPLICATION_LAYER; + } } *************** *** 45,49 **** while(it.hasNext()){ String nextcmd = it.next(); ! cmdproc.call(nextcmd, cmdproc.ALLMODE | cmdproc.APPLICATION_LAYER); //running_config.add(nextcmd); } --- 52,56 ---- while(it.hasNext()){ String nextcmd = it.next(); ! executeCommand(nextcmd); //running_config.add(nextcmd); } *************** *** 81,96 **** } - /** Add 'command', which contain parameters 'params' - * @return false if 'command' already exists - */ - public boolean add(String command, Vector<String> params){ - return addBefore(command, params, null); - } - - public boolean addBefore(String command, Vector<String> params, String beforeCommand){ - String fullcmd = createCommand(command, params); - return addBefore(fullcmd, beforeCommand); - } - /** Add full 'command' * @return false if 'command' already exists --- 88,91 ---- *************** *** 105,111 **** boolean found = false; int index = -1; ! Pattern p = Pattern.compile(beforeCommand); for(int i=0; i<config.size() && !found; i++){ ! if(p.matcher((String)config.get(i)).find()){ index = i; } --- 100,114 ---- boolean found = false; int index = -1; ! Pattern p = null; ! try { ! if(beforeCommand!=null){ ! p = Pattern.compile(beforeCommand); ! } ! } catch(PatternSyntaxException e) { ! System.out.println("addBefore: pattern "+beforeCommand+" have incorrent syntax\n"); ! e.printStackTrace(); ! } for(int i=0; i<config.size() && !found; i++){ ! if(beforeCommand!=null && p.matcher((String)config.get(i)).find()){ index = i; } *************** *** 132,143 **** boolean result = false; ! Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(working_config); ! Iterator<String> it = config.iterator(); ! while(it.hasNext()){ ! if(p.matcher(it.next()).find()){ ! it.remove(); ! result = true; } } return result; --- 135,151 ---- boolean result = false; ! try{ ! Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(working_config); ! Iterator<String> it = config.iterator(); ! while(it.hasNext()){ ! if(p.matcher(it.next()).find()){ ! it.remove(); ! result = true; ! } } + } catch(PatternSyntaxException e) { + System.out.println("remove: pattern "+command+" have incorrent syntax\n"); + e.printStackTrace(); } return result; *************** *** 150,164 **** boolean result = false; ! Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(working_config); ! Iterator<String> it = config.iterator(); ! while(it.hasNext() && !result){ ! if(p.matcher(it.next()).find()){ ! result = true; } } return result; } private String getCommandPart(String command, int paramc){ String result = ""; --- 158,181 ---- boolean result = false; ! try{ ! Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(working_config); ! Iterator<String> it = config.iterator(); ! while(it.hasNext() && !result){ ! if(p.matcher(it.next()).find()){ ! result = true; ! } } + } catch(PatternSyntaxException e) { + System.out.println("isExists: pattern "+command+" have incorrent syntax\n"); + e.printStackTrace(); } return result; } + public String executeCommand(String command){ + return cmdproc.call(command, cmdproc.ALLMODE | device_type, ""); + } + private String getCommandPart(String command, int paramc){ String result = ""; Index: CommandsTree.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandsTree.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CommandsTree.java 15 Oct 2007 21:41:42 -0000 1.2 --- CommandsTree.java 16 Oct 2007 23:02:31 -0000 1.3 *************** *** 121,124 **** --- 121,128 ---- } + public void setFunction(CommandInterface function){ + this.function = function; + } + public int getModes(){ return modes; *************** *** 212,216 **** if(nextnode != null && nextnode.getName().compareTo(cmds[i])==0){ if(i == cmds.length-1){ ! existed = true; // exit from cycle } } --- 216,230 ---- 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("")){ ! nextnode.setDescription(description); ! } ! } ! else{ ! existed = true; // exit from cycle ! } } } *************** *** 277,280 **** --- 291,295 ---- int modes = 0; String params = ""; + Vector<String> vprms = new Vector<String>(0); CommandNode node = root; *************** *** 283,286 **** --- 298,304 ---- node = node.getNode(cmds[i], mode); if(node != null){ + if(node.getName().equals(ANYWORD)){ + vprms.add(cmds[i]); + } func = node.getFunction(); modes = node.getModes(); *************** *** 289,294 **** } if(func!=null && (modes & mode & MODES)!=0 && (modes & mode & LAYERS)!=0){ ! String sprms[] = params.split(" "); ! Vector<String> vprms = new Vector<String>(0); if(node==null) i--; for(; i<cmds.length; i++){ --- 307,311 ---- } if(func!=null && (modes & mode & MODES)!=0 && (modes & mode & LAYERS)!=0){ ! //String sprms[] = params.split(" "); if(node==null) i--; for(; i<cmds.length; i++){ *************** *** 352,367 **** node = node.getNode(cmds[i], mode); if(node!=null){ if(node.getFunction()!=null){ - result = new Vector<Pair>(1); result.add(new Pair(node.getParameters(), "")); } - else{ - Vector<String> nodecmds = node.getCommands("", mode); - result = new Vector<Pair>(nodecmds.size()); - for(int j=0; j<nodecmds.size(); j++){ - String nodename = nodecmds.get(j); - result.add(new Pair(nodename, node.getNode(nodename,mode).getDescription())); - } - } } } --- 369,381 ---- node = node.getNode(cmds[i], mode); if(node!=null){ + Vector<String> nodecmds = node.getCommands("", mode); + result = new Vector<Pair>(nodecmds.size()+1); + for(int j=0; j<nodecmds.size(); j++){ + String nodename = nodecmds.get(j); + result.add(new Pair(nodename, node.getNode(nodename,mode).getDescription())); + } if(node.getFunction()!=null){ result.add(new Pair(node.getParameters(), "")); } } } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Simulation.java 15 Oct 2007 18:25:54 -0000 1.18 --- Simulation.java 16 Oct 2007 23:02:31 -0000 1.19 *************** *** 343,352 **** public void setCustomSubnetMask(String inNodeName,String inInterface,String inCustomSubnetMask)throws InvalidNetworkLayerDeviceException, InvalidNodeNameException, InvalidNetworkInterfaceNameException,InvalidSubnetMaskException { if (nodeTable.containsKey(inNodeName)){ ! try{ Node temp = (Node)nodeTable.get(inNodeName); if (temp instanceof NetworkLayerDevice)//test if device is a network layer device { NetworkLayerDevice nld = (NetworkLayerDevice)temp; ! nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); } else --- 343,353 ---- public void setCustomSubnetMask(String inNodeName,String inInterface,String inCustomSubnetMask)throws InvalidNetworkLayerDeviceException, InvalidNodeNameException, InvalidNetworkInterfaceNameException,InvalidSubnetMaskException { if (nodeTable.containsKey(inNodeName)){ ! // try{ Node temp = (Node)nodeTable.get(inNodeName); if (temp instanceof NetworkLayerDevice)//test if device is a network layer device { NetworkLayerDevice nld = (NetworkLayerDevice)temp; ! //nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! nld.getConfig().executeCommand("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask); } else *************** *** 354,360 **** throw new InvalidNetworkLayerDeviceException("This device is not a network layered device"); } ! }catch (InvalidNetworkInterfaceNameException e){ ! throw e; ! } }else{ throw new InvalidNodeNameException("Node does not exist"); --- 355,361 ---- throw new InvalidNetworkLayerDeviceException("This device is not a network layered device"); } ! // }catch (InvalidNetworkInterfaceNameException e){ ! // throw e; ! // } }else{ throw new InvalidNodeNameException("Node does not exist"); *************** *** 384,388 **** { //test if device is a network layer device NetworkLayerDevice t = (NetworkLayerDevice)temp; ! t.setDefaultGateway(inGatewayIPAddress); } else --- 385,391 ---- { //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"); } else *************** *** 442,447 **** if (temp instanceof NetworkLayerDevice){ //test if device is a network layer device NetworkLayerDevice t = (NetworkLayerDevice)temp; ! ! macAddress = t.setIPAddress(inNodeInterface,inIPAddress); updateARP(inIPAddress, macAddress, inNodeName); //t.addToARP(inIPAddress, macAddress); --- 445,451 ---- if (temp instanceof NetworkLayerDevice){ //test if device is a network layer device NetworkLayerDevice t = (NetworkLayerDevice)temp; ! //t.setIPAddress(inNodeInterface,inIPAddress); ! t.getConfig().executeCommand("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface)); ! macAddress = t.getMACAddress(inNodeInterface); updateARP(inIPAddress, macAddress, inNodeName); //t.addToARP(inIPAddress, macAddress); *************** *** 525,529 **** { NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; ! tempNet.addToARPStatic(inIPAddress, inMACAddress); } --- 529,534 ---- { NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; ! //tempNet.addToARPStatic(inIPAddress, inMACAddress); ! tempNet.getConfig().executeCommand("arp "+inIPAddress+" "+inMACAddress); } *************** *** 544,548 **** { NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; ! tempNet.removeARP(inIPAddress); } --- 549,554 ---- { NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; ! //tempNet.removeARP(inIPAddress); ! tempNet.getConfig().executeCommand("no arp "+inIPAddress); } Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NetworkInterface.java 15 Oct 2007 18:25:54 -0000 1.8 --- NetworkInterface.java 16 Oct 2007 23:02:31 -0000 1.9 *************** *** 115,118 **** --- 115,120 ---- protected boolean up; + protected String description = ""; + public void UP(){ up = true; *************** *** 457,460 **** --- 459,470 ---- } + + public String getDescription(){ + return description; + } + + public void setDescription(String description){ + this.description = description; + } }//EOF Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CommandProcessor.java 15 Oct 2007 21:41:42 -0000 1.4 --- CommandProcessor.java 16 Oct 2007 23:02:31 -0000 1.5 *************** *** 11,14 **** --- 11,15 ---- import core.protocolsuite.tcp_ip.InvalidIPAddressException; + import core.protocolsuite.tcp_ip.InvalidSubnetMaskException; import core.protocolsuite.tcp_ip.Route_entry; import core.protocolsuite.tcp_ip.SNMP; *************** *** 50,54 **** private erase_startup_config_CommandClass erase_startup_config_Command = new erase_startup_config_CommandClass(); private help_CommandClass help_Command = new help_CommandClass(); [...1312 lines suppressed...] ! Telnet_server telnets = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.PC.TELNET_SERVER_ID); ! if(telnets != null){ ! if(params.size()==0){ ! try{ ! telnets.Close(); ! }catch(TransportLayerException e) { } ! device.getConfig().remove("^telnet server .*"); ! } ! else{ ! out += "Invalid parameters\n"; ! } ! } ! else{ ! out += "This instruction not supported by device\n"; ! } ! } ! else{ ! out += "This instruction not supported by device\n"; } return out; Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Node.java 15 Oct 2007 21:41:42 -0000 1.13 --- Node.java 16 Oct 2007 23:02:31 -0000 1.14 *************** *** 422,426 **** */ ! protected NetworkInterface getNetworkInterface(String interfaceName) throws InvalidNetworkInterfaceNameException{ if(NetworkInterfacetable.containsKey(interfaceName)){ --- 422,426 ---- */ ! public NetworkInterface getNetworkInterface(String interfaceName) throws InvalidNetworkInterfaceNameException{ if(NetworkInterfacetable.containsKey(interfaceName)){ |
From: QweR <qw...@us...> - 2007-10-16 23:02:38
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24483/guiUI Modified Files: Terminal.java Log Message: config saving partially works Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Terminal.java 15 Oct 2007 21:41:43 -0000 1.4 --- Terminal.java 16 Oct 2007 23:02:31 -0000 1.5 *************** *** 23,31 **** import java.awt.Color; import java.awt.event.WindowEvent; - import core.TransportLayerException; import java.awt.Font; import java.awt.event.KeyListener; - import java.util.regex.*; - import core.protocolsuite.tcp_ip.*; import java.util.Vector; import core.CommandsTree; --- 23,28 ---- *************** *** 36,43 **** import core.Pair; import core.CommandProcessor; ! import java.awt.Toolkit; ! import java.awt.event.FocusEvent; ! import java.awt.event.FocusListener; ! import javax.swing.SwingUtilities; /** --- 33,37 ---- import core.Pair; import core.CommandProcessor; ! import core.InvalidNetworkInterfaceNameException; /** *************** *** 61,64 **** --- 55,60 ---- private int device_type; private CommandProcessor cmdproc; + private boolean interface_mode = false; + private String interface_name = ""; private clear_terminal_CommandClass clear_terminal_Command = new clear_terminal_CommandClass(); *************** *** 67,70 **** --- 63,67 ---- private configure_terminal_CommandClass configure_terminal_Command = new configure_terminal_CommandClass(); private exit_CommandClass exit_Command = new exit_CommandClass(); + private interface_CommandClass interface_Command = new interface_CommandClass(); private logout_CommandClass logout_Command = new logout_CommandClass(); private ping_CommandClass ping_Command = new ping_CommandClass(); *************** *** 79,83 **** current_mode = CommandsTree.STD_MODE; ! if(device.getClass().equals(ApplicationLayerDevice.class)){ device_type = CommandsTree.APPLICATION_LAYER; } --- 76,80 ---- current_mode = CommandsTree.STD_MODE; ! if(device instanceof core.ApplicationLayerDevice){ device_type = CommandsTree.APPLICATION_LAYER; } *************** *** 92,95 **** --- 89,95 ---- 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"); *************** *** 153,157 **** text += data+"\n"+device.NodeProtocolStack.getParentNodeName(); if(current_mode == cmdproc.CONF_MODE){ ! text += "(config)"; } text += "# "; --- 153,161 ---- text += data+"\n"+device.NodeProtocolStack.getParentNodeName(); if(current_mode == cmdproc.CONF_MODE){ ! text += "(config"; ! if(interface_mode){ ! text += "-if"; ! } ! text += ")"; } text += "# "; *************** *** 181,185 **** } appendToTerminal(cmdline.getText() + "\n"); ! String tmptext = cmdproc.call(cmdline.getText(), current_mode | device_type); if(tmptext==null){ tmptext = "% Incomplete command.\n"; --- 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"; *************** *** 201,205 **** addToTerminal(cmdline.getText()); int caretPos = cmdline.getCaretPosition(); ! String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode | device_type); //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 | device_type, interface_name); //String last_str = cmdline.getText().substring(caretPos); if(compl_str!=null && !compl_str.endsWith(" ")){ *************** *** 211,215 **** case '?': { String tmptext = cmdline.getText() + "?\n"; ! Vector<Pair> tmpv = cmdproc.help(cmdline.getText().substring(0,cmdline.getCaretPosition()), current_mode | device_type); 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 | device_type, interface_name); if(tmpv!=null){ for(int i=0; i<tmpv.size(); i++){ *************** *** 331,336 **** public String call(Vector<String> params){ if(current_mode == cmdproc.CONF_MODE){ ! current_mode = cmdproc.STD_MODE; ! device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; } else if(current_mode == cmdproc.STD_MODE){ --- 335,346 ---- public String call(Vector<String> params){ if(current_mode == cmdproc.CONF_MODE){ ! if(interface_mode){ ! interface_mode = false; ! interface_name = ""; ! } ! else{ ! current_mode = cmdproc.STD_MODE; ! device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; ! } } else if(current_mode == cmdproc.STD_MODE){ *************** *** 340,343 **** --- 350,373 ---- } }; + class interface_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(params.size()==1){ + try { + device.getNetworkInterface(params.get(0)); + if(!interface_mode){ + interface_mode = true; + interface_name = "interface "+params.get(0); + } + } catch (InvalidNetworkInterfaceNameException ex) { + out += "error: invalid inferface\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; class logout_CommandClass implements CommandInterface{ public String call(Vector<String> params){ |
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17243/core Modified Files: ApplicationLayerDevice.java CommandProcessor.java CommandsTree.java DeviceConfig.java Node.java PC.java Log Message: add interface commands into console fixed TCP.closePort & UDP.closePort Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CommandProcessor.java 14 Oct 2007 22:14:52 -0000 1.3 --- CommandProcessor.java 15 Oct 2007 21:41:42 -0000 1.4 *************** *** 14,17 **** --- 14,18 ---- import core.protocolsuite.tcp_ip.SNMP; import core.protocolsuite.tcp_ip.TCP_session; + import core.protocolsuite.tcp_ip.Telnet_server; import core.protocolsuite.tcp_ip.UDP_session; import core.protocolsuite.tcp_ip.jnSocket; *************** *** 51,54 **** --- 52,79 ---- private host_CommandClass host_Command = new host_CommandClass(); private reload_CommandClass reload_Command = new reload_CommandClass(); + private interface__description_CommandClass interface__description_Command = new interface__description_CommandClass(); + private interface__clock_rate_CommandClass interface__clock_rate_Command = new interface__clock_rate_CommandClass(); + private interface__ip_address_CommandClass interface__ip_address_Command = new interface__ip_address_CommandClass(); + private interface__ip_access_group_CommandClass interface__ip_access_group_Command = new interface__ip_access_group_CommandClass(); + private interface__ip_nat_CommandClass interface__ip_nat_Command = new interface__ip_nat_CommandClass(); + private interface__ip_unreachables_CommandClass interface__ip_unreachables_Command = new interface__ip_unreachables_CommandClass(); + private interface__ip_redirects_CommandClass interface__ip_redirects_Command = new interface__ip_redirects_CommandClass(); + private interface__ip_mask_replay_CommandClass interface__ip_mask_replay_Command = new interface__ip_mask_replay_CommandClass(); + private interface__ip_information_replay_CommandClass interface__ip_information_replay_Command = new interface__ip_information_replay_CommandClass(); + private interface__ip_dhcp_client_CommandClass interface__ip_dhcp_client_Command = new interface__ip_dhcp_client_CommandClass(); + private interface__mac_address_CommandClass interface__mac_address_Command = new interface__mac_address_CommandClass(); + private interface__shutdown_CommandClass interface__shutdown_Command = new interface__shutdown_CommandClass(); + private no_interface__description_CommandClass no_interface__description_Command = new no_interface__description_CommandClass(); + private no_interface__clock_rate_CommandClass no_interface__clock_rate_Command = new no_interface__clock_rate_CommandClass(); + private no_interface__ip_address_CommandClass no_interface__ip_address_Command = new no_interface__ip_address_CommandClass(); + private no_interface__ip_access_group_CommandClass no_interface__ip_access_group_Command = new no_interface__ip_access_group_CommandClass(); + private no_interface__ip_nat_CommandClass no_interface__ip_nat_Command = new no_interface__ip_nat_CommandClass(); + private no_interface__ip_unreachables_CommandClass no_interface__ip_unreachables_Command = new no_interface__ip_unreachables_CommandClass(); + private no_interface__ip_redirects_CommandClass no_interface__ip_redirects_Command = new no_interface__ip_redirects_CommandClass(); + private no_interface__ip_mask_replay_CommandClass no_interface__ip_mask_replay_Command = new no_interface__ip_mask_replay_CommandClass(); + private no_interface__ip_information_replay_CommandClass no_interface__ip_information_replay_Command = new no_interface__ip_information_replay_CommandClass(); + private no_interface__ip_dhcp_client_CommandClass no_interface__ip_dhcp_client_Command = new no_interface__ip_dhcp_client_CommandClass(); + 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_route_CommandClass ip_route_Command = new ip_route_CommandClass(); private no_ip_route_CommandClass no_ip_route_Command = new no_ip_route_CommandClass(); *************** *** 86,89 **** --- 111,115 ---- private telnet_CommandClass telnet_Command = new telnet_CommandClass(); private telnet_server_CommandClass telnet_server_Command = new telnet_server_CommandClass(); + private no_telnet_server_CommandClass no_telnet_server_Command = new no_telnet_server_CommandClass(); private traceroute_CommandClass traceroute_Command = new traceroute_CommandClass(); private write_memory_CommandClass write_memory_Command = new write_memory_CommandClass(); *************** *** 101,104 **** --- 127,131 ---- commands.addDescription("clock","Manage the system clock"); commands.add("clock set", clock_set_Command, STD_CONF_MODE | NO_LAYER, "<hh:mm:ss> <1-31> <1-12> <1970-2100>", "Set the time and date"); + commands.addDescription("copy","Copy confuguration files"); commands.add("copy running-config startup-config", copy_running_startup_Command, STD_CONF_MODE | NO_LAYER, "<src-config> <dest-config>", "Copy from one file to another"); commands.add("copy startup-config running-config", copy_startup_running_Command, STD_CONF_MODE | NO_LAYER, "<src-config> <dest-config>", "Copy from one file to another"); *************** *** 109,112 **** --- 136,175 ---- commands.add("host", host_Command, CONF_MODE | NETWORK_LAYER, "(<interface> <ip> | <hostname>)", "Set system's network name or IP-address"); commands.add("reload", reload_Command, STD_MODE | NO_LAYER, "<cr>", "Halt and perform a cold restart"); + + + commands.addDescription("interface","Select an interface to configure"); + commands.addDescription("interface *","Any available interface name"); + commands.add("interface * description", interface__description_Command, CONF_MODE | NETWORK_LAYER, "<description>", "Interface specific description"); + commands.add("interface * clock-rate", interface__clock_rate_Command, CONF_MODE | NETWORK_LAYER, "<1-4000000>", "Specify clock-rate"); + commands.addDescription("interface * ip","Configure Internet Protocol"); + commands.add("interface * ip address", interface__ip_address_Command, CONF_MODE | NETWORK_LAYER, "<ip address> <net mask>", "Set the IP address of an interface"); + commands.add("interface * ip access-group", interface__ip_access_group_Command, CONF_MODE | NETWORK_LAYER, "<acl name> (in|out)", "Specify access control for packets"); + commands.add("interface * ip nat", interface__ip_nat_Command, CONF_MODE | NETWORK_LAYER, "(inside|outside)", "NAT interface commands"); + commands.add("interface * ip unreachables", interface__ip_unreachables_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Enable sending ICMP Unreachable messages"); + commands.add("interface * ip redirects", interface__ip_redirects_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Enable sending ICMP Redirect messages"); + commands.add("interface * ip mask-replay", interface__ip_mask_replay_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Enable sending ICMP Mask Reply messages"); + commands.add("interface * ip information-replay", interface__ip_information_replay_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Enable sending ICMP Information Reply messages"); + commands.addDescription("interface * dhcp","Configure DHCP parameters for this interface"); + commands.add("interface * ip dhcp client", interface__ip_dhcp_client_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Enable DHCP client"); + 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"); + commands.add("no interface * description", no_interface__description_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Clear interface description"); + commands.add("no interface * clock-rate", no_interface__clock_rate_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Set clock-rate to default"); + commands.addDescription("no interface * ip","Configure Internet Protocol"); + commands.add("no interface * ip address", no_interface__ip_address_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Set the IP address of an interface to default"); + commands.add("no interface * ip access-group", no_interface__ip_access_group_Command, CONF_MODE | NETWORK_LAYER, "<acl name> (in|out)", "Disable access control for packets"); + commands.add("no interface * ip nat", no_interface__ip_nat_Command, CONF_MODE | NETWORK_LAYER, "(inside|outside)", "Disable NAT on interface"); + commands.add("no interface * ip unreachables", no_interface__ip_unreachables_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Disable sending ICMP Unreachable messages"); + commands.add("no interface * ip redirects", no_interface__ip_redirects_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Disable sending ICMP Redirect messages"); + commands.add("no interface * ip mask-replay", no_interface__ip_mask_replay_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Disable sending ICMP Mask Reply messages"); + commands.add("no interface * ip information-replay", no_interface__ip_information_replay_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Disable sending ICMP Information Reply messages"); + commands.addDescription("no interface * dhcp","Configure DHCP parameters for this interface"); + commands.add("no interface * ip dhcp client", no_interface__ip_dhcp_client_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Disable DHCP client"); + commands.add("no interface * mac-address", no_interface__mac_address_Command, CONF_MODE | NETWORK_LAYER, "<cr>", "Set interface MAC address to default"); + 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"); *************** *** 152,156 **** commands.add("snmp-server port", snmp_server_port_Command, CONF_MODE | APPLICATION_LAYER, "<port>", "Specify server port"); commands.add("telnet", telnet_Command, STD_CONF_MODE | APPLICATION_LAYER, "<IP>", "Open a telnet connection"); ! commands.add("telnet-server", telnet_server_Command, CONF_MODE | APPLICATION_LAYER, "<port>", "Enable TELNET; Specify server port"); commands.add("traceroute", traceroute_Command, STD_CONF_MODE | NETWORK_LAYER, "<IP>", "Trace route to destination"); commands.addDescription("write","Write running configuration to memory or terminal"); --- 215,220 ---- commands.add("snmp-server port", snmp_server_port_Command, CONF_MODE | APPLICATION_LAYER, "<port>", "Specify server port"); commands.add("telnet", telnet_Command, STD_CONF_MODE | APPLICATION_LAYER, "<IP>", "Open a telnet connection"); ! commands.add("telnet-server", telnet_server_Command, CONF_MODE | APPLICATION_LAYER, "<port>", "Enable TELNET server; Specify server port"); ! commands.add("no telnet-server", no_telnet_server_Command, CONF_MODE | APPLICATION_LAYER, "<cr>", "Disable TELNET server"); commands.add("traceroute", traceroute_Command, STD_CONF_MODE | NETWORK_LAYER, "<IP>", "Trace route to destination"); commands.addDescription("write","Write running configuration to memory or terminal"); *************** *** 315,318 **** --- 379,526 ---- } }; + class interface__description_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__clock_rate_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__ip_access_group_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__ip_address_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__ip_nat_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__ip_unreachables_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__ip_redirects_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__ip_mask_replay_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__ip_information_replay_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__ip_dhcp_client_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__mac_address_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class interface__shutdown_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__description_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__clock_rate_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__ip_address_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__ip_access_group_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__ip_nat_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__ip_unreachables_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__ip_redirects_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__ip_mask_replay_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__ip_information_replay_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__ip_dhcp_client_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__mac_address_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; + class no_interface__shutdown_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + return out; + } + }; class ip_route_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 629,637 **** class snmp_server_community_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! return "Command not supported yet.\n"; } }; class no_snmp_server_community_CommandClass implements CommandInterface{ public String call(Vector<String> params){ return "Command not supported yet.\n"; } --- 837,869 ---- class snmp_server_community_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! String out = ""; ! if(params.size()==1){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); ! try{ ! snmpa.Close(); ! }catch(TransportLayerException e) { } ! snmpa.setPassword(params.get(0)); ! try{ ! snmpa.Listen(); ! } ! catch(TransportLayerException e) { ! out+="SNMP agent: unable to listen\n"; ! } ! device.getConfig().remove("^snmp server community .*"); ! device.getConfig().add("snmp server community",params); ! } ! return out; } }; class no_snmp_server_community_CommandClass implements CommandInterface{ public String call(Vector<String> params){ + String out = ""; + if(params.size() == 0){ + SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); + try{ + snmpa.Close(); + }catch(TransportLayerException e) { } + device.getConfig().remove("^snmp server community .*"); + } return "Command not supported yet.\n"; } *************** *** 639,643 **** class snmp_server_port_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! return "Command not supported yet.\n"; } }; --- 871,896 ---- class snmp_server_port_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! String out = ""; ! if(params.size()==1){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); ! try{ ! snmpa.Close(); ! }catch(TransportLayerException e) { } ! try{ ! int port = Integer.parseInt(params.get(0)); ! snmpa.setPort(port); ! try{ ! snmpa.Listen(); ! } ! catch(TransportLayerException e) { ! out+="SNMP agent: unable to listen\n"; ! } ! device.getConfig().remove("^snmp server port .*"); ! device.getConfig().add("snmp server port",params); ! }catch(NumberFormatException e){ ! out += "Invalid parameters\n"; ! } ! } ! return out; } }; *************** *** 649,653 **** class telnet_server_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! return "Command not supported yet.\n"; } }; --- 902,940 ---- class telnet_server_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! String out = ""; ! if(params.size()==1){ ! Telnet_server snmpa = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.PC.TELNET_SERVER_ID); ! try{ ! snmpa.Close(); ! }catch(TransportLayerException e) { } ! try{ ! int port = Integer.parseInt(params.get(0)); ! snmpa.setPort(port); ! try{ ! snmpa.Listen(); ! } ! catch(TransportLayerException e) { ! out+="Telnet server: unable to listen\n"; ! } ! device.getConfig().remove("^telnet server .*"); ! device.getConfig().add("telnet server",params); ! }catch(NumberFormatException e){ ! out += "Invalid parameters\n"; ! } ! } ! return out; ! } ! }; ! class no_telnet_server_CommandClass implements CommandInterface{ ! public String call(Vector<String> params){ ! String out = ""; ! if(params.size()==0){ ! Telnet_server snmpa = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.PC.TELNET_SERVER_ID); ! try{ ! snmpa.Close(); ! }catch(TransportLayerException e) { } ! device.getConfig().remove("^telnet server .*"); ! } ! return out; } }; Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DeviceConfig.java 14 Oct 2007 22:14:52 -0000 1.3 --- DeviceConfig.java 15 Oct 2007 21:41:42 -0000 1.4 *************** *** 85,90 **** */ public boolean add(String command, Vector<String> params){ String fullcmd = createCommand(command, params); ! return add(fullcmd); } --- 85,94 ---- */ public boolean add(String command, Vector<String> params){ + return addBefore(command, params, null); + } + + public boolean addBefore(String command, Vector<String> params, String beforeCommand){ String fullcmd = createCommand(command, params); ! return addBefore(fullcmd, beforeCommand); } *************** *** 93,105 **** */ public boolean add(String command){ boolean result = false; LinkedList config = getConfig(working_config); - Iterator<String> it = config.iterator(); boolean found = false; ! while(it.hasNext() && !found){ ! found = (command.compareToIgnoreCase(it.next())==0); } if(!found){ ! config.add(command); result = true; } --- 97,124 ---- */ 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; ! Pattern p = Pattern.compile(beforeCommand); ! for(int i=0; i<config.size() && !found; i++){ ! if(p.matcher((String)config.get(i)).find()){ ! index = i; ! } ! if(command.compareToIgnoreCase((String)config.get(i))==0){ ! found = true; ! } } if(!found){ ! if(beforeCommand==null){ ! config.add(command); ! } ! else{ ! config.add(index, command); ! } result = true; } *************** *** 107,144 **** } - // /** Replace existing elements by 'command', which contain parameters after 'paramc' argument - // * - // */ - // public boolean replace(int config_name, String command, int paramc){ - // boolean result = false; - // - // if(paramc>0){ - // String req_cmd = getCommandPart(command, paramc); - // LinkedList config = getConfig(config_name); - // boolean manyfound = false; - // int index = -1; - // for(int i=0; i<config.size() && !manyfound; i++){ - // if(req_cmd.compareToIgnoreCase(getCommandPart((String)config.get(i), paramc))==0){ - // if(index == -1){ - // index = i; - // } - // else{ - // manyfound = true; - // } - // } - // } - // if(!manyfound){ - // if(index == -1){ - // config.add(command); - // } - // else{ - // config.set(index, command); - // } - // result = true; - // } - // } - // return result; - // } - /** Remove all elements match with 'command' * --- 126,129 ---- Index: CommandsTree.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandsTree.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CommandsTree.java 12 Oct 2007 21:06:39 -0000 1.1 --- CommandsTree.java 15 Oct 2007 21:41:42 -0000 1.2 *************** *** 30,33 **** --- 30,34 ---- public static final int LAYERS = APPLICATION_LAYER; public static final int ALLMODE = MODES | LAYERS; + public static final String ANYWORD = "*"; CommandNode root = new CommandNode("."); *************** *** 73,88 **** boolean allFounds = false; int cmdsize = command.length(); for(int i=0; i<tree.size() && !allFounds; i++){ CommandNode node = (CommandNode)tree.get(i); String nodename = node.getName(); ! 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)); } ! else if(cmp < 0){ ! allFounds = true; } } } return nodes; --- 74,98 ---- boolean allFounds = false; int cmdsize = command.length(); + CommandNode anywordNode = null; for(int i=0; i<tree.size() && !allFounds; i++){ CommandNode node = (CommandNode)tree.get(i); String nodename = node.getName(); ! if(!nodename.equals(ANYWORD)){ ! 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)); ! } ! else if(cmp < 0){ ! allFounds = true; ! } } ! else{ ! anywordNode = (CommandNode)tree.get(i);; } } + if(nodes.size()==0 && anywordNode!=null){ + nodes.add(anywordNode); + } } return nodes; Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PC.java 15 Oct 2007 12:04:32 -0000 1.14 --- PC.java 15 Oct 2007 21:41:42 -0000 1.15 *************** *** 86,117 **** class PC extends ApplicationLayerDevice { ! ! - /** - * 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 PC(String inName) { - super(inName,7); ! ! Echo echoServer = new Echo(NodeProtocolStack, 7, 1, core.ProtocolStack.UIDGen++); - Echo echoClient = new Echo(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); - Echo_tcp echotcpServer = new Echo_tcp(NodeProtocolStack, 17, 1, core.ProtocolStack.UIDGen++); - Echo_tcp echotcpClient = new Echo_tcp(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); --- 86,123 ---- class PC extends ApplicationLayerDevice { ! public final static int ECHO_SERVER_ID = 7; ! public final static int ECHO_CLIENT_ID = 30007; ! public final static int ECHO_TCP_SERVER_ID = 17; ! public final static int ECHO_TCP_CLIENT_ID = 30017; ! public final static int TELNET_SERVER_ID = 23; ! public final static int TELNET_CLIENT_ID = 30023; ! public final static int POSIX_TELNET_CLIENT_ID = 10023; ! 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 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++); Echo echoClient = new Echo(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); Echo_tcp echotcpServer = new Echo_tcp(NodeProtocolStack, 17, 1, core.ProtocolStack.UIDGen++); Echo_tcp echotcpClient = new Echo_tcp(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); *************** *** 120,124 **** Telnet_server telnetServer = new Telnet_server((ApplicationLayerDevice)this, NodeProtocolStack, 23, 1, core.ProtocolStack.UIDGen++); - Telnet_client telnetClient = new Telnet_client((ApplicationLayerDevice)this, NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); --- 126,129 ---- *************** *** 128,155 **** DHCPC dhcpc = new DHCPC(NodeProtocolStack, core.ProtocolStack.UIDGen++); ! addApp(echoServer, 7); ! ! addApp(ptc, 10023); ! ! addApp(echoClient, 30007); ! addApp(echotcpServer, 17); ! addApp(echotcpClient, 30017); ! addApp(telnetServer, 23); ! addApp(telnetClient, 30023); ! addApp(snmpAgent, 161); ! addApp(snmpManager, 30161); ! addApp(dhcpd, 67); ! addApp(dhcpc, 68); ! ! 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); ! } --- 133,152 ---- DHCPC dhcpc = new DHCPC(NodeProtocolStack, core.ProtocolStack.UIDGen++); ! addApp(echoServer, ECHO_SERVER_ID); ! addApp(echoClient, ECHO_CLIENT_ID); ! addApp(echotcpServer, ECHO_TCP_SERVER_ID); ! addApp(echotcpClient, ECHO_TCP_CLIENT_ID); ! addApp(telnetServer, TELNET_SERVER_ID); ! addApp(telnetClient, TELNET_CLIENT_ID); + addApp(ptc, POSIX_TELNET_CLIENT_ID); ! addApp(snmpAgent, SNMP_AGENT_ID); ! addApp(snmpManager, SNMP_MANAGER_ID); ! addApp(dhcpd, DHCP_SERVER_ID); ! addApp(dhcpc, DHCP_CLIENT_ID); } Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Node.java 15 Oct 2007 12:04:32 -0000 1.12 --- Node.java 15 Oct 2007 21:41:42 -0000 1.13 *************** *** 169,173 **** //Creates a protocolstack of that type. if(Simulation.getProtocolType() == ProtocolStack.TCP_IP){ ! NodeProtocolStack = new core.protocolsuite.tcp_ip.ProtocolStack(this,inProtocolStackLayers); }else if(Simulation.getProtocolType() == ProtocolStack.APPLETALK){ //NodeProtocolStack = new core.protocolsuite.appletalk.ProtocolStack(this); //Not implemented --- 169,173 ---- //Creates a protocolstack of that type. if(Simulation.getProtocolType() == ProtocolStack.TCP_IP){ ! NodeProtocolStack = new core.protocolsuite.tcp_ip.ProtocolStack(this,inProtocolStackLayers); }else if(Simulation.getProtocolType() == ProtocolStack.APPLETALK){ //NodeProtocolStack = new core.protocolsuite.appletalk.ProtocolStack(this); //Not implemented Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ApplicationLayerDevice.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ApplicationLayerDevice.java 15 Oct 2007 12:04:32 -0000 1.4 --- ApplicationLayerDevice.java 15 Oct 2007 21:41:42 -0000 1.5 *************** *** 20,26 **** /** Creates a new instance of ApplicationLayerDevice */ public ApplicationLayerDevice(String inName, int inProtocolStackLayers) { ! super(inName, inProtocolStackLayers); ! Apps = new Hashtable(); ! } public void addApp(Object app, int code){ --- 20,27 ---- /** Creates a new instance of ApplicationLayerDevice */ public ApplicationLayerDevice(String inName, int inProtocolStackLayers) { ! super(inName, inProtocolStackLayers); ! Apps = new Hashtable(); ! initApplications(); ! } public void addApp(Object app, int code){ *************** *** 34,37 **** --- 35,39 ---- public void turnOn(){ super.turnOn(); + initApplications(); } *************** *** 39,51 **** Enumeration<Application> ap = Apps.elements(); while(ap.hasMoreElements()){ try{ ! ap.nextElement().Free(); }catch(TransportLayerException e){ e.printStackTrace(); - } } super.turnOff(); } } --- 41,61 ---- Enumeration<Application> ap = Apps.elements(); while(ap.hasMoreElements()){ + Application appl = ap.nextElement(); try{ ! appl.Free(); }catch(TransportLayerException e){ e.printStackTrace(); } + // catch(Exception e){ + // System.out.println("Application "+appl.getUID()+" throws exception"); + // e.printStackTrace(); + // } } super.turnOff(); } + + public void initApplications(){ + + } } |
From: QweR <qw...@us...> - 2007-10-15 21:41:49
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17243/core/protocolsuite/tcp_ip Modified Files: Echo.java SNMP.java Tcp.java Telnet_server.java Udp.java Log Message: add interface commands into console fixed TCP.closePort & UDP.closePort Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Echo.java 1 Oct 2007 04:58:12 -0000 1.28 --- Echo.java 15 Oct 2007 21:41:42 -0000 1.29 *************** *** 61,72 **** */ public void Close() throws TransportLayerException ! { ! printLayerInfo("Echo application", "Echo application closed socket."); mParentStack.SL().close(appSock); } public void Free() throws TransportLayerException ! { ! printLayerInfo("Echo application", "Echo application freed socket."); mParentStack.SL().free(appSock); } --- 61,80 ---- */ public void Close() throws TransportLayerException ! { ! if(appType == 0){ ! printLayerInfo("Echo application", "Echo application closed socket."); ! }else{ ! printLayerInfo("Echo application", "Echo server closed socket."); ! } mParentStack.SL().close(appSock); } public void Free() throws TransportLayerException ! { ! if(appType == 0){ ! printLayerInfo("Echo application", "Echo application freed socket."); ! }else{ ! printLayerInfo("Echo application", "Echo server freed socket."); ! } mParentStack.SL().free(appSock); } Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** Tcp.java 14 Oct 2007 22:14:52 -0000 1.101 --- Tcp.java 15 Oct 2007 21:41:43 -0000 1.102 *************** *** 521,544 **** { int portToClose=mSL.get_socket(sock).src_port; - TCP_session Elm = getSession(mSL.get_socket(sock).genKey()); ! if(portToClose!=0 && Elm!=null){ TCP_session mainses = getSession(jnSocket.genTCPkey(portToClose,"0.0.0.0",0)); if(mainses != null && mainses.getSocket() == sock){ // remove listening session on client side only removeSession(jnSocket.genTCPkey(portToClose,"0.0.0.0",0)); } ! Enumeration<Integer> segs = Elm.getAllSegmentToResendNumbers(); ! while(segs.hasMoreElements()){ ! int segment = segs.nextElement().intValue(); ! long tid = Elm.removeSegmentToResend(segment); ! removeTimer(tid); } - removeSession(mSL.get_socket(sock).genKey()); - //mSL.close(Elm.sock); - printLayerInfo("Local port " + portToClose + " closed."); } else ! throw new TransportLayerException("TCP Error: port "+ portToClose +" is not being LISTENED to by the application: \"" + mSL.get_socket(sock).app.toString() + "\"."); } --- 521,544 ---- { int portToClose=mSL.get_socket(sock).src_port; ! if(portToClose!=0){ TCP_session mainses = getSession(jnSocket.genTCPkey(portToClose,"0.0.0.0",0)); if(mainses != null && mainses.getSocket() == sock){ // remove listening session on client side only removeSession(jnSocket.genTCPkey(portToClose,"0.0.0.0",0)); } ! TCP_session Elm = getSession(mSL.get_socket(sock).genKey()); ! if(Elm != null){ ! Enumeration<Integer> segs = Elm.getAllSegmentToResendNumbers(); ! while(segs.hasMoreElements()){ ! int segment = segs.nextElement().intValue(); ! long tid = Elm.removeSegmentToResend(segment); ! removeTimer(tid); ! } ! removeSession(mSL.get_socket(sock).genKey()); } printLayerInfo("Local port " + portToClose + " closed."); } else ! throw new TransportLayerException("TCP Error: port "+ portToClose +" is not being LISTENED."); } Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Udp.java 14 Oct 2007 22:14:52 -0000 1.42 --- Udp.java 15 Oct 2007 21:41:43 -0000 1.43 *************** *** 276,282 **** // bind port to socket public void bindPort(int sock_num, int in_Port) throws TransportLayerException ! { ! int lsPort=PORT_INIT; ! if(!mSL.get_socket(sock_num).open_state){ if (in_Port>=0 && in_Port<=65535) { //create such a record in hashtable --- 276,280 ---- // bind port to socket public void bindPort(int sock_num, int in_Port) throws TransportLayerException ! { if(!mSL.get_socket(sock_num).open_state){ if (in_Port>=0 && in_Port<=65535) { //create such a record in hashtable *************** *** 352,357 **** Simulation.addLayerInfo(UDP_Info); removeSession(jnSocket.genUDPkey(portToClose)); ! mSL.close(Elm.sock); ! } else throw new TransportLayerException("UDP Error: port "+ portToClose +" is not being LISTENED to by the application: \"" + mSL.get_socket(sock).app.toString() + "\"."); } --- 350,354 ---- Simulation.addLayerInfo(UDP_Info); removeSession(jnSocket.genUDPkey(portToClose)); ! } else throw new TransportLayerException("UDP Error: port "+ portToClose +" is not being LISTENED."); } Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Telnet_server.java 14 Oct 2007 22:14:52 -0000 1.18 --- Telnet_server.java 15 Oct 2007 21:41:43 -0000 1.19 *************** *** 325,329 **** try{ snmpa.Close(); ! snmpa.Disconnect(); out+="SNMP agent stoped\r\n"; snmpa.setPassword(l_pass); --- 325,329 ---- try{ snmpa.Close(); ! //snmpa.Disconnect(); out+="SNMP agent stoped\r\n"; snmpa.setPassword(l_pass); Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** SNMP.java 15 Oct 2007 12:04:33 -0000 1.24 --- SNMP.java 15 Oct 2007 21:41:42 -0000 1.25 *************** *** 161,170 **** public void Close() throws TransportLayerException { //mParentStack.CloseUDP(this); ! printInfo("SNMP agent closed socket."); //<--- FIXME!!! mParentStack.SL().close(appSock); } public void Free() throws TransportLayerException{ ! printInfo("SNMP agent freed socket."); //<--- FIXME!!! mParentStack.SL().free(appSock); } --- 161,180 ---- public void Close() throws TransportLayerException { //mParentStack.CloseUDP(this); ! if(appType==0){ ! printInfo("SNMP agent closed socket."); ! } ! else if(appType==1){ ! printInfo("SNMP manager closed socket."); ! } mParentStack.SL().close(appSock); } public void Free() throws TransportLayerException{ ! if(appType==0){ ! printInfo("SNMP agent freed socket."); ! } ! else if(appType==1){ ! printInfo("SNMP manager freed socket."); ! } mParentStack.SL().free(appSock); } *************** *** 203,216 **** } - - /** - * This method disconnects from server. - * @author QweR - * @version v0.01 - */ - public void Disconnect()throws TransportLayerException { - //mParentStack.freeUDPPort(this); - mParentStack.SL().close(appSock); - } /** --- 213,216 ---- *************** *** 399,403 **** } else if(appType==1) { ! Disconnect(); } retIP="unknown"; --- 399,403 ---- } else if(appType==1) { ! Close(); } retIP="unknown"; |
From: QweR <qw...@us...> - 2007-10-15 21:41:49
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17243/guiUI Modified Files: Terminal.java Log Message: add interface commands into console fixed TCP.closePort & UDP.closePort Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Terminal.java 14 Oct 2007 22:14:52 -0000 1.3 --- Terminal.java 15 Oct 2007 21:41:43 -0000 1.4 *************** *** 146,307 **** //!!!!!: add more headers here } - - private String runcmd(String cmd) { - String out=""; - if(cmd.compareTo("")==0) { - //nothing - } - else if(cmd.compareTo("?")==0 || cmd.compareToIgnoreCase("help")==0) { - out += " route \t show/edit route table\n"; - out += " arp \t show/edit arp table\n"; - out += " snmp \t on/off snmp agent\n"; - out += " counters\t show network counters\n"; - out += " quit \t close terminal session\n"; - out += " ? or help\tshow this screen\n"; - } - else if(cmd.compareToIgnoreCase("quit")==0) { - this.dispose(); - } - else { - String tokens[]=cmd.split(" "); - Matcher m; - if(tokens[0].compareTo("route")==0){ - if((m=Pattern.compile(" +print$").matcher(cmd)).find()) { - - String routes[] = device.NodeProtocolStack.getRouteTableEntries(); - out += "IP routing table:\n" + "Destination" + "\t" + "Gateway" + "\t" + "Genmask" + "\t" + "Type" + "\t" + "Iface\n"; - for(int i=0; i<routes.length - 1; i++){ - Route_entry r = device.NodeProtocolStack.getRouteTableEntry(routes[i]); - out += routes[i] + "\t" + r.gateway + "\t" + r.genMask + "\t" + r.Type + "\t" + r.iFace + "\n"; - } - } - else if((m=Pattern.compile(" +add +([^ ]+) +([^ ]+) +([^ ]+)( +([^ ]+|\\*))?$").matcher(cmd)).find()) { - if(m.group(5)!=null) { - device.NodeProtocolStack.addRoute(new Route_entry(m.group(1), m.group(5), m.group(3), m.group(2), 0)); - } - else { - device.NodeProtocolStack.addRoute(new Route_entry(m.group(1), "", m.group(3), m.group(2), 0)); - } - out+="Route added.\n"; - } - else if((m=Pattern.compile(" +del +([^ ]+)$").matcher(cmd)).find()) { - device.NodeProtocolStack.removeRoute(m.group(1)); - out+="Route to " + tokens[2] + " removed.\n"; - } - else{ - out+="Unknown route command. Usage:\n"; - out+=" route add (<host ip>|<network ip>) <target interface> <netmask> [<gateway>|*]\n" + - " add new route record\n"; - out+=" route del (<host ip>|<network ip>) delete route record\n"; - out+=" route print print route table\n"; - } - } - else if(tokens[0].compareTo("snmp")==0){ - if(device instanceof core.ApplicationLayerDevice) { - if((m=Pattern.compile(" +(on|\\d+)( +([^ ]+))?$").matcher(cmd)).find()) { - int l_port=161; - String l_pass="public"; - if(m.group(1).compareTo("on")!=0) l_port = Integer.parseInt(m.group(1)); - if(m.group(3)!=null) { - if(m.group(3).compareTo("")!=0) l_pass = m.group(3); - } - SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(161); - try{ - snmpa.Close(); - snmpa.Disconnect(); - out+="SNMP agent stoped\n"; - snmpa.setPassword(l_pass); - snmpa.setPort(l_port); - try{ - snmpa.Listen(); - out+="Now SNMP agent listen on port " + String.valueOf(l_port) + "\n"; - } - catch(TransportLayerException e) { - out+="Unable to open connection on SNMP agent\n"; - } - } - catch(TransportLayerException e) { - out+="Unable to close connection on SNMP agent\n"; - } - } - else if((m=Pattern.compile(" +off$").matcher(cmd)).find()) { - SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(161); - try{ - snmpa.Close(); - out+="SNMP agent stoped\n"; - } - catch(TransportLayerException e) { - out+="Unable to close connection on SNMP agent\n"; - } - } - else { - out+="Unknown snmp command. Usage:\n"; - out+=" snmp (on|<port number>) [community name] Start SNMP agent\n"; - out+=" snmp off Stop SNMP agent\n"; - } - } - else { - out += "Sorry, but this device not supported SNMP.\n"; - } - } - else if(tokens[0].compareTo("counters")==0){ - out += " Recieved IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getinputIPCount()).toString() + - "\n Sent IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getoutputIPCount()).toString() + - "\n ARP Packets: " + Integer.valueOf(device.NodeProtocolStack.getARPCount()).toString() + - "\n Recieved TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPinputCount()).toString() + - "\n Sent TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPoutputCount()).toString() + - "\n Sent TCP ACK's: " + Integer.valueOf(device.NodeProtocolStack.getTCPACKCount()).toString() + - "\n Sent TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPSDCount()).toString() + - "\n Recieved TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPRDCount()).toString() + - "\n Recieved UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPinputCount()).toString() + - "\n Sent UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPoutputCount()).toString() + - "\n"; - } - else if(tokens[0].compareTo("arp")==0){ - if((m=Pattern.compile(" +-a$").matcher(cmd)).find()) { - try{ - Vector<Vector<String>> ArpTable = device.NodeProtocolStack.getARPTable(); - if(ArpTable.size()>0){ - out += "Internet Address\tPhysical Address\t\tType\n"; - for(int i=0;i<ArpTable.size();i++) - { - out += ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2) + "\n"; - } - } - else{ - out += "No ARP Entries Found\n"; - } - } - catch(Exception e) - { - //Should never get here. - } - } - else if((m=Pattern.compile(" +-d +([^ ]+)$").matcher(cmd)).find()) { - device.NodeProtocolStack.removeARP(m.group(1)); - out += "Removed ARP entry for ip " + m.group(1) + "\n"; - } - else if((m=Pattern.compile(" +-s +([^ ]+) +([^ ]+)$").matcher(cmd)).find()) { - device.NodeProtocolStack.addToARPStatic(m.group(1), m.group(2)); - out += "Created new static ARP entry: " + m.group(1) + " is " + m.group(2) + "\n"; - } - else { - out+="Unknown arp command. Usage:\n"; - out+=" arp -a print ARP table\n"; - out+=" arp -d <ip address> delete record from ARP table\n"; - out+=" arp -s <ip address> <MAC address> add new ARP record\n"; - } - } - else out = tokens[0] + ": command not found\n"; - } - addToTerminal(out); - return out; - } - // - // private String removeSpaces(String s) { - // while(s.startsWith(" ")) s = s.substring(1); - // while(s.endsWith(" ")) s = s.substring(0, s.length()-1); - // return s; - // } /** Add text and prompt to terminal --- 146,149 ---- |
From: Alexander B. <da...@us...> - 2007-10-15 18:26:02
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24241/guiUI Modified Files: GuiHub.java GuiNode.java GuiPC.java GuiRouter.java GuiSwitch.java MainScreen.java MenuBar.java SandBox.java SimulationToolBar.java Added Files: GuiCSUDSU.java Log Message: CSU/DSU Unit added; new graphics; wan interface TCP external connection... Index: MenuBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MenuBar.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** MenuBar.java 15 Sep 2007 18:50:49 -0000 1.15 --- MenuBar.java 15 Oct 2007 18:25:54 -0000 1.16 *************** *** 56,59 **** --- 56,60 ---- private JMenuItem mnuHub = new JMenuItem("Hub ..."); private JMenuItem mnuSwitch = new JMenuItem("Switch ..."); + private JMenuItem mnuCSUDSU = new JMenuItem("CSU/DSU device..."); private JMenuItem mnuExternalNAT = new JMenuItem("Socks Proxy..."); *************** *** 129,132 **** --- 130,134 ---- mnuAdd.add(mnuHub); mnuAdd.add(mnuSwitch); + mnuAdd.add(mnuCSUDSU); mnuAdd.add(mnuExternalNAT); *************** *** 210,213 **** --- 212,223 ---- }); + //Add action listener to new CSU/DSU menuitem + mnuCSUDSU.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.setAllHighlightsOff(); + controller.addingNode(SandBox.CSUDSU_CURSOR); + } + }); + //Add action listener to new router menuitem mnuRouter.addActionListener(new ActionListener(){ Index: GuiSwitch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiSwitch.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuiSwitch.java 13 Sep 2007 13:38:52 -0000 1.2 --- GuiSwitch.java 15 Oct 2007 18:25:54 -0000 1.3 *************** *** 1,47 **** /* 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. - 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; /** * <P>The GuiSwitch class is used to instantiate new Switches on the GUI</P> * * @author luke_hamilton * @since 15th November 2004 * @version v0.20 */ public class GuiSwitch extends DataLinkLayerDevice { /** * @param inName The name of the switch * @param inMainscreen The JFrame that the Switch will be created on */ public GuiSwitch(String inName, MainScreen inMainScreen) { ! super(inName, inMainScreen,"images/simulation/switch_large.gif"); } } --- 1,94 ---- /* + 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. + - 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; + + /** + * <P>The GuiSwitch class is used to instantiate new Switches on the GUI</P> + * + * @author luke_hamilton + * @since 15th November 2004 + * @version v0.20 + */ + + public class GuiSwitch extends DataLinkLayerDevice { + + /** + * @param inName The name of the switch + * @param inMainscreen The JFrame that the Switch will be created on + */ + public GuiSwitch(String inName, MainScreen inMainScreen) { ! ! super(inName, inMainScreen,"images/simulation/switch.png"); ! } + } + Index: SimulationToolBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SimulationToolBar.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimulationToolBar.java 12 Oct 2006 17:26:26 -0000 1.2 --- SimulationToolBar.java 15 Oct 2007 18:25:54 -0000 1.3 *************** *** 1,200 **** ! /* ! 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. ! - 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 java.awt.Color; ! import java.awt.event.ActionEvent; ! import java.awt.event.ActionListener; ! import javax.swing.ImageIcon; ! import javax.swing.JButton; ! import javax.swing.JOptionPane; ! ! /** ! * <P>The SimulationToolBar class is the toolbar used for creating new Nodes</P> ! * ! * @author VC2 Team. ! * @since 15th November 2004 ! * @version v0.20 ! */ ! ! public class SimulationToolBar extends ToolBar{ ! private ClassLoader cl = this.getClass().getClassLoader(); ! ! private JButton btnNewPC = new JButton(new ImageIcon(cl.getResource("images/simulation/PC_small.gif"))); ! private JButton btnNewRouter = new JButton(new ImageIcon(cl.getResource("images/simulation/router_small.gif"))); ! private JButton btnNewSwitch = new JButton(new ImageIcon(cl.getResource("images/simulation/switch_small.gif"))); ! private JButton btnNewHub = new JButton(new ImageIcon(cl.getResource("images/simulation/hub_small.gif"))); ! private JButton btnNewLink = new JButton(new ImageIcon(cl.getResource("images/simulation/link.gif"))); ! ! Color activatedColor = Color.RED; ! Color deactivatedColor = btnNewLink.getBackground(); ! ! /** ! * Constructor to build a SimulationToolBar ! * @param inMainScreen The JFrame that the SimulationToolBar will be placed on. ! */ ! public SimulationToolBar(MainScreen inMainScreen) { ! super(inMainScreen); ! ! // Call method to create the toolbar ! ! buildToolbar(); ! } ! ! /** ! * This method is called from the constructor of SimulationToolBar ! * It sets up the buttons, action listeners, tooltips and borders for the ! * buttons on the Simulation toolbar. ! * @author VC2 Team. ! * @version v0.20 ! **/ ! ! private void buildToolbar(){ ! ! //Set the tooltips for these buttons ! ! btnNewPC.setToolTipText("Creates a new PC"); ! btnNewRouter.setToolTipText("Creats a new Router"); ! btnNewLink.setToolTipText("Creates a new Link between two nodes"); ! btnNewSwitch.setToolTipText("Creates a new Switch"); ! btnNewHub.setToolTipText("Creates a new Hub"); ! ! //Set the buttons to have no borders so that they don't make the toolbar look like crap. ! btnNewPC.setBorderPainted(false); ! btnNewRouter.setBorderPainted(false); ! btnNewLink.setBorderPainted(false); ! btnNewSwitch.setBorderPainted(false); ! btnNewHub.setBorderPainted(false); ! ! //Set action listener for PC toolbar item ! btnNewPC.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! highlightButton(btnNewPC, true); ! controller.addingNode(SandBox.PC_CURSOR); ! } ! }); ! ! //Set action listener for Hub toolbar item ! btnNewHub.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! highlightButton(btnNewHub, true); ! controller.addingNode(SandBox.HUB_CURSOR); ! } ! }); ! ! //Set action listener for Router toolbar item ! btnNewRouter.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! highlightButton(btnNewRouter, true); ! controller.addingNode(SandBox.ROUTER_CURSOR); ! } ! }); ! ! //Set action listener for Switch toolbar item ! ! btnNewSwitch.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! highlightButton(btnNewSwitch, true); ! controller.addingNode(SandBox.SWITCH_CURSOR); ! } ! }); ! ! ! btnNewLink.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! setLinkHighlight(true); ! controller.creatingLink(); ! ! ! } ! }); ! ! this.add(btnNewPC); ! this.add(btnNewRouter); ! this.add(btnNewHub); ! this.add(btnNewSwitch); ! this.add(btnNewLink); ! } ! ! // Will make a button highlight red to indicate that it is in use. ! // Alternatively it will go back to grey when dormant. ! ! /** ! * This method is called from the constructor of StandardToolBar ! * It sets up the buttons, action listeners, tooltips and borders for the ! * buttons on the standard toolbar. ! * ! * This method is called from the setLinkHighlight method ! * @param inButton The button that's highlighted status will be changed ! * @param blnStatus True or False depending on whether the button should be highlighted or not. ! * @author VC2 Team. ! * @version v0.20 ! **/ ! ! public void highlightButton(JButton inButton, boolean blnStatus){ ! if(blnStatus) ! { ! inButton.setBackground(activatedColor); ! } ! else ! { ! inButton.setBackground(deactivatedColor); ! } ! } ! ! /** ! * This method calls the highlightButton method to set the Link button highlighted status on or off. ! * @param inValue True or False depending on whether the button should be highlighted or not. ! * @author VC2 Team. ! * @version v0.20 ! **/ ! ! public void setLinkHighlight(boolean inValue){ ! highlightButton(btnNewLink, inValue); ! } ! ! /** ! * This method will set the background colour of all buttons to off. ! * @author VC2 Team. ! * @version v0.20 ! **/ ! ! public void setHighlightsOff(){ ! btnNewPC.setBackground(deactivatedColor); ! btnNewRouter.setBackground(deactivatedColor); ! btnNewSwitch.setBackground(deactivatedColor); ! btnNewHub.setBackground(deactivatedColor); ! btnNewLink.setBackground(deactivatedColor); ! ! } ! } --- 1,423 ---- ! /* ! ! 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. ! ! - 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 java.awt.Color; ! ! import java.awt.event.ActionEvent; ! ! import java.awt.event.ActionListener; ! ! import javax.swing.ImageIcon; ! ! import javax.swing.JButton; ! ! import javax.swing.JOptionPane; ! ! ! ! /** ! ! * <P>The SimulationToolBar class is the toolbar used for creating new Nodes</P> ! ! * ! ! * @author VC2 Team. ! ! * @since 15th November 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! public class SimulationToolBar extends ToolBar{ ! ! private ClassLoader cl = this.getClass().getClassLoader(); ! ! ! ! private JButton btnNewPC = new JButton(new ImageIcon(cl.getResource("images/simulation/PC_small.gif"))); ! ! private JButton btnNewRouter = new JButton(new ImageIcon(cl.getResource("images/simulation/router_small.gif"))); ! ! private JButton btnNewSwitch = new JButton(new ImageIcon(cl.getResource("images/simulation/switch_small.gif"))); ! ! private JButton btnNewHub = new JButton(new ImageIcon(cl.getResource("images/simulation/hub_small.gif"))); ! ! private JButton btnNewCSUDSU = new JButton(new ImageIcon(cl.getResource("images/simulation/csudsu_small.png"))); ! ! private JButton btnNewLink = new JButton(new ImageIcon(cl.getResource("images/simulation/link.gif"))); ! ! ! ! Color activatedColor = Color.RED; ! ! Color deactivatedColor = btnNewLink.getBackground(); ! ! ! ! /** ! ! * Constructor to build a SimulationToolBar ! ! * @param inMainScreen The JFrame that the SimulationToolBar will be placed on. ! ! */ ! ! public SimulationToolBar(MainScreen inMainScreen) { ! ! super(inMainScreen); ! ! ! ! // Call method to create the toolbar ! ! ! ! buildToolbar(); ! ! } ! ! ! ! /** ! ! * This method is called from the constructor of SimulationToolBar ! ! * It sets up the buttons, action listeners, tooltips and borders for the ! ! * buttons on the Simulation toolbar. ! ! * @author VC2 Team. ! ! * @version v0.20 ! ! **/ ! ! ! ! private void buildToolbar(){ ! ! ! ! //Set the tooltips for these buttons ! ! ! ! btnNewPC.setToolTipText("Creates a new PC"); ! ! btnNewRouter.setToolTipText("Creats a new Router"); ! ! btnNewLink.setToolTipText("Creates a new Link between two nodes"); ! ! btnNewSwitch.setToolTipText("Creates a new Switch"); ! ! btnNewHub.setToolTipText("Creates a new Hub"); ! ! btnNewCSUDSU.setToolTipText("Creates a new CSU/DSU device"); ! ! ! ! //Set the buttons to have no borders so that they don't make the toolbar look like crap. ! ! btnNewPC.setBorderPainted(false); ! ! btnNewRouter.setBorderPainted(false); ! ! btnNewLink.setBorderPainted(false); ! ! btnNewSwitch.setBorderPainted(false); ! ! btnNewHub.setBorderPainted(false); ! ! btnNewCSUDSU.setBorderPainted(false); ! ! ! ! //Set action listener for PC toolbar item ! ! btnNewPC.addActionListener(new ActionListener(){ ! ! public void actionPerformed(ActionEvent e){ ! ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! ! highlightButton(btnNewPC, true); ! ! controller.addingNode(SandBox.PC_CURSOR); ! ! } ! ! }); ! ! ! ! //Set action listener for Hub toolbar item ! ! btnNewHub.addActionListener(new ActionListener(){ ! ! public void actionPerformed(ActionEvent e){ ! ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! ! highlightButton(btnNewHub, true); ! ! controller.addingNode(SandBox.HUB_CURSOR); ! ! } ! ! }); ! ! ! //Set action listener for Hub toolbar item ! ! btnNewCSUDSU.addActionListener(new ActionListener(){ ! ! public void actionPerformed(ActionEvent e){ ! ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! ! highlightButton(btnNewCSUDSU, true); ! ! controller.addingNode(SandBox.CSUDSU_CURSOR); ! ! } ! ! }); ! ! //Set action listener for Router toolbar item ! ! btnNewRouter.addActionListener(new ActionListener(){ ! ! public void actionPerformed(ActionEvent e){ ! ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! ! highlightButton(btnNewRouter, true); ! ! controller.addingNode(SandBox.ROUTER_CURSOR); ! ! } ! ! }); ! ! ! ! //Set action listener for Switch toolbar item ! ! ! ! btnNewSwitch.addActionListener(new ActionListener(){ ! ! public void actionPerformed(ActionEvent e){ ! ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! ! highlightButton(btnNewSwitch, true); ! ! controller.addingNode(SandBox.SWITCH_CURSOR); ! ! } ! ! }); ! ! ! ! ! ! btnNewLink.addActionListener(new ActionListener(){ ! ! public void actionPerformed(ActionEvent e){ ! ! setHighlightsOff(); //Clean out any buttons that may have been highlighted previously. ! ! setLinkHighlight(true); ! ! controller.creatingLink(); ! ! ! ! ! ! } ! ! }); ! ! ! ! this.add(btnNewPC); ! ! this.add(btnNewRouter); ! ! this.add(btnNewHub); ! ! this.add(btnNewSwitch); ! ! this.add(btnNewCSUDSU); ! ! this.add(btnNewLink); ! ! } ! ! ! ! // Will make a button highlight red to indicate that it is in use. ! ! // Alternatively it will go back to grey when dormant. ! ! ! ! /** ! ! * This method is called from the constructor of StandardToolBar ! ! * It sets up the buttons, action listeners, tooltips and borders for the ! ! * buttons on the standard toolbar. ! ! * ! ! * This method is called from the setLinkHighlight method ! ! * @param inButton The button that's highlighted status will be changed ! ! * @param blnStatus True or False depending on whether the button should be highlighted or not. ! ! * @author VC2 Team. ! ! * @version v0.20 ! ! **/ ! ! ! ! public void highlightButton(JButton inButton, boolean blnStatus){ ! ! if(blnStatus) ! ! { ! ! inButton.setBackground(activatedColor); ! ! } ! ! else ! ! { ! ! inButton.setBackground(deactivatedColor); ! ! } ! ! } ! ! ! ! /** ! ! * This method calls the highlightButton method to set the Link button highlighted status on or off. ! ! * @param inValue True or False depending on whether the button should be highlighted or not. ! ! * @author VC2 Team. ! ! * @version v0.20 ! ! **/ ! ! ! ! public void setLinkHighlight(boolean inValue){ ! ! highlightButton(btnNewLink, inValue); ! ! } ! ! ! ! /** ! ! * This method will set the background colour of all buttons to off. ! ! * @author VC2 Team. ! ! * @version v0.20 ! ! **/ ! ! ! ! public void setHighlightsOff(){ ! ! btnNewPC.setBackground(deactivatedColor); ! ! btnNewRouter.setBackground(deactivatedColor); ! ! btnNewSwitch.setBackground(deactivatedColor); ! ! btnNewHub.setBackground(deactivatedColor); ! ! btnNewLink.setBackground(deactivatedColor); ! ! btnNewCSUDSU.setBackground(deactivatedColor); ! ! } ! ! } ! Index: GuiPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiPC.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuiPC.java 13 Sep 2007 13:38:52 -0000 1.3 --- GuiPC.java 15 Oct 2007 18:25:54 -0000 1.4 *************** *** 1,48 **** /* 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. - 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; /** * <P>The GuiPC class is used to instantiate new PC on the GUI</P> * * @author VC2 Team. * @since 15th November 2004 * @version v0.20 */ public class GuiPC extends ApplicationLayerDevice { /** * @param inName The name of the PC * @param inMainscreen The JFrame that the router will be created on */ public GuiPC(String inName, MainScreen inMainScreen){ ! super(inName, inMainScreen, "images/simulation/PC_large.gif"); } } --- 1,96 ---- /* + 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. + - 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; + + /** + * <P>The GuiPC class is used to instantiate new PC on the GUI</P> + * + * @author VC2 Team. + * @since 15th November 2004 + * @version v0.20 + */ + + public class GuiPC extends ApplicationLayerDevice { + + /** + * @param inName The name of the PC + * @param inMainscreen The JFrame that the router will be created on + */ + + public GuiPC(String inName, MainScreen inMainScreen){ ! ! super(inName, inMainScreen, "images/simulation/mymac.png"); ! } + } + --- NEW FILE: GuiCSUDSU.java --- package guiUI; public class GuiCSUDSU extends DataLinkLayerDevice { /** * @param inName The name of the switch * @param inMainscreen The JFrame that the Switch will be created on */ public GuiCSUDSU(String inName, MainScreen inMainScreen) { super(inName, inMainScreen,"images/simulation/csudsu2.png"); } } Index: SandBox.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SandBox.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SandBox.java 13 Oct 2007 12:57:00 -0000 1.7 --- SandBox.java 15 Oct 2007 18:25:54 -0000 1.8 *************** *** 54,57 **** --- 54,58 ---- public static final int HUB_CURSOR = 3; public static final int EXTERNALNAT_CURSOR = 4; + public static final int CSUDSU_CURSOR = 5; private Cursor csrDefault = new Cursor(Cursor.DEFAULT_CURSOR); *************** *** 62,83 **** private boolean blnPlaceableLocation = false; private int controlX; ! private int controlY; // Create the various cursors for this panel ! private ClassLoader cl = this.getClass().getClassLoader(); ! Image pcImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/PC_large.gif")); Cursor customPCCursor = Toolkit.getDefaultToolkit().createCustomCursor(pcImage, cursorLocation, "pcCursor"); ! Image routerImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/router_large.gif")); Cursor customRouterCursor = Toolkit.getDefaultToolkit().createCustomCursor(routerImage, cursorLocation, "routerCursor"); ! Image switchImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/switch_large.gif")); Cursor customSwitchCursor = Toolkit.getDefaultToolkit().createCustomCursor(switchImage, cursorLocation, "switchCursor"); ! Image hubImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/hub_large.gif")); Cursor customHubCursor = Toolkit.getDefaultToolkit().createCustomCursor(hubImage, cursorLocation, "hubCursor"); Image externalnatImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/network_local.png")); Cursor customExternalNATCursor = Toolkit.getDefaultToolkit().createCustomCursor(externalnatImage, cursorLocation, "externalnatCursor"); public SandBox(MainScreen inMainScreen){ --- 63,87 ---- private boolean blnPlaceableLocation = false; private int controlX; ! private int controlY; // Create the various cursors for this panel ! private ClassLoader cl = this.getClass().getClassLoader(); ! Image pcImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/mymac.png")); Cursor customPCCursor = Toolkit.getDefaultToolkit().createCustomCursor(pcImage, cursorLocation, "pcCursor"); ! Image routerImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/router.png")); Cursor customRouterCursor = Toolkit.getDefaultToolkit().createCustomCursor(routerImage, cursorLocation, "routerCursor"); ! Image switchImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/switch.png")); Cursor customSwitchCursor = Toolkit.getDefaultToolkit().createCustomCursor(switchImage, cursorLocation, "switchCursor"); ! Image hubImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/hub.png")); Cursor customHubCursor = Toolkit.getDefaultToolkit().createCustomCursor(hubImage, cursorLocation, "hubCursor"); Image externalnatImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/network_local.png")); Cursor customExternalNATCursor = Toolkit.getDefaultToolkit().createCustomCursor(externalnatImage, cursorLocation, "externalnatCursor"); + + Image csudsuImage = Toolkit.getDefaultToolkit().getImage(cl.getResource("images/simulation/csudsu2.png")); + Cursor customCSUDSUCursor = Toolkit.getDefaultToolkit().createCustomCursor(csudsuImage, cursorLocation, "csudsuCursor"); public SandBox(MainScreen inMainScreen){ *************** *** 208,211 **** --- 212,219 ---- Point NodeLocation = new Point(e.getX(), e.getY()); controller.addExternalNAT(NodeLocation); + }else if(this.getCursor() == customCSUDSUCursor){ + this.setCursor(csrDefault); + Point NodeLocation = new Point(e.getX(), e.getY()); + controller.addCSUDSU(NodeLocation); } } *************** *** 231,234 **** --- 239,244 ---- }else if(cursorType == EXTERNALNAT_CURSOR){ this.setCursor(customExternalNATCursor); + }else if(cursorType == CSUDSU_CURSOR){ + this.setCursor(customCSUDSUCursor); } Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** MainScreen.java 15 Oct 2007 12:04:33 -0000 1.71 --- MainScreen.java 15 Oct 2007 18:25:54 -0000 1.72 *************** *** 406,410 **** } ! public MainScreen() { Sim = new Simulation(core.ProtocolStack.TCP_IP); --- 406,410 ---- } ! public MainScreen(){ Sim = new Simulation(core.ProtocolStack.TCP_IP); *************** *** 885,888 **** --- 885,939 ---- } + public void addCSUDSU(Point inPoint){ + + String result = JOptionPane.showInputDialog(this,"Please enter a CSU/DSU device name:","Create New CSU/DSU", JOptionPane.PLAIN_MESSAGE); + + if(result != null){ + + result = result.trim(); + + if (!result.equalsIgnoreCase("")){ + + try { + + Sim.addCSUDSU(result); + + GuiCSUDSU tempCSUDSU = new GuiCSUDSU(result,this); + + tempCSUDSU.setNodeLocation(inPoint); + + GUInodeTable.put(result,tempCSUDSU); + + this.Sandbox.add(tempCSUDSU); + + Sandbox.setLayer(tempCSUDSU,3,0); + + isDirty = true; + + this.setAllHighlightsOff(); + + //pnlConsole.append("Added Hub "+result+" to simulation\n"); + + } catch (InvalidNodeNameException e) { + + JOptionPane.showMessageDialog(this, "Invalid CSU/DSU device name entered. Node with name: '" + result+"' all ready exist within Simulation","Invalid CSU/DSU device name", JOptionPane.ERROR_MESSAGE); + + } + + + + }else{ + + JOptionPane.showMessageDialog(this, "CSU/DSU device name not entered","CSU/DSU device name not entered",JOptionPane.WARNING_MESSAGE); + + } + + } + + this.setAllHighlightsOff(); + + this.refreshNodeInformationTab(); + + } /** *************** *** 1227,1231 **** ! public void createLink(String strLinkName, String inFirstNodeName, String inSecondNodeName){ --- 1278,1282 ---- ! public void createLink(String strLinkName, String inFirstNodeName, String inSecondNodeName, int LinkType){ *************** *** 1257,1261 **** ! Sandbox.addLine(strLinkName, FirstPoint,SecondPoint, 0); //FIXME! --- 1308,1312 ---- ! Sandbox.addLine(strLinkName, FirstPoint,SecondPoint, LinkType); //FIXME! *************** *** 2348,2353 **** Sandbox.setLayer(tempSwitch,3,0); ! GUInodeTable.put(strNodeName,tempSwitch); }else if(strClassName.contains("GuiPC")){ --- 2399,2421 ---- Sandbox.setLayer(tempSwitch,3,0); ! GUInodeTable.put(strNodeName,tempSwitch); ! ! }else if(strClassName.contains("GuiCSUDSU")){ ! ! deviceType = 1; ! ! Sim.addCSUDSU(strNodeName); ! ! 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")){ *************** *** 2449,2457 **** String ln[] = ((String) links.get(strLinkName)).split("\\|"); ! ! Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); ! ! this.createLink(strLinkName, ln[0], strNodeName); ! } --- 2517,2531 ---- String ln[] = ((String) links.get(strLinkName)).split("\\|"); ! ! if(iface[0].contains("eth")){ ! Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Ethernet10T); ! }else if(iface[0].contains("cua")){ ! Sim.addConsoleLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Console); ! }else if(iface[0].contains("ser")){ ! Sim.addSerialLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Serial); ! } } Index: GuiNode.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiNode.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GuiNode.java 13 Oct 2007 12:57:00 -0000 1.4 --- GuiNode.java 15 Oct 2007 18:25:54 -0000 1.5 *************** *** 184,190 **** ! public final static int NodeHeight = 50; ! public final static int NodeWidth = 45; --- 184,190 ---- ! public final static int NodeHeight = 64; ! public final static int NodeWidth = 64; *************** *** 270,274 **** //Dimension dim = this.getPreferredSize(); ! this.setBounds(0,0,75,55); this.addMouseListener(this); --- 270,275 ---- //Dimension dim = this.getPreferredSize(); ! //this.setBounds(0,0,75,55); ! this.setBounds(0,0,NodeWidth+10,NodeHeight+10); this.addMouseListener(this); Index: GuiRouter.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiRouter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuiRouter.java 13 Sep 2007 13:38:52 -0000 1.2 --- GuiRouter.java 15 Oct 2007 18:25:54 -0000 1.3 *************** *** 1,48 **** /* 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. - 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; /** * <P>The GuiRouter class is used to instantiate new Routers on the GUI</P> * * @author VC2 Team. * @since 15th November 2004 * @version v0.20 */ public class GuiRouter extends NetworkLayerDevice { /** * @param inName The name of the router * @param inMainscreen The JFrame that the router will be created on */ public GuiRouter(String inName, MainScreen inMainScreen){ ! super(inName, inMainScreen,"images/simulation/router_large.gif"); } } --- 1,96 ---- /* + 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. + - 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; + + /** + * <P>The GuiRouter class is used to instantiate new Routers on the GUI</P> + * + * @author VC2 Team. + * @since 15th November 2004 + * @version v0.20 + */ + + public class GuiRouter extends NetworkLayerDevice { + + /** + * @param inName The name of the router + * @param inMainscreen The JFrame that the router will be created on + */ + + public GuiRouter(String inName, MainScreen inMainScreen){ ! ! super(inName, inMainScreen,"images/simulation/Router.png"); // router_large.gif ! } + } + Index: GuiHub.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiHub.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuiHub.java 13 Sep 2007 13:38:52 -0000 1.2 --- GuiHub.java 15 Oct 2007 18:25:54 -0000 1.3 *************** *** 1,48 **** /* 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. - 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; /** * <P>The GuiHub class is used to instantiate new Hub's on the GUI</P> * * @author VC2 Team. * @since 15th November 2004 * @version v0.20 */ public class GuiHub extends DataLinkLayerDevice { /** * @param inName The name of the Hub * @param inMainscreen The JFrame that the router will be created on */ public GuiHub(String inName, MainScreen inMainScreen) { ! super(inName, inMainScreen,"images/simulation/hub_large.gif"); } } --- 1,96 ---- /* + 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. + - 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; + + /** + * <P>The GuiHub class is used to instantiate new Hub's on the GUI</P> + * + * @author VC2 Team. + * @since 15th November 2004 + * @version v0.20 + */ + + public class GuiHub extends DataLinkLayerDevice { + + /** + * @param inName The name of the Hub + * @param inMainscreen The JFrame that the router will be created on + */ + + public GuiHub(String inName, MainScreen inMainScreen) { ! ! super(inName, inMainScreen,"images/simulation/hub.png"); ! } + } + |
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24241/core Modified Files: NetworkInterface.java Packet.java Simulation.java Version.java WANNetworkInterface.java WANSocket.java Added Files: CSUDSU.java Log Message: CSU/DSU Unit added; new graphics; wan interface TCP external connection... --- NEW FILE: CSUDSU.java --- /* Java Network Simulator (jNetSim) 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 Ice Team 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 core; import java.util.*; public class CSUDSU extends DataLinkLayerDevice { String lanPort; String wanPort; int sz = 0; public CSUDSU(String inName) { super(inName, 1); //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(){ super.Reset(); } public void turnOn() { super.turnOn(); } public void turnOff() { super.turnOff(); } public int getState(){ return sz; } protected void receivePacket(Packet inPacket,String inInterfaceName) throws LowLinkException{ if(sz!=1){ if(inInterfaceName == lanPort){ NetworkInterface tempInterface = (NetworkInterface)this.NetworkInterfacetable.get(wanPort); tempInterface.sendPacket(inPacket); }else{ SerialNetworkInterface tempInterface = (SerialNetworkInterface)this.NetworkInterfacetable.get(lanPort); tempInterface.sendPacket(inPacket); } } } } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Simulation.java 15 Oct 2007 12:04:32 -0000 1.17 --- Simulation.java 15 Oct 2007 18:25:54 -0000 1.18 *************** *** 1018,1021 **** --- 1018,1029 ---- } } + + 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"); + } + } /** * This method will check to see if the switch name is contained within the Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** NetworkInterface.java 15 Oct 2007 12:04:32 -0000 1.7 --- NetworkInterface.java 15 Oct 2007 18:25:54 -0000 1.8 *************** *** 117,124 **** --- 117,136 ---- public void UP(){ up = true; + LayerInfo pingInfo = new LayerInfo(getClass().getName()); + pingInfo.setObjectName(parentNode.getName()); + pingInfo.setDataType("Interface"); + pingInfo.setLayer("Link"); + pingInfo.setDescription("Interface " + name + " state set to up!"); + Simulation.addLayerInfo(pingInfo); } public void DOWN(){ up = false; + LayerInfo pingInfo = new LayerInfo(getClass().getName()); + pingInfo.setObjectName(parentNode.getName()); + pingInfo.setDataType("Interface"); + pingInfo.setLayer("Link"); + pingInfo.setDescription("Interface " + name + " state set to down!"); + Simulation.addLayerInfo(pingInfo); } Index: WANSocket.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANSocket.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WANSocket.java 14 Oct 2007 17:19:07 -0000 1.1 --- WANSocket.java 15 Oct 2007 18:25:54 -0000 1.2 *************** *** 11,15 **** import java.io.*; import java.net.*; ! /** * --- 11,18 ---- import java.io.*; import java.net.*; ! import core.protocolsuite.tcp_ip.IP_packet; ! import core.protocolsuite.tcp_ip.ICMP_packet; ! import core.protocolsuite.tcp_ip.UDP_packet; ! import core.protocolsuite.tcp_ip.TCP_packet; /** * *************** *** 47,56 **** try{ if(server){ s = new ServerSocket(port); ! ih = new IncomeConnectionHandler(s, this); ih.start(); return true; } ! }catch(Exception e) {} return false; } --- 50,62 ---- try{ if(server){ + parentInterface.addLayerInfo("Wan interface", "Starting listening for peer..."); s = new ServerSocket(port); ! ih = new IncomeConnectionHandler(s, this, parentInterface); ih.start(); return true; } ! }catch(Exception e) { ! parentInterface.addLayerInfo("Wan interface", "Listen error: " + e.toString()); ! } return false; } *************** *** 59,68 **** try{ if(!server){ c = new Socket(Hostname, port); ! ch = new ClientConnectionHandler(c, this); ch.start(); return true; } ! }catch(Exception e){} return false; } --- 65,77 ---- try{ if(!server){ + parentInterface.addLayerInfo("Wan interface", "Starting connecting to peer..."); c = new Socket(Hostname, port); ! ch = new ClientConnectionHandler(c, this, parentInterface); ch.start(); return true; } ! }catch(Exception e){ ! parentInterface.addLayerInfo("Wan interface", "Connection error: " + e.toString()); ! } return false; } *************** *** 88,92 **** } ! public void recievePacket(String inPacket){ } --- 97,128 ---- } ! public void recievePacket(String inPacket) throws LowLinkException{ ! System.out.println(inPacket); ! ! String[] packets = inPacket.split("#"); ! ! char ptype = packets[packets.length - 1].charAt(0); ! ! System.out.println(ptype); ! ! switch(ptype){ ! case 'M': ! ICMP_packet icmp = new ICMP_packet(""); ! icmp.fromBytes(inPacket); ! parentInterface.receivePacket(icmp); ! break; ! case 'I': ! IP_packet ip = new IP_packet(""); ! ip.fromBytes(inPacket); ! parentInterface.receivePacket(ip); ! break; ! case 'T': ! break; ! case 'U': ! UDP_packet udp = new UDP_packet("","",0,0); ! udp.fromBytes(inPacket); ! parentInterface.receivePacket(udp); ! break; ! } } *************** *** 103,106 **** --- 139,143 ---- Node node; WANSocket w; + WANNetworkInterface parentInterface; private InputStream in; *************** *** 108,115 **** ! IncomeConnectionHandler(ServerSocket s, WANSocket w) { this.s = s; this.node = node; this.w = w; } --- 145,153 ---- ! IncomeConnectionHandler(ServerSocket s, WANSocket w, WANNetworkInterface parentInterface) { this.s = s; this.node = node; this.w = w; + this.parentInterface = parentInterface; } *************** *** 117,120 **** --- 155,160 ---- try{ Socket incoming = s.accept(); + parentInterface.addLayerInfo("Wan interface", "Accepted connection from peer."); + parentInterface.connected = true; w.setClientSocket(incoming, new PrintWriter(new OutputStreamWriter(incoming.getOutputStream()))); BufferedReader in = new BufferedReader( new InputStreamReader(incoming.getInputStream())); *************** *** 132,135 **** --- 172,176 ---- w.setClientSocket(null, null); }catch(Exception e){ + parentInterface.addLayerInfo("Wan interface", "Error during communication: " + e.toString()); e.printStackTrace(); } *************** *** 144,157 **** private InputStream in; private BufferedReader reader; ! ClientConnectionHandler(Socket s, WANSocket w) { this.s = s; this.node = node; this.w = w; } public void run() { try{ w.setClientSocket(s, new PrintWriter(new OutputStreamWriter(s.getOutputStream()))); BufferedReader in = new BufferedReader( new InputStreamReader(s.getInputStream())); --- 185,202 ---- private InputStream in; private BufferedReader reader; + + WANNetworkInterface parentInterface; ! ClientConnectionHandler(Socket s, WANSocket w, WANNetworkInterface parentInterface) { this.s = s; this.node = node; this.w = w; + this.parentInterface = parentInterface; } public void run() { try{ + parentInterface.addLayerInfo("Wan interface", "Connected to peer."); w.setClientSocket(s, new PrintWriter(new OutputStreamWriter(s.getOutputStream()))); BufferedReader in = new BufferedReader( new InputStreamReader(s.getInputStream())); *************** *** 169,172 **** --- 214,218 ---- w.setClientSocket(null, null); }catch(Exception e){ + parentInterface.addLayerInfo("Wan interface", "Error during communication: " + e.toString()); e.printStackTrace(); } Index: Version.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Version.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Version.java 1 Oct 2007 04:58:11 -0000 1.13 --- Version.java 15 Oct 2007 18:25:54 -0000 1.14 *************** *** 40,48 **** */ public class Version { ! public final static String CORE_VERSION = "v0.34"; //version of the simulation core public final static String YEARS = "2005 - 2007"; public static final String TEAM_MEMBERS[] = { ! "http://sf.net/projects/javanetsim","release date: 01 Oct 2007", "", "fork of jFirewallSim project (http://sf.net/projects/jfirewallsim/)", "from 03 Nov 2005","", --- 40,48 ---- */ public class Version { ! public final static String CORE_VERSION = "v0.38"; //version of the simulation core public final static String YEARS = "2005 - 2007"; public static final String TEAM_MEMBERS[] = { ! "http://sf.net/projects/javanetsim","release date: 03 Nov 2007", "", "fork of jFirewallSim project (http://sf.net/projects/jfirewallsim/)", "from 03 Nov 2005","", Index: WANNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANNetworkInterface.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WANNetworkInterface.java 14 Oct 2007 17:19:07 -0000 1.1 --- WANNetworkInterface.java 15 Oct 2007 18:25:54 -0000 1.2 *************** *** 96,99 **** --- 96,100 ---- public void UP(){ + super.UP(); up = listen(); up &= connect(); *************** *** 101,106 **** public void DOWN(){ ! close(); ! up = false; } --- 102,107 ---- public void DOWN(){ ! super.DOWN(); ! close(); } *************** *** 138,141 **** --- 139,144 ---- } + addLayerInfo("WAN Packet","Recieved and accepted packet at interface " + name); + parentNode.receivePacket(inPacket, name); } *************** *** 150,153 **** --- 153,158 ---- } + addLayerInfo("WAN Packet", "Sending packet from interface "+ name); + if(connected){ try{ *************** *** 162,165 **** --- 167,171 ---- } }catch(Exception e){ + addLayerInfo("WAN Connection", "Error: " + e.toString()); e.printStackTrace(); } *************** *** 171,174 **** --- 177,188 ---- } + public void addLayerInfo(String DataType, String Msg){ + LayerInfo pingInfo = new LayerInfo(getClass().getName()); + pingInfo.setObjectName(parentNode.getName()); + pingInfo.setDataType(DataType); + pingInfo.setLayer("Link"); + pingInfo.setDescription(Msg); + Simulation.addLayerInfo(pingInfo); + } public boolean isActive(){ *************** *** 181,185 **** } ! protected boolean listen(){ try{ switch(type){ --- 195,199 ---- } ! protected boolean listen(){ try{ switch(type){ *************** *** 228,232 **** if(!server){ s = new WANSocket(this, Host, port, server); ! return s.connect(); }else{ return false; --- 242,247 ---- if(!server){ s = new WANSocket(this, Host, port, server); ! connected = s.connect(); ! return connected; }else{ return false; Index: Packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Packet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Packet.java 14 Oct 2007 17:19:07 -0000 1.3 --- Packet.java 15 Oct 2007 18:25:54 -0000 1.4 *************** *** 52,57 **** } public String RawtoBytes(){ ! return "P|" + (int)UniqueIdentfier + "|" + hopCount + "#"; } --- 52,70 ---- } + public void fromBytes(String str){ + RawfromBytes(str); + } + public String RawtoBytes(){ ! return "P|" + (int)UniqueIdentfier + "|" + hopCount + "|#"; ! } ! ! public void RawfromBytes(String str){ ! String[] fields = str.split("\\|"); ! ! UniqueIdentfier = Integer.valueOf(fields[1]); ! hopCount = Integer.valueOf(fields[2]); ! ! System.out.println(UniqueIdentfier + " " + hopCount); } |
From: Alexander B. <da...@us...> - 2007-10-15 18:26:00
|
Update of /cvsroot/javanetsim/javaNetSim/images/simulation In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24241/images/simulation Modified Files: Router.png Added Files: csudsu.png csudsu2.png csudsu_small.png hub.png mymac.png switch.png Log Message: CSU/DSU Unit added; new graphics; wan interface TCP external connection... --- NEW FILE: mymac.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hub.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: csudsu2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: csudsu_small.png --- (This appears to be a binary file; contents omitted.) Index: Router.png =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/images/simulation/Router.png,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Binary files /tmp/cvsJEp8De and /tmp/cvsYoBRAu differ --- NEW FILE: switch.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: csudsu.png --- (This appears to be a binary file; contents omitted.) |
From: Alexander B. <da...@us...> - 2007-10-15 18:25:59
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24241/core/protocolsuite/tcp_ip Modified Files: ICMP_packet.java IP_packet.java UDP_packet.java Log Message: CSU/DSU Unit added; new graphics; wan interface TCP external connection... Index: ICMP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ICMP_packet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ICMP_packet.java 14 Oct 2007 17:19:07 -0000 1.3 --- ICMP_packet.java 15 Oct 2007 18:25:54 -0000 1.4 *************** *** 119,125 **** return RawtoBytes() + IPtoBytes() + ICMPtoBytes(); } public String ICMPtoBytes(){ ! return "M|" + mMessageCode + "|" + ICMP_message + "#"; } --- 119,142 ---- return RawtoBytes() + IPtoBytes() + ICMPtoBytes(); } + + public void fromBytes(String str){ + RawfromBytes(str); + IPfromBytes(str); + ICMPfromBytes(str); + } public String ICMPtoBytes(){ ! return "M|" + mMessageCode + "|" + ICMP_message + "|#"; ! } ! ! public void ICMPfromBytes(String str){ ! String icmp = str.replaceAll(".*#M\\|", ""); ! ! System.out.println(icmp); ! ! String[] fields = icmp.split("\\|"); ! ! mMessageCode = Integer.valueOf(fields[0]); ! ICMP_message = fields[1]; } Index: IP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IP_packet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IP_packet.java 14 Oct 2007 17:19:07 -0000 1.4 --- IP_packet.java 15 Oct 2007 18:25:54 -0000 1.5 *************** *** 251,256 **** } public String IPtoBytes(){ ! return "I|" + mSourceIPAddress + "|" + mDestIPAddress + "#"; } --- 251,272 ---- } + public void fromBytes(String str){ + RawfromBytes(str); + IPfromBytes(str); + } + public String IPtoBytes(){ ! return "I|" + mSourceIPAddress + "|" + mDestIPAddress + "|#"; ! } ! ! public void IPfromBytes(String str){ ! String ip = str.replaceAll(".*#I\\|", ""); ! ! System.out.println(ip); ! ! String[] fields = ip.split("\\|"); ! ! mSourceIPAddress = fields[0]; ! mDestIPAddress = fields[1]; } Index: UDP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/UDP_packet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UDP_packet.java 18 Nov 2005 19:41:32 -0000 1.4 --- UDP_packet.java 15 Oct 2007 18:25:54 -0000 1.5 *************** *** 237,240 **** --- 237,268 ---- } + public String toBytes(){ + return RawtoBytes() + IPtoBytes() + UDPtoBytes(); + } + + public void fromBytes(String str){ + RawfromBytes(str); + IPfromBytes(str); + UDPfromBytes(str); + } + + public String UDPtoBytes(){ + return "U|" + UDP_MessageLength + "|" + UDP_message + "|" + UDP_srcPort + "|" + UDP_destPort + "|#"; + } + + public void UDPfromBytes(String str){ + String icmp = str.replaceAll(".*#U\\|", ""); + + System.out.println(icmp); + + String[] fields = icmp.split("\\|"); + + UDP_MessageLength = Integer.valueOf(fields[0]); + UDP_message = fields[1]; + UDP_srcPort = Integer.valueOf(fields[2]); + UDP_destPort = Integer.valueOf(fields[3]); + } + + }//EOF |
From: Alexander B. <da...@us...> - 2007-10-15 12:04:37
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5217/guiUI Modified Files: LinkLayerPanel.java MainScreen.java SetTCPIPPropertiesDialog.java Log Message: Serial(FrameRelay) NICS + minor fixes in socket layer/protocol stack... Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** MainScreen.java 14 Oct 2007 22:14:52 -0000 1.70 --- MainScreen.java 15 Oct 2007 12:04:33 -0000 1.71 *************** *** 1170,1175 **** break; case core.NetworkInterface.Console: ! Sim.addSerialLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); break; } --- 1170,1178 ---- break; case core.NetworkInterface.Console: ! Sim.addConsoleLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); break; + case core.NetworkInterface.Serial: + Sim.addSerialLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); + break; } Index: LinkLayerPanel.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkLayerPanel.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LinkLayerPanel.java 14 Oct 2007 17:19:07 -0000 1.4 --- LinkLayerPanel.java 15 Oct 2007 12:04:33 -0000 1.5 *************** *** 158,161 **** --- 158,164 ---- 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; } Index: SetTCPIPPropertiesDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SetTCPIPPropertiesDialog.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SetTCPIPPropertiesDialog.java 13 Oct 2007 12:57:00 -0000 1.8 --- SetTCPIPPropertiesDialog.java 15 Oct 2007 12:04:33 -0000 1.9 *************** *** 434,438 **** for (int i = 0; i < nics.length; i++) { //Add them to the combobox ! if(Sim.getNode(NodeName).getIntType((String)nics[i]) == core.NetworkInterface.Ethernet10T ) cmbInterface.addItem(nics[i]); } --- 434,438 ---- for (int i = 0; i < nics.length; i++) { //Add them to the combobox ! if(Sim.getNode(NodeName).isActiveInterface((String)nics[i]) ) cmbInterface.addItem(nics[i]); } |
From: Alexander B. <da...@us...> - 2007-10-15 12:04:37
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5217/core Modified Files: ApplicationLayerDevice.java NetworkInterface.java NetworkLayerDevice.java Node.java PC.java Router.java Simulation.java Added Files: SerialLink.java SerialNetworkInterface.java Serial_packet.java Log Message: Serial(FrameRelay) NICS + minor fixes in socket layer/protocol stack... Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PC.java 14 Oct 2007 17:19:07 -0000 1.13 --- PC.java 15 Oct 2007 12:04:32 -0000 1.14 *************** *** 150,154 **** 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); } --- 150,154 ---- 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); } Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Node.java 14 Oct 2007 22:14:52 -0000 1.11 --- Node.java 15 Oct 2007 12:04:32 -0000 1.12 *************** *** 284,288 **** NetworkInterfacetable.put(interfaceName,new WANNetworkInterface(interfaceName,this)); break; ! } } --- 284,290 ---- NetworkInterfacetable.put(interfaceName,new WANNetworkInterface(interfaceName,this)); break; ! case NetworkInterface.Serial: ! NetworkInterfacetable.put(interfaceName,new SerialNetworkInterface(interfaceName,this)); ! break; } } --- NEW FILE: SerialNetworkInterface.java --- /* 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. - 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 core; class SerialNetworkInterface extends NetworkInterface{ /** * FrameRelay ClockRate * */ protected int ClockRate; protected SerialNetworkInterface(String inName, Node parent) { super(inName,parent); ClockRate = 400000; } protected void receivePacket(Packet inPacket) throws LowLinkException { Serial_packet tempPacket = (Serial_packet)inPacket; if(tempPacket.getClockRate() == ClockRate ){ 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); Simulation.addLayerInfo(pingInfo); Packet temp = tempPacket.getData(); parentNode.receivePacket(temp, name); }else{ 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."); Simulation.addLayerInfo(pingInfo); } } public int getType(){ return NetworkInterface.Serial; } protected void sendPacket(Packet inPacket) throws LowLinkException { Serial_packet Packet = new Serial_packet(inPacket, ClockRate); SerialLink temp = (SerialLink)connectedLink; // Create Layer info LayerInfo pingInfo = new LayerInfo(getClass().getName()); pingInfo.setObjectName(parentNode.getName()); pingInfo.setDataType("FrameRelay Packet"); pingInfo.setLayer("Link"); pingInfo.setDescription("Sending packet from interface "+ name); Simulation.addLayerInfo(pingInfo); if(temp!=null){ try{ temp.transportPacket(Packet, getSourceName()); }catch(LowLinkException ex){ LayerInfo frameErrInfo = new LayerInfo(getClass().getName()); frameErrInfo.setObjectName(parentNode.getName()); frameErrInfo.setDataType("FrameRelay Packet"); frameErrInfo.setLayer("Link"); frameErrInfo.setDescription(ex.toString()); Simulation.addLayerInfo(frameErrInfo); //throw new LowLinkException(ex.toString()); } } } /** * Returns the NetworkInterface's MAC Address. * @author bevan_calliess * @return MACAddress * @version v0.20 */ protected int getClockRate() { return ClockRate; } public boolean isActive(){ return true; } protected final void setClockRate(int ClockRate){ this.ClockRate = ClockRate; } /** * This method displays details about the current interface card * @author bevan_calliess * @return String * @version v0.20 */ protected String getDetails(){ return "Interface: "+name + "\t\tClock Rate: " + ClockRate +"\t\t"+ getConnectLinkDetails(); } } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Simulation.java 14 Oct 2007 22:14:52 -0000 1.16 --- Simulation.java 15 Oct 2007 12:04:32 -0000 1.17 *************** *** 606,610 **** } ! public void addSerialLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface) throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { --- 606,610 ---- } ! public void addConsoleLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface) throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { *************** *** 629,632 **** --- 629,655 ---- } + public void addSerialLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface) + throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { + + if (!linkTable.containsKey(inLinkName)) { + + //test if node's exist within hashtable + if(nodeTable.containsKey(inFirstNodeName) && nodeTable.containsKey(inSecondNodeName)){ + Node tempNode1 = (Node) nodeTable.get(inFirstNodeName); + Node tempNode2 = (Node) nodeTable.get(inSecondNodeName); + + //Return NetworkInterface from Node objects + NetworkInterface interface1 = tempNode1.getNetworkInterface(inFirstNodeInterface); + NetworkInterface interface2 = tempNode2.getNetworkInterface(inSecondNodeInterface); + + //Create link and add it to hashtable + linkTable.put(inLinkName,new SerialLink(inLinkName, interface1, interface2)); + }else{ + throw new InvalidNodeNameException("Invalid node name"); + } + } else + throw new InvalidLinkNameException("Link already exists with same name."); + } + /** * This method checks to see if inLinkName is contained within the has table(linkTable).If so, *************** *** 1174,1182 **** if(tempIP != null) { ! vecInterfaceInfo.add((String)tempNetwork.getIPAddress(strInterfaceName)); } else { ! vecInterfaceInfo.add((String)"IP Address not set"); } vecInterfaceInfo.add((String)tempNetwork.getSubnetMask(strInterfaceName)); --- 1197,1205 ---- if(tempIP != null) { ! vecInterfaceInfo.add((String)tempNetwork.getIPAddress(strInterfaceName)); } else { ! vecInterfaceInfo.add((String)"IP Address not set"); } vecInterfaceInfo.add((String)tempNetwork.getSubnetMask(strInterfaceName)); Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NetworkLayerDevice.java 14 Oct 2007 22:14:52 -0000 1.10 --- NetworkLayerDevice.java 15 Oct 2007 12:04:32 -0000 1.11 *************** *** 89,93 **** //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton public String getSubnetMask(String inInterface) { ! if(((NetworkInterface)(NetworkInterfacetable.get(inInterface))).getType() == NetworkInterface.Ethernet10T){ return NodeProtocolStack.getSubnetMask(inInterface); }else{ --- 89,93 ---- //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton public String getSubnetMask(String inInterface) { ! if(((NetworkInterface)(NetworkInterfacetable.get(inInterface))).isActive()){ return NodeProtocolStack.getSubnetMask(inInterface); }else{ *************** *** 107,111 **** //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton public String getIPAddress(String inInterface){ ! if(((NetworkInterface)(NetworkInterfacetable.get(inInterface))).getType() == NetworkInterface.Ethernet10T){ return NodeProtocolStack.getIPAddress(inInterface); }else{ --- 107,111 ---- //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton public String getIPAddress(String inInterface){ ! if(((NetworkInterface)(NetworkInterfacetable.get(inInterface))).isActive() ){ return NodeProtocolStack.getIPAddress(inInterface); }else{ *************** *** 163,166 **** --- 163,178 ---- } } + + public void sendPacket(Packet inPacket, String inInterfaceKey) throws InvalidNetworkInterfaceNameException, CommunicationException, LowLinkException{ + if (NetworkInterfacetable.containsKey(inInterfaceKey)) + { + NetworkInterface temp = (NetworkInterface)NetworkInterfacetable.get(inInterfaceKey); + temp.sendPacket(inPacket); + } + else + { + throw new InvalidNetworkInterfaceNameException("Inteface does not exist."); + } + } *************** *** 235,242 **** if (NetworkInterfacetable.containsKey(inInterface)) { NodeProtocolStack.setIPAddress(inInterface, inIPAddress); ! EthernetNetworkInterface tempNic = (EthernetNetworkInterface) NetworkInterfacetable.get( inInterface); ! macAddress = tempNic.getMACAddress(); } else { --- 247,256 ---- if (NetworkInterfacetable.containsKey(inInterface)) { NodeProtocolStack.setIPAddress(inInterface, inIPAddress); ! if(NetworkInterfacetable.get(inInterface) instanceof EthernetNetworkInterface){ ! EthernetNetworkInterface tempNic = (EthernetNetworkInterface) NetworkInterfacetable.get( inInterface); ! macAddress = tempNic.getMACAddress(); ! } } else { --- NEW FILE: Serial_packet.java --- /* 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. - 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 core; public class Serial_packet extends Packet { private int ClockRate; public Serial_packet(Packet inPacket, int inClockRate) { Data = inPacket; ClockRate = inClockRate; } public int getClockRate(){ return ClockRate; } public void setClockRate(int inClockRate){ ClockRate = inClockRate; } } --- NEW FILE: SerialLink.java --- /* 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. - 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 core; import java.util.*; /** * SerialLink extends Link. It sets two Interface links to a pc. * @author luke_hamilton * @author bevan_calliess * @since Sep 17, 2004 * @version v0.20 */ public class SerialLink extends Link { public SerialLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); NetworkInterfaces.add(inSecondNodeInterface); inFirstNodeInterface.setConnectedLink(this); inSecondNodeInterface.setConnectedLink(this); } public SerialLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface, double sieveCoeff)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); NetworkInterfaces.add(inSecondNodeInterface); inFirstNodeInterface.setConnectedLink(this); inSecondNodeInterface.setConnectedLink(this); this.setSC(sieveCoeff); } public void transportPacket(Serial_packet inPacket,String inSourceName) throws LowLinkException { Iterator it = NetworkInterfaces.iterator(); while (it.hasNext()) { NetworkInterface temp = (NetworkInterface) it.next(); if (!temp.getSourceName().equals(inSourceName)) { temp.receivePacket(inPacket); } } } } Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NetworkInterface.java 14 Oct 2007 17:19:07 -0000 1.6 --- NetworkInterface.java 15 Oct 2007 12:04:32 -0000 1.7 *************** *** 134,137 **** --- 134,138 ---- public final static int Wireless = 2; public final static int WAN = 3; + public final static int Serial = 4; public static String getIntName(int type){ *************** *** 145,148 **** --- 146,151 ---- case 3: return "wan"; + case 4: + return "ser"; default: return "unk"; Index: Router.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Router.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Router.java 14 Oct 2007 17:19:07 -0000 1.4 --- Router.java 15 Oct 2007 12:04:32 -0000 1.5 *************** *** 50,53 **** --- 50,54 ---- 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); } Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ApplicationLayerDevice.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ApplicationLayerDevice.java 14 Oct 2007 22:14:52 -0000 1.3 --- ApplicationLayerDevice.java 15 Oct 2007 12:04:32 -0000 1.4 *************** *** 38,49 **** public void turnOff(){ Enumeration<Application> ap = Apps.elements(); ! // while(ap.hasMoreElements()){ ! // try{ ! // ap.nextElement().Free(); ! // }catch(TransportLayerException e){ ! // e.printStackTrace(); ! // } ! // } ! super.turnOn(); } } --- 38,50 ---- public void turnOff(){ Enumeration<Application> ap = Apps.elements(); ! while(ap.hasMoreElements()){ ! try{ ! ap.nextElement().Free(); ! }catch(TransportLayerException e){ ! e.printStackTrace(); ! ! } ! } ! super.turnOff(); } } |
From: Alexander B. <da...@us...> - 2007-10-15 12:04:37
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5217/core/protocolsuite/tcp_ip Modified Files: DHCPD.java Echo_tcp.java ExternalProxyApp.java ProtocolStack.java SNMP.java socketLayer.java Log Message: Serial(FrameRelay) NICS + minor fixes in socket layer/protocol stack... Index: socketLayer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/socketLayer.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** socketLayer.java 14 Oct 2007 00:22:14 -0000 1.11 --- socketLayer.java 15 Oct 2007 12:04:33 -0000 1.12 *************** *** 166,176 **** jnSocket jnsock = (jnSocket)sockTable.get(sock); jnsock.app = null; ! jnsock.open_state = false; ! if(jnsock.type == jnsock.UDP_socket){ ! mParentStack.UDP().closePort(sock); ! } ! else if(jnsock.type == jnsock.TCP_socket){ ! mParentStack.TCP().closePort(sock); ! } jnsock.src_port = 0; jnsock.src_IP = ""; --- 166,178 ---- jnSocket jnsock = (jnSocket)sockTable.get(sock); jnsock.app = null; ! if(jnsock.open_state){ ! if(jnsock.type == jnsock.UDP_socket){ ! mParentStack.UDP().closePort(sock); ! } ! else if(jnsock.type == jnsock.TCP_socket){ ! mParentStack.TCP().closePort(sock); ! } ! jnsock.open_state = false; ! } jnsock.src_port = 0; jnsock.src_IP = ""; Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** ProtocolStack.java 14 Oct 2007 22:14:52 -0000 1.60 --- ProtocolStack.java 15 Oct 2007 12:04:33 -0000 1.61 *************** *** 267,287 **** inPacket.setSourceIPAddress(sourceIP); // test if on local of remote network ! if(outInterface[1]==null){ ! destMAC = mARPprotocol.getMACAddress(inPacket.getDestIPAddress(),outInterface[0]); ! } ! else{ ! //String GatewayAddress = mIPprotocol.getDefaultGateway(); ! GatewayAddress = mIPprotocol.getGateway(inPacket.getDestIPAddress()); ! String outIface = mIPprotocol.getInterface(inPacket.getDestIPAddress()); [...1390 lines suppressed...] ! for(int i=0; i<nics.size(); i++) { ! try{ ! iface = (String)(nics.get(i)); ! if(temp.isActiveInterface(iface)){ ! IP = getIPAddress((String)nics.get(i)); ! if(IP != null){ ! return IP; ! } } ! }catch(InvalidNetworkInterfaceNameException e){ ! e.printStackTrace(); ! } ! } ! return ""; ! } ! }//EOF Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Echo_tcp.java 29 Sep 2007 20:33:35 -0000 1.38 --- Echo_tcp.java 15 Oct 2007 12:04:33 -0000 1.39 *************** *** 72,75 **** --- 72,80 ---- public void Close() throws TransportLayerException { + if(appType == 0){ + printLayerInfo("Echo application", "Echo TCP server closed socket."); + }else{ + printLayerInfo("Echo application", "Echo TCP server closed socket."); + } mParentStack.SL().close(appSock); for(int i=0; i<connections.size(); i++){ *************** *** 80,84 **** public void Free() throws TransportLayerException{ ! Close(); mParentStack.SL().free(appSock); for(int i=0; i<connections.size(); i++){ --- 85,93 ---- public void Free() throws TransportLayerException{ ! if(appType == 0){ ! printLayerInfo("Echo application", "Echo TCP application freed socket."); ! }else{ ! printLayerInfo("Echo application", "Echo TCP server freed socket."); ! } mParentStack.SL().free(appSock); for(int i=0; i<connections.size(); i++){ Index: ExternalProxyApp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ExternalProxyApp.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ExternalProxyApp.java 1 Oct 2007 04:58:12 -0000 1.6 --- ExternalProxyApp.java 15 Oct 2007 12:04:33 -0000 1.7 *************** *** 80,89 **** //throw new TransportLayerException("Cannot bind port " + listenPort + "."); recieved = 0; ! try{ ! if(appType != 0) mParentStack.ListenTCP(this, listenPort); ! } catch (TransportLayerException e) ! { ! e.printStackTrace(); ! } } --- 80,89 ---- //throw new TransportLayerException("Cannot bind port " + listenPort + "."); recieved = 0; ! //try{ ! //if(appType != 0) mParentStack.ListenTCP(this, listenPort); ! //} catch (TransportLayerException e) ! //{ ! // e.printStackTrace(); ! //} } *************** *** 102,111 **** { //mParentStack.FreeTCPApplication(this); ! mParentStack.CloseTCP(this); recieved = 0; } public void Free() throws TransportLayerException{ ! mParentStack.FreeTCPApplication(this); recieved = 0; } --- 102,111 ---- { //mParentStack.FreeTCPApplication(this); ! //mParentStack.CloseTCP(this); recieved = 0; } public void Free() throws TransportLayerException{ ! //mParentStack.FreeTCPApplication(this); recieved = 0; } *************** *** 122,126 **** public void Disconnect() throws TransportLayerException, LowLinkException{ try { ! mParentStack.FinalizeTCP(this); //will close client connection }catch(Exception e){ ///*TODO*: here to catch --- 122,126 ---- public void Disconnect() throws TransportLayerException, LowLinkException{ try { ! //mParentStack.FinalizeTCP(this); //will close client connection }catch(Exception e){ ///*TODO*: here to catch *************** *** 135,139 **** Simulation.addLayerInfo(protInfo3); ! mParentStack.CloseTCP(this); Close(); } --- 135,139 ---- Simulation.addLayerInfo(protInfo3); ! //mParentStack.CloseTCP(this); Close(); } *************** *** 155,159 **** try{ ! mParentStack.CloseTCP(this); Close(); EN.NATDisconnect(this); --- 155,159 ---- try{ ! //mParentStack.CloseTCP(this); Close(); EN.NATDisconnect(this); *************** *** 222,226 **** { ! mParentStack.SendTCP(this, Data,-1); //processing the protocol doings. --- 222,226 ---- { ! // mParentStack.SendTCP(this, Data,-1); //processing the protocol doings. Index: DHCPD.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPD.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DHCPD.java 14 Oct 2007 17:19:07 -0000 1.2 --- DHCPD.java 15 Oct 2007 12:04:33 -0000 1.3 *************** *** 270,279 **** o.Gateway = l.Gateway; ! protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCP Server"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Sending DHCPOFFER(xid=" + o.xid + ") packet to 255.255.255.255 with op=1 chaddr='" + o.chaddr + "' DHCP Server='" + o.DHCPServer + "' yiaddr='" + o.yiaddr + "'."); try{ --- 270,280 ---- o.Gateway = l.Gateway; ! LayerInfo protInfo1 = new LayerInfo(getClass().getName()); ! protInfo1.setObjectName(mParentStack.getParentNodeName()); ! protInfo1.setDataType("DHCP Server"); ! protInfo1.setLayer("Application "); ! protInfo1.setDescription("Sending DHCPOFFER(xid=" + o.xid + ") packet to 255.255.255.255 with op=1 chaddr='" + o.chaddr + "' DHCP Server='" + o.DHCPServer + "' yiaddr='" + o.yiaddr + "'."); + Simulation.addLayerInfo(protInfo); try{ Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** SNMP.java 14 Oct 2007 22:14:52 -0000 1.23 --- SNMP.java 15 Oct 2007 12:04:33 -0000 1.24 *************** *** 161,171 **** public void Close() throws TransportLayerException { //mParentStack.CloseUDP(this); - mParentStack.SL().close(appSock); printInfo("SNMP agent closed socket."); //<--- FIXME!!! } public void Free() throws TransportLayerException{ - mParentStack.SL().free(appSock); printInfo("SNMP agent freed socket."); //<--- FIXME!!! } --- 161,171 ---- public void Close() throws TransportLayerException { //mParentStack.CloseUDP(this); printInfo("SNMP agent closed socket."); //<--- FIXME!!! + mParentStack.SL().close(appSock); } public void Free() throws TransportLayerException{ printInfo("SNMP agent freed socket."); //<--- FIXME!!! + mParentStack.SL().free(appSock); } *************** *** 420,424 **** */ public boolean getRequest(String Host, int port, Vector<String> r,String password) throws LowLinkException, TransportLayerException, CommunicationException, InvalidNetworkLayerDeviceException { - mParentStack.FreeUDPApplication(this); if (Connect(Host, port)) { String pack = createSNMPHeader(getNextID(),SNMP_GET); --- 420,423 ---- *************** *** 447,451 **** */ public boolean getNextRequest(String Host, int port, Vector<String> r,String password) throws LowLinkException, TransportLayerException, CommunicationException, InvalidNetworkLayerDeviceException { - mParentStack.FreeUDPApplication(this); if (Connect(Host, port)) { String pack = createSNMPHeader(getNextID(),SNMP_GETNEXT); --- 446,449 ---- *************** *** 475,479 **** */ public boolean setRequest(String Host, int port, Vector<String> r,Vector<String> v,String password) throws LowLinkException, TransportLayerException, CommunicationException, InvalidNetworkLayerDeviceException { - mParentStack.FreeUDPApplication(this); if (Connect(Host, port)) { String pack = createSNMPHeader(getNextID(),SNMP_SET); --- 473,476 ---- |
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26945/core Modified Files: ApplicationLayerDevice.java CommandProcessor.java DeviceConfig.java NetworkLayerDevice.java Node.java Simulation.java Log Message: Some console commands was corrected Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DeviceConfig.java 14 Oct 2007 00:22:14 -0000 1.2 --- DeviceConfig.java 14 Oct 2007 22:14:52 -0000 1.3 *************** *** 81,99 **** } ! /** Add 'command', which contain parameters after 'paramc' argument * @return false if 'command' already exists */ public boolean add(String command, Vector<String> params){ - boolean result = false; - String fullcmd = createCommand(command, params); LinkedList config = getConfig(working_config); Iterator<String> it = config.iterator(); boolean found = false; while(it.hasNext() && !found){ ! found = (fullcmd.compareToIgnoreCase(it.next())==0); } if(!found){ ! config.add(createCommand(command, params)); result = true; } --- 81,105 ---- } ! /** Add 'command', which contain parameters 'params' * @return false if 'command' already exists */ public boolean add(String command, Vector<String> params){ String fullcmd = createCommand(command, params); + return add(fullcmd); + } + + /** Add full 'command' + * @return false if 'command' already exists + */ + public boolean add(String command){ + boolean result = false; LinkedList config = getConfig(working_config); Iterator<String> it = config.iterator(); boolean found = false; while(it.hasNext() && !found){ ! found = (command.compareToIgnoreCase(it.next())==0); } if(!found){ ! config.add(command); result = true; } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Simulation.java 14 Oct 2007 17:19:07 -0000 1.15 --- Simulation.java 14 Oct 2007 22:14:52 -0000 1.16 *************** *** 305,309 **** { NetworkLayerDevice t = (NetworkLayerDevice)tempNode; ! arpEntries = t.getARPTable(); }else { --- 305,320 ---- { NetworkLayerDevice t = (NetworkLayerDevice)tempNode; ! Vector<Vector<String>> ArpTable = t.getARPTable(); ! arpEntries = new String[ArpTable.size()+1]; ! if(ArpTable.size()>0){ ! arpEntries[0] = "Internet Address\tPhysical Address\t\tType\n"; ! for(int i=0;i<ArpTable.size();i++) ! { ! arpEntries[i+1] = ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2) + "\n"; ! } ! } ! else{ ! arpEntries[0] = "No ARP Entries Found\n"; ! } }else { Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NetworkLayerDevice.java 13 Oct 2007 12:57:00 -0000 1.9 --- NetworkLayerDevice.java 14 Oct 2007 22:14:52 -0000 1.10 *************** *** 60,64 **** --- 60,80 ---- public NetworkLayerDevice(String inName, int inProtocolStackLayers) { super(inName, inProtocolStackLayers); + //set default startup-config + config.working_config = DeviceConfig.STARTUP_CONFIG; + //config.add("ip telnet 21"); + //end set default startup-config + config.working_config = DeviceConfig.RUNNING_CONFIG; + config.load(); } + + public void turnOn(){ + super.turnOn(); + config.load(); + } + + public void turnOff(){ + config.clear(DeviceConfig.RUNNING_CONFIG); + super.turnOff(); + } /** *************** *** 164,170 **** * @author robert_hulford * @author bevan_calliess ! * @return String[] - The arp table entries */ ! public String[] getARPTable() { return NodeProtocolStack.getARPTable(); } --- 180,186 ---- * @author robert_hulford * @author bevan_calliess ! * @return Vector<Vector<String>> - The arp table entries */ ! public Vector<Vector<String>> getARPTable() { return NodeProtocolStack.getARPTable(); } Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CommandProcessor.java 14 Oct 2007 00:22:14 -0000 1.2 --- CommandProcessor.java 14 Oct 2007 22:14:52 -0000 1.3 *************** *** 13,16 **** --- 13,20 ---- import core.protocolsuite.tcp_ip.Route_entry; import core.protocolsuite.tcp_ip.SNMP; + import core.protocolsuite.tcp_ip.TCP_session; + import core.protocolsuite.tcp_ip.UDP_session; + import core.protocolsuite.tcp_ip.jnSocket; + import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; *************** *** 49,52 **** --- 53,57 ---- 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(); + private ip_tcp_window_size_CommandClass ip_tcp_window_size_Command = new ip_tcp_window_size_CommandClass(); private show_access_lists_CommandClass show_access_lists_Command = new show_access_lists_CommandClass(); private show_arp_CommandClass show_arp_Command = new show_arp_CommandClass(); *************** *** 59,67 **** private show_interfaces_CommandClass show_interfaces_Command = new show_interfaces_CommandClass(); private show_ip_CommandClass show_ip_Command = new show_ip_CommandClass(); private show_kron_CommandClass show_kron_Command = new show_kron_CommandClass(); private show_location_CommandClass show_location_Command = new show_location_CommandClass(); private show_logging_CommandClass show_logging_Command = new show_logging_CommandClass(); private show_ntp_CommandClass show_ntp_Command = new show_ntp_CommandClass(); - private show_ip_route_CommandClass show_ip_route_Command = new show_ip_route_CommandClass(); private show_running_config_CommandClass show_running_config_Command = new show_running_config_CommandClass(); private show_sessions_CommandClass show_sessions_Command = new show_sessions_CommandClass(); --- 64,72 ---- private show_interfaces_CommandClass show_interfaces_Command = new show_interfaces_CommandClass(); private show_ip_CommandClass show_ip_Command = new show_ip_CommandClass(); + private show_ip_route_CommandClass show_ip_route_Command = new show_ip_route_CommandClass(); private show_kron_CommandClass show_kron_Command = new show_kron_CommandClass(); private show_location_CommandClass show_location_Command = new show_location_CommandClass(); private show_logging_CommandClass show_logging_Command = new show_logging_CommandClass(); private show_ntp_CommandClass show_ntp_Command = new show_ntp_CommandClass(); private show_running_config_CommandClass show_running_config_Command = new show_running_config_CommandClass(); private show_sessions_CommandClass show_sessions_Command = new show_sessions_CommandClass(); *************** *** 70,75 **** --- 75,89 ---- private show_snmp_version_CommandClass show_snmp_version_Command = new show_snmp_version_CommandClass(); private show_startup_config_CommandClass show_startup_config_Command = new show_startup_config_CommandClass(); + private show_tcp_sessions_CommandClass show_tcp_sessions_Command = new show_tcp_sessions_CommandClass(); + private show_tcp_statistics_CommandClass show_tcp_statistics_Command = new show_tcp_statistics_CommandClass(); + private show_tcp_window_size_CommandClass show_tcp_window_size_Command = new show_tcp_window_size_CommandClass(); + private show_udp_sessions_CommandClass show_udp_sessions_Command = new show_udp_sessions_CommandClass(); + private show_udp_statistics_CommandClass show_udp_statistics_Command = new show_udp_statistics_CommandClass(); private show_version_CommandClass show_version_Command = new show_version_CommandClass(); + private snmp_server_community_CommandClass snmp_server_community_Command = new snmp_server_community_CommandClass(); + private no_snmp_server_community_CommandClass no_snmp_server_community_Command = new no_snmp_server_community_CommandClass(); + private snmp_server_port_CommandClass snmp_server_port_Command = new snmp_server_port_CommandClass(); private telnet_CommandClass telnet_Command = new telnet_CommandClass(); + private telnet_server_CommandClass telnet_server_Command = new telnet_server_CommandClass(); private traceroute_CommandClass traceroute_Command = new traceroute_CommandClass(); private write_memory_CommandClass write_memory_Command = new write_memory_CommandClass(); *************** *** 99,102 **** --- 113,118 ---- 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"); *************** *** 118,128 **** commands.add("show running-config", show_running_config_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "Current operating configuration"); commands.add("show sessions", show_sessions_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "Information about Telnet connections"); ! commands.addDescription("show snmp","snmp statistics"); commands.add("show snmp community", show_snmp_community_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show snmp community"); commands.add("show snmp mib", show_snmp_mib_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show mib objects"); commands.add("show snmp version", show_snmp_version_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show snmp version"); commands.add("show startup-config", show_startup_config_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "Contents of startup configuration"); commands.add("show version", show_version_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "System hardware and software status"); commands.add("telnet", telnet_Command, STD_CONF_MODE | APPLICATION_LAYER, "<IP>", "Open a telnet connection"); commands.add("traceroute", traceroute_Command, STD_CONF_MODE | NETWORK_LAYER, "<IP>", "Trace route to destination"); commands.addDescription("write","Write running configuration to memory or terminal"); --- 134,156 ---- commands.add("show running-config", show_running_config_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "Current operating configuration"); commands.add("show sessions", show_sessions_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "Information about Telnet connections"); ! commands.addDescription("show snmp","SNMP statistics"); commands.add("show snmp community", show_snmp_community_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show snmp community"); commands.add("show snmp mib", show_snmp_mib_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show mib objects"); commands.add("show snmp version", show_snmp_version_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show snmp version"); commands.add("show startup-config", show_startup_config_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "Contents of startup configuration"); + commands.addDescription("show tcp","TCP information"); + commands.add("show tcp sessions", show_tcp_sessions_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "Print all TCP sessions"); + commands.add("show tcp statistics", show_tcp_statistics_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "TCP statistics"); + commands.add("show tcp window-size", show_tcp_window_size_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "TCP window-size"); + commands.addDescription("show udp","TCP information"); + commands.add("show udp sessions", show_udp_sessions_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "Print all UDP sessions"); + 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"); + commands.add("no snmp-server community", no_snmp_server_community_Command, CONF_MODE | APPLICATION_LAYER, "<cr>", "Disable SNMP"); + commands.add("snmp-server port", snmp_server_port_Command, CONF_MODE | APPLICATION_LAYER, "<port>", "Specify server port"); commands.add("telnet", telnet_Command, STD_CONF_MODE | APPLICATION_LAYER, "<IP>", "Open a telnet connection"); + commands.add("telnet-server", telnet_server_Command, CONF_MODE | APPLICATION_LAYER, "<port>", "Enable TELNET; Specify server port"); commands.add("traceroute", traceroute_Command, STD_CONF_MODE | NETWORK_LAYER, "<IP>", "Trace route to destination"); commands.addDescription("write","Write running configuration to memory or terminal"); *************** *** 195,201 **** public String call(Vector<String> params){ String out = ""; ! String arps[] = device.NodeProtocolStack.getARPTable(); ! for(int i=1; i<arps.length; i++){ ! device.NodeProtocolStack.removeARP(arps[i].split(" ")[0]); } out += "ARP table have been cleared\n"; --- 223,229 ---- public String call(Vector<String> params){ String out = ""; ! Vector<Vector<String>> ArpTable = device.NodeProtocolStack.getARPTable(); ! for(int i=1; i<ArpTable.size(); i++){ ! device.NodeProtocolStack.removeARP(ArpTable.get(i).get(0)); } out += "ARP table have been cleared\n"; *************** *** 283,289 **** class reload_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! //device.cold_restart(); ! device.getConfig().load(); ! return ""; } }; --- 311,316 ---- class reload_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! device.Reset(); ! return "Device reloaded\n"; } }; *************** *** 292,295 **** --- 319,324 ---- String out = ""; if(params.size()==4){ + device.getConfig().remove("^ip route "+params.get(0)+" "+params.get(1)); + device.getConfig().add("ip route", params); device.NodeProtocolStack.addRoute(new Route_entry(params.get(0), params.get(2), params.get(1), params.get(3), 0)); out+="Route added.\n"; *************** *** 305,308 **** --- 334,338 ---- String out = ""; if(params.size()==1){ + device.getConfig().remove("^ip route "+params.get(0)+" "+params.get(1)); device.NodeProtocolStack.removeRoute(params.get(0)); out+="Route to " + params.get(0) + " removed.\n"; *************** *** 314,317 **** --- 344,366 ---- } }; + class ip_tcp_window_size_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(params.size()==1){ + try{ + int ws = Integer.parseInt(params.get(0)); + device.NodeProtocolStack.TCP().getWindowSize(); + out += "TCP window size is " + device.NodeProtocolStack.TCP().getWindowSize() + " segments"; + } + catch(NumberFormatException e){ + out += "Invalid window size\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; class show_access_lists_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 323,330 **** String out = ""; try{ ! String ArpTable[] = device.NodeProtocolStack.getARPTable(); ! for(int i=0;i<ArpTable.length;i++) ! { ! out += ArpTable[i] + "\n"; } } --- 372,385 ---- String out = ""; try{ ! Vector<Vector<String>> ArpTable = device.NodeProtocolStack.getARPTable(); ! if(ArpTable.size()>0){ ! out += "Internet Address\tPhysical Address\t\tType\n"; ! for(int i=0;i<ArpTable.size();i++) ! { ! out += ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2) + "\n"; ! } ! } ! else{ ! out += "No ARP Entries Found\n"; } } *************** *** 398,414 **** "\n Sent IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getoutputIPCount()).toString() + "\n ARP Packets: " + Integer.valueOf(device.NodeProtocolStack.getARPCount()).toString(); - if(device.getClass().equals(ApplicationLayerDevice.class)){ - out += "\n Recieved TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPinputCount()).toString() + - "\n Sent TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPoutputCount()).toString() + - "\n Sent TCP ACK's: " + Integer.valueOf(device.NodeProtocolStack.getTCPACKCount()).toString() + - "\n Sent TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPSDCount()).toString() + - "\n Recieved TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPRDCount()).toString() + - "\n Recieved UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPinputCount()).toString() + - "\n Sent UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPoutputCount()).toString(); - } out += "\n"; return out; } }; class show_kron_CommandClass implements CommandInterface{ public String call(Vector<String> params){ --- 453,477 ---- "\n Sent IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getoutputIPCount()).toString() + "\n ARP Packets: " + Integer.valueOf(device.NodeProtocolStack.getARPCount()).toString(); out += "\n"; return out; } }; + class show_ip_route_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(params.size()==0){ + String routes[] = device.NodeProtocolStack.getRouteTableEntries(); + out += "IP routing table:\n" + "Destination" + "\t" + "Genmask" + "\t" + "Gateway" + "\t" + "Type" + "\t" + "Iface\n"; + for(int i=0; i<routes.length - 1; i++){ + Route_entry r = device.NodeProtocolStack.getRouteTableEntry(routes[i]); + out += routes[i] + "\t" + r.genMask + "\t" + r.gateway + "\t" + r.Type + "\t" + r.iFace + "\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; class show_kron_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 431,451 **** } }; - class show_ip_route_CommandClass implements CommandInterface{ - public String call(Vector<String> params){ - String out = ""; - if(params.size()==0){ - String routes[] = device.NodeProtocolStack.getRouteTableEntries(); - out += "IP routing table:\n" + "Destination" + "\t" + "Genmask" + "\t" + "Gateway" + "\t" + "Type" + "\t" + "Iface\n"; - for(int i=0; i<routes.length - 1; i++){ - Route_entry r = device.NodeProtocolStack.getRouteTableEntry(routes[i]); - out += routes[i] + "\t" + r.genMask + "\t" + r.gateway + "\t" + r.Type + "\t" + r.iFace + "\n"; - } - } - else{ - out += "Invalid parameters\n"; - } - return out; - } - }; class show_running_config_CommandClass implements CommandInterface{ public String call(Vector<String> params){ --- 494,497 ---- *************** *** 506,509 **** --- 552,623 ---- } }; + class show_tcp_sessions_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "Source\tDestination\tState\n"; + Enumeration<String> keys = device.NodeProtocolStack.TCP().getSessionKeys(); + while(keys.hasMoreElements()){ + String key = keys.nextElement(); + TCP_session tcps = device.NodeProtocolStack.TCP().getSession(key); + jnSocket jnsock = device.NodeProtocolStack.SL().get_socket(tcps.getSocket()); + out += jnsock.src_IP+":"+jnsock.src_port+"\t"+jnsock.dst_IP+":"+jnsock.src_port+"\t"+tcps.getState()+"\n"; + } + out += ""; + } + return out; + } + }; + class show_tcp_statistics_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "\n Recieved TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPinputCount()).toString() + + "\n Sent TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPoutputCount()).toString() + + "\n Sent TCP ACK's: " + Integer.valueOf(device.NodeProtocolStack.getTCPACKCount()).toString() + + "\n Sent TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPSDCount()).toString() + + "\n Recieved TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPRDCount()).toString() + + "\n"; + } + return out; + } + }; + class show_tcp_window_size_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "Windows size is " + device.NodeProtocolStack.TCP().getWindowSize() + " segments"; + } + return out; + } + }; + class show_udp_sessions_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "Source\tDestination\tState\n"; + Enumeration<String> keys = device.NodeProtocolStack.UDP().getSessionKeys(); + while(keys.hasMoreElements()){ + String key = keys.nextElement(); + UDP_session udps = device.NodeProtocolStack.UDP().getSession(key); + jnSocket jnsock = device.NodeProtocolStack.SL().get_socket(udps.getSocket()); + out += jnsock.src_IP+":"+jnsock.src_port+"\t"+jnsock.dst_IP+":"+jnsock.src_port+"\n"; + } + out += ""; + } + return out; + } + }; + class show_udp_statistics_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "\n Recieved UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPinputCount()).toString() + + "\n Sent UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPoutputCount()).toString() + + "\n"; + } + return out; + } + }; class show_version_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 513,516 **** --- 627,645 ---- } }; + class snmp_server_community_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + return "Command not supported yet.\n"; + } + }; + class no_snmp_server_community_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + return "Command not supported yet.\n"; + } + }; + class snmp_server_port_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + return "Command not supported yet.\n"; + } + }; class telnet_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 518,521 **** --- 647,655 ---- } }; + class telnet_server_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + return "Command not supported yet.\n"; + } + }; class traceroute_CommandClass implements CommandInterface{ public String call(Vector<String> params){ Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Node.java 14 Oct 2007 17:19:07 -0000 1.10 --- Node.java 14 Oct 2007 22:14:52 -0000 1.11 *************** *** 128,131 **** --- 128,133 ---- public boolean On; + + private int ProtocolStackLayers; *************** *** 155,193 **** name=inName; ! On = true; ! ! if(inProtocolStackLayers != 1){ ! ! //This test the current simulation object for the type of protocol that is being used and then ! ! //Creates a protocolstack of that type. ! ! if(Simulation.getProtocolType() == ProtocolStack.TCP_IP){ ! ! NodeProtocolStack = new core.protocolsuite.tcp_ip.ProtocolStack(this,inProtocolStackLayers); ! ! }else if(Simulation.getProtocolType() == ProtocolStack.APPLETALK){ ! ! //NodeProtocolStack = new core.protocolsuite.appletalk.ProtocolStack(this); //Not implemented ! ! }else if(Simulation.getProtocolType() == ProtocolStack.IBM_SNA){ ! ! //NodeProtocolStack = new core.protocolsuite.ibm_sna.ProtocolStack(this); //Not implemented ! ! }else if(Simulation.getProtocolType() == ProtocolStack.IPX_SPX){ ! ! //NodeProtocolStack = new core.protocolsuite.ipx_spx.ProtocolStack(this); //Not implemented ! ! } ! ! }else{ ! ! NodeProtocolStack = null; //Set layer 1 devices protocolstack to null ! ! } } ! /** --- 157,184 ---- name=inName; ! ProtocolStackLayers = inProtocolStackLayers; ! ! init(inProtocolStackLayers); } ! private void init(int inProtocolStackLayers){ ! On = true; ! if(inProtocolStackLayers != 1){ ! //This test the current simulation object for the type of protocol that is being used and then ! //Creates a protocolstack of that type. ! if(Simulation.getProtocolType() == ProtocolStack.TCP_IP){ ! NodeProtocolStack = new core.protocolsuite.tcp_ip.ProtocolStack(this,inProtocolStackLayers); ! }else if(Simulation.getProtocolType() == ProtocolStack.APPLETALK){ ! //NodeProtocolStack = new core.protocolsuite.appletalk.ProtocolStack(this); //Not implemented ! }else if(Simulation.getProtocolType() == ProtocolStack.IBM_SNA){ ! //NodeProtocolStack = new core.protocolsuite.ibm_sna.ProtocolStack(this); //Not implemented ! }else if(Simulation.getProtocolType() == ProtocolStack.IPX_SPX){ ! //NodeProtocolStack = new core.protocolsuite.ipx_spx.ProtocolStack(this); //Not implemented ! } ! }else{ ! NodeProtocolStack = null; //Set layer 1 devices protocolstack to null ! } ! } /** *************** *** 341,345 **** public int getState() { return 0; } ! public void Reset() {} --- 332,348 ---- public int getState() { return 0; } ! public void Reset() { ! turnOff(); ! turnOn(); ! } ! ! public void turnOn() { ! init(ProtocolStackLayers); ! } ! ! public void turnOff() { ! On = false; ! NodeProtocolStack = null; ! } Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ApplicationLayerDevice.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ApplicationLayerDevice.java 3 Dec 2005 19:23:19 -0000 1.2 --- ApplicationLayerDevice.java 14 Oct 2007 22:14:52 -0000 1.3 *************** *** 8,11 **** --- 8,13 ---- package core; + import core.protocolsuite.tcp_ip.Application; + import java.util.Enumeration; import java.util.Hashtable; *************** *** 23,31 **** public void addApp(Object app, int code){ ! Apps.put(code, app); } public Object getApp(int code){ ! return Apps.get(code); } } --- 25,49 ---- public void addApp(Object app, int code){ ! Apps.put(code, app); } public Object getApp(int code){ ! return Apps.get(code); ! } ! ! public void turnOn(){ ! super.turnOn(); ! } ! ! public void turnOff(){ ! Enumeration<Application> ap = Apps.elements(); ! // while(ap.hasMoreElements()){ ! // try{ ! // ap.nextElement().Free(); ! // }catch(TransportLayerException e){ ! // e.printStackTrace(); ! // } ! // } ! super.turnOn(); } } |
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26945/core/protocolsuite/tcp_ip Modified Files: ARP.java ProtocolStack.java SNMP.java TCP_session.java Tcp.java Telnet_server.java Udp.java Log Message: Some console commands was corrected Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Udp.java 14 Oct 2007 17:19:07 -0000 1.41 --- Udp.java 14 Oct 2007 22:14:52 -0000 1.42 *************** *** 225,229 **** String sessionID; boolean Found=false; ! Enumeration LocalSessions = getSessionKeys(); --- 225,229 ---- String sessionID; boolean Found=false; ! Enumeration<String> LocalSessions = getSessionKeys(); *************** *** 233,237 **** while ( (LocalSessions.hasMoreElements()) && !(Found) ) { ! sessionID = (String)LocalSessions.nextElement(); Elm = getSession(sessionID); if ( sock == Elm.sock && Elm.sock >=0 ) --- 233,237 ---- while ( (LocalSessions.hasMoreElements()) && !(Found) ) { ! sessionID = LocalSessions.nextElement(); Elm = getSession(sessionID); if ( sock == Elm.sock && Elm.sock >=0 ) *************** *** 372,376 **** } ! private UDP_session getSession(String key){ UDP_session udps; synchronized(sessionTable_lock){ --- 372,376 ---- } ! public UDP_session getSession(String key){ UDP_session udps; synchronized(sessionTable_lock){ *************** *** 380,385 **** } ! private Enumeration getSessionKeys(){ ! Enumeration keys; synchronized(sessionTable_lock){ keys = sessionTable.keys(); --- 380,385 ---- } ! public Enumeration<String> getSessionKeys(){ ! Enumeration<String> keys; synchronized(sessionTable_lock){ keys = sessionTable.keys(); Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Telnet_server.java 1 Oct 2007 04:58:12 -0000 1.17 --- Telnet_server.java 14 Oct 2007 22:14:52 -0000 1.18 *************** *** 379,386 **** if((m=Pattern.compile(" +-a$").matcher(cmd)).find()) { try{ ! String ArpTable[] = mParentStack.getARPTable(); ! for(int i=0;i<ArpTable.length;i++) ! { ! out += ArpTable[i] + "\r\n"; } } --- 379,392 ---- if((m=Pattern.compile(" +-a$").matcher(cmd)).find()) { try{ ! Vector<Vector<String>> ArpTable = mParentStack.getARPTable(); ! if(ArpTable.size()>0){ ! out += "Internet Address\tPhysical Address\t\tType\r\n"; ! for(int i=0;i<ArpTable.size();i++) ! { ! out += ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2) + "\r\n"; ! } ! } ! else{ ! out += "No ARP Entries Found\r\n"; } } Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** ProtocolStack.java 14 Oct 2007 17:19:07 -0000 1.59 --- ProtocolStack.java 14 Oct 2007 22:14:52 -0000 1.60 *************** *** 61,66 **** import java.io.Serializable; - import core.protocolsuite.tcp_ip.ICMP_packet; - import core.InvalidNetworkInterfaceNameException; --- 61,64 ---- *************** *** 73,83 **** import core.*; - import java.util.Timer; - - import java.util.TimerTask; - import java.util.ArrayList; ! ! import core.Error; --- 71,76 ---- import core.*; import java.util.ArrayList; ! import java.util.Vector; *************** *** 638,642 **** * @author robert_hulford ! * @return String[] - The arp table entries * @version v0.20 --- 631,635 ---- * @author robert_hulford ! * @return Vector<Vector<String>> - The arp table entries * @version v0.20 *************** *** 644,648 **** */ ! public String[] getARPTable() { return mARPprotocol.getARPTable(); --- 637,641 ---- */ ! public Vector<Vector<String>> getARPTable() { return mARPprotocol.getARPTable(); Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** Tcp.java 14 Oct 2007 17:19:07 -0000 1.100 --- Tcp.java 14 Oct 2007 22:14:52 -0000 1.101 *************** *** 241,244 **** --- 241,245 ---- private Timer timer; private PriorityQueue tcp_timers = new PriorityQueue(); + private int window_size = 10; //tcp window-size for new sessions private Object tcp_timers_lock = new Object(); //for locking queue tcp_timers private int current_time = 0; *************** *** 333,337 **** String sessionID; boolean Found=false; ! Enumeration LocalSessions = getSessionKeys(); TCP_session Elm; --- 334,338 ---- String sessionID; boolean Found=false; ! Enumeration<String> LocalSessions = getSessionKeys(); TCP_session Elm; *************** *** 339,343 **** while ( (LocalSessions.hasMoreElements()) && !(Found) ) { ! sessionID = (String)LocalSessions.nextElement(); Elm = getSession(sessionID); if ( sock == Elm.sock && mSL.get_socket(Elm.sock).open_state ) --- 340,344 ---- while ( (LocalSessions.hasMoreElements()) && !(Found) ) { ! sessionID = LocalSessions.nextElement(); Elm = getSession(sessionID); if ( sock == Elm.sock && mSL.get_socket(Elm.sock).open_state ) *************** *** 794,797 **** --- 795,813 ---- } + public int getWindowSize(){ + return window_size; + } + + public void setWindowSize(int windowSize){ + if(windowSize>0){ + window_size = windowSize; + Enumeration<String> keys = getSessionKeys(); + while(keys.hasMoreElements()){ + String key = keys.nextElement(); + getSession(key).setWindowSize(windowSize); + } + } + } + private void recv_CLOSED(TCP_session Elm, TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { *************** *** 1037,1040 **** --- 1053,1057 ---- private TCP_session addSession(String key, int sock){ TCP_session tcps = new TCP_session(sock); + tcps.setWindowSize(window_size); synchronized(sessionTable_lock){ sessionTable.put(key, tcps); *************** *** 1053,1057 **** } ! private TCP_session getSession(String key){ TCP_session tcps; synchronized(sessionTable_lock){ --- 1070,1074 ---- } ! public TCP_session getSession(String key){ TCP_session tcps; synchronized(sessionTable_lock){ *************** *** 1061,1066 **** } ! private Enumeration getSessionKeys(){ ! Enumeration keys; synchronized(sessionTable_lock){ keys = sessionTable.keys(); --- 1078,1083 ---- } ! public Enumeration<String> getSessionKeys(){ ! Enumeration<String> keys; synchronized(sessionTable_lock){ keys = sessionTable.keys(); Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ARP.java 13 Oct 2007 12:57:00 -0000 1.8 --- ARP.java 14 Oct 2007 22:14:52 -0000 1.9 *************** *** 233,237 **** * @author bevan_calliess ! * @return String Array - An array of strings that can be used to display the ARP table. * @version v0.20 --- 233,237 ---- * @author bevan_calliess ! * @return Vector<Vector<String>> - An array of strings that can be used to display the ARP table. Format (Internet Address,Physical Address,Type) * @version v0.20 *************** *** 239,243 **** */ ! public String[] getARPTable() { --- 239,243 ---- */ ! public Vector<Vector<String>> getARPTable() { *************** *** 246,292 **** cleanARPTable(); - ! ! String output[] = new String[ARPTable.size()+1]; ! int counter = 0; - String ipAddress; - char padding = ' '; - - if(ARPTable.size()>0){ - - output[0] = "Internet Address Physical Address Type"; - - - Iterator it = ARPTable.iterator(); - while(it.hasNext()) { - counter++; - ARPTableEntry currEnt = (ARPTableEntry)it.next(); - ipAddress = pad(currEnt.getIPAddress(),20,padding); ! ! output[counter] = ipAddress + currEnt.getMACAddress() + " " + currEnt.getEntryType(); ! } - }else{ ! ! output[0] = "No ARP Entries Found"; ! } - - return output; --- 246,273 ---- cleanARPTable(); ! Vector<Vector<String>> output = new Vector<Vector<String>>(0); int counter = 0; String ipAddress; char padding = ' '; if(ARPTable.size()>0){ Iterator it = ARPTable.iterator(); while(it.hasNext()) { counter++; ARPTableEntry currEnt = (ARPTableEntry)it.next(); ipAddress = pad(currEnt.getIPAddress(),20,padding); ! Vector<String> outrecord = new Vector<String>(3); ! output.add(outrecord); ! outrecord.add(ipAddress); ! outrecord.add(currEnt.getMACAddress()); ! outrecord.add(currEnt.getEntryType()); } }else{ ! //output.size() == 0 -- arp table is empty } return output; Index: TCP_session.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/TCP_session.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TCP_session.java 1 Oct 2007 04:58:12 -0000 1.9 --- TCP_session.java 14 Oct 2007 22:14:52 -0000 1.10 *************** *** 253,256 **** --- 253,275 ---- } + public String getStateString(){ + String out; + switch(getState()){ + case CLOSED: out = "CLOSED"; break; + case LISTEN: out = "LISTEN"; break; + case SYN_SENT: out = "SYN_SENT"; break; + case SYN_RCVD: out = "SYN_RCVD"; break; + case ESTABLISHED: out = "ESTABLISHED"; break; + case FIN_WAIT_1: out = "FIN_WAIT_1"; break; + case FIN_WAIT_2: out = "FIN_WAIT_2"; break; + case CLOSING: out = "CLOSING"; break; + case TIME_WAIT: out = "TIME_WAIT"; break; + case CLOSE_WAIT: out = "CLOSE_WAIT"; break; + case LAST_ACK: out = "LAST_ACK"; break; + default: out = ""; + } + return out; + } + public void setState(int stt){ if(stt >=0 && stt <= 10) Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SNMP.java 12 Oct 2007 21:06:39 -0000 1.22 --- SNMP.java 14 Oct 2007 22:14:52 -0000 1.23 *************** *** 1175,1182 **** //"IP.ARPTable" str=""; ! stra = ((NetworkLayerDevice)current_device).getARPTable(); ! for(int i=1;i<stra.length;i++) { ! if(i!=1) str+=", "; ! str+=stra[i]; } getIDbyName("IP", "ARPTable"); --- 1175,1182 ---- //"IP.ARPTable" str=""; ! Vector<Vector<String>> ArpTable = ((NetworkLayerDevice)current_device).getARPTable(); ! for(int i=0;i<ArpTable.size();i++) { ! if(i!=0) str+=", "; ! str += ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2); } getIDbyName("IP", "ARPTable"); |
From: QweR <qw...@us...> - 2007-10-14 22:14:57
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26945/guiUI Modified Files: MainScreen.java Terminal.java Log Message: Some console commands was corrected Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** MainScreen.java 14 Oct 2007 17:19:07 -0000 1.69 --- MainScreen.java 14 Oct 2007 22:14:52 -0000 1.70 *************** *** 3643,3650 **** try{ if(Sim.getNode(inNodeName).On == true){ ! Sim.getNode(inNodeName).On = false; return "Turn On"; }else{ ! Sim.getNode(inNodeName).On = true; return "Turn Off"; } --- 3643,3650 ---- try{ if(Sim.getNode(inNodeName).On == true){ ! Sim.getNode(inNodeName).turnOff(); return "Turn On"; }else{ ! Sim.getNode(inNodeName).turnOn(); return "Turn Off"; } Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Terminal.java 14 Oct 2007 00:22:14 -0000 1.2 --- Terminal.java 14 Oct 2007 22:14:52 -0000 1.3 *************** *** 261,268 **** if((m=Pattern.compile(" +-a$").matcher(cmd)).find()) { try{ ! String ArpTable[] = device.NodeProtocolStack.getARPTable(); ! for(int i=0;i<ArpTable.length;i++) ! { ! out += ArpTable[i] + "\n"; } } --- 261,274 ---- if((m=Pattern.compile(" +-a$").matcher(cmd)).find()) { try{ ! Vector<Vector<String>> ArpTable = device.NodeProtocolStack.getARPTable(); ! if(ArpTable.size()>0){ ! out += "Internet Address\tPhysical Address\t\tType\n"; ! for(int i=0;i<ArpTable.size();i++) ! { ! out += ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2) + "\n"; ! } ! } ! else{ ! out += "No ARP Entries Found\n"; } } *************** *** 463,467 **** device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; ! return ""; } }; --- 469,473 ---- device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; ! return "Enter configuration commands, one per line. End with 'exit'"; } }; *************** *** 470,474 **** device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; ! return "Running-config was erased"; } }; --- 476,480 ---- 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'"; } }; *************** *** 477,481 **** device.getConfig().working_config = DeviceConfig.STARTUP_CONFIG; current_mode = cmdproc.CONF_MODE; ! return "Starting-config editing"; } }; --- 483,487 ---- 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'"; } }; |
From: Alexander B. <da...@us...> - 2007-10-14 17:19:13
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21615/core Modified Files: NetworkInterface.java Node.java PC.java Packet.java Router.java Simulation.java Added Files: ConsoleLink.java ConsoleNetworkInterface.java WANNetworkInterface.java WANRMI.java WANRMIServer.java WANSocket.java Removed Files: SerialLink.java SerialNetworkInterface.java Log Message: Added WAN interfaces class prototypes... Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PC.java 13 Oct 2007 12:57:00 -0000 1.12 --- PC.java 14 Oct 2007 17:19:07 -0000 1.13 *************** *** 60,63 **** --- 60,65 ---- import core.protocolsuite.tcp_ip.Telnet_server; import core.protocolsuite.tcp_ip.Telnet_client; + import core.protocolsuite.tcp_ip.DHCPC; + import core.protocolsuite.tcp_ip.DHCPD; import core.protocolsuite.tcp_ip.Echo_tcp; import core.protocolsuite.tcp_ip.PosixTelnetClient; *************** *** 122,125 **** --- 124,130 ---- PosixTelnetClient ptc = new PosixTelnetClient(NodeProtocolStack, core.ProtocolStack.UIDGen++); + + DHCPD dhcpd = new DHCPD(NodeProtocolStack, core.ProtocolStack.UIDGen++); + DHCPC dhcpc = new DHCPC(NodeProtocolStack, core.ProtocolStack.UIDGen++); addApp(echoServer, 7); *************** *** 138,145 **** addApp(snmpAgent, 161); addApp(snmpManager, 30161); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Wireless) + "0", NetworkInterface.Wireless, true); } --- 143,154 ---- addApp(snmpAgent, 161); addApp(snmpManager, 30161); + + addApp(dhcpd, 67); + addApp(dhcpc, 68); 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); } --- NEW FILE: ConsoleLink.java --- /* 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. - 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 core; import java.util.*; import core.FalseRandom; /** * ConsoleLink extends Link. It sets two Interface links to a pc. * @author luke_hamilton * @author bevan_calliess * @since Sep 17, 2004 * @version v0.20 */ public class ConsoleLink extends Link { /** * Constructor to be used by the Simulation when connecting 2 PC's * We have made a design decision to restrict a Ethernet link to only has 2 ends. * @author bevan_calliess * @author luke_hamilton * @param String Name - Node name eg: PC1 * @param inInterface1 The first Interface to connect this link to eg: eth0 * @param inInterface2 The Seceond Interface to connect this link to eg: eth1 * @throws InvalidLinkConnectionException */ public ConsoleLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); NetworkInterfaces.add(inSecondNodeInterface); inFirstNodeInterface.setConnectedLink(this); inSecondNodeInterface.setConnectedLink(this); } } --- SerialNetworkInterface.java DELETED --- Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Simulation.java 13 Oct 2007 12:57:00 -0000 1.14 --- Simulation.java 14 Oct 2007 17:19:07 -0000 1.15 *************** *** 610,614 **** //Create link and add it to hashtable ! linkTable.put(inLinkName,new SerialLink(inLinkName, interface1, interface2)); }else{ throw new InvalidNodeNameException("Invalid node name"); --- 610,614 ---- //Create link and add it to hashtable ! linkTable.put(inLinkName,new ConsoleLink(inLinkName, interface1, interface2)); }else{ throw new InvalidNodeNameException("Invalid node name"); --- NEW FILE: WANRMIServer.java --- package core; import java.rmi.*; import java.rmi.server.*; /** * * @author key */ public class WANRMIServer extends UnicastRemoteObject implements WANRMI{ WANNetworkInterface parentInterface; /** Creates a new instance of WANRMIServer */ public WANRMIServer(WANNetworkInterface inParentInterface) throws RemoteException { super(); parentInterface = inParentInterface; } public void recievePacket(Packet inPacket) throws RemoteException{ System.out.println("TEST!!!"); } public void setServiceName(String inService) throws RemoteException{ parentInterface.setConnService(inService); } } --- NEW FILE: WANRMI.java --- (This appears to be a binary file; contents omitted.) --- SerialLink.java DELETED --- --- NEW FILE: ConsoleNetworkInterface.java --- /* 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. - 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 core; //import java.util.*; /** * A NetworkInterface represents the physical interface between * a Node and a physical Link (network cable). Think of it as the NIC * (Network Interface Card) of a Node. This particular Network Interface * is modelled on an Ethernet Interface Card. * * <P>Different Nodes can contain different numbers of NetworkInterfaces. * A client PC usually only has one NetworkInterface, whereas a Router contains * at least two. A Hub or a Switch often has 8 or 16.</P> * * <P>In order for a Node to be able to send or receive network information (packets), * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> * * <P>NetworkInterfaces receive and send packets to and from DatalinkProtocols and * the Link object they are connected to.</P> * * @author Tristan Veness * @author Bevan Calliess * @since 19 September 2004 * @version v0.20 */ class ConsoleNetworkInterface extends NetworkInterface{ /** * Constructs a NetworkInterface object with the name inName and a * reference to it's parent Node. * @author bevan_calliess * @param inName - The name to give the NetworkInterface eg: eth0 * @param parent - The Node that the NetworkInterface is to be added to, it's parent. * @version v0.20 */ protected ConsoleNetworkInterface(String inName, Node parent) { super(inName,parent); } protected void receivePacket(Packet inPacket) throws LowLinkException { } public int getType(){ return NetworkInterface.Console; } protected void sendPacket(Packet inPacket) throws LowLinkException { } public boolean isActive(){ return false; } /** * This method displays details about the current interface card * @author bevan_calliess * @return String * @version v0.20 */ protected String getDetails(){ return "Interface: "+name + "\t\t" + "\t\t"+ getConnectLinkDetails(); } } --- NEW FILE: WANSocket.java --- (This appears to be a binary file; contents omitted.) Index: Router.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Router.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Router.java 13 Oct 2007 12:57:00 -0000 1.3 --- Router.java 14 Oct 2007 17:19:07 -0000 1.4 *************** *** 49,53 **** addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "1", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, false); } --- 49,53 ---- 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); } Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Node.java 13 Oct 2007 12:57:00 -0000 1.9 --- Node.java 14 Oct 2007 17:19:07 -0000 1.10 *************** *** 287,293 **** } break; ! case NetworkInterface.Serial: ! NetworkInterfacetable.put(interfaceName,new SerialNetworkInterface(interfaceName,this)); break; } } --- 287,297 ---- } break; ! case NetworkInterface.Console: ! NetworkInterfacetable.put(interfaceName,new ConsoleNetworkInterface(interfaceName,this)); break; + case NetworkInterface.WAN: + NetworkInterfacetable.put(interfaceName,new WANNetworkInterface(interfaceName,this)); + break; + } } *************** *** 508,513 **** case NetworkInterface.Ethernet10T: return "Ethernet"; ! case NetworkInterface.Serial: ! return "Serial"; case NetworkInterface.Wireless: return "Wireless"; --- 512,517 ---- case NetworkInterface.Ethernet10T: return "Ethernet"; ! case NetworkInterface.Console: ! return "Console"; case NetworkInterface.Wireless: return "Wireless"; *************** *** 522,525 **** --- 526,538 ---- } + public NetworkInterface getNIC(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + return (NetworkInterface)NetworkInterfacetable.get(inInterfaceName); + }else{ + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + } + } + + /* public void setMACAddress(String inInterfaceName, String MAC)throws InvalidNetworkInterfaceNameException, SimulationException{ *************** *** 639,649 **** Enumeration keys = NetworkInterfacetable.keys(); ! if(keys.hasMoreElements()) { String strInterfaceName = (String) keys.nextElement(); ! ! return strInterfaceName; } ! else return null; } --- 652,665 ---- Enumeration keys = NetworkInterfacetable.keys(); ! while(keys.hasMoreElements()) { String strInterfaceName = (String) keys.nextElement(); ! ! if(((NetworkInterface)NetworkInterfacetable.get(strInterfaceName)).isActive()){ ! return strInterfaceName; ! } } ! ! return null; } Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NetworkInterface.java 13 Oct 2007 12:57:00 -0000 1.5 --- NetworkInterface.java 14 Oct 2007 17:19:07 -0000 1.6 *************** *** 112,120 **** protected Node parentNode; public final static int Unknown = 0; public final static int Ethernet10T = 0; ! public final static int Serial = 1; public final static int Wireless = 2; public static String getIntName(int type){ --- 112,137 ---- protected Node parentNode; + + protected boolean up; + + public void UP(){ + up = true; + } + + public void DOWN(){ + up = false; + } + + public boolean isUP(){ + return up; + } + + public final static int Unknown = 0; public final static int Ethernet10T = 0; ! public final static int Console = 1; public final static int Wireless = 2; + public final static int WAN = 3; public static String getIntName(int type){ *************** *** 125,129 **** return "cua"; case 2: ! return "wifi"; default: return "unk"; --- 142,148 ---- return "cua"; case 2: ! return "wrl"; ! case 3: ! return "wan"; default: return "unk"; *************** *** 158,162 **** name = inName; ! parentNode = inParent; } --- 177,183 ---- name = inName; ! parentNode = inParent; ! ! up = true; } --- NEW FILE: WANNetworkInterface.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 core; import java.rmi.*; import java.rmi.Naming; public class WANNetworkInterface extends NetworkInterface{ public final static int NotSet = 0; public final static int SocketTCP = 1; public final static int SocketUDP = 2; public final static int RMI = 3; public final static int Corba = 4; protected int type; protected boolean server; // for socket connections protected String Host; protected int port; protected String Service; protected boolean connected; protected WANRMIServer RMIServer; protected WANRMI RMIClient; protected WANSocket s; public void setServer(boolean inServer){ server = inServer; } public boolean getServer(){ return server; } public int getConnType(){ return type; } public void setConnType(int inType){ type = inType; } public int getConnPort(){ return port; } public void setConnPort(int inPort){ port = inPort; } public String getConnHost(){ return Host; } public void setConnHost(String inHost){ Host = inHost; } public String getConnService(){ return Service; } public void setConnService(String inService){ Service = inService; } public void UP(){ up = listen(); up &= connect(); } public void DOWN(){ close(); up = false; } public WANNetworkInterface(String inName, Node parent) { super(inName, parent); type = 0; connected = false; Service = ""; Host = ""; if (System.getSecurityManager() == null) System.setSecurityManager ( new RMISecurityManager() ); //temp debug values Host = "127.0.0.1"; port = 18008; type = this.SocketTCP; server = true; } protected void receivePacket(Packet inPacket) throws LowLinkException { // cast the packet to an EthernetPacket //Ethernet_packet tempPacket = (Ethernet_packet)inPacket; switch(type){ case RMI: { if(!connected){ connect(); } } break; case SocketTCP: case SocketUDP: //Nothing to do... break; } parentNode.receivePacket(inPacket, name); } public int getType(){ return NetworkInterface.WAN; } protected void sendPacket(Packet inPacket) throws LowLinkException { if(!connected){ connect(); } if(connected){ try{ switch(type){ case RMI: RMIServer.recievePacket(inPacket); break; case SocketTCP: case SocketUDP: s.sendPacket(inPacket); break; } }catch(Exception e){ e.printStackTrace(); } } } protected void sendPacket(Packet inPacket, String inMacAddress) throws CommunicationException, LowLinkException { sendPacket(inPacket); } public boolean isActive(){ return true; } protected String getDetails(){ return "Interface: "+name; } protected boolean listen(){ try{ switch(type){ case RMI: { RMIServer = new WANRMIServer(this); Naming.bind (name, RMIServer); return true; } case SocketTCP: case SocketUDP: if(server){ s = new WANSocket(this, Host, port, server); return s.listen(); }else{ return false; } } }catch(Exception e){ e.printStackTrace(); } return false; } protected boolean connect(){ try{ switch(type){ case RMI: { if(Host == "" || Service == ""){ //Error return false; } RMIClient = null; RMIClient = (WANRMI) Naming.lookup ("rmi://" + Host + "/" + Service); RMIClient.setServiceName(name); connected = true; return true; } case SocketTCP: if(!server){ s = new WANSocket(this, Host, port, server); return s.connect(); }else{ return false; } case SocketUDP: //nothing to do... break; } }catch(Exception e){ e.printStackTrace(); } return false; } protected void close(){ try{ connected = false; switch(type){ case RMI: RMIClient = null; Naming.unbind(name); RMIServer = null; break; case SocketTCP: case SocketUDP: s.Close(); s = null; break; } }catch(Exception e){ e.printStackTrace(); } } } Index: Packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Packet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Packet.java 20 Nov 2005 20:30:53 -0000 1.2 --- Packet.java 14 Oct 2007 17:19:07 -0000 1.3 *************** *** 48,52 **** protected int hopCount=0; ! /** * Gets the data with the table --- 48,59 ---- protected int hopCount=0; ! public String toBytes(){ ! return RawtoBytes(); ! } ! ! public String RawtoBytes(){ ! return "P|" + (int)UniqueIdentfier + "|" + hopCount + "#"; ! } ! /** * Gets the data with the table |
From: Alexander B. <da...@us...> - 2007-10-14 17:19:12
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21615/core/protocolsuite/tcp_ip Modified Files: DHCPC.java DHCPD.java DHCPPacket.java ICMP_packet.java IP_packet.java IpV4.java ProtocolStack.java Tcp.java Udp.java Log Message: Added WAN interfaces class prototypes... Index: DHCPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPC.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DHCPC.java 13 Oct 2007 12:57:00 -0000 1.1 --- DHCPC.java 14 Oct 2007 17:19:07 -0000 1.2 *************** *** 1,7 **** /* * DHCPC.java - * - * Created on 19 Nov 2005 Ç., 14:09 - * */ --- 1,4 ---- *************** *** 31,36 **** /** Creates a new instance of DHCPC */ ! public DHCPC(ProtocolStack inParentStack, int listenPort, int appType, int UID) { ! super(inParentStack, listenPort, appType, UID); appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); running = false; --- 28,33 ---- /** Creates a new instance of DHCPC */ ! public DHCPC(ProtocolStack inParentStack, int UID) { ! super(inParentStack, 0,0, UID); appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); running = false; *************** *** 48,56 **** mParentStack.SL().bind(appSock, mParentStack.getSrcIP(), 68); mParentStack.SL().listen(appSock); ! printLayerInfo("DHCP Client", "DHCPC binded port " + listenPort + "."); } catch (Exception e) { ! printLayerInfo("DHCP Client", "Error: cannot bind port " + listenPort + "."); ! throw new TransportLayerException("Cannot bind port " + listenPort + "."); } } --- 45,53 ---- mParentStack.SL().bind(appSock, mParentStack.getSrcIP(), 68); mParentStack.SL().listen(appSock); ! printLayerInfo("DHCP Client", "DHCP Client binded port " + 68 + "."); } catch (Exception e) { ! printLayerInfo("DHCP Client", "Error: cannot bind port " + 68 + "."); ! throw new TransportLayerException("Cannot bind port " + 68 + "."); } } *************** *** 148,156 **** p.fromBytes(Data); ! if(p.op == 2 && p.xid == xid){ switch(p.msgType){ case 2: //OFFER if(!completed){ DHCPPacket r = new DHCPPacket(); r.op = 1; --- 145,162 ---- p.fromBytes(Data); ! if(p.op == 2 && p.xid == xid){ switch(p.msgType){ case 2: //OFFER if(!completed){ + + LayerInfo protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP client"); + protInfo.setLayer("Application "); + protInfo.setDescription("Recieved DHCPOFFER(xid=" + p.xid + ") from " + p.DHCPServer + " with op=2 yiaddr='" + p.yiaddr + + "' lease time=" + p.leaseTime + "."); + Simulation.addLayerInfo(protInfo); + DHCPPacket r = new DHCPPacket(); r.op = 1; *************** *** 159,162 **** --- 165,182 ---- DHCPServer = r.DHCPServer = p.DHCPServer; r.WantedIP = p.yiaddr; + r.chaddr = mParentStack.getMACAddress(iface); + + protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP client"); + protInfo.setLayer("Application "); + protInfo.setDescription("Sending DHCPREQUEST(xid=" + p.xid + ") packet to 255.255.255.255 with op=1 chaddr='" + + 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()); + } } break; *************** *** 167,172 **** if(!completed){ // here set up interfaces... try{ ! mParentStack.setIPAddress(iface,p.yiaddr ); mParentStack.setCustomSubnetMask(iface,p.SubnetMask ); mParentStack.setDefaultGateway(p.Gateway); --- 187,207 ---- if(!completed){ // here set up interfaces... + LayerInfo protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP client"); + protInfo.setLayer("Application "); + protInfo.setDescription("Recieved DHCPACK(xid=" + p.xid + ") from " + p.DHCPServer + " with op=2 yiaddr='" + p.yiaddr + + "' lease time=" + p.leaseTime + " subnet mask='" + p.SubnetMask + "' default gateway='" + p.Gateway + "'."); + Simulation.addLayerInfo(protInfo); + + protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP client"); + protInfo.setLayer("Application "); + protInfo.setDescription("Updating " + iface + " IP configuration."); + Simulation.addLayerInfo(protInfo); + try{ ! mParentStack.setIPAddress(iface, p.yiaddr ); mParentStack.setCustomSubnetMask(iface,p.SubnetMask ); mParentStack.setDefaultGateway(p.Gateway); *************** *** 182,235 **** }else{ //Invalid or not our packet; simply drop - } - //processing the protocol doings. - /*if(appType == 0){ - //client processing recieve - // printing some ... LayerInfo protInfo = new LayerInfo(getClass().getName()); protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCPC Protocol Data"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Recieving DHCPC message '" + Data + "' from server."); ! Simulation.addLayerInfo(protInfo); ! ! //mParentStack.UDP().closePort(sock); ! ! }else{ ! //server processing recieve ! try{ ! String sdHost = mParentStack.SL().get_socket(sock).dst_IP; ! int sdPort = mParentStack.SL().get_socket(sock).dst_port; ! ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCPC Protocol Data"); protInfo.setLayer("Application "); ! protInfo.setDescription("Recieving DHCPC message '" + Data + "' from client " + sdHost + ":" + sdPort + ". Total recieved messages by server: " + recieved); Simulation.addLayerInfo(protInfo); ! ! LayerInfo protInfo2 = new LayerInfo(getClass().getName()); ! protInfo2.setObjectName(mParentStack.getParentNodeName()); ! protInfo2.setDataType("DHCPC Protocol Data"); ! protInfo2.setLayer("Application "); ! protInfo2.setDescription("Sending DHCPC message '" + Data + "' to client."); ! Simulation.addLayerInfo(protInfo2); ! ! SendData(Data); ! ! /*LayerInfo protInfo3 = new LayerInfo(getClass().getName()); ! protInfo3.setObjectName(mParentStack.getParentNodeName()); ! protInfo3.setDataType("DHCPC Protocol Data"); ! protInfo3.setLayer("Application "); ! protInfo3.setDescription("Server closing connection. Now listening on " + listenPort + "."); ! Simulation.addLayerInfo(protInfo3);*/ ! ! //Close(); ! //Listen(); ! /* }catch(Exception e){ ! System.out.println(e.toString()); ! ///*TODO*: here to catch ! } ! }*/ } --- 217,227 ---- }else{ //Invalid or not our packet; simply drop LayerInfo protInfo = new LayerInfo(getClass().getName()); protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCP client"); protInfo.setLayer("Application "); ! protInfo.setDescription("Recieved DHCP packet with invalid xid=" + p.xid + " and/or data."); Simulation.addLayerInfo(protInfo); ! } } *************** *** 243,250 **** */ public void StartDHCPC(String inIface, String WantedIP) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ running = true; completed = false; iface = inIface; ! Listen(); --- 235,246 ---- */ public void StartDHCPC(String inIface, String WantedIP) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ + if(running){ + Close(); + } + running = true; completed = false; iface = inIface; ! Listen(); *************** *** 253,261 **** xid = d.xid; d.WantedIP = WantedIP; ! d.chaddr = mParentStack.getIPAddress(iface); ! d.ciaddr = mParentStack.getMACAddress(iface); d.msgType = 1; ! SendData(appSock, "255.255.255.255", 67, d.toBytes()); } } --- 249,278 ---- xid = d.xid; d.WantedIP = WantedIP; ! d.ciaddr = mParentStack.getIPAddress(iface); ! d.chaddr = mParentStack.getMACAddress(iface); d.msgType = 1; ! if(d.ciaddr == null){ ! d.ciaddr = ""; ! } ! ! String Data = d.toBytes(); ! ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCP client"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Starting DHCP discover process on interface " + iface + "... Transaction ID is " + xid + "."); ! Simulation.addLayerInfo(protInfo); ! ! protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCP client"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Sending DHCPDISCOVER packet to 255.255.255.255 with op=1 chaddr='" + ! d.chaddr + "' ciaddr='" + d.ciaddr + "' preferred IP='" + WantedIP + "'."); ! Simulation.addLayerInfo(protInfo); ! ! SendData(appSock, "255.255.255.255", 67, Data); } } Index: DHCPPacket.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPPacket.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DHCPPacket.java 13 Oct 2007 12:57:00 -0000 1.1 --- DHCPPacket.java 14 Oct 2007 17:19:07 -0000 1.2 *************** *** 2,9 **** * DHCPPacket.java * - * Created on 11 Îêòÿáðü 2007 ã., 19:20 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. */ --- 2,5 ---- *************** *** 84,88 **** //| | //| | ! tmp = convertMAC(chaddr); c[28] = tmp.charAt(0); c[29] = tmp.charAt(1); --- 80,89 ---- //| | //| | ! ! try{ ! tmp = convertMAC(chaddr); ! }catch(Exception e){ ! System.out.println(e.toString()); ! } c[28] = tmp.charAt(0); c[29] = tmp.charAt(1); *************** *** 165,171 **** res += String.valueOf(o,0,optIdx); ! for(int j=0; j<res.length(); j++){ ! System.out.println(j + ":\t" + (short) res.charAt(j) ); ! } return res; --- 166,172 ---- res += String.valueOf(o,0,optIdx); ! /*for(int j=0; j<res.length(); j++){ ! System.out.println(j + ":\t" + (short) res.charAt(j) ); ! }*/ return res; *************** *** 176,181 **** int i = 0; - //Integer. - for(int j = 0; j<6; j++){ mac[j] = (char)Integer.parseInt(MAC.substring(i, i+2),16); --- 177,180 ---- *************** *** 190,199 **** byte[] ip = new byte[4]; ip[0] = (byte)o1; ! ip[1] = (byte)o1; ! ip[2] = (byte)o1; ! ip[3] = (byte)o1; try{ res = java.net.InetAddress.getByAddress(ip).getHostAddress(); ! }catch(Exception e){ res = ""; } return res; --- 189,201 ---- byte[] ip = new byte[4]; ip[0] = (byte)o1; ! ip[1] = (byte)o2; ! ip[2] = (byte)o3; ! ip[3] = (byte)o4; try{ res = java.net.InetAddress.getByAddress(ip).getHostAddress(); ! }catch(Exception e){ ! e.printStackTrace(); ! res = ""; ! } return res; Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Udp.java 14 Oct 2007 00:22:14 -0000 1.40 --- Udp.java 14 Oct 2007 17:19:07 -0000 1.41 *************** *** 112,116 **** { // test if this packet is for a local Address. ! if(mParentStack.isInternalIP(inPacket.getDestIPAddress())){ // test if destination UDP port exists on this NeworkLayerDevice --- 112,116 ---- { // test if this packet is for a local Address. ! if(mParentStack.isInternalIP(inPacket.getDestIPAddress()) || mParentStack.isBroadcastIP(inPacket.getDestIPAddress())){ // test if destination UDP port exists on this NeworkLayerDevice Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** ProtocolStack.java 13 Oct 2007 12:57:00 -0000 1.58 --- ProtocolStack.java 14 Oct 2007 17:19:07 -0000 1.59 *************** *** 221,228 **** --- 221,252 ---- String GatewayAddress = null; String outInterface[] = new String[2]; + if(!IPV4Address.validateDecIP(inPacket.mDestIPAddress)){ throw new CommunicationException("Packet dropped host unreachable: " + inPacket.mDestIPAddress); } + try{ + IPV4Address p_ip = new IPV4Address(inPacket.mDestIPAddress); + + if(p_ip.isBroadcast()){ + NetworkLayerDevice temp = (NetworkLayerDevice)mParentNode; + ArrayList nics = mParentNode.getAllInterfacesNames(); + + for(int i=0; i<nics.size(); i++){ + if(temp.isActiveInterface((String)nics.get(i))){ + LayerInfo routeInfo = new LayerInfo(getClass().getName()); + routeInfo.setObjectName(getParentNodeName()); + routeInfo.setDataType(trimClassName(inPacket.getClass().getName())); + routeInfo.setLayer("Network"); + routeInfo.setDescription("Packet Received: Network Layer Device is sending broadcast packet through interface " + (String)nics.get(i) + "."); + Simulation.addLayerInfo(routeInfo); + inPacket.mSourceIPAddress = mIPprotocol.getIPAddress((String)nics.get(i)); + temp.sendPacket("FF:FF:FF:FF:FF:FF", inPacket, (String)nics.get(i) ); + } + } + + return ; + } + outInterface = mIPprotocol.router(inPacket.getDestIPAddress()); try{ *************** *** 324,327 **** --- 348,353 ---- System.out.println("::" + inPacket + "::"); System.out.println("ProtocolStack.java: SendPacket " + e.toString()); + }catch(Exception e){ + e.printStackTrace(); } *************** *** 1243,1247 **** } ! /** --- 1269,1282 ---- } ! public boolean isBroadcastIP(String inTestIPAddress){ ! try{ ! IPV4Address ip = new IPV4Address(inTestIPAddress); ! if(ip.isBroadcast()){ ! return true; ! } ! }catch(Exception e){} ! ! return false; ! } /** Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** Tcp.java 14 Oct 2007 00:22:14 -0000 1.99 --- Tcp.java 14 Oct 2007 17:19:07 -0000 1.100 *************** *** 2,6 **** Java Network Simulator (javaNetSim) ! Copyright (c) 2006, 2005, Ice Team; All rights reserved. Copyright (c) 2004, jFirewallSim development team; All rights reserved. --- 2,6 ---- Java Network Simulator (javaNetSim) ! Copyright (c) 2007, 2006, 2005, Ice Team; All rights reserved. Copyright (c) 2004, jFirewallSim development team; All rights reserved. Index: IP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IP_packet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IP_packet.java 24 Feb 2006 10:20:11 -0000 1.3 --- IP_packet.java 14 Oct 2007 17:19:07 -0000 1.4 *************** *** 246,249 **** --- 246,257 ---- } + + public String toBytes(){ + return RawtoBytes() + IPtoBytes(); + } + + public String IPtoBytes(){ + return "I|" + mSourceIPAddress + "|" + mDestIPAddress + "#"; + } }//EOF Index: ICMP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ICMP_packet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ICMP_packet.java 20 Nov 2005 20:30:53 -0000 1.2 --- ICMP_packet.java 14 Oct 2007 17:19:07 -0000 1.3 *************** *** 116,118 **** --- 116,126 ---- } + public String toBytes(){ + return RawtoBytes() + IPtoBytes() + ICMPtoBytes(); + } + + public String ICMPtoBytes(){ + return "M|" + mMessageCode + "|" + ICMP_message + "#"; + } + }//EOF \ No newline at end of file Index: IpV4.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IpV4.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** IpV4.java 13 Oct 2007 12:57:00 -0000 1.11 --- IpV4.java 14 Oct 2007 17:19:07 -0000 1.12 *************** *** 858,863 **** Enumeration en = ipAddress.elements(); - - while(en.hasMoreElements()){ --- 858,861 ---- Index: DHCPD.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPD.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DHCPD.java 13 Oct 2007 12:57:00 -0000 1.1 --- DHCPD.java 14 Oct 2007 17:19:07 -0000 1.2 *************** *** 1,7 **** /* * DHCPD.java - * - * Created on 19 Nov 2005 Ç., 14:09 - * */ --- 1,4 ---- *************** *** 31,34 **** --- 28,35 ---- } + public pool new_pool(){ + return new pool(); + } + public class lease{ public String IP; *************** *** 45,49 **** public int leaseTime; ! public long leased; } --- 46,56 ---- public int leaseTime; ! public long leased; ! ! public lease(){ ! negotiation_started = 0; ! xid = 0; ! completed = false; ! } } *************** *** 52,57 **** /** Creates a new instance of DHCPD */ ! public DHCPD(ProtocolStack inParentStack, int listenPort, int appType, int UID) { ! super(inParentStack, listenPort, appType, UID); appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); } --- 59,64 ---- /** Creates a new instance of DHCPD */ ! public DHCPD(ProtocolStack inParentStack, int UID) { ! super(inParentStack, 0, 0, UID); appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); } *************** *** 67,75 **** mParentStack.SL().bind(appSock, mParentStack.getSrcIP(), 67); mParentStack.SL().listen(appSock); ! printLayerInfo("DHCP server", "DHCP server starts listening in port " + listenPort + "."); } catch (Exception e) { ! printLayerInfo("DHCP server", "Error: cannot bind port " + listenPort + "."); ! throw new TransportLayerException("Cannot bind port " + listenPort + "."); } } --- 74,82 ---- mParentStack.SL().bind(appSock, mParentStack.getSrcIP(), 67); mParentStack.SL().listen(appSock); ! printLayerInfo("DHCP server", "DHCP server starts listening in port " + 67 + "."); } catch (Exception e) { ! printLayerInfo("DHCP server", "Error: cannot bind port " + 67 + "."); ! throw new TransportLayerException("Cannot bind port " + 67 + "."); } } *************** *** 165,168 **** --- 172,224 ---- lease l = new lease(); + l.IP = ""; + + String IP; + String Genmask; + String Network, PoolNetwork; + String PoolName; + + for(Enumeration e = pools.keys(); e.hasMoreElements();){ + PoolName = (String)e.nextElement(); + pool p = (pool)pools.get(PoolName); + + try{ + byte b[] = java.net.InetAddress.getByName(p.IP).getAddress(); + + boolean done = false; + + while(!done){ + if(b[3] < 254){ + b[3]++; + }else if(b[2] < 254){ + b[2]++; + }else if(b[1] < 254){ + b[1]++; + }else if(b[0] < 254){ + b[0]++; + }else{ + break; + } + + IP = java.net.InetAddress.getByAddress(b).getHostAddress(); + Network = IPV4Address.toDecimalString(IPV4Address.IPandMask(IPV4Address.toBinaryString(IP), IPV4Address.toBinaryString(p.Genmask))); + PoolNetwork = IPV4Address.toDecimalString(IPV4Address.IPandMask(IPV4Address.toBinaryString(p.IP), IPV4Address.toBinaryString(p.Genmask))); + + if(Network.equals(PoolNetwork)){ + if(!leases.containsKey(IP)){ + l.IP = IP; + l.Genmask = p.Genmask; + l.Gateway = p.Gateway; + l.MAC = MAC; + return l; + } + }else{ + break; + } + } + + }catch(Exception e2){} + } + return l; } *************** *** 183,208 **** switch(p.msgType){ case 1: IP = findLease(p.chaddr); if(IP==""){ lease l = advertLease(p.chaddr); - l.xid = p.xid; - l.negotiation_started = (System.currentTimeMillis()/1000); - - leases.put(l.IP, l); - - DHCPPacket o = new DHCPPacket(); - - o.chaddr = p.chaddr; - o.msgType = 2; - o.DHCPServer = mParentStack.SL().get_socket(appSock).src_IP; - o.yiaddr = l.IP; - o.SubnetMask = l.Genmask; - o.Gateway = l.Gateway; ! try{ ! SendData(appSock, "255.255.255.255", 68, o.toBytes()); ! }catch(CommunicationException e){ ! throw new TransportLayerException(e.toString()); } } --- 239,285 ---- switch(p.msgType){ case 1: + { + LayerInfo protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP Server"); + protInfo.setLayer("Application "); + protInfo.setDescription("Recieved DHCPDISCOVER(xid=" + p.xid + ") from " + p.chaddr + " with op=1."); + Simulation.addLayerInfo(protInfo); + IP = findLease(p.chaddr); if(IP==""){ lease l = advertLease(p.chaddr); ! if(l.IP!=""){ ! l.xid = p.xid; ! l.negotiation_started = (System.currentTimeMillis()/1000); ! ! leases.put(l.IP, l); ! ! DHCPPacket o = new DHCPPacket(); ! ! o.chaddr = p.chaddr; ! o.msgType = 2; ! o.DHCPServer = mParentStack.SL().get_socket(appSock).src_IP; ! o.leaseTime = 3600; ! o.yiaddr = l.IP; ! o.op = 2; ! l.xid = o.xid = p.xid; ! o.SubnetMask = l.Genmask; ! o.Gateway = l.Gateway; ! ! protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCP Server"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Sending DHCPOFFER(xid=" + o.xid + ") packet to 255.255.255.255 with op=1 chaddr='" + ! o.chaddr + "' DHCP Server='" + o.DHCPServer + "' yiaddr='" + o.yiaddr + "'."); ! ! try{ ! SendData(appSock, "255.255.255.255", 68, o.toBytes()); ! }catch(CommunicationException e){ ! throw new TransportLayerException(e.toString()); ! } } } *************** *** 213,218 **** --- 290,347 ---- } */ + } break; case 3: + IP = findLease(p.chaddr); + + LayerInfo protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP Server"); + protInfo.setLayer("Application "); + protInfo.setDescription("Recieved DHCPREQUEST(xid=" + p.xid + ") from " + p.chaddr + " with op=1 and preferred IP='" + p.WantedIP + "'."); + Simulation.addLayerInfo(protInfo); + + if(IP!=""){ + lease l = (lease)leases.get(IP); + + if(l.xid == p.xid){ + l.leased = (System.currentTimeMillis()/1000); + l.negotiation_started = 0; + l.completed = true; + + DHCPPacket o = new DHCPPacket(); + + o.chaddr = p.chaddr; + o.msgType = 5; + o.DHCPServer = mParentStack.SL().get_socket(appSock).src_IP; + o.leaseTime = 3600; + o.yiaddr = l.IP; + o.xid = l.xid; + o.op = 2; + o.SubnetMask = l.Genmask; + o.Gateway = l.Gateway; + o.WantedIP = ""; + + protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP Server"); + protInfo.setLayer("Application "); + protInfo.setDescription("Sending DHCPACK(xid=" + o.xid + ") packet to 255.255.255.255 with op=1 chaddr='" + + o.chaddr + "' DHCP Server='" + o.DHCPServer + "' yiaddr='" + o.yiaddr + "'..."); + + try{ + SendData(appSock, "255.255.255.255", 68, o.toBytes()); + }catch(CommunicationException e){ + throw new TransportLayerException(e.toString()); + } + }else{ + protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP Server"); + protInfo.setLayer("Application "); + protInfo.setDescription("Recieved DHCP packet with invalid xid=" + p.xid + "."); + Simulation.addLayerInfo(protInfo); + } + } /*if(!findLease()){ *************** *** 223,278 **** }else{ // drop it; - } - - /* recieved++; - //processing the protocol doings. - if(appType == 0){ - //client processing recieve - // printing some ... - LayerInfo protInfo = new LayerInfo(getClass().getName()); - protInfo.setObjectName(mParentStack.getParentNodeName()); - protInfo.setDataType("DHCPD Protocol Data"); - protInfo.setLayer("Application "); - protInfo.setDescription("Recieving DHCPD message '" + Data + "' from server."); - Simulation.addLayerInfo(protInfo); - - //mParentStack.UDP().closePort(sock); - - }else{ - //server processing recieve - try{ - String sdHost = mParentStack.SL().get_socket(sock).dst_IP; - int sdPort = mParentStack.SL().get_socket(sock).dst_port; - LayerInfo protInfo = new LayerInfo(getClass().getName()); protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCPD Protocol Data"); protInfo.setLayer("Application "); ! protInfo.setDescription("Recieving DHCPD message '" + Data + "' from client " + sdHost + ":" + sdPort + ". Total recieved messages by server: " + recieved); Simulation.addLayerInfo(protInfo); ! ! LayerInfo protInfo2 = new LayerInfo(getClass().getName()); ! protInfo2.setObjectName(mParentStack.getParentNodeName()); ! protInfo2.setDataType("DHCPD Protocol Data"); ! protInfo2.setLayer("Application "); ! protInfo2.setDescription("Sending DHCPD message '" + Data + "' to client."); ! Simulation.addLayerInfo(protInfo2); ! ! SendData(Data); ! ! /*LayerInfo protInfo3 = new LayerInfo(getClass().getName()); ! protInfo3.setObjectName(mParentStack.getParentNodeName()); ! protInfo3.setDataType("DHCPD Protocol Data"); ! protInfo3.setLayer("Application "); ! protInfo3.setDescription("Server closing connection. Now listening on " + listenPort + "."); ! Simulation.addLayerInfo(protInfo3);*/ ! ! //Close(); ! //Listen(); ! /* }catch(Exception e){ ! System.out.println(e.toString()); ! ///*TODO*: here to catch ! } ! }*/ } --- 352,362 ---- }else{ // drop it; LayerInfo protInfo = new LayerInfo(getClass().getName()); protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("DHCP Server"); protInfo.setLayer("Application "); ! protInfo.setDescription("Recieved DHCP packet with invalid data."); Simulation.addLayerInfo(protInfo); ! } } |
From: Alexander B. <da...@us...> - 2007-10-14 17:19:11
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21615/guiUI Modified Files: ApplicationLayerDevice.java LinkLayerPanel.java MainScreen.java Log Message: Added WAN interfaces class prototypes... Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** MainScreen.java 13 Oct 2007 12:57:00 -0000 1.68 --- MainScreen.java 14 Oct 2007 17:19:07 -0000 1.69 *************** *** 95,98 **** --- 95,100 ---- import core.protocolsuite.tcp_ip.Telnet_server; import core.protocolsuite.tcp_ip.Telnet_client; + import core.protocolsuite.tcp_ip.DHCPD; + import core.protocolsuite.tcp_ip.DHCPC; import guiUI.Terminal; import javax.swing.JViewport; *************** *** 1167,1171 **** Sim.addEthernetLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); break; ! case core.NetworkInterface.Serial: Sim.addSerialLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); break; --- 1169,1173 ---- Sim.addEthernetLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); break; ! case core.NetworkInterface.Console: Sim.addSerialLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); break; *************** *** 1427,1431 **** //pnlConsole.append(pad(recording[1],15,' ')+packet+pad(recording[3],10,' ')+layer+recording[5]+ "\n"); ! //System.out.println(pad(recording[1],15,' ')+packet+pad(recording[3],10,' ')+layer+recording[5]+ "\n"); insertInConsole(recording[1], packet, layer, recording[5]); } --- 1429,1433 ---- //pnlConsole.append(pad(recording[1],15,' ')+packet+pad(recording[3],10,' ')+layer+recording[5]+ "\n"); ! System.out.println(pad(recording[1],15,' ')+packet+pad(recording[3],10,' ')+layer+recording[5]+ "\n"); insertInConsole(recording[1], packet, layer, recording[5]); } *************** *** 2842,2846 **** for (i=0; i<mConsole.getColumnCount(); i++) { ! cur += "<TD vAlign=\"top\">" + (String) mConsole.getValueAt(j,i) + "</TD>"; //Select TR bgColor. if (!color_selected) --- 2844,2848 ---- for (i=0; i<mConsole.getColumnCount(); i++) { ! cur += "<TD vAlign=\"top\">" + (String) mConsole.getValueAt(j,i) + " </TD>"; //Select TR bgColor. if (!color_selected) *************** *** 2925,2929 **** for (i=0; i<5; i++) { ! out.append("<TD vAlign=\"top\">" + (String) mConsole.getValueAt(j,i) + "</TD>"); } out.append("\r\n</TR>\r\n"); --- 2927,2931 ---- for (i=0; i<5; i++) { ! out.append("<TD vAlign=\"top\">" + (String) mConsole.getValueAt(j,i) + " </TD>"); } out.append("\r\n</TR>\r\n"); *************** *** 2983,2987 **** + "<TD>Name: " + strNodeName + "</TD>\r\n" + "<TD>Default gateway: " + strDefGate + "</TD>\r\n" ! + "<TD> </TD><TD> </TD><TD> </TD>\r\n</TR>\r\n\t<!-- device interfaces-->\r\n"); } out.append("\t<TR bgColor=#CCCCCC>\r\n"); --- 2985,2989 ---- + "<TD>Name: " + strNodeName + "</TD>\r\n" + "<TD>Default gateway: " + strDefGate + "</TD>\r\n" ! + "<TD> </TD><TD> </TD><TD> </TD><TD> </TD>\r\n</TR>\r\n\t<!-- device interfaces-->\r\n"); } out.append("\t<TR bgColor=#CCCCCC>\r\n"); *************** *** 3652,3655 **** --- 3654,3682 ---- } + + public void DHCPD(String inNodeName){ + try{ + DHCPD dhcpd = ((DHCPD)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(67)); + + DHCPD.pool p = dhcpd.new_pool(); + p.Gateway = "172.168.0.1"; + p.IP = "172.168.0.10"; + p.Genmask = "255.255.255.0"; + p.MAC = ""; + + dhcpd.pools.put(p.IP, p); + + dhcpd.Listen(); + }catch(Exception e){} + } + + public void DHCPC(String inNodeName){ + try{ + ((DHCPC)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(68)).StartDHCPC("eth0",""); + }catch(Exception e){ + e.printStackTrace(); + } + } + /** *************** *** 4116,4119 **** --- 4143,4156 ---- new EthPortProperties(this,NodeName, IntName,Sim,Sandbox); 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); + }else{ + ((core.WANNetworkInterface)(temp.getNIC(IntName))).setServer(false); + } + + ((core.WANNetworkInterface)(temp.getNIC(IntName))).UP(); + break; default: break; Index: LinkLayerPanel.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkLayerPanel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LinkLayerPanel.java 13 Oct 2007 12:57:00 -0000 1.3 --- LinkLayerPanel.java 14 Oct 2007 17:19:07 -0000 1.4 *************** *** 155,159 **** LineTable.put(inName,new LinkLine(new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y), new BasicStroke(2.0f), Color.BLACK)); 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.BLUE)); break; --- 155,159 ---- LineTable.put(inName,new LinkLine(new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y), new BasicStroke(2.0f), Color.BLACK)); 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; Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/ApplicationLayerDevice.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ApplicationLayerDevice.java 8 Nov 2006 14:27:29 -0000 1.9 --- ApplicationLayerDevice.java 14 Oct 2007 17:19:07 -0000 1.10 *************** *** 30,37 **** private JMenuItem mnuTelnetConnect = new JMenuItem("Telnet client."); private JMenuItem mnuPosixTelnet = new JMenuItem("RFC(line) telnet client."); ! private 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"); /** Creates a new instance of ApplicationLayerDevice */ --- 30,39 ---- 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 */ *************** *** 112,115 **** --- 114,129 ---- }); + mnuDHCPD.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.DHCPD(lblNodeName.getText()); + } + }); + + mnuDHCPC.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.DHCPC(lblNodeName.getText()); + } + }); + mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuSNMPStartAgent); *************** *** 122,125 **** --- 136,142 ---- mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuPosixTelnet); + mnuAppLayer.addSeparator(); + mnuAppLayer.add(mnuDHCPC); + mnuAppLayer.add(mnuDHCPD); } } |
From: Alexander B. <da...@us...> - 2007-10-14 17:19:10
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21615 Modified Files: TODO.txt Added Files: wideall.policy Log Message: Added WAN interfaces class prototypes... Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** TODO.txt 13 Oct 2007 12:57:00 -0000 1.24 --- TODO.txt 14 Oct 2007 17:19:06 -0000 1.25 *************** *** 4,16 **** *** Whole Project ! 2. Socks Proxy(old -- Nat Gateway) to external network. ! 3. ReNew Console(IOS-similar command line) and normal config files. ! 4. VPN-client/VPN-gateway (sockets, RMI and Corba mechanisms) (or PPP Client/PPP Gateway -- ??) ! 5. Second level Switches (VLAN, etc...) ! 7. Firewalls (NAT, PAT, etc) ! 8. Access-lists in Firewalls/Routers/PCs ! 9. DHCP server/clients : main engine, re-leasing. ! 10. DNS server/clents. ! 11. Wi-Fi Access-Points and Wi-Fi adapters in PCs *** Documentation/Comments --- 4,21 ---- *** 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. ! 5. Network Printers ! 6. Repeaters ! 7. Ethernet fiber Lines and converters ! 8. Firewalls (NAT, PAT, etc) ! 9. Second level Switches (VLAN, etc...) ! 10. Access-lists in Firewalls/Routers/PCs ! 11. DNS server/clents. ! 12. Wi-Fi Access-Points and Wi-Fi adapters in PCs *** Documentation/Comments --- NEW FILE: wideall.policy --- grant { // Allow everything for now permission java.security.AllPermission; }; |
From: QweR <qw...@us...> - 2007-10-14 00:22:19
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25590/core Modified Files: CommandProcessor.java DeviceConfig.java Log Message: Some small bugs fixed Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CommandProcessor.java 12 Oct 2007 21:06:39 -0000 1.1 --- CommandProcessor.java 14 Oct 2007 00:22:14 -0000 1.2 *************** *** 36,41 **** private NoCommandClass noCommand = new NoCommandClass(); ! private arp_add_CommandClass arp_add_Command = new arp_add_CommandClass(); ! private arp_remove_CommandClass arp_remove_Command = new arp_remove_CommandClass(); private clear_arp_CommandClass clear_arp_Command = new clear_arp_CommandClass(); private clock_set_CommandClass clock_set_Command = new clock_set_CommandClass(); --- 36,41 ---- private NoCommandClass noCommand = new NoCommandClass(); ! private arp_CommandClass arp_Command = new arp_CommandClass(); ! private no_arp_CommandClass no_arp_Command = new no_arp_CommandClass(); private clear_arp_CommandClass clear_arp_Command = new clear_arp_CommandClass(); private clock_set_CommandClass clock_set_Command = new clock_set_CommandClass(); *************** *** 80,89 **** device = dev; - - commands.addDescription("no","Negate a command or set its defaults"); ! commands.addDescription("arp","Configure arp table"); ! commands.add("arp", arp_add_Command, CONF_MODE | NETWORK_LAYER, "<IP> <MAC>", "Add record to arp table"); ! commands.add("no arp", arp_remove_Command, CONF_MODE | NETWORK_LAYER, "<IP|MAC>", "Remove record from arp table"); commands.addDescription("clear","Reset functions"); commands.add("clear arp", clear_arp_Command, STD_CONF_MODE | NETWORK_LAYER, "<cr>", "Clear the entire ARP cache"); --- 80,86 ---- device = dev; commands.addDescription("no","Negate a command or set its defaults"); ! commands.add("arp", arp_Command, CONF_MODE | NETWORK_LAYER, "<IP> <MAC>", "Add record to arp table"); ! commands.add("no arp", no_arp_Command, CONF_MODE | NETWORK_LAYER, "<IP>", "Remove record from arp table"); commands.addDescription("clear","Reset functions"); commands.add("clear arp", clear_arp_Command, STD_CONF_MODE | NETWORK_LAYER, "<cr>", "Clear the entire ARP cache"); *************** *** 166,173 **** } }; ! class arp_add_CommandClass implements CommandInterface{ public String call(Vector<String> params){ String out = ""; if(params.size()==2){ device.NodeProtocolStack.addToARPStatic(params.get(0), params.get(1)); out += "Created new static ARP entry: " + params.get(0) + " is " + params.get(1) + "\n"; --- 163,172 ---- } }; ! class arp_CommandClass implements CommandInterface{ public String call(Vector<String> params){ String out = ""; if(params.size()==2){ + device.getConfig().remove("^arp.*"+params.get(0)+".*$"); + device.getConfig().add("arp", params); device.NodeProtocolStack.addToARPStatic(params.get(0), params.get(1)); out += "Created new static ARP entry: " + params.get(0) + " is " + params.get(1) + "\n"; *************** *** 179,186 **** } }; ! class arp_remove_CommandClass implements CommandInterface{ public String call(Vector<String> params){ String out = ""; if(params.size()==1){ device.NodeProtocolStack.removeARP(params.get(0)); out += "Removed ARP entry for ip " + params.get(0) + "\n"; --- 178,186 ---- } }; ! class no_arp_CommandClass implements CommandInterface{ public String call(Vector<String> params){ String out = ""; if(params.size()==1){ + device.getConfig().remove("^arp "+params.get(0)+" "); device.NodeProtocolStack.removeARP(params.get(0)); out += "Removed ARP entry for ip " + params.get(0) + "\n"; *************** *** 261,264 **** --- 261,266 ---- try{ device.setIPAddress(params.get(0), params.get(1)); + device.getConfig().remove("^host .*"); + device.getConfig().add("host", params); } catch(InvalidNetworkInterfaceNameException e){ *************** *** 366,370 **** class show_hostname_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! return "Command not supported yet.\n"; } }; --- 368,372 ---- class show_hostname_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! return (device.NodeProtocolStack.getParentNodeName() + "\n"); } }; *************** *** 394,400 **** public String call(Vector<String> params){ String out = " Recieved IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getinputIPCount()).toString() + ! "\n Sent IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getoutputIPCount()).toString() + ! "\n ARP Packets: " + Integer.valueOf(device.NodeProtocolStack.getARPCount()).toString() + ! "\n Recieved TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPinputCount()).toString() + "\n Sent TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPoutputCount()).toString() + "\n Sent TCP ACK's: " + Integer.valueOf(device.NodeProtocolStack.getTCPACKCount()).toString() + --- 396,403 ---- public String call(Vector<String> params){ String out = " Recieved IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getinputIPCount()).toString() + ! "\n Sent IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getoutputIPCount()).toString() + ! "\n ARP Packets: " + Integer.valueOf(device.NodeProtocolStack.getARPCount()).toString(); ! if(device.getClass().equals(ApplicationLayerDevice.class)){ ! out += "\n Recieved TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPinputCount()).toString() + "\n Sent TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPoutputCount()).toString() + "\n Sent TCP ACK's: " + Integer.valueOf(device.NodeProtocolStack.getTCPACKCount()).toString() + *************** *** 402,407 **** "\n Recieved TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPRDCount()).toString() + "\n Recieved UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPinputCount()).toString() + ! "\n Sent UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPoutputCount()).toString() + ! "\n"; return out; } --- 405,411 ---- "\n Recieved TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPRDCount()).toString() + "\n Recieved UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPinputCount()).toString() + ! "\n Sent UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPoutputCount()).toString(); ! } ! out += "\n"; return out; } *************** *** 462,466 **** public String call(Vector<String> params){ SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(161); ! return (snmpa.getPassword()+"\n"); } }; --- 466,478 ---- public String call(Vector<String> params){ SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(161); ! String out = "SNMP Community: "; ! if(snmpa.getPassword().equals("")){ ! out += "<not set>"; ! } ! else{ ! out += snmpa.getPassword(); ! } ! out += "\n"; ! return out; } }; *************** *** 468,472 **** public String call(Vector<String> params){ SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(161); ! String out = ""; for(int i=0; i<snmpa.SNMPgroups.size(); i++){ SNMP.SNMPInstance gr = snmpa.SNMPgroups.get(i); --- 480,484 ---- public String call(Vector<String> params){ SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(161); ! String out = "SNMP mibs:\n"; for(int i=0; i<snmpa.SNMPgroups.size(); i++){ SNMP.SNMPInstance gr = snmpa.SNMPgroups.get(i); Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeviceConfig.java 12 Oct 2007 21:06:39 -0000 1.1 --- DeviceConfig.java 14 Oct 2007 00:22:14 -0000 1.2 *************** *** 12,15 **** --- 12,17 ---- import java.util.Iterator; import java.util.LinkedList; + import java.util.Vector; + import java.util.regex.Pattern; /** *************** *** 22,25 **** --- 24,29 ---- public final static int STARTUP_CONFIG = 2; + public int working_config = RUNNING_CONFIG; + private NetworkLayerDevice device; private CommandProcessor cmdproc; *************** *** 42,46 **** String nextcmd = it.next(); cmdproc.call(nextcmd, cmdproc.ALLMODE | cmdproc.APPLICATION_LAYER); ! running_config.add(nextcmd); } } --- 46,50 ---- String nextcmd = it.next(); cmdproc.call(nextcmd, cmdproc.ALLMODE | cmdproc.APPLICATION_LAYER); ! //running_config.add(nextcmd); } } *************** *** 80,152 **** * @return false if 'command' already exists */ ! public boolean add(int config_name, String command, int paramc){ boolean result = false; ! if(paramc>0){ ! String req_cmd = getCommandPart(command, paramc); ! LinkedList config = getConfig(config_name); ! Iterator<String> it = config.iterator(); ! boolean found = false; ! while(it.hasNext() && !found){ ! found = (req_cmd.compareToIgnoreCase(getCommandPart(it.next(), paramc))==0); ! } ! if(!found){ ! config.add(command); ! result = true; ! } } return result; } ! /** Replace existing elements by 'command', which contain parameters after 'paramc' argument * */ ! public boolean replace(int config_name, String command, int paramc){ boolean result = false; ! if(paramc>0){ ! String req_cmd = getCommandPart(command, paramc); ! LinkedList config = getConfig(config_name); ! boolean manyfound = false; ! int index = -1; ! for(int i=0; i<config.size() && !manyfound; i++){ ! if(req_cmd.compareToIgnoreCase(getCommandPart((String)config.get(i), paramc))==0){ ! if(index == -1){ ! index = i; ! } ! else{ ! manyfound = true; ! } ! } ! } ! if(!manyfound){ ! if(index == -1){ ! config.add(command); ! } ! else{ ! config.set(index, command); ! } result = true; } } return result; ! } ! /** Remove all elements start with 'command' and contain equal or above than 'paramc' arguments * */ ! public boolean remove(int config_name, String command, int paramc){ boolean result = false; ! if(paramc>0){ ! String req_cmd = getCommandPart(command, paramc); ! LinkedList config = getConfig(config_name); ! Iterator<String> it = config.iterator(); ! while(it.hasNext()){ ! if(req_cmd.compareToIgnoreCase(getCommandPart(it.next(), paramc))==0){ ! it.remove(); ! } } - result = true; } return result; --- 84,169 ---- * @return false if 'command' already exists */ ! public boolean add(String command, Vector<String> params){ boolean result = false; ! String fullcmd = createCommand(command, params); ! LinkedList config = getConfig(working_config); ! Iterator<String> it = config.iterator(); ! boolean found = false; ! while(it.hasNext() && !found){ ! found = (fullcmd.compareToIgnoreCase(it.next())==0); ! } ! if(!found){ ! config.add(createCommand(command, params)); ! result = true; } return result; } ! // /** Replace existing elements by 'command', which contain parameters after 'paramc' argument ! // * ! // */ ! // public boolean replace(int config_name, String command, int paramc){ ! // boolean result = false; ! // ! // if(paramc>0){ ! // String req_cmd = getCommandPart(command, paramc); ! // LinkedList config = getConfig(config_name); ! // boolean manyfound = false; ! // int index = -1; ! // for(int i=0; i<config.size() && !manyfound; i++){ ! // if(req_cmd.compareToIgnoreCase(getCommandPart((String)config.get(i), paramc))==0){ ! // if(index == -1){ ! // index = i; ! // } ! // else{ ! // manyfound = true; ! // } ! // } ! // } ! // if(!manyfound){ ! // if(index == -1){ ! // config.add(command); ! // } ! // else{ ! // config.set(index, command); ! // } ! // result = true; ! // } ! // } ! // return result; ! // } ! ! /** Remove all elements match with 'command' * */ ! public boolean remove(String command){ boolean result = false; ! Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(working_config); ! Iterator<String> it = config.iterator(); ! while(it.hasNext()){ ! if(p.matcher(it.next()).find()){ ! it.remove(); result = true; } } return result; ! } ! /** Is exists 'command' in 'config_name' ? * */ ! public boolean isExists(String command){ boolean result = false; ! Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(working_config); ! Iterator<String> it = config.iterator(); ! while(it.hasNext() && !result){ ! if(p.matcher(it.next()).find()){ ! result = true; } } return result; *************** *** 165,167 **** --- 182,191 ---- } + private String createCommand(String command, Vector<String> params){ + for(int i=0; i<params.size(); i++){ + command += " " + params.get(i); + } + return command; + } + } |
From: QweR <qw...@us...> - 2007-10-14 00:22:19
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25590/guiUI Modified Files: Terminal.java Log Message: Some small bugs fixed Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Terminal.java 12 Oct 2007 21:06:39 -0000 1.1 --- Terminal.java 14 Oct 2007 00:22:14 -0000 1.2 *************** *** 32,41 **** import core.CommandInterface; import core.Version; - import java.awt.event.ActionEvent; - import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.JComponent; import core.Pair; import core.CommandProcessor; /** --- 32,43 ---- import core.CommandInterface; import core.Version; import java.awt.event.KeyEvent; import javax.swing.JComponent; import core.Pair; import core.CommandProcessor; + import java.awt.Toolkit; + import java.awt.event.FocusEvent; + import java.awt.event.FocusListener; + import javax.swing.SwingUtilities; /** *************** *** 58,62 **** private int current_mode; private int device_type; - private int current_config; private CommandProcessor cmdproc; --- 60,63 ---- *************** *** 78,83 **** current_mode = CommandsTree.STD_MODE; ! device_type = CommandsTree.APPLICATION_LAYER; ! current_config = DeviceConfig.RUNNING_CONFIG; cmdproc.add("clear terminal", clear_terminal_Command, cmdproc.STD_CONF_MODE | cmdproc.NETWORK_LAYER, "<cr>", "Clear screen"); --- 79,88 ---- current_mode = CommandsTree.STD_MODE; ! if(device.getClass().equals(ApplicationLayerDevice.class)){ ! 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"); *************** *** 100,126 **** panel.add(scrollpane, BorderLayout.CENTER); panel.setPreferredSize(new java.awt.Dimension(600,500)); ! scrollpane.setViewportView(terminal); terminal.setEnabled(true); terminal.setEditable(false); ! terminal.setFocusable(false); terminal.setBackground(Color.BLACK); terminal.setForeground(Color.WHITE); terminal.setFont(new Font("Courier New", Font.PLAIN, 12)); addToTerminal("javaNetSim console "+Version.CORE_VERSION+", "+Version.YEARS); - - cmdline.setVisible(true); - cmdline.setEnabled(true); - cmdline.setFocusable(true); - cmdline.setFocusCycleRoot(true); - cmdline.setFocusTraversalKeysEnabled(false); - cmdline.setInputVerifier(cmdverifier); ! cmdline.addKeyListener(cmdverifier); ! this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { printInfo(); } }); } --- 105,137 ---- panel.add(scrollpane, BorderLayout.CENTER); panel.setPreferredSize(new java.awt.Dimension(600,500)); ! ! cmdline.setVisible(true); ! cmdline.setEnabled(true); ! cmdline.setFocusable(true); ! cmdline.setFocusCycleRoot(true); ! cmdline.setFocusTraversalKeysEnabled(false); ! cmdline.setInputVerifier(cmdverifier); ! cmdline.requestFocus(); ! cmdline.addKeyListener(cmdverifier); ! scrollpane.setViewportView(terminal); terminal.setEnabled(true); terminal.setEditable(false); ! //terminal.setFocusable(false); terminal.setBackground(Color.BLACK); terminal.setForeground(Color.WHITE); terminal.setFont(new Font("Courier New", Font.PLAIN, 12)); addToTerminal("javaNetSim console "+Version.CORE_VERSION+", "+Version.YEARS); ! this.pack(); ! cmdline.requestFocusInWindow(); ! this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { printInfo(); } + public void windowGainedFocus(WindowEvent e) { + cmdline.requestFocusInWindow(); + } }); } *************** *** 344,348 **** String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode | device_type); //String last_str = cmdline.getText().substring(caretPos); ! if(compl_str!=null){ cmdline.setText(compl_str+" "); //cmdline.setText(compl_str+last_str); --- 355,359 ---- String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode | device_type); //String last_str = cmdline.getText().substring(caretPos); ! if(compl_str!=null && !compl_str.endsWith(" ")){ cmdline.setText(compl_str+" "); //cmdline.setText(compl_str+last_str); *************** *** 450,454 **** class configure_terminal_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! current_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; return ""; --- 461,465 ---- 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 ""; *************** *** 457,461 **** class configure_replace_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! current_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; return "Running-config was erased"; --- 468,472 ---- 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"; *************** *** 464,468 **** class configure_memory_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! current_config = DeviceConfig.STARTUP_CONFIG; current_mode = cmdproc.CONF_MODE; return "Starting-config editing"; --- 475,479 ---- 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"; *************** *** 473,476 **** --- 484,488 ---- if(current_mode == cmdproc.CONF_MODE){ current_mode = cmdproc.STD_MODE; + device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; } else if(current_mode == cmdproc.STD_MODE){ *************** *** 518,523 **** public String call(Vector<String> params){ String out = ""; ! for(int i=0; i<params.size(); i++){ ! out += params.get(i) + "\n"; } return out; --- 530,535 ---- public String call(Vector<String> params){ String out = ""; ! for(int i=0; i<history.size(); i++){ ! out += history.get(i) + "\n"; } return out; |
From: QweR <qw...@us...> - 2007-10-14 00:22:19
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25590/core/protocolsuite/tcp_ip Modified Files: Tcp.java Udp.java socketLayer.java Log Message: Some small bugs fixed Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** Tcp.java 1 Oct 2007 04:58:12 -0000 1.98 --- Tcp.java 14 Oct 2007 00:22:14 -0000 1.99 *************** *** 396,400 **** if (mSL.get_socket(sock_num).src_port==in_Port){ printLayerInfo("TCP error: can not double bind to port "+ in_Port +"! Server is already listening to this port"); ! throw new TransportLayerException("error: can not bind listen to port "+ in_Port +"! Server is already listening to this port"); } else{ --- 396,400 ---- if (mSL.get_socket(sock_num).src_port==in_Port){ printLayerInfo("TCP error: can not double bind to port "+ in_Port +"! Server is already listening to this port"); ! throw new TransportLayerException("TCP error: can not bind listen to port "+ in_Port +"! Server is already listening to this port"); } else{ Index: socketLayer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/socketLayer.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** socketLayer.java 1 Oct 2007 04:58:13 -0000 1.10 --- socketLayer.java 14 Oct 2007 00:22:14 -0000 1.11 *************** *** 160,165 **** mParentStack.TCP().closePort(sock); } ! jnsock.src_port = 0; ! jnsock.src_IP = ""; } public void free(int sock) throws TransportLayerException{ --- 160,165 ---- mParentStack.TCP().closePort(sock); } ! //jnsock.src_port = 0; ! //jnsock.src_IP = ""; } public void free(int sock) throws TransportLayerException{ Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Udp.java 1 Oct 2007 04:58:12 -0000 1.39 --- Udp.java 14 Oct 2007 00:22:14 -0000 1.40 *************** *** 277,298 **** public void bindPort(int sock_num, int in_Port) throws TransportLayerException { ! int lsPort=PORT_INIT; ! ! if ( mSL.get_socket(sock_num).src_port == 0 ) ! { ! if (in_Port>=0 && in_Port<=65535) ! { ! //create such a record in hashtable ! mSL.get_socket(sock_num).src_port = in_Port; ! printLayerInfo("Local port " + in_Port + " binded."); ! } else // ! { ! throw new TransportLayerException("UDP error: can not listen to port "+ in_Port +"! Use port range from 1 to 65535 to listen to."); ! } ! } else // ! { ! if (mSL.get_socket(sock_num).src_port==in_Port) throw new TransportLayerException("error: can not double listen to port "+ in_Port +"! Server is already listening to this port"); ! throw new TransportLayerException("UDP error: can not listen to port "+ in_Port +"! Already listening to port " + lsPort); ! } } --- 277,301 ---- public void bindPort(int sock_num, int in_Port) throws TransportLayerException { ! int lsPort=PORT_INIT; ! ! if(!mSL.get_socket(sock_num).open_state){ ! if (in_Port>=0 && in_Port<=65535) { //create such a record in hashtable ! mSL.get_socket(sock_num).src_port = in_Port; ! printLayerInfo("Local port " + in_Port + " binded."); ! } else // ! { ! throw new TransportLayerException("UDP error: can not listen to port "+ in_Port +"! Use port range from 1 to 65535 to listen to."); ! } ! } ! else{ ! if (mSL.get_socket(sock_num).src_port==in_Port){ ! printLayerInfo("UDP error: can not double bind to port "+ in_Port +"! Server is already listening to this port"); ! throw new TransportLayerException("UDP error: can not bind listen to port "+ in_Port +"! Server is already listening to this port"); ! } ! else{ ! printLayerInfo("UDP error: can not bind to port "+ in_Port +"! Already listening to port " + mSL.get_socket(sock_num).src_port); ! throw new TransportLayerException("UDP error: can not bind to port "+ in_Port +"! Already listening to port " + mSL.get_socket(sock_num).src_port); ! } ! } } |
From: Alexander B. <da...@us...> - 2007-10-13 12:57:07
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30660/core Modified Files: DataLinkLayerDevice.java EthernetNetworkInterface.java ExternalProxy.java Hub.java NetworkInterface.java NetworkInterfacePort.java NetworkLayerDevice.java Node.java PC.java ProtocolStack.java Router.java Simulation.java Switch.java Added Files: SerialLink.java SerialNetworkInterface.java Log Message: Multiple changes in Link Layer, added DHCP D/C prototype, broadcast packets (+ forwarding), changed menu structure, added MAC address editing, Serial link type and more... Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PC.java 8 Nov 2006 14:27:29 -0000 1.11 --- PC.java 13 Oct 2007 12:57:00 -0000 1.12 *************** *** 139,143 **** addApp(snmpManager, 30161); ! addNetworkInterface("eth0"); } --- 139,145 ---- addApp(snmpManager, 30161); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Ethernet10T) + "0", NetworkInterface.Ethernet10T, true); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, false); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Wireless) + "0", NetworkInterface.Wireless, true); } Index: DataLinkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DataLinkLayerDevice.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataLinkLayerDevice.java 20 Nov 2005 20:30:53 -0000 1.2 --- DataLinkLayerDevice.java 13 Oct 2007 12:57:00 -0000 1.3 *************** *** 55,60 **** protected void addNetworkInterface(String interfaceName) { ! NetworkInterfacetable.put(interfaceName,new NetworkInterfacePort(interfaceName,this)); ! } public Object[] getAllInterfaces(){ --- 55,60 ---- protected void addNetworkInterface(String interfaceName) { ! NetworkInterfacetable.put(interfaceName,new NetworkInterfacePort(interfaceName,this)); ! } public Object[] getAllInterfaces(){ Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Node.java 14 Sep 2007 11:14:49 -0000 1.8 --- Node.java 13 Oct 2007 12:57:00 -0000 1.9 *************** *** 235,240 **** */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! return; --- 235,240 ---- */ ! protected void receivePacket(Packet inPacket) throws LowLinkException ! { return; *************** *** 277,284 **** * */ ! protected void addNetworkInterface(String interfaceName) { ! ! NetworkInterfacetable.put(interfaceName,new EthernetNetworkInterface(interfaceName,this)); } --- 277,294 ---- * */ ! protected void addNetworkInterface(String interfaceName, int type, boolean active) { + switch(type){ + case NetworkInterface.Ethernet10T: + if(active){ + NetworkInterfacetable.put(interfaceName,new EthernetNetworkInterface(interfaceName,this)); + }else{ + NetworkInterfacetable.put(interfaceName,new NetworkInterfacePort(interfaceName,this)); + } + break; + case NetworkInterface.Serial: + NetworkInterfacetable.put(interfaceName,new SerialNetworkInterface(interfaceName,this)); + break; + } } *************** *** 445,451 **** if(NetworkInterfacetable.containsKey(inInterfaceName)){ ! EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); ! ! return temp.getMACAddress(); } --- 455,465 ---- if(NetworkInterfacetable.containsKey(inInterfaceName)){ ! //"Not Applicable" ! if(((NetworkInterface)(NetworkInterfacetable.get(inInterfaceName))).getType() == NetworkInterface.Ethernet10T){ ! EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); ! return temp.getMACAddress(); ! }else{ ! return "Not Applicable"; ! } } *************** *** 454,458 **** --- 468,541 ---- } + + public int getIntType(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ + + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + + NetworkInterface temp =(NetworkInterface)NetworkInterfacetable.get(inInterfaceName); + + return temp.getType(); + + } + + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + + } + + public boolean isActiveInterface(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ + + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + + NetworkInterface temp =(NetworkInterface)NetworkInterfacetable.get(inInterfaceName); + return temp.isActive(); + + } + + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + + } + + + + public String getIntSType(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ + + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + + NetworkInterface temp =(NetworkInterface)NetworkInterfacetable.get(inInterfaceName); + + switch(temp.getType()){ + case NetworkInterface.Ethernet10T: + return "Ethernet"; + case NetworkInterface.Serial: + return "Serial"; + case NetworkInterface.Wireless: + return "Wireless"; + default: + return "Unknown"; + } + + } + + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + + } + + /* public void setMACAddress(String inInterfaceName, String MAC)throws InvalidNetworkInterfaceNameException, SimulationException{ + + if(NetworkInterfacetable.containsKey(inInterfaceName)){ + + EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); + + if(MAC.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]")){ + temp.setMacAddress(MAC); + }else{ + throw new SimulationException("Invalid MAC address!"); + } + + }else{ + throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); + } + } */ --- NEW FILE: SerialNetworkInterface.java --- /* 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. - 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 core; //import java.util.*; /** * A NetworkInterface represents the physical interface between * a Node and a physical Link (network cable). Think of it as the NIC * (Network Interface Card) of a Node. This particular Network Interface * is modelled on an Ethernet Interface Card. * * <P>Different Nodes can contain different numbers of NetworkInterfaces. * A client PC usually only has one NetworkInterface, whereas a Router contains * at least two. A Hub or a Switch often has 8 or 16.</P> * * <P>In order for a Node to be able to send or receive network information (packets), * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> * * <P>NetworkInterfaces receive and send packets to and from DatalinkProtocols and * the Link object they are connected to.</P> * * @author Tristan Veness * @author Bevan Calliess * @since 19 September 2004 * @version v0.20 */ class SerialNetworkInterface extends NetworkInterface{ /** * Constructs a NetworkInterface object with the name inName and a * reference to it's parent Node. * @author bevan_calliess * @param inName - The name to give the NetworkInterface eg: eth0 * @param parent - The Node that the NetworkInterface is to be added to, it's parent. * @version v0.20 */ protected SerialNetworkInterface(String inName, Node parent) { super(inName,parent); } protected void receivePacket(Packet inPacket) throws LowLinkException { } public int getType(){ return NetworkInterface.Serial; } protected void sendPacket(Packet inPacket) throws LowLinkException { } public boolean isActive(){ return false; } /** * This method displays details about the current interface card * @author bevan_calliess * @return String * @version v0.20 */ protected String getDetails(){ return "Interface: "+name + "\t\t" + "\t\t"+ getConnectLinkDetails(); } } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Simulation.java 22 Nov 2006 21:18:38 -0000 1.13 --- Simulation.java 13 Oct 2007 12:57:00 -0000 1.14 *************** *** 595,598 **** --- 595,621 ---- } + public void addSerialLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface) + throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { + + if (!linkTable.containsKey(inLinkName)) { + + //test if node's exist within hashtable + if(nodeTable.containsKey(inFirstNodeName) && nodeTable.containsKey(inSecondNodeName)){ + Node tempNode1 = (Node) nodeTable.get(inFirstNodeName); + Node tempNode2 = (Node) nodeTable.get(inSecondNodeName); + + //Return NetworkInterface from Node objects + NetworkInterface interface1 = tempNode1.getNetworkInterface(inFirstNodeInterface); + NetworkInterface interface2 = tempNode2.getNetworkInterface(inSecondNodeInterface); + + //Create link and add it to hashtable + linkTable.put(inLinkName,new SerialLink(inLinkName, interface1, interface2)); + }else{ + throw new InvalidNodeNameException("Invalid node name"); + } + } else + throw new InvalidLinkNameException("Link already exists with same name."); + } + /** * This method checks to see if inLinkName is contained within the has table(linkTable).If so, *************** *** 609,613 **** * @version v0.20 **/ ! public void addEthernetLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface, String sieveCoeff) throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { --- 632,636 ---- * @version v0.20 **/ ! public void addEthernetLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface, String sieveCoeff ) throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { *************** *** 1130,1139 **** { Vector vecInterfaceInfo = new Vector(); ! vecInterfaceInfo.add(inNodeName); vecInterfaceInfo.add(strDefaultGateway); String strInterfaceName = (String)it.next(); vecInterfaceInfo.add(strInterfaceName); ! try{ ! vecInterfaceInfo.add((String)tempNetwork.getMACAddress(strInterfaceName)); String tempIP = tempNetwork.getIPAddress(strInterfaceName); if(tempIP != null) --- 1153,1163 ---- { Vector vecInterfaceInfo = new Vector(); ! vecInterfaceInfo.add(inNodeName); vecInterfaceInfo.add(strDefaultGateway); String strInterfaceName = (String)it.next(); vecInterfaceInfo.add(strInterfaceName); ! try{ ! vecInterfaceInfo.add((String)tempNetwork.getIntSType(strInterfaceName)); ! vecInterfaceInfo.add((String)tempNetwork.getMACAddress(strInterfaceName)); String tempIP = tempNetwork.getIPAddress(strInterfaceName); if(tempIP != null) *************** *** 1169,1184 **** while(it.hasNext()) ! { Vector vecInterfaceInfo = new Vector(); vecInterfaceInfo.add(inNodeName); ! vecInterfaceInfo.add("Not Applicable"); ! String strInterfaceName = (String)it.next(); ! vecInterfaceInfo.add(strInterfaceName); ! try{ ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add("Not Applicable"); ! NetworkInterface tempNetworkCard = tempData.getNetworkInterface(strInterfaceName); ! vecInterfaceInfo.add((String)tempNetworkCard.getConnectLinkName()); } --- 1193,1209 ---- while(it.hasNext()) ! { Vector vecInterfaceInfo = new Vector(); vecInterfaceInfo.add(inNodeName); ! String strInterfaceName = (String)it.next(); ! try{ ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add(strInterfaceName); ! vecInterfaceInfo.add((String)tempData.getIntSType(strInterfaceName)); ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add("Not Applicable"); ! vecInterfaceInfo.add("Not Applicable"); ! NetworkInterface tempNetworkCard = tempData.getNetworkInterface(strInterfaceName); ! vecInterfaceInfo.add((String)tempNetworkCard.getConnectLinkName()); } Index: Hub.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Hub.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Hub.java 24 Feb 2006 10:20:10 -0000 1.5 --- Hub.java 13 Oct 2007 12:57:00 -0000 1.6 *************** *** 57,65 **** public Hub(String inName) { super(inName, 1); //pass name and protocolstack layer ! addNetworkInterface("eth0"); ! addNetworkInterface("eth1"); ! addNetworkInterface("eth2"); ! addNetworkInterface("eth3"); ! addNetworkInterface("eth4"); } --- 57,65 ---- 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); ! 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); } *************** *** 115,119 **** --- 115,121 ---- }else{ sz=1; + System.out.println("Hub buffer overflow?"); System.out.println(th.toString()); + System.out.println(th.getStackTrace().length); throw new LowLinkException("Hub buffer overflow (packet loop flood?)."); } Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ProtocolStack.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ProtocolStack.java 1 Dec 2005 15:03:28 -0000 1.6 --- ProtocolStack.java 13 Oct 2007 12:57:00 -0000 1.7 *************** *** 147,151 **** */ ! public abstract void receivePacket(Packet inPacket) throws LowLinkException,TransportLayerPortException; --- 147,151 ---- */ ! public abstract void receivePacket(Packet inPacket, String inInterface) throws LowLinkException,TransportLayerPortException; Index: NetworkInterfacePort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterfacePort.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NetworkInterfacePort.java 14 Sep 2007 11:14:49 -0000 1.5 --- NetworkInterfacePort.java 13 Oct 2007 12:57:00 -0000 1.6 *************** *** 186,189 **** --- 186,192 ---- } + public int getType(){ + return NetworkInterface.Ethernet10T; + } --- NEW FILE: SerialLink.java --- /* 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. - 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 core; import java.util.*; import core.FalseRandom; /** * SerialLink extends Link. It sets two Interface links to a pc. * @author luke_hamilton * @author bevan_calliess * @since Sep 17, 2004 * @version v0.20 */ public class SerialLink extends Link { /** * Constructor to be used by the Simulation when connecting 2 PC's * We have made a design decision to restrict a Ethernet link to only has 2 ends. * @author bevan_calliess * @author luke_hamilton * @param String Name - Node name eg: PC1 * @param inInterface1 The first Interface to connect this link to eg: eth0 * @param inInterface2 The Seceond Interface to connect this link to eg: eth1 * @throws InvalidLinkConnectionException */ public SerialLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); NetworkInterfaces.add(inSecondNodeInterface); inFirstNodeInterface.setConnectedLink(this); inSecondNodeInterface.setConnectedLink(this); } } Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NetworkInterface.java 9 Nov 2006 15:31:55 -0000 1.4 --- NetworkInterface.java 13 Oct 2007 12:57:00 -0000 1.5 *************** *** 101,105 **** ! abstract class NetworkInterface implements Serializable{ /** The NetworkInterface's name, eg "eth0" */ --- 101,105 ---- ! public abstract class NetworkInterface implements Serializable{ /** The NetworkInterface's name, eg "eth0" */ *************** *** 113,118 **** protected Node parentNode; ! ! /** --- 113,143 ---- protected Node parentNode; ! public final static int Unknown = 0; ! public final static int Ethernet10T = 0; ! public final static int Serial = 1; ! public final static int Wireless = 2; ! ! public static String getIntName(int type){ ! switch(type){ ! case 0: ! return "eth"; ! case 1: ! return "cua"; ! case 2: ! return "wifi"; ! default: ! return "unk"; ! } ! } ! ! ! public boolean isActive(){ ! return false; ! } ! ! public int getType(){ ! return -1; ! } ! /** *************** *** 131,135 **** protected NetworkInterface(String inName, Node inParent) { ! name = inName; parentNode = inParent; --- 156,160 ---- protected NetworkInterface(String inName, Node inParent) { ! name = inName; parentNode = inParent; Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NetworkLayerDevice.java 12 Oct 2007 21:06:39 -0000 1.8 --- NetworkLayerDevice.java 13 Oct 2007 12:57:00 -0000 1.9 *************** *** 73,77 **** --- 73,81 ---- //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton public String getSubnetMask(String inInterface) { + if(((NetworkInterface)(NetworkInterfacetable.get(inInterface))).getType() == NetworkInterface.Ethernet10T){ return NodeProtocolStack.getSubnetMask(inInterface); + }else{ + return "Not Applicable"; + } } *************** *** 87,91 **** --- 91,99 ---- //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton public String getIPAddress(String inInterface){ + if(((NetworkInterface)(NetworkInterfacetable.get(inInterface))).getType() == NetworkInterface.Ethernet10T){ return NodeProtocolStack.getIPAddress(inInterface); + }else{ + return "Not Applicable"; + } } *************** *** 98,103 **** * @version v0.20 */ ! public void receivePacket(Packet inPacket) throws LowLinkException { ! NodeProtocolStack.receivePacket(inPacket); } --- 106,111 ---- * @version v0.20 */ ! public void receivePacket(Packet inPacket, String inInterface) throws LowLinkException { ! NodeProtocolStack.receivePacket(inPacket, inInterface); } *************** *** 229,233 **** */ ! protected void setMACAddress(String inInterface, String inMACAddress) throws InvalidNetworkInterfaceNameException { if (NetworkInterfacetable.containsKey(inInterface)) { EthernetNetworkInterface tempNic = --- 237,241 ---- */ ! public void setMACAddress(String inInterface, String inMACAddress) throws InvalidNetworkInterfaceNameException { if (NetworkInterfacetable.containsKey(inInterface)) { EthernetNetworkInterface tempNic = Index: Router.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Router.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Router.java 20 Nov 2005 20:30:53 -0000 1.2 --- Router.java 13 Oct 2007 12:57:00 -0000 1.3 *************** *** 47,53 **** protected Router(String inName) { super(inName,3); ! addNetworkInterface("eth0"); ! addNetworkInterface("eth1"); ! } --- 47,53 ---- 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); ! addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Serial) + "0", NetworkInterface.Serial, false); } Index: Switch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Switch.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Switch.java 12 Oct 2006 17:55:11 -0000 1.5 --- Switch.java 13 Oct 2007 12:57:00 -0000 1.6 *************** *** 61,84 **** IntCaches = new Hashtable(); ! addNetworkInterface("eth0"); ! Hashtable iceth0 = new Hashtable(); ! IntCaches.put("eth0", iceth0); ! addNetworkInterface("eth1"); ! Hashtable iceth1 = new Hashtable(); ! IntCaches.put("eth1", iceth1); ! addNetworkInterface("eth2"); ! Hashtable iceth2 = new Hashtable(); ! IntCaches.put("eth2", iceth2); ! addNetworkInterface("eth3"); ! Hashtable iceth3 = new Hashtable(); ! IntCaches.put("eth3", iceth3); - addNetworkInterface("eth4"); - Hashtable iceth4 = new Hashtable(); - IntCaches.put("eth4", iceth4); } --- 61,98 ---- IntCaches = new Hashtable(); + 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); } Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EthernetNetworkInterface.java 12 Oct 2006 16:14:14 -0000 1.7 --- EthernetNetworkInterface.java 13 Oct 2007 12:57:00 -0000 1.8 *************** *** 106,110 **** Packet temp = tempPacket.getData(); ! parentNode.receivePacket(temp); }else{ //Packet is not for the Interface Drop Packet and record something in --- 106,110 ---- Packet temp = tempPacket.getData(); ! parentNode.receivePacket(temp, name); }else{ //Packet is not for the Interface Drop Packet and record something in *************** *** 119,122 **** --- 119,126 ---- } + public int getType(){ + return NetworkInterface.Ethernet10T; + } + /** * Typecasts the variables being passed in into a EthernetPacket packet and *************** *** 168,171 **** --- 172,179 ---- return MACAddress; } + + public boolean isActive(){ + return true; + } /** Index: ExternalProxy.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ExternalProxy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExternalProxy.java 22 Nov 2006 21:18:38 -0000 1.1 --- ExternalProxy.java 13 Oct 2007 12:57:00 -0000 1.2 *************** *** 69,73 **** super(inName,3); NodeProtocolStack.initNAT(); ! addNetworkInterface("eth0"); externalIP = null; Apps = new Hashtable(); --- 69,73 ---- super(inName,3); NodeProtocolStack.initNAT(); ! addNetworkInterface("eth0", NetworkInterface.Ethernet10T, true ); externalIP = null; Apps = new Hashtable(); *************** *** 122,129 **** }else{ ! NodeProtocolStack.receivePacket(inPacket); } }else{ ! NodeProtocolStack.receivePacket(inPacket); } } --- 122,129 ---- }else{ ! NodeProtocolStack.receivePacket(inPacket, "unk"); } }else{ ! NodeProtocolStack.receivePacket(inPacket, "unk"); } } |
From: Alexander B. <da...@us...> - 2007-10-13 12:57:07
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30660/guiUI Modified Files: GuiNode.java LinkDialog.java LinkLayerPanel.java LinkProperties.java MainScreen.java NodePropertiesDialog.java SandBox.java SetTCPIPPropertiesDialog.java Added Files: EthPortProperties.java Removed Files: breakLinkDialog.java Log Message: Multiple changes in Link Layer, added DHCP D/C prototype, broadcast packets (+ forwarding), changed menu structure, added MAC address editing, Serial link type and more... Index: LinkProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkProperties.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LinkProperties.java 14 Sep 2007 11:14:51 -0000 1.7 --- LinkProperties.java 13 Oct 2007 12:57:00 -0000 1.8 *************** *** 337,341 **** --- 337,343 ---- for (int i = 0; i < nics.length; i++) { //Add them to the combobox + if(Sim.getNode(NodeName).getIntType((String)nics[i]) == core.NetworkInterface.Ethernet10T ){ cmbInterface.addItem(nics[i]); + } } cmbInterface.setEnabled(true); Index: LinkLayerPanel.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkLayerPanel.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LinkLayerPanel.java 13 Sep 2007 13:38:52 -0000 1.2 --- LinkLayerPanel.java 13 Oct 2007 12:57:00 -0000 1.3 *************** *** 1,129 **** /* 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. - 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 java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.*; import java.awt.Color; import java.awt.Point; import java.util.Hashtable; import java.util.Enumeration; import javax.swing.JPanel; /** * This object is an extension of the Java Swing JPanel. * It has been extended so that we can overide the paint method * and use it to draw the various links. It will be inserted into the * bottom layer of a layered pane so that it always sits behind the * various Nodes being displayed on teh screen. * * @author bevan_calliess * */ public class LinkLayerPanel extends JPanel { final static String FAKELINE = new String("FakeLine"); final static BasicStroke stroke = new BasicStroke(3.0f); final static Color linkCol = Color.BLUE; private Hashtable LineTable = new Hashtable(); /** * This method will take the name of the Link and the starting * and ending points that it is drawn between. * A 2DLine object is created using these co-ordinates and then * it is added to a hashTable using the name as a key * so that it can be located and moved and/or removed as required. * @param inName Used as the key for the hashTable * @param inStart Used for the first set of co-ordinates p1x and p1y * @param inEnd Used for the second set of co-ordinates p2x and p2y */ ! public void addLine(String inName,Point inStart, Point inEnd){ ! Line2D.Double Line = new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y); ! LineTable.put(inName,Line); repaint(); } /** * This method will remove a line from the hashtable so that * it will no longer be drawn. * @param inName */ public void removeLine(String inName){ LineTable.remove(inName); repaint(); } /** * This method is Used to move the co-ordinates of a particular * line in the hashTable. * * @param inName Key to the HashTable.(linkName) * @param inWhichEnd Which set of co_ordinates to move p1 or p2 * @param inPosition The position to move those cordinates to. */ public void moveLine(String inName,int inWhichEnd,Point inPosition){ if(LineTable.containsKey(inName)) { ! Line2D.Double myLine = (Line2D.Double)LineTable.get(inName); if(inWhichEnd == 1){ Point2D p1 = (Point2D)inPosition; ! Point2D p2 = myLine.getP2(); ! myLine.setLine(p1,p2); }else{ ! Point2D p1 = myLine.getP1(); Point2D p2 = (Point2D)inPosition; ! myLine.setLine(p1,p2); } repaint(); } } /** * Overides the standard paint method so that it * draws the various lines on the screen. */ public void paint(Graphics g) { super.paint(g); Graphics2D g2D = (Graphics2D)g; ! g2D.setStroke(stroke); ! g2D.setPaint(linkCol); ! Enumeration it = LineTable.elements(); ! ! while(it.hasMoreElements()){ ! Line2D.Double myLine = (Line2D.Double)it.nextElement(); ! g2D.draw(myLine); } } } --- 1,271 ---- /* + 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. + - 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 java.awt.BasicStroke; + import java.awt.Graphics; + import java.awt.Graphics2D; + import java.awt.geom.*; + import java.awt.Color; + import java.awt.Point; + import java.util.Hashtable; + import java.util.Enumeration; + + import javax.swing.JPanel; + + /** + * This object is an extension of the Java Swing JPanel. + * It has been extended so that we can overide the paint method + * and use it to draw the various links. It will be inserted into the + * bottom layer of a layered pane so that it always sits behind the + * various Nodes being displayed on teh screen. + * + * @author bevan_calliess + * + */ + + public class LinkLayerPanel extends JPanel { + + final static String FAKELINE = new String("FakeLine"); + final static BasicStroke stroke = new BasicStroke(3.0f); + final static Color linkCol = Color.BLUE; + + class LinkLine{ + public Line2D.Double Line; + public BasicStroke stroke; + public Color linkCol; + + public LinkLine(Line2D.Double inLine, BasicStroke instroke, Color inlinkCol){ + Line = inLine; + stroke = instroke; + linkCol = inlinkCol; + } + } + private Hashtable LineTable = new Hashtable(); + + + /** + * This method will take the name of the Link and the starting + * and ending points that it is drawn between. + * A 2DLine object is created using these co-ordinates and then + * it is added to a hashTable using the name as a key + * so that it can be located and moved and/or removed as required. + * @param inName Used as the key for the hashTable + * @param inStart Used for the first set of co-ordinates p1x and p1y + * @param inEnd Used for the second set of co-ordinates p2x and p2y + */ ! ! public void addLine(String inName,Point inStart, Point inEnd, int type){ ! ! switch(type){ ! case core.NetworkInterface.Ethernet10T: ! LineTable.put(inName,new LinkLine(new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y), new BasicStroke(2.0f), Color.BLACK)); ! 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.BLUE)); ! break; ! } ! repaint(); + } + /** + * This method will remove a line from the hashtable so that + * it will no longer be drawn. + * @param inName + */ + public void removeLine(String inName){ + LineTable.remove(inName); + repaint(); + } + + /** + * This method is Used to move the co-ordinates of a particular + * line in the hashTable. + * + * @param inName Key to the HashTable.(linkName) + * @param inWhichEnd Which set of co_ordinates to move p1 or p2 + * @param inPosition The position to move those cordinates to. + */ + public void moveLine(String inName,int inWhichEnd,Point inPosition){ + if(LineTable.containsKey(inName)) + { ! ! LinkLine myLine = (LinkLine)LineTable.get(inName); ! if(inWhichEnd == 1){ + Point2D p1 = (Point2D)inPosition; ! ! Point2D p2 = myLine.Line.getP2(); ! ! myLine.Line.setLine(p1,p2); ! }else{ ! ! Point2D p1 = myLine.Line.getP1(); ! Point2D p2 = (Point2D)inPosition; ! ! myLine.Line.setLine(p1,p2); ! } + repaint(); + } + + } + + /** + * Overides the standard paint method so that it + * draws the various lines on the screen. + */ + public void paint(Graphics g) + { + super.paint(g); + Graphics2D g2D = (Graphics2D)g; ! Enumeration it = LineTable.elements(); ! ! while(it.hasMoreElements()){ ! ! LinkLine myLine = (LinkLine)it.nextElement(); ! ! g2D.setStroke(myLine.stroke); ! ! g2D.setPaint(myLine.linkCol); ! ! g2D.draw(myLine.Line); ! } + } + } + Index: LinkDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkDialog.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LinkDialog.java 15 Sep 2007 11:34:58 -0000 1.3 --- LinkDialog.java 13 Oct 2007 12:57:00 -0000 1.4 *************** *** 103,112 **** txtLinkName.setText(inPC1 + "-TO-" + inPC2); lblFirstNode.setText(inPC1); ! pnlMessage.add(lblMessage); pnlLinkScreen.add(pnlMessage); ! pnlLinkInfo.add(lblNameLink); ! pnlLinkInfo.add(txtLinkName); pnlLinkScreen.add(pnlLinkInfo); pnlFirstNode.add(lblFirstNode, BorderLayout.NORTH); --- 103,113 ---- txtLinkName.setText(inPC1 + "-TO-" + inPC2); + txtLinkName.setVisible(false); lblFirstNode.setText(inPC1); ! pnlMessage.add(lblMessage); pnlLinkScreen.add(pnlMessage); ! //pnlLinkInfo.add(lblNameLink); ! //pnlLinkInfo.add(txtLinkName); pnlLinkScreen.add(pnlLinkInfo); pnlFirstNode.add(lblFirstNode, BorderLayout.NORTH); *************** *** 142,146 **** * @author Team VC2 */ ! public String getLinkName() { --- 143,147 ---- * @author Team VC2 */ ! public String getLinkName() { Index: NodePropertiesDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/NodePropertiesDialog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NodePropertiesDialog.java 13 Sep 2007 13:38:52 -0000 1.2 --- NodePropertiesDialog.java 13 Oct 2007 12:57:00 -0000 1.3 *************** *** 1,128 **** --- 1,258 ---- /* + 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. + - 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 javax.swing.JButton; + import javax.swing.JDialog; + import javax.swing.JPanel; + import javax.swing.*; + import java.awt.event.*; + import java.awt.*; + import java.util.*; + import javax.swing.table.*; + + /** + * This class is used to display general information about a + * GUINode. It will display the IP Address information including + * default gateway and any Interface specific information such as + * the Current IP address and subnetmask. + * @author Michael + */ + public class NodePropertiesDialog extends JDialog implements ActionListener + { + + private JLabel lblNodeNameLabel = new JLabel("Node Name : "); + private JLabel lblNodeName = new JLabel(); + private JLabel lblGatewayLabel = new JLabel("Default Gateway : "); + private JLabel lblGatewayAddress = new JLabel(); + private JButton btnOK = new JButton("OK"); + + JPanel pnlNodeNameDetails = new JPanel(); + JPanel pnlGatewayDetails = new JPanel(); + + JPanel pnlOKButton = new JPanel(); + + public NodePropertiesDialog(JFrame frame, Vector inVectorMasterList){ + super(frame); + ArrayList aryColumnNames = new ArrayList(); + aryColumnNames.add("Name"); + aryColumnNames.add("Gateway"); + aryColumnNames.add("Interface Name"); + + aryColumnNames.add("Type"); + aryColumnNames.add("MAC Address"); + aryColumnNames.add("IP Address"); + aryColumnNames.add("Subnet Mask"); + aryColumnNames.add("Link Name"); + + Vector col = new Vector(aryColumnNames); + JTable tblInfo = new JTable(inVectorMasterList, col); + TableModel model = tblInfo.getModel(); + + // Remove the first 2 column names + lblNodeName.setText(tblInfo.getModel().getValueAt(0, 0).toString()); + tblInfo.getColumnModel().removeColumn(tblInfo.getColumnModel().getColumn(0)); + lblGatewayAddress.setText(tblInfo.getModel().getValueAt(0, 1).toString()); + tblInfo.getColumnModel().removeColumn(tblInfo.getColumnModel().getColumn(0)); + + //Makes uneditable + tblInfo.setEnabled(false); + tblInfo.getTableHeader().setReorderingAllowed(false); + JScrollPane scrPane = new JScrollPane(tblInfo); + + + //ArrayList temp = (ArrayList)inArrayMasterList.get(0); + //lblNodeName.setText((String)temp.get(0)); + //lblGatewayAddress.setText((String)temp.get(1)); + + JPanel pnlPropertiesScreen = (JPanel)this.getContentPane(); + pnlPropertiesScreen.setLayout(new BoxLayout(pnlPropertiesScreen, BoxLayout.Y_AXIS)); + pnlNodeNameDetails.setLayout(new FlowLayout()); + pnlOKButton.setLayout(new FlowLayout()); + + pnlNodeNameDetails.setPreferredSize(new Dimension(50,50)); + pnlNodeNameDetails.add(lblNodeNameLabel); + pnlNodeNameDetails.add(lblNodeName); + pnlGatewayDetails.add(lblGatewayLabel); + pnlGatewayDetails.add(lblGatewayAddress); + pnlPropertiesScreen.add(pnlNodeNameDetails); + pnlPropertiesScreen.add(pnlGatewayDetails); + pnlPropertiesScreen.add(scrPane); + pnlOKButton.add(btnOK); + pnlPropertiesScreen.add(pnlOKButton); + + this.setSize(700,200); + this.setLocationRelativeTo(null); + this.setModal(true); + this.setResizable(false); + btnOK.setToolTipText("Close the screen"); + + //Set default button to be btnOK + this.getRootPane().setDefaultButton(btnOK); + btnOK.addActionListener(this); + } + + + public void actionPerformed(ActionEvent e) + { + if(e.getSource() == btnOK) + { + + this.dispose(); + } + } + + } + Index: SetTCPIPPropertiesDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SetTCPIPPropertiesDialog.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SetTCPIPPropertiesDialog.java 13 Sep 2007 13:38:53 -0000 1.7 --- SetTCPIPPropertiesDialog.java 13 Oct 2007 12:57:00 -0000 1.8 *************** *** 434,438 **** for (int i = 0; i < nics.length; i++) { //Add them to the combobox ! cmbInterface.addItem(nics[i]); } cmbInterface.setEnabled(true); --- 434,439 ---- for (int i = 0; i < nics.length; i++) { //Add them to the combobox ! if(Sim.getNode(NodeName).getIntType((String)nics[i]) == core.NetworkInterface.Ethernet10T ) ! cmbInterface.addItem(nics[i]); } cmbInterface.setEnabled(true); --- breakLinkDialog.java DELETED --- --- NEW FILE: EthPortProperties.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 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 Ethernet Port Props * */ public class EthPortProperties extends javax.swing.JDialog { private JPanel backpanel; private JLabel lblInterface, cmbInterface; private JLabel lblNodeName, cmbNodeName; private JLabel lblError; private JButton btnOk; private JTextField txtMAC; private JLabel lblMAC; private MainScreen controller; private Simulation Sim; private SandBox SBox; private String NodeName=""; private String NodeInt=""; private boolean ErrorFlag = true; public EthPortProperties(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("Ethernet 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:"); } { lblMAC = new JLabel(); backpanel.add(lblMAC, new GridBagConstraints( 0, 2, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblMAC.setText("MAC Address:"); } { 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); } txtMAC = new JTextField(); txtMAC.addFocusListener(new FocusAdapter() { public void actionPerformed(ActionEvent e) { lblError.setVisible(false); } }); txtMAC.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(txtMAC, gridBagConstraints_3); txtMAC.setText(Sim.getNode(NodeName).getMACAddress(NodeInt)); 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 method 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 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); temp.setMACAddress(NodeInt, SC); 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 method is executed when the user hits the cancel button * @author luke_hamilton * @author Key * */ private void cancelButton(){ this.dispose(); } } Index: SandBox.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SandBox.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SandBox.java 16 Sep 2007 17:44:14 -0000 1.6 --- SandBox.java 13 Oct 2007 12:57:00 -0000 1.7 *************** *** 108,113 **** */ ! public void addLine(String inName,Point inStart, Point inEnd){ ! pnlLinkLayer.addLine(inName, inStart,inEnd); } --- 108,113 ---- */ ! public void addLine(String inName,Point inStart, Point inEnd, int type){ ! pnlLinkLayer.addLine(inName, inStart,inEnd, type); } Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** MainScreen.java 12 Oct 2007 21:06:39 -0000 1.67 --- MainScreen.java 13 Oct 2007 12:57:00 -0000 1.68 *************** *** 203,207 **** //private JTextArea pnlConsole = new JTextArea(); ! private JTextArea pnlNodeInformation = new JTextArea(); ColorRenderer colorRenderer; --- 203,207 ---- //private JTextArea pnlConsole = new JTextArea(); ! private JEditorPane pnlNodeInformation = new JEditorPane(); ColorRenderer colorRenderer; *************** *** 1119,1123 **** }else{ ! LinkDialog dlgLink = new LinkDialog(inNode1 ,inNode2,strFirstNodeInter, strSecondNodeInter); dlgLink.setTitle("Create Link between " + inNode1 + " and " + inNode2 + "?"); --- 1119,1123 ---- }else{ ! LinkDialog dlgLink = new LinkDialog(inNode1 , inNode2, strFirstNodeInter, strSecondNodeInter); dlgLink.setTitle("Create Link between " + inNode1 + " and " + inNode2 + "?"); *************** *** 1132,1175 **** if(dlgLink.getWasOKPressed()){ ! String strLinkName = dlgLink.getLinkName(); String strFirstNodeInterface = dlgLink.getFirstSelectedInterface(); String strSecondNodeInterface = dlgLink.getSecondSelectedInterface(); ! Sim.addEthernetLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); ! ! GuiNode tempFirstNode = (GuiNode)GUInodeTable.get(inNode1); ! ! ! Point FirstPoint = new Point((tempFirstNode.getX() + ! tempFirstNode.getWidth() / 2), (tempFirstNode.getY() + ! tempFirstNode.getHeight() / 2)); ! GuiNode tempSecondNode = (GuiNode)GUInodeTable.get(inNode2); ! Point SecondPoint = new Point((tempSecondNode.getX() + ! tempSecondNode.getWidth() / 2), (tempSecondNode.getY() + ! tempSecondNode.getHeight() / 2)); - - Sandbox.addLine(strLinkName, FirstPoint,SecondPoint); ! ! tempFirstNode.setConnectedLinkName(strLinkName,1, inNode2); ! tempSecondNode.setConnectedLinkName(strLinkName,2, inNode1); //pnlConsole.append("Added Link between "+ inNode1 +" and " + inNode2 + "\n"); ! } --- 1132,1185 ---- if(dlgLink.getWasOKPressed()){ ! String strFirstNodeInterface = dlgLink.getFirstSelectedInterface(); String strSecondNodeInterface = dlgLink.getSecondSelectedInterface(); + + String strLinkName = inNode1 + "-" + Sim.getNode(inNode1).getIntSType(strFirstNodeInterface) + "-" + inNode2; ! if( Sim.getNode(inNode1).getIntType(strFirstNodeInterface) == Sim.getNode(inNode2).getIntType(strSecondNodeInterface)){ ! ! GuiNode tempFirstNode = (GuiNode)GUInodeTable.get(inNode1); ! Point FirstPoint = new Point((tempFirstNode.getX() + ! tempFirstNode.getWidth() / 2), (tempFirstNode.getY() + ! tempFirstNode.getHeight() / 2)); ! GuiNode tempSecondNode = (GuiNode)GUInodeTable.get(inNode2); ! Point SecondPoint = new Point((tempSecondNode.getX() + ! tempSecondNode.getWidth() / 2), (tempSecondNode.getY() + ! tempSecondNode.getHeight() / 2)); ! ! switch(Sim.getNode(inNode1).getIntType(strFirstNodeInterface)){ ! case core.NetworkInterface.Ethernet10T: ! Sim.addEthernetLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); ! break; ! case core.NetworkInterface.Serial: ! Sim.addSerialLink(strLinkName,inNode1, strFirstNodeInterface, inNode2, strSecondNodeInterface); ! break; ! } ! ! Sandbox.addLine(strLinkName, FirstPoint, SecondPoint, Sim.getNode(inNode1).getIntType(strFirstNodeInterface)); ! tempFirstNode.setConnectedLinkName(strLinkName,1, inNode2); ! tempSecondNode.setConnectedLinkName(strLinkName,2, inNode1); //pnlConsole.append("Added Link between "+ inNode1 +" and " + inNode2 + "\n"); ! }else{ ! JOptionPane.showMessageDialog(this,"Cannot connect interfaces with different types!","Error!",JOptionPane.ERROR_MESSAGE); ! } } *************** *** 1242,1246 **** ! Sandbox.addLine(strLinkName, FirstPoint,SecondPoint); --- 1252,1256 ---- ! Sandbox.addLine(strLinkName, FirstPoint,SecondPoint, 0); //FIXME! *************** *** 1308,1317 **** catch(LowLinkException e){ ! insertInConsole("(none)", "(none)", "*SYSTEM*", e.toString()); } catch(CommunicationException e){ ! insertInConsole("(none)", "(none)", "*SYSTEM*", e.toString()); } --- 1318,1327 ---- catch(LowLinkException e){ ! insertInConsole(inNodeName, "Link", "*SYSTEM*", e.toString()); } catch(CommunicationException e){ ! insertInConsole(inNodeName, "Network", "*SYSTEM*", e.toString()); } *************** *** 1417,1421 **** //pnlConsole.append(pad(recording[1],15,' ')+packet+pad(recording[3],10,' ')+layer+recording[5]+ "\n"); ! System.out.println(pad(recording[1],15,' ')+packet+pad(recording[3],10,' ')+layer+recording[5]+ "\n"); insertInConsole(recording[1], packet, layer, recording[5]); } --- 1427,1431 ---- //pnlConsole.append(pad(recording[1],15,' ')+packet+pad(recording[3],10,' ')+layer+recording[5]+ "\n"); ! //System.out.println(pad(recording[1],15,' ')+packet+pad(recording[3],10,' ')+layer+recording[5]+ "\n"); insertInConsole(recording[1], packet, layer, recording[5]); } *************** *** 1482,1563 **** ! /** ! ! * Creates a Properties Dialog on the specific Node ! ! * @param String inNodeName The name node to show properties on ! ! */ ! ! ! ! public void showBreakLinkDialog(String inNodeName) ! ! { ! ! Object[] nodesArray = null; ! ! int selectedIndex = -1; ! ! ! ! //if null is passed from the menubar item ! ! //Get array of nodes from within the simulation ! ! if(inNodeName == null){ ! ! ArrayList Values = new ArrayList(); ! ! Enumeration enum1 = GUInodeTable.keys(); ! ! while(enum1.hasMoreElements()){ ! ! String key = (String)enum1.nextElement(); ! ! GuiNode tempNode = (GuiNode)GUInodeTable.get(key); ! ! if(tempNode instanceof NetworkLayerDevice){ ! ! Values.add(key); ! ! } ! ! } ! ! nodesArray = Values.toArray(); ! ! ! ! //Else pass the selected node name ! ! }else{ ! ! nodesArray = new Object[1]; ! ! nodesArray[0] = inNodeName; ! ! selectedIndex = 0; ! ! } ! ! ! ! //test that there are any node within the simulation ! ! if(nodesArray.length != 0){ ! ! new breakLinkDialog(this,nodesArray,selectedIndex,Sim,Sandbox); ! ! this.refreshNodeInformationTab(); ! ! }else ! ! JOptionPane.showMessageDialog(this,"There are currently no node's within the simulation","Warning!",JOptionPane.WARNING_MESSAGE); ! ! } ! ! ! --- 1492,1496 ---- ! *************** *** 1575,1579 **** { - Object[] nodesArray = null; --- 1508,1511 ---- *************** *** 1754,1758 **** public void addFakeLine(Point inPosition){ ! Sandbox.addLine(LinkLayerPanel.FAKELINE, inPosition, inPosition); } --- 1686,1690 ---- public void addFakeLine(Point inPosition){ ! Sandbox.addLine(LinkLayerPanel.FAKELINE, inPosition, inPosition, 0); } *************** *** 2474,2478 **** String strLinkName = iface[1]; ! if(deviceType==2){ if(!iface[2].contains("null")){ --- 2406,2410 ---- String strLinkName = iface[1]; ! if(deviceType==2 && !iface[2].contains("Not Applicable")){ if(!iface[2].contains("null")){ *************** *** 3037,3044 **** String strDefGate = (String)LineData.elementAt(1); String strInterfaceName = (String)LineData.elementAt(2); ! String strMAC = (String)LineData.elementAt(3); ! String strIP = (String)LineData.elementAt(4); ! String strSubnet = (String)LineData.elementAt(5); ! String strLinkName = (String)LineData.elementAt(6); if(!strCurrentNodeName.equals(strNodeName)) --- 2969,2977 ---- String strDefGate = (String)LineData.elementAt(1); String strInterfaceName = (String)LineData.elementAt(2); ! String strInterfaceType = (String)LineData.elementAt(3); ! String strMAC = (String)LineData.elementAt(4); ! String strIP = (String)LineData.elementAt(5); ! String strSubnet = (String)LineData.elementAt(6); ! String strLinkName = (String)LineData.elementAt(7); if(!strCurrentNodeName.equals(strNodeName)) *************** *** 3054,3057 **** --- 2987,2991 ---- out.append("\t<TR bgColor=#CCCCCC>\r\n"); out.append("\t<TD>Interface: " + strInterfaceName + "</TD>\r\n" + + "\t<TD>Type: " + strInterfaceType + "</TD>\r\n" + "\t<TD>MAC address: " + strMAC + "</TD>\r\n" + "\t<TD>IP address: " + strIP + "</TD>\r\n" + *************** *** 3236,3331 **** clearNodeInformation(); ! ! Enumeration enu = GUInodeTable.keys(); ! ! String strCurrentNodeName = ""; ! ! ! ! while(enu.hasMoreElements()) ! ! { ! ! try ! ! { ! ! Vector NodeData = Sim.getAllNodeInformation((String)enu.nextElement()); ! ! Iterator it = NodeData.iterator(); ! ! pnlNodeInformation.append(pad("", 130, '*')+" \n"); ! ! ! ! while(it.hasNext()) ! ! { ! ! Vector LineData = (Vector)it.next(); ! ! String strNodeName = pad((String)LineData.elementAt(0), 25, ' '); ! ! String strDG = pad((String)LineData.elementAt(1), 20, ' '); ! ! String strInterfaceName = pad((String)LineData.elementAt(2), 15, ' '); ! ! String strMAC = pad((String)LineData.elementAt(3), 25, ' '); ! ! String strIP = pad((String)LineData.elementAt(4), 25, ' '); ! ! String strSubnet = pad((String)LineData.elementAt(5), 20, ' '); ! ! String strLinkName = pad((String)LineData.elementAt(6), 45, ' '); ! ! ! ! ! ! if(!strCurrentNodeName.equals(strNodeName)) ! ! { ! ! ! ! strCurrentNodeName = strNodeName; ! ! pnlNodeInformation.append("Information for : " + strNodeName); ! ! pnlNodeInformation.append(" Default Gateway : " + strDG + "\n\n"); ! ! pnlNodeInformation.append("\tInterface MAC Address IP Address Subnet Mask Link Name \n"); ! ! } ! ! ! ! pnlNodeInformation.append("\t" + strInterfaceName); ! ! pnlNodeInformation.append(strMAC); ! ! pnlNodeInformation.append(strIP); ! ! pnlNodeInformation.append(strSubnet); ! ! pnlNodeInformation.append(strLinkName); ! ! pnlNodeInformation.append("\n"); ! ! ! ! } ! ! } ! ! catch(Exception e) ! ! { ! ! ! ! } ! ! } } --- 3170,3179 ---- clearNodeInformation(); ! ! StringBuffer temp = generate_html_node_info(); ! ! pnlNodeInformation.setContentType("text/html"); ! pnlNodeInformation.setText(temp.toString()); ! pnlNodeInformation.setEditable(false); } *************** *** 4097,4110 **** htmlText = htmlText + "<table border='0' cellpadding='1' cellspacing='5'>"; ! htmlText = htmlText + "<tr><td>Interface</td><td>MAC</td><td>IP</td><td>Netmask</td><td>Link To</td></tr>"; for(int i=0; i<VectorMasterList.size(); i++){ htmlText = htmlText + "<tr>"; ! Vector vecInterfaceInfo = (Vector) VectorMasterList.get(i); htmlText = htmlText + "<td>" + vecInterfaceInfo.get(2) + "</td>"; htmlText = htmlText + "<td>" + vecInterfaceInfo.get(3) + "</td>"; htmlText = htmlText + "<td>" + vecInterfaceInfo.get(4) + "</td>"; htmlText = htmlText + "<td>" + vecInterfaceInfo.get(5) + "</td>"; ! String lnk = (String) vecInterfaceInfo.get(6); lnk = lnk.replaceAll("-TO-" + inNodeName,""); lnk = lnk.replaceAll(inNodeName + "-TO-",""); --- 3945,3959 ---- htmlText = htmlText + "<table border='0' cellpadding='1' cellspacing='5'>"; ! htmlText = htmlText + "<tr><td>Interface</td><td>Type</td><td>MAC</td><td>IP</td><td>Netmask</td><td>Link To</td></tr>"; for(int i=0; i<VectorMasterList.size(); i++){ htmlText = htmlText + "<tr>"; ! Vector vecInterfaceInfo = (Vector) VectorMasterList.get(i); htmlText = htmlText + "<td>" + vecInterfaceInfo.get(2) + "</td>"; htmlText = htmlText + "<td>" + vecInterfaceInfo.get(3) + "</td>"; htmlText = htmlText + "<td>" + vecInterfaceInfo.get(4) + "</td>"; htmlText = htmlText + "<td>" + vecInterfaceInfo.get(5) + "</td>"; ! htmlText = htmlText + "<td>" + vecInterfaceInfo.get(6) + "</td>"; ! String lnk = (String) vecInterfaceInfo.get(7); lnk = lnk.replaceAll("-TO-" + inNodeName,""); lnk = lnk.replaceAll(inNodeName + "-TO-",""); *************** *** 4252,4256 **** */ ! public Cursor getCurrentSandboxCursor() --- 4101,4138 ---- */ ! public Object[] getInterfaces(String NodeName) throws InvalidNodeNameException{ ! Object nics[] = Sim.getAllInterfaces(NodeName); //Get object array of interface names ! Arrays.sort(nics); ! return nics; ! } ! ! public void showIntProps(String NodeName, String IntName){ ! try{ ! Node temp = Sim.getNode(NodeName); ! int itype = temp.getIntType(IntName); ! ! switch(itype){ ! case core.NetworkInterface.Ethernet10T: ! new EthPortProperties(this,NodeName, IntName,Sim,Sandbox); ! break; ! default: ! break; ! } ! ! this.refreshNodeInformationTab(); ! }catch(Exception e){ } ! } ! ! public void breakLink(String NodeName, String IntName){ ! if(JOptionPane.showConfirmDialog(this,"Disconnect link from port " + IntName + " on " + NodeName + "?","Confirm disconnect!",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION){ ! try{ ! String str = Sim.disconnectLink(NodeName, IntName); ! Sandbox.removeLine(str); ! this.refreshNodeInformationTab(); ! //controller.addToConsole(NodeName +"'s link on interface "+Interface+" has been disconnected!\n"); ! //^^^FIXME! ! }catch(Exception e){ } ! } ! } public Cursor getCurrentSandboxCursor() Index: GuiNode.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiNode.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuiNode.java 14 Sep 2007 11:14:51 -0000 1.3 --- GuiNode.java 13 Oct 2007 12:57:00 -0000 1.4 *************** *** 121,124 **** --- 121,125 ---- protected JLabel lblIcon = new JLabel(); + protected String tmpName = ""; *************** *** 143,149 **** private JMenuItem mnuTurn = new JMenuItem("Turn Off"); ! private JMenuItem mnuLink = new JMenuItem("Links properties"); ! ! private JMenuItem mnuBreakLink = new JMenuItem("Break link"); private String strNodeName; --- 144,152 ---- private JMenuItem mnuTurn = new JMenuItem("Turn Off"); ! private JMenu mnuBreakLink = new JMenu("Disconnect link:"); ! ! private JMenuItem mnuLink = new JMenuItem("Links properties"); ! ! private JMenu mnuInt = new JMenu("Interface properties:"); private String strNodeName; *************** *** 302,315 **** }); ! mnuBreakLink.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.showBreakLinkDialog(lblNodeName.getText()); ! } ! }); mnuLink.addActionListener(new ActionListener(){ --- 305,343 ---- }); + ! try{ ! Object ints[] = controller.getInterfaces(lblNodeName.getText()); ! for(int i = 0; i < ints.length; i++){ ! JMenuItem mnuI = new JMenuItem((String) ints[i]); ! mnuI.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! ! controller.showIntProps(lblNodeName.getText(), ((JMenuItem)e.getSource()).getText()); ! } ! }); ! mnuInt.add(mnuI); ! ! JMenuItem mnuDI = new JMenuItem((String) ints[i]); ! mnuDI.addActionListener(new ActionListener(){ ! ! public void actionPerformed(ActionEvent e){ ! ! controller.breakLink(lblNodeName.getText(), ((JMenuItem)e.getSource()).getText()); ! ! } ! ! }); ! mnuBreakLink.add(mnuDI); ! } ! ! }catch(Exception e){ ! e.printStackTrace(); ! } ! mnuLink.addActionListener(new ActionListener(){ *************** *** 322,329 **** }); GuiNodePopMenu.add(mnuDelete); GuiNodePopMenu.add(mnuTurn); - GuiNodePopMenu.add(mnuLink); GuiNodePopMenu.add(mnuBreakLink); mnuTurn.addActionListener(new ActionListener(){ --- 350,359 ---- }); + GuiNodePopMenu.add(mnuDelete); GuiNodePopMenu.add(mnuTurn); GuiNodePopMenu.add(mnuBreakLink); + GuiNodePopMenu.add(mnuLink); + GuiNodePopMenu.add(mnuInt); mnuTurn.addActionListener(new ActionListener(){ *************** *** 651,655 **** boolean ena = controller.isOn(lblNodeName.getText()); for(int i=2; i< GuiNodePopMenu.getSubElements().length; i++){ ! ((JMenuItem)GuiNodePopMenu.getSubElements()[i]).setEnabled(ena); } GuiNodePopMenu.show(e.getComponent(),e.getX(),e.getY()); --- 681,685 ---- boolean ena = controller.isOn(lblNodeName.getText()); for(int i=2; i< GuiNodePopMenu.getSubElements().length; i++){ ! ((JMenuItem)GuiNodePopMenu.getSubElements()[i]).setEnabled(ena); } GuiNodePopMenu.show(e.getComponent(),e.getX(),e.getY()); |
From: Alexander B. <da...@us...> - 2007-10-13 12:57:06
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30660 Modified Files: CVS_STRUCT.txt README.txt TODO.txt linux.sh windows.bat Log Message: Multiple changes in Link Layer, added DHCP D/C prototype, broadcast packets (+ forwarding), changed menu structure, added MAC address editing, Serial link type and more... Index: linux.sh =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/linux.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** linux.sh 26 Oct 2006 17:06:10 -0000 1.2 --- linux.sh 13 Oct 2007 12:57:00 -0000 1.3 *************** *** 1,2 **** #!/bin/sh ! java -jar javaNetSim.jar \ No newline at end of file --- 1,2 ---- #!/bin/sh ! java -Xss50m -Xoss100m -jar javaNetSim.jar \ No newline at end of file Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** TODO.txt 14 Sep 2007 15:30:08 -0000 1.23 --- TODO.txt 13 Oct 2007 12:57:00 -0000 1.24 *************** *** 8,16 **** 4. VPN-client/VPN-gateway (sockets, RMI and Corba mechanisms) (or PPP Client/PPP Gateway -- ??) 5. Second level Switches (VLAN, etc...) - 6. Normal SocketLayer (instead of current ugly mechanism) 7. Firewalls (NAT, PAT, etc) 8. Access-lists in Firewalls/Routers/PCs ! 9. DHCP server/clients, DNS. ! 10. Wi-Fi Access-Points and Wi-Fi adapters in PCs *** Documentation/Comments --- 8,16 ---- 4. VPN-client/VPN-gateway (sockets, RMI and Corba mechanisms) (or PPP Client/PPP Gateway -- ??) 5. Second level Switches (VLAN, etc...) 7. Firewalls (NAT, PAT, etc) 8. Access-lists in Firewalls/Routers/PCs ! 9. DHCP server/clients : main engine, re-leasing. ! 10. DNS server/clents. ! 11. Wi-Fi Access-Points and Wi-Fi adapters in PCs *** Documentation/Comments Index: CVS_STRUCT.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/CVS_STRUCT.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CVS_STRUCT.txt 16 Sep 2007 19:22:15 -0000 1.1 --- CVS_STRUCT.txt 13 Oct 2007 12:57:00 -0000 1.2 *************** *** 5,9 **** Branches: ! * MAIN branch. Current (new, exprimental, non-stable) sources. Experiments should be made here. * STABLE* -- stable releases. Stabling here. ! * STABLE-0_33 \ No newline at end of file --- 5,10 ---- Branches: ! * MAIN branch. Current (new, experimental, non-stable) sources. Experiments should be made here. * STABLE* -- stable releases. Stabling here. ! * STABLE-0_33 ! * STABLE-0_34 \ No newline at end of file Index: README.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/README.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** README.txt 14 Sep 2007 15:30:08 -0000 1.12 --- README.txt 13 Oct 2007 12:57:00 -0000 1.13 *************** *** 3,7 **** ################################### ! Version: Public Release Version 0.33 Website: http://sf.net/projects/javanetsim Authors: See 'About' menu. --- 3,7 ---- ################################### ! Version: Public Release Version 0.34 Website: http://sf.net/projects/javanetsim Authors: See 'About' menu. *************** *** 32,35 **** --- 32,49 ---- ********************* + ***** Release Version 0.34 1th October 2007 ***** + + Fixed + ----- + + GUI Issues - + + 1. More Java 6 related diaglog fixes. + + New Features + ------------ + + 1. TCP & UDP protocol fully rewritten with socket layer. + ***** Release Version 0.33 16th September 2007 ***** Index: windows.bat =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/windows.bat,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** windows.bat 12 Oct 2006 15:21:23 -0000 1.3 --- windows.bat 13 Oct 2007 12:57:00 -0000 1.4 *************** *** 1,2 **** rem Java > 1.5 ! java -jar javaNetSim.jar --- 1,2 ---- rem Java > 1.5 ! java -Xss50m -Xoss100m -jar javaNetSim.jar |