javanetsim-cvs Mailing List for javaNetSim (Page 7)
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
|
From: QweR <qw...@us...> - 2007-11-20 20:07:24
|
Update of /cvsroot/javanetsim/javaNetSim/images/simulation In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23411/images/simulation Added Files: router.png Log Message: --- NEW FILE: router.png --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/javanetsim/javaNetSim/images/simulation In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22265/images/simulation Removed Files: PC_large.gif hub_large.png router1.gif router2.jpg router_large.gif router_large.png server.jpg switch1.jpg Log Message: Images deleted... --- server.jpg DELETED --- --- router_large.gif DELETED --- --- switch1.jpg DELETED --- --- router2.jpg DELETED --- --- router1.gif DELETED --- --- router_large.png DELETED --- --- hub_large.png DELETED --- --- PC_large.gif DELETED --- |
From: QweR <qw...@us...> - 2007-11-20 19:54:09
|
Update of /cvsroot/javanetsim/javaNetSim/images/simulation In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17313/images/simulation Removed Files: Router.png Log Message: ip parameters for serial interfaces are saving --- Router.png DELETED --- |
From: QweR <qw...@us...> - 2007-11-20 19:54:06
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17313/core Modified Files: DeviceConfig.java Log Message: ip parameters for serial interfaces are saving Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DeviceConfig.java 17 Nov 2007 21:38:58 -0000 1.9 --- DeviceConfig.java 20 Nov 2007 19:53:03 -0000 1.10 *************** *** 416,420 **** if(eni!=null && !eni.getMACAddress().equalsIgnoreCase(eni.defaultMACAddress)) conf.add("interface "+intName+" mac-address "+eni.getMACAddress()); ! if(eni!=null && device.getIPAddress((String)ins[i])!=null && !device.getIPAddress((String)ins[i]).equals("")) conf.add("interface "+intName+" ip address "+device.getIPAddress((String)ins[i])+" "+device.getSubnetMask((String)ins[i])); if(sni!=null && sni.getClockRate()!=sni.DEFAULT_CLOCKRATE) --- 416,420 ---- if(eni!=null && !eni.getMACAddress().equalsIgnoreCase(eni.defaultMACAddress)) conf.add("interface "+intName+" mac-address "+eni.getMACAddress()); ! if((eni!=null || sni!=null) && device.getIPAddress((String)ins[i])!=null && !device.getIPAddress((String)ins[i]).equals("")) conf.add("interface "+intName+" ip address "+device.getIPAddress((String)ins[i])+" "+device.getSubnetMask((String)ins[i])); if(sni!=null && sni.getClockRate()!=sni.DEFAULT_CLOCKRATE) |
From: Alexander B. <da...@us...> - 2007-11-20 19:17:18
|
Update of /cvsroot/javanetsim/javaNetSim/images/simulation In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3154/images/simulation Removed Files: link.png Log Message: Minor bugs in WAN interfaces fixed... --- link.png DELETED --- |
From: Alexander B. <da...@us...> - 2007-11-20 19:17:15
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3154/core Modified Files: Version.java WANCorbaClient.java WANCorbaServer.java WANDatagram.java WANNetworkInterface.java Log Message: Minor bugs in WAN interfaces fixed... Index: WANNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANNetworkInterface.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WANNetworkInterface.java 19 Nov 2007 18:37:07 -0000 1.7 --- WANNetworkInterface.java 20 Nov 2007 19:17:09 -0000 1.8 *************** *** 188,214 **** System.out.println(ptype); ! switch(ptype){ ! case 'M': ! ICMP_packet icmp = new ICMP_packet(""); ! icmp.fromBytes(inPacket); ! receivePacket(icmp); ! break; ! case 'I': ! IP_packet ip = new IP_packet(""); ! ip.fromBytes(inPacket); ! receivePacket(ip); ! break; ! case 'T': ! TCP_packet tcp = new TCP_packet("","",0,0); ! tcp.fromBytes(inPacket); ! receivePacket(tcp); ! break; ! case 'U': ! UDP_packet udp = new UDP_packet("","",0,0); ! udp.fromBytes(inPacket); ! receivePacket(udp); ! break; } - } --- 188,217 ---- System.out.println(ptype); ! try{ ! switch(ptype){ ! case 'M': ! ICMP_packet icmp = new ICMP_packet(""); ! icmp.fromBytes(inPacket); ! receivePacket(icmp); ! break; ! case 'I': ! IP_packet ip = new IP_packet(""); ! ip.fromBytes(inPacket); ! receivePacket(ip); ! break; ! case 'T': ! TCP_packet tcp = new TCP_packet("","",0,0); ! tcp.fromBytes(inPacket); ! receivePacket(tcp); ! break; ! case 'U': ! UDP_packet udp = new UDP_packet("","",0,0); ! udp.fromBytes(inPacket); ! receivePacket(udp); ! break; ! } ! }catch(Exception e){ ! //nothing to do.... } } *************** *** 265,269 **** case RMI: { ! RMIServer = new WANRMIServer(this); Naming.bind (name, RMIServer); return true; --- 268,272 ---- case RMI: { ! RMIServer = new WANRMIServer(this); Naming.bind (name, RMIServer); return true; *************** *** 272,276 **** case Corba: { ! CORBAServer = new WANCorbaServer(this, name); return true; } --- 275,279 ---- case Corba: { ! CORBAServer = new WANCorbaServer(this, Host, port, name); return true; } *************** *** 311,315 **** RMIClient = null; RMIClient = (WANRMI) Naming.lookup ! ("rmi://" + Host + "/" + Service); RMIClient.setServiceName(name); --- 314,318 ---- RMIClient = null; RMIClient = (WANRMI) Naming.lookup ! ("rmi://" + Host + ":" + port + "/" + Service); RMIClient.setServiceName(name); *************** *** 325,329 **** } CORBAClient = new WANCorbaClient(this); ! CORBAClient.Connect(Service); CORBAClient.setServiceName(name); --- 328,332 ---- } CORBAClient = new WANCorbaClient(this); ! CORBAClient.Connect(Host, port, Service); CORBAClient.setServiceName(name); Index: Version.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Version.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Version.java 15 Oct 2007 18:25:54 -0000 1.14 --- Version.java 20 Nov 2007 19:17:09 -0000 1.15 *************** *** 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","", --- 40,48 ---- */ public class Version { ! public final static String CORE_VERSION = "v0.39"; //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: 20 Nov 2007", "", "fork of jFirewallSim project (http://sf.net/projects/jfirewallsim/)", "from 03 Nov 2005","", Index: WANCorbaClient.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANCorbaClient.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WANCorbaClient.java 19 Nov 2007 15:14:07 -0000 1.1 --- WANCorbaClient.java 20 Nov 2007 19:17:09 -0000 1.2 *************** *** 28,34 **** } ! public void Connect(String service){ try{ ! String args[] = {"","-ORBInitialPort","1050","-ORBInitialHost","localhost"}; orb = ORB.init(args, null); --- 28,34 ---- } ! public void Connect(String ORBHostname, int ORBPort, String service){ try{ ! String args[] = {"","-ORBInitialPort",String.valueOf(ORBPort),"-ORBInitialHost",ORBHostname}; orb = ORB.init(args, null); Index: WANCorbaServer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANCorbaServer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WANCorbaServer.java 19 Nov 2007 15:10:28 -0000 1.2 --- WANCorbaServer.java 20 Nov 2007 19:17:09 -0000 1.3 *************** *** 47,53 **** WANNetworkInterface parentInterface; ! public WANCorbaServer(WANNetworkInterface inParentInterface, String name) { parentInterface = inParentInterface; ! String args[] = {"","-ORBInitialPort","1050","-ORBInitialHost","localhost"}; parentInterface.addLayerInfo("Wan interface", "Starting CORBA Server..."); orb = ORB.init(args, null); --- 47,53 ---- WANNetworkInterface parentInterface; ! public WANCorbaServer(WANNetworkInterface inParentInterface, String ORBHostname, int ORBPort, String name) { parentInterface = inParentInterface; ! String args[] = {"","-ORBInitialPort",String.valueOf(ORBPort),"-ORBInitialHost",ORBHostname}; parentInterface.addLayerInfo("Wan interface", "Starting CORBA Server..."); orb = ORB.init(args, null); Index: WANDatagram.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANDatagram.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WANDatagram.java 19 Nov 2007 18:37:07 -0000 1.1 --- WANDatagram.java 20 Nov 2007 19:17:09 -0000 1.2 *************** *** 49,52 **** --- 49,53 ---- }else{ s = new DatagramSocket(); + sendPacket("P#"); } *************** *** 134,140 **** DatagramPacket packet = new DatagramPacket(buf, buf.length); ! s.receive(packet); ! w.recievePacket(new String(packet.getData())); } --- 135,143 ---- DatagramPacket packet = new DatagramPacket(buf, buf.length); ! s.receive(packet); ! setClientAddress(packet.getAddress().getHostAddress(), packet.getPort()); ! ! w.recievePacket((new String(packet.getData(),"ascii")).substring(0, packet.getLength())); } |
From: Alexander B. <da...@us...> - 2007-11-20 19:17:15
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3154 Modified Files: README.txt TODO.txt Log Message: Minor bugs in WAN interfaces fixed... Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** TODO.txt 10 Nov 2007 13:25:38 -0000 1.28 --- TODO.txt 20 Nov 2007 19:17:09 -0000 1.29 *************** *** 4,8 **** *** Whole Project - 2. Add (UDPz sockets, RMI and Corba mechanisms) to CSU/DSU units 3. DHCP server/clients : re-leasing, MAC-filter and excludes. 4. Socks Proxy(old -- Nat Gateway) to external network. --- 4,7 ---- *************** *** 10,14 **** 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 --- 9,12 ---- Index: README.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/README.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** README.txt 19 Oct 2007 15:57:00 -0000 1.14 --- README.txt 20 Nov 2007 19:17:09 -0000 1.15 *************** *** 32,35 **** --- 32,45 ---- ********************* + ***** Release Version 0.39 20rd November 2007 ***** + + New Features + ------------ + + 1. CSU/DSU unit new connection types: RMI, CORBA, UDP. + 2. Addded printers. + 3. Added access-lists. + 4. New devices subtypes for Hubs, Switches and Routers. + ***** Release Version 0.38 3rd November 2007 ***** |
From: Alexander B. <da...@us...> - 2007-11-20 19:17:14
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3154/guiUI Modified Files: GuiRouter.java WANPortProperties.java Log Message: Minor bugs in WAN interfaces fixed... Index: WANPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/WANPortProperties.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WANPortProperties.java 19 Nov 2007 15:10:28 -0000 1.3 --- WANPortProperties.java 20 Nov 2007 19:17:09 -0000 1.4 *************** *** 349,358 **** cmbRole = new JComboBox(); ! /*cmbRole.addFocusListener(new FocusAdapter() { ! public void actionPerformed(ActionEvent e) { ! //lblError.setVisible(false); ! } ! });*/ ! cmbRole.setEnabled(true); final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints(); --- 349,353 ---- cmbRole = new JComboBox(); ! cmbRole.setEnabled(true); final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints(); *************** *** 450,453 **** --- 445,455 ---- } }); + + cmbRole.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + selectRole(); + lblError.setVisible(false); + } + }); selectWANType(); *************** *** 459,462 **** --- 461,486 ---- } + private void selectRole(){ + switch(cmbType.getSelectedIndex() + 1){ + case WANNetworkInterface.RMI: + if(cmbRole.getSelectedIndex() == 1){ + txtService.setText(""); + txtService.setEnabled(false); + txtPort.setEnabled(false); + txtPort.setText("1099"); + }else{ + txtService.setEnabled(true); + txtPort.setEnabled(true); + } + break; + case WANNetworkInterface.Corba: + if(cmbRole.getSelectedIndex() == 1){ + txtService.setEnabled(false); + txtService.setText(""); + }else + txtService.setEnabled(true); + break; + } + } private void selectWANType(){ *************** *** 473,488 **** case WANNetworkInterface.RMI: cmbRole.setEnabled(true); ! txtHost.setEnabled(true); ! txtPort.setEnabled(false); ! txtPort.setText(""); ! txtService.setEnabled(true); ! break; ! case WANNetworkInterface.Corba: cmbRole.setEnabled(true); ! txtHost.setEnabled(false); ! txtPort.setEnabled(false); ! txtPort.setText(""); ! txtService.setEnabled(true); break; } --- 497,520 ---- case WANNetworkInterface.RMI: cmbRole.setEnabled(true); ! if(cmbRole.getSelectedIndex() == 1){ ! txtService.setText(""); ! txtService.setEnabled(false); ! txtPort.setEnabled(false); ! txtPort.setText("1099"); ! }else{ ! txtService.setEnabled(true); ! txtPort.setEnabled(true); ! } ! txtHost.setEnabled(true); ! break; case WANNetworkInterface.Corba: cmbRole.setEnabled(true); ! if(cmbRole.getSelectedIndex() == 1){ ! txtService.setText(""); ! txtService.setEnabled(false); ! }else ! txtService.setEnabled(true); ! txtHost.setEnabled(true); ! txtPort.setEnabled(true); break; } *************** *** 496,519 **** private void okButton(){ try { ! switch(cmbType.getSelectedIndex() + 1){ ! case WANNetworkInterface.SocketTCP: ! case WANNetworkInterface.SocketUDP: ! if(!txtPort.getText().matches("[0-9]+")){ ! JOptionPane.showMessageDialog(this,"Invalid Port", "Error!", JOptionPane.ERROR_MESSAGE); ! return; ! } ! wan.setConnType(cmbType.getSelectedIndex() + 1); ! wan.setConnHost(txtHost.getText()); ! wan.setConnPort(Integer.valueOf(txtPort.getText())); ! wan.setServer( cmbRole.getSelectedIndex() == 1 ); ! break; ! ! case WANNetworkInterface.RMI: ! case WANNetworkInterface.Corba: ! wan.setConnType(cmbType.getSelectedIndex() + 1); ! wan.setConnHost(txtHost.getText()); ! wan.setConnService(txtService.getText()); ! break; ! } if(wan.isUP()) wan.DOWN(); --- 528,542 ---- private void okButton(){ try { ! if(!txtPort.getText().matches("[0-9]+")){ ! JOptionPane.showMessageDialog(this,"Invalid Port", "Error!", JOptionPane.ERROR_MESSAGE); ! return; ! } ! wan.setConnType(cmbType.getSelectedIndex() + 1); ! wan.setConnHost(txtHost.getText()); ! wan.setConnPort(Integer.valueOf(txtPort.getText())); ! wan.setServer( cmbRole.getSelectedIndex() == 1 ); ! wan.setConnType(cmbType.getSelectedIndex() + 1); ! wan.setConnHost(txtHost.getText()); ! wan.setConnService(txtService.getText()); if(wan.isUP()) wan.DOWN(); Index: GuiRouter.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiRouter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuiRouter.java 15 Oct 2007 18:25:54 -0000 1.3 --- GuiRouter.java 20 Nov 2007 19:17:09 -0000 1.4 *************** *** 89,93 **** public GuiRouter(String inName, MainScreen inMainScreen){ ! super(inName, inMainScreen,"images/simulation/Router.png"); // router_large.gif } --- 89,93 ---- public GuiRouter(String inName, MainScreen inMainScreen){ ! super(inName, inMainScreen,"images/simulation/router.png"); // router_large.gif } |
From: Alexander B. <da...@us...> - 2007-11-19 18:37:10
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6445/core Modified Files: WANNetworkInterface.java Added Files: WANDatagram.java Log Message: UDP Transport added for WANs... Index: WANNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANNetworkInterface.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WANNetworkInterface.java 19 Nov 2007 15:10:28 -0000 1.6 --- WANNetworkInterface.java 19 Nov 2007 18:37:07 -0000 1.7 *************** *** 61,64 **** --- 61,65 ---- protected WANSocket s; + protected WANDatagram d; /* Interface properties setup functions */ *************** *** 225,230 **** RMIClient.recievePacket(inPacket.toBytes()); break; - case SocketTCP: case SocketUDP: s.sendPacket(inPacket.toBytes()); break; --- 226,233 ---- RMIClient.recievePacket(inPacket.toBytes()); break; case SocketUDP: + d.sendPacket(inPacket.toBytes()); + break; + case SocketTCP: s.sendPacket(inPacket.toBytes()); break; *************** *** 273,279 **** } - case SocketTCP: case SocketUDP: if(server){ s = new WANSocket(this, Host, port, server); return s.listen(); --- 276,288 ---- } case SocketUDP: if(server){ + d = new WANDatagram(this, Host, port, server); + return d.listen(); + }else{ + return false; + } + case SocketTCP: + if(server){ s = new WANSocket(this, Host, port, server); return s.listen(); *************** *** 332,337 **** } case SocketUDP: ! //nothing to do... ! break; } }catch(Exception e){ --- 341,351 ---- } case SocketUDP: ! if(!server){ ! d = new WANDatagram(this, Host, port, server); ! connected = d.connect(); ! return connected; ! }else{ ! return false; ! } } }catch(Exception e){ *************** *** 361,366 **** } break; - case SocketTCP: case SocketUDP: if(s!= null) s.close(); s = null; --- 375,383 ---- } break; case SocketUDP: + if(d!= null) d.close(); + d = null; + break; + case SocketTCP: if(s!= null) s.close(); s = null; --- NEW FILE: WANDatagram.java --- (This appears to be a binary file; contents omitted.) |
From: Alexander B. <da...@us...> - 2007-11-19 15:14:10
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22775/core Added Files: WANCorbaClient.java Log Message: Nessessary files for CORBA... --- NEW FILE: WANCorbaClient.java --- (This appears to be a binary file; contents omitted.) |
From: Alexander B. <da...@us...> - 2007-11-19 15:10:39
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21171/core/protocolsuite/tcp_ip Modified Files: Tcp.java Log Message: CORBA interface for WAN fully added. Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** Tcp.java 17 Nov 2007 21:38:58 -0000 1.104 --- Tcp.java 19 Nov 2007 15:10:28 -0000 1.105 *************** *** 248,252 **** private Timer timer; private PriorityQueue tcp_timers = new PriorityQueue(); ! private int window_size = 2; //tcp window-size for new sessions private Object tcp_timers_lock = new Object(); //for locking queue tcp_timers private int current_time = 0; --- 248,252 ---- 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; |
From: Alexander B. <da...@us...> - 2007-11-19 15:10:33
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21171/core Modified Files: EthernetLink.java WANCorbaServer.java WANNetworkInterface.java WANSocket.java Log Message: CORBA interface for WAN fully added. Index: EthernetLink.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetLink.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** EthernetLink.java 11 Nov 2007 19:51:57 -0000 1.13 --- EthernetLink.java 19 Nov 2007 15:10:28 -0000 1.14 *************** *** 42,45 **** --- 42,46 ---- public class EthernetLink extends Link { java.security.SecureRandom rng; + /** * Constructor to be used by the Simulation when connecting 2 PC's *************** *** 51,57 **** * @param inInterface2 The Seceond Interface to connect this link to eg: eth1 * @throws InvalidLinkConnectionException ! */ ! ! public EthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); --- 52,57 ---- * @param inInterface2 The Seceond Interface to connect this link to eg: eth1 * @throws InvalidLinkConnectionException ! */ ! public EthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface)throws InvalidLinkConnectionException { super(inName); NetworkInterfaces.add(inFirstNodeInterface); *************** *** 68,71 **** --- 68,72 ---- inFirstNodeInterface.setConnectedLink(this); inSecondNodeInterface.setConnectedLink(this); + rng = new java.security.SecureRandom(); this.setSC(sieveCoeff); rng = new java.security.SecureRandom(); Index: WANNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANNetworkInterface.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WANNetworkInterface.java 10 Nov 2007 13:25:38 -0000 1.5 --- WANNetworkInterface.java 19 Nov 2007 15:10:28 -0000 1.6 *************** *** 57,62 **** --- 57,67 ---- protected WANRMI RMIClient; + protected WANCorbaServer CORBAServer; + protected WANCorbaClient CORBAClient; + protected WANSocket s; + /* Interface properties setup functions */ + public void setServer(boolean inServer){ server = inServer; *************** *** 99,102 **** --- 104,111 ---- } + /* /Interface properties setup functions */ + + /* Standart javaNetSim interface functions */ + public void UP(){ up = listen(); *************** *** 112,115 **** --- 121,139 ---- } + public int getType(){ + return NetworkInterface.WAN; + } + + public boolean isActive(){ + return true; + } + + + protected String getDetails(){ + return "Interface: "+name; + } + + /* /Standart javaNetSim interface functions */ + public WANNetworkInterface(String inName, Node parent) { super(inName, parent); *************** *** 125,131 **** } public void receivePacket(Packet inPacket) throws LowLinkException { - // cast the packet to an EthernetPacket - //Ethernet_packet tempPacket = (Ethernet_packet)inPacket; switch(type){ case RMI: --- 149,154 ---- } + // forwards packet to device stack public void receivePacket(Packet inPacket) throws LowLinkException { switch(type){ case RMI: *************** *** 136,139 **** --- 159,169 ---- } break; + case Corba: + { + if(!connected){ + connect(); + } + } + break; case SocketTCP: case SocketUDP: *************** *** 143,150 **** addLayerInfo("WAN Packet","Recieved and accepted packet at interface " + name); ! parentNode.receivePacket(inPacket, name); } public void receivePacket(String inPacket) throws LowLinkException{ System.out.println(inPacket); --- 173,181 ---- addLayerInfo("WAN Packet","Recieved and accepted packet at interface " + name); ! parentNode.receivePacket(inPacket, name); } + // decode recieved packet to Packet class public void receivePacket(String inPacket) throws LowLinkException{ System.out.println(inPacket); *************** *** 180,188 **** } ! ! public int getType(){ ! return NetworkInterface.WAN; ! } ! protected void sendPacket(Packet inPacket) throws LowLinkException { if(!connected){ --- 211,216 ---- } ! ! // sending packet through WAN interface protected void sendPacket(Packet inPacket) throws LowLinkException { if(!connected){ *************** *** 199,205 **** case SocketTCP: case SocketUDP: ! ! s.sendPacket(inPacket); break; } }catch(Exception e){ --- 227,235 ---- case SocketTCP: case SocketUDP: ! s.sendPacket(inPacket.toBytes()); break; + case Corba: + CORBAClient.sendPacket(inPacket.toBytes()); + break; } }catch(Exception e){ *************** *** 210,217 **** --- 240,249 ---- } + // this is the same as upper function, MAC is ignored here protected void sendPacket(Packet inPacket, String inMacAddress) throws CommunicationException, LowLinkException { sendPacket(inPacket); } + // adding layerInfo public void addLayerInfo(String DataType, String Msg){ LayerInfo pingInfo = new LayerInfo(getClass().getName()); *************** *** 223,235 **** } ! public boolean isActive(){ ! return true; ! } ! ! ! protected String getDetails(){ ! return "Interface: "+name; ! } ! protected boolean listen(){ try{ --- 255,260 ---- } ! ! // starts listening on transport protected boolean listen(){ try{ *************** *** 242,245 **** --- 267,276 ---- } + case Corba: + { + CORBAServer = new WANCorbaServer(this, name); + return true; + } + case SocketTCP: case SocketUDP: *************** *** 252,255 **** --- 283,287 ---- } }catch(Exception e){ + addLayerInfo("Wan interface", "Unknown error during connect: " + e.toString()); e.printStackTrace(); } *************** *** 258,261 **** --- 290,294 ---- + // starts connecting through transport public boolean connect(){ try{ *************** *** 276,279 **** --- 309,326 ---- return true; } + case Corba: + { + if(Service == ""){ + //Error + return false; + } + CORBAClient = new WANCorbaClient(this); + CORBAClient.Connect(Service); + CORBAClient.setServiceName(name); + + connected = true; + + return true; + } case SocketTCP: if(!server){ *************** *** 294,297 **** --- 341,345 ---- } + // closing transport protected void close(){ try{ *************** *** 303,309 **** RMIServer = null; break; case SocketTCP: case SocketUDP: ! if(s!= null) s.Close(); s = null; break; --- 351,367 ---- RMIServer = null; break; + case Corba: + if(CORBAServer != null){ + CORBAServer.close(); + CORBAServer = null; + } + if(CORBAClient != null){ + CORBAClient.close(); + CORBAClient = null; + } + break; case SocketTCP: case SocketUDP: ! if(s!= null) s.close(); s = null; break; Index: WANCorbaServer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANCorbaServer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WANCorbaServer.java 10 Nov 2007 13:25:39 -0000 1.1 --- WANCorbaServer.java 19 Nov 2007 15:10:28 -0000 1.2 *************** *** 11,14 **** --- 11,20 ---- class WANCorbaImpl extends WANCorbaPOA { private ORB orb; + WANNetworkInterface parentInterface; + + public WANCorbaImpl(WANNetworkInterface inParentInterface){ + super(); + parentInterface = inParentInterface; + } public void setORB(ORB orb_val) { *************** *** 17,24 **** public void receivePacket (String inPacket){ System.out.println(inPacket); } public void setServiceName (String inService){ ! System.out.println(inService); } --- 23,37 ---- public void receivePacket (String inPacket){ + parentInterface.addLayerInfo("Wan interface", "Recieved packet from remote peer."); + try{ + parentInterface.receivePacket(inPacket); + }catch(Exception e){ + parentInterface.addLayerInfo("Wan interface", "LowLink Exception: " + e.toString()); + } System.out.println(inPacket); } public void setServiceName (String inService){ ! parentInterface.addLayerInfo("Wan interface", "Recieved peer service name " + inService); ! parentInterface.setConnService(inService); } *************** *** 32,40 **** public class WANCorbaServer { ORB orb; ! public WANCorbaServer(String name) { ! String args[] = {"",""}; orb = ORB.init(args, null); ! WANCorbaServerHandler wh = new WANCorbaServerHandler(orb, name); wh.start(); } --- 45,56 ---- public class WANCorbaServer { ORB orb; + WANNetworkInterface parentInterface; ! public WANCorbaServer(WANNetworkInterface inParentInterface, String name) { ! parentInterface = inParentInterface; ! String args[] = {"","-ORBInitialPort","1050","-ORBInitialHost","localhost"}; ! parentInterface.addLayerInfo("Wan interface", "Starting CORBA Server..."); orb = ORB.init(args, null); ! WANCorbaServerHandler wh = new WANCorbaServerHandler(orb, name, parentInterface); wh.start(); } *************** *** 42,45 **** --- 58,62 ---- public void close(){ if(orb!=null){ + parentInterface.addLayerInfo("Wan interface", "Shutting down CORBA Server..."); orb.shutdown(false); orb = null; *************** *** 49,54 **** class WANCorbaServerHandler extends Thread { ORB orb; ! WANCorbaServerHandler(ORB orb, String name) { try{ this.orb = orb; --- 66,75 ---- class WANCorbaServerHandler extends Thread { ORB orb; + boolean error; + WANNetworkInterface parentInterface; ! WANCorbaServerHandler(ORB orb, String name, WANNetworkInterface inParentInterface) { ! parentInterface = inParentInterface; ! error = false; try{ this.orb = orb; *************** *** 56,60 **** rootpoa.the_POAManager().activate(); ! WANCorbaImpl wImpl = new WANCorbaImpl(); wImpl.setORB(orb); --- 77,81 ---- rootpoa.the_POAManager().activate(); ! WANCorbaImpl wImpl = new WANCorbaImpl(parentInterface); wImpl.setORB(orb); *************** *** 70,84 **** NameComponent path[] = ncRef.to_name( name ); ncRef.rebind(path, href); } catch (Exception e) { e.printStackTrace(System.out); } } ! public void run() { try{ orb.run(); }catch (Exception e) { e.printStackTrace(System.out); } --- 91,115 ---- NameComponent path[] = ncRef.to_name( name ); ncRef.rebind(path, href); + + parentInterface.addLayerInfo("Wan interface", "Registered in NameService as " + name); } catch (Exception e) { + parentInterface.addLayerInfo("Wan interface", "Error during register in NameService as " + name + "; error: " + e.toString()); + error = true; e.printStackTrace(System.out); } } ! public void run() { ! if(error){ ! parentInterface.DOWN(); ! return; ! } try{ orb.run(); }catch (Exception e) { + parentInterface.addLayerInfo("Wan interface", "Error in CORBA Server: " + e.toString()); + parentInterface.DOWN(); e.printStackTrace(System.out); } Index: WANSocket.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANSocket.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WANSocket.java 10 Nov 2007 13:25:38 -0000 1.4 --- WANSocket.java 19 Nov 2007 15:10:28 -0000 1.5 *************** *** 74,78 **** } ! public void Close(){ try{ if(s!=null){ --- 74,78 ---- } ! public void close(){ try{ if(s!=null){ *************** *** 98,104 **** } ! public void sendPacket(Packet inPacket){ if(c != null){ ! out.println(inPacket.toBytes()); out.flush(); } --- 98,104 ---- } ! public void sendPacket(String inPacket){ if(c != null){ ! out.println(inPacket); out.flush(); } |
From: Alexander B. <da...@us...> - 2007-11-19 15:10:32
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21171/guiUI Modified Files: MainScreen.java WANPortProperties.java Log Message: CORBA interface for WAN fully added. Index: WANPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/WANPortProperties.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WANPortProperties.java 10 Nov 2007 13:25:39 -0000 1.2 --- WANPortProperties.java 19 Nov 2007 15:10:28 -0000 1.3 *************** *** 480,486 **** case WANNetworkInterface.Corba: ! cmbRole.setEnabled(false); ! txtHost.setEnabled(true); ! txtPort.setEnabled(true); txtPort.setText(""); txtService.setEnabled(true); --- 480,486 ---- case WANNetworkInterface.Corba: ! cmbRole.setEnabled(true); ! txtHost.setEnabled(false); ! txtPort.setEnabled(false); txtPort.setText(""); txtService.setEnabled(true); Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** MainScreen.java 11 Nov 2007 19:51:57 -0000 1.81 --- MainScreen.java 19 Nov 2007 15:10:28 -0000 1.82 *************** *** 616,619 **** --- 616,621 ---- core.ProtocolStack.UIDGen = 0; + + //Math.random() new SplashWindow("images/firewall.gif",2000); *************** *** 1649,1653 **** //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]); } --- 1651,1655 ---- //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]); } |
From: QweR <qw...@us...> - 2007-11-17 21:39:08
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8566/guiUI Modified Files: EthPortProperties.java SerPortProperties.java Terminal.java Log Message: console, ACLs and TCP fixed Index: EthPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/EthPortProperties.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EthPortProperties.java 20 Oct 2007 22:54:40 -0000 1.3 --- EthPortProperties.java 17 Nov 2007 21:38:58 -0000 1.4 *************** *** 310,319 **** temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); temp.getConfig().executeCommand("no int " + NodeInt + " shutdown"); ! temp.getConfig().remove("int " + NodeInt + " shutdown"); ! temp.getConfig().add("no int " + NodeInt + " shutdown"); }else{ temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); ! temp.getConfig().remove("int " + NodeInt + " shutdown"); ! temp.getConfig().add("no int " + NodeInt + " shutdown"); } --- 310,319 ---- temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); temp.getConfig().executeCommand("no int " + NodeInt + " shutdown"); ! // temp.getConfig().remove("int " + NodeInt + " shutdown"); ! // temp.getConfig().add("no int " + NodeInt + " shutdown"); }else{ temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); ! // temp.getConfig().remove("int " + NodeInt + " shutdown"); ! // temp.getConfig().add("no int " + NodeInt + " shutdown"); } Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Terminal.java 23 Oct 2007 20:14:48 -0000 1.7 --- Terminal.java 17 Nov 2007 21:38:58 -0000 1.8 *************** *** 42,45 **** --- 42,49 ---- public class Terminal extends JFrame { + protected final static int DEF_MODE = 0; + protected final static int IF_MODE = 1; + protected final static int ACL_MODE = 2; + private JPanel panel; private JScrollPane scrollpane; *************** *** 56,61 **** private int device_type; private CommandProcessor cmdproc; ! private boolean interface_mode = false; ! private String interface_name = ""; private clear_terminal_CommandClass clear_terminal_Command = new clear_terminal_CommandClass(); --- 60,65 ---- private int device_type; private CommandProcessor cmdproc; ! private int interface_mode = DEF_MODE; ! private String command_prefix = ""; private clear_terminal_CommandClass clear_terminal_Command = new clear_terminal_CommandClass(); *************** *** 65,68 **** --- 69,74 ---- private exit_CommandClass exit_Command = new exit_CommandClass(); private interface_CommandClass interface_Command = new interface_CommandClass(); + private ip_access_list_standart_CommandClass ip_access_list_standart_Command = new ip_access_list_standart_CommandClass(); + private ip_access_list_extended_CommandClass ip_access_list_extended_Command = new ip_access_list_extended_CommandClass(); private logout_CommandClass logout_Command = new logout_CommandClass(); private ping_CommandClass ping_Command = new ping_CommandClass(); *************** *** 92,95 **** --- 98,103 ---- cmdproc.add("interface *", interface_Command, ""); cmdproc.add("interface * exit", exit_Command, ""); + // cmdproc.add("ip access-list standart *", ip_access_list_standart_Command, "Standard Access List"); + // cmdproc.add("ip access-list extended *", ip_access_list_extended_Command, "Extended Access List"); cmdproc.add("logout", logout_Command, "Exit from the console"); cmdproc.add("ping", ping_Command, "Send echo messages"); *************** *** 129,133 **** this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { ! printInfo(); } public void windowGainedFocus(WindowEvent e) { --- 137,141 ---- this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { ! //printInfo(); } public void windowGainedFocus(WindowEvent e) { *************** *** 138,142 **** public void exitWindow() { ! printInfo(); this.dispose(); } --- 146,150 ---- public void exitWindow() { ! //printInfo(); this.dispose(); } *************** *** 154,159 **** if(current_mode.conf_mode == CommandInterface.CONF_MODE){ text += "(config"; ! if(interface_mode){ ! text += "-if"; } text += ")"; --- 162,169 ---- if(current_mode.conf_mode == CommandInterface.CONF_MODE){ text += "(config"; ! switch(interface_mode){ ! case IF_MODE: text += "-if"; break; ! case ACL_MODE: text += "-ext-nacl"; break; ! default: } text += ")"; *************** *** 184,195 **** pos_history = history.size(); } ! appendToTerminal(cmdline.getText() + "\n"); ! String tmptext = cmdproc.call(cmdline.getText(), current_mode, interface_name); ! if(tmptext==null){ ! tmptext = "% Incomplete command.\n"; } addToTerminal(tmptext); cmdline.setText(""); ! printInfo(); break; } --- 194,208 ---- pos_history = history.size(); } ! String tmptext = ""; ! if(cmdline.getText().compareTo("")!=0){ ! appendToTerminal(cmdline.getText() + "\n"); ! tmptext = cmdproc.call(cmdline.getText(), current_mode, command_prefix); ! if(tmptext==null){ ! tmptext = "% Incomplete command.\n"; ! } } addToTerminal(tmptext); cmdline.setText(""); ! //printInfo(); break; } *************** *** 205,209 **** addToTerminal(cmdline.getText()); int caretPos = cmdline.getCaretPosition(); ! String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode, interface_name); //String last_str = cmdline.getText().substring(caretPos); if(compl_str!=null && !compl_str.endsWith(" ")){ --- 218,222 ---- addToTerminal(cmdline.getText()); int caretPos = cmdline.getCaretPosition(); ! String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode, command_prefix); //String last_str = cmdline.getText().substring(caretPos); if(compl_str!=null && !compl_str.endsWith(" ")){ *************** *** 215,219 **** case '?': { String tmptext = cmdline.getText() + "?\n"; ! Vector<Pair> tmpv = cmdproc.help(cmdline.getText().substring(0,cmdline.getCaretPosition()), current_mode, interface_name); if(tmpv!=null){ for(int i=0; i<tmpv.size(); i++){ --- 228,232 ---- case '?': { String tmptext = cmdline.getText() + "?\n"; ! Vector<Pair> tmpv = cmdproc.help(cmdline.getText().substring(0,cmdline.getCaretPosition()), current_mode, command_prefix); if(tmpv!=null){ for(int i=0; i<tmpv.size(); i++){ *************** *** 356,362 **** public String call(Vector<String> params){ if(current_mode.conf_mode == CommandInterface.CONF_MODE){ ! if(interface_mode){ ! interface_mode = false; ! interface_name = ""; } else{ --- 369,375 ---- public String call(Vector<String> params){ if(current_mode.conf_mode == CommandInterface.CONF_MODE){ ! if(interface_mode!=DEF_MODE){ ! interface_mode = DEF_MODE; ! command_prefix = ""; } else{ *************** *** 381,387 **** try { device.getNetworkInterface(params.get(0)); ! if(!interface_mode){ ! interface_mode = true; ! interface_name = "interface "+params.get(0); } } catch (InvalidNetworkInterfaceNameException ex) { --- 394,400 ---- try { device.getNetworkInterface(params.get(0)); ! if(interface_mode==DEF_MODE){ ! interface_mode = IF_MODE; ! command_prefix = "interface "+params.get(0); } } catch (InvalidNetworkInterfaceNameException ex) { *************** *** 395,398 **** --- 408,473 ---- } }; + class ip_access_list_standart_CommandClass extends CommandInterface{ + public ip_access_list_standart_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); + call_params = "<cr>"; + no_call_params = "<cr>"; + } + public String call(Vector<String> params){ + String out = ""; + if(params.size()==1){ + try{ + int iacl = Integer.parseInt(params.get(0)); + if(iacl>=1 && iacl<=99){ + if(interface_mode==DEF_MODE){ + interface_mode = ACL_MODE; + command_prefix = "ip access-list standart "+params.get(0); + } + } + else{ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 1 to 99\n"; + } + } + catch(NumberFormatException e){ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 1 to 99\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; + class ip_access_list_extended_CommandClass extends CommandInterface{ + public ip_access_list_extended_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.CALL_ONLY); + call_params = "<cr>"; + no_call_params = "<cr>"; + } + public String call(Vector<String> params){ + String out = ""; + if(params.size()==1){ + try{ + int iacl = Integer.parseInt(params.get(0)); + if(iacl>=100 && iacl<=2699){ + if(interface_mode==DEF_MODE){ + interface_mode = ACL_MODE; + command_prefix = "ip access-list standart "+params.get(0); + } + } + else{ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 100 to 2699\n"; + } + } + catch(NumberFormatException e){ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 100 to 2699\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; class logout_CommandClass extends CommandInterface{ public logout_CommandClass (){ Index: SerPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SerPortProperties.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SerPortProperties.java 19 Oct 2007 19:38:06 -0000 1.2 --- SerPortProperties.java 17 Nov 2007 21:38:58 -0000 1.3 *************** *** 311,320 **** temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); temp.getConfig().executeCommand("no int " + NodeInt + " shutdown"); ! temp.getConfig().remove("int " + NodeInt + " shutdown"); ! temp.getConfig().add("no int " + NodeInt + " shutdown"); }else{ temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); ! temp.getConfig().remove("int " + NodeInt + " shutdown"); ! temp.getConfig().add("no int " + NodeInt + " shutdown"); } }else{ --- 311,320 ---- temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); temp.getConfig().executeCommand("no int " + NodeInt + " shutdown"); ! // temp.getConfig().remove("int " + NodeInt + " shutdown"); ! // temp.getConfig().add("no int " + NodeInt + " shutdown"); }else{ temp.getConfig().executeCommand("int " + NodeInt + " shutdown"); ! // temp.getConfig().remove("int " + NodeInt + " shutdown"); ! // temp.getConfig().add("no int " + NodeInt + " shutdown"); } }else{ |
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8566/core/protocolsuite/tcp_ip Modified Files: DHCPC.java DHCPD.java ProtocolStack.java SNMP.java Tcp.java Telnet_server.java Log Message: console, ACLs and TCP fixed Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Telnet_server.java 20 Oct 2007 22:54:40 -0000 1.21 --- Telnet_server.java 17 Nov 2007 21:38:58 -0000 1.22 *************** *** 28,31 **** --- 28,33 ---- } + public boolean running = false; + private ApplicationLayerDevice mDevice; private String cmdline = ""; *************** *** 60,63 **** --- 62,66 ---- mParentStack.SL().bind(appSock, mParentStack.getSrcIP(), listenPort); mParentStack.SL().listen(appSock); + running = true; }catch (TransportLayerException e){ System.out.println(e.toString());; *************** *** 80,83 **** --- 83,87 ---- public void Close() throws TransportLayerException { + running = false; mParentStack.SL().close(appSock); Enumeration keys = connections.keys(); *************** *** 327,331 **** else if(tokens[0].compareTo("snmp")==0){ 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)); --- 331,335 ---- else if(tokens[0].compareTo("snmp")==0){ if((m=Pattern.compile(" +(on|\\d+)( +([^ ]+))?$").matcher(cmd)).find()) { ! int l_port=SNMP.DEFAULT_PORT; String l_pass="public"; if(m.group(1).compareTo("on")!=0) l_port = Integer.parseInt(m.group(1)); Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** ProtocolStack.java 19 Oct 2007 08:52:27 -0000 1.62 --- ProtocolStack.java 17 Nov 2007 21:38:58 -0000 1.63 *************** *** 742,746 **** UDP_Info.setDataType("UDP Packet"); UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Transport level doesn't dupport on this device."); Simulation.addLayerInfo(UDP_Info); } --- 742,746 ---- UDP_Info.setDataType("UDP Packet"); UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Transport level doesn't support on this device."); Simulation.addLayerInfo(UDP_Info); } *************** *** 757,762 **** UDP_Info.setDataType("TCP Packet"); UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Transport level doesn't dupport on this device."); ! Simulation.addLayerInfo(UDP_Info); } catch (CommunicationException ce) {} --- 757,762 ---- UDP_Info.setDataType("TCP Packet"); UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Transport level doesn't support on this device."); ! Simulation.addLayerInfo(UDP_Info); } catch (CommunicationException ce) {} Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** Tcp.java 11 Nov 2007 19:51:57 -0000 1.103 --- Tcp.java 17 Nov 2007 21:38:58 -0000 1.104 *************** *** 620,624 **** String pack_flags = (packet.get_ACK_flag()?"ACK,":"")+(packet.get_SYN_flag()?"SYN,":"")+(packet.get_FIN_flag()?"FIN,":"")+(packet.get_RST_flag()?"RST":""); System.out.println("|| <<< TCP send pack: src="+pack_src+" dst="+pack_dst+" flags="+pack_flags+" seq="+packet.get_sequence_number()+" ack="+packet.get_acknowledgment_number()+" data='"+packet.getTCP_message()+"'"); ! System.out.println("|| <<<< Host="+mParentStack.getHostName()+" IP="+mParentStack.getSrcIP()+" sock="+Elm.getSocket()+" state="+Elm.getStateString()); printLayerInfo("TCP packet send to "+pack_dst+" flags="+pack_flags+" seq="+packet.get_sequence_number()+" ack="+packet.get_acknowledgment_number()+" data='"+packet.getTCP_message()+"'"); --- 620,628 ---- String pack_flags = (packet.get_ACK_flag()?"ACK,":"")+(packet.get_SYN_flag()?"SYN,":"")+(packet.get_FIN_flag()?"FIN,":"")+(packet.get_RST_flag()?"RST":""); System.out.println("|| <<< TCP send pack: src="+pack_src+" dst="+pack_dst+" flags="+pack_flags+" seq="+packet.get_sequence_number()+" ack="+packet.get_acknowledgment_number()+" data='"+packet.getTCP_message()+"'"); ! try{ ! System.out.println("|| <<<< Host="+mParentStack.getHostName()+" IP="+mParentStack.getSrcIP()+" sock="+Elm.getSocket()+" state="+Elm.getStateString()); ! }catch(NullPointerException e){ ! System.out.println(e.getMessage()); ! } printLayerInfo("TCP packet send to "+pack_dst+" flags="+pack_flags+" seq="+packet.get_sequence_number()+" ack="+packet.get_acknowledgment_number()+" data='"+packet.getTCP_message()+"'"); *************** *** 1038,1047 **** readySegments = tcpp.get_sequence_number(); } if(readySegments>0){ mSL.recv(Elm.getSocket(), out); } - boolean flags[] = genFlags(ACK); - //sendTCPSegment(Elm.getSocket(), "", flags, readySegments+1, resendtimes_NULL); - sendTCPSegment(Elm.getSocket(), "", flags, Elm.getNextSequenceNumber(), resendtimes_NULL); } --- 1042,1053 ---- readySegments = tcpp.get_sequence_number(); } + if(packet!=null){ + boolean flags[] = genFlags(ACK); + //sendTCPSegment(Elm.getSocket(), "", flags, readySegments+1, resendtimes_NULL); + sendTCPSegment(Elm.getSocket(), "", flags, Elm.getNextSequenceNumber(), resendtimes_NULL); + } if(readySegments>0){ mSL.recv(Elm.getSocket(), out); } } Index: DHCPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPC.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DHCPC.java 20 Oct 2007 13:27:20 -0000 1.3 --- DHCPC.java 17 Nov 2007 21:38:58 -0000 1.4 *************** *** 92,96 **** */ public void Close() throws TransportLayerException ! { printLayerInfo("DHCP Client", "DHCP Client application closed socket."); mParentStack.SL().close(appSock); --- 92,97 ---- */ public void Close() throws TransportLayerException ! { ! running = false; printLayerInfo("DHCP Client", "DHCP Client application closed socket."); mParentStack.SL().close(appSock); Index: DHCPD.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPD.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DHCPD.java 20 Oct 2007 22:54:40 -0000 1.5 --- DHCPD.java 17 Nov 2007 21:38:58 -0000 1.6 *************** *** 9,15 **** --- 9,17 ---- import core.LowLinkException; import core.LayerInfo; + import core.Pair; import core.Simulation; import java.util.Hashtable; import java.util.Enumeration; + import java.util.Vector; /** *************** *** 57,60 **** --- 59,63 ---- public Hashtable pools = new Hashtable(); public Hashtable leases = new Hashtable(); + private Vector<Pair> exclude = new Vector<Pair>(0); /** Creates a new instance of DHCPD */ *************** *** 365,373 **** public void excludeAddress(String low_ip, String high_ip){ ! } public void no_excludeAddress(String low_ip, String high_ip){ ! } --- 368,395 ---- public void excludeAddress(String low_ip, String high_ip){ ! boolean found = false; ! for(int i=0; i<exclude.size() && !found; i++){ ! Pair el = exclude.get(i); ! if(el.getFirst().equals(low_ip) && el.getSecond().equals(high_ip)){ ! found = true; ! } ! } ! if(!found){ ! exclude.add(new Pair(low_ip, high_ip)); ! } } public void no_excludeAddress(String low_ip, String high_ip){ ! for(int i=0; i<exclude.size(); i++){ ! Pair el = exclude.get(i); ! if(el.getFirst().equals(low_ip) && el.getSecond().equals(high_ip)){ ! exclude.remove(i); ! break; ! } ! } ! } ! ! public Vector<Pair> getExcludeAddresses(){ ! return exclude; } Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** SNMP.java 20 Oct 2007 13:27:21 -0000 1.26 --- SNMP.java 17 Nov 2007 21:38:58 -0000 1.27 *************** *** 69,73 **** --- 69,75 ---- public final static int SNMP_TRAP = 4; public final static int SNMP_RESPONSE = 5; + public final static int DEFAULT_PORT = 161; private static int SNMPID = 0; + public boolean running = false; public Vector<SNMPInstance> SNMPgroups = new Vector<SNMPInstance>(0); private String current_password = ""; *************** *** 145,148 **** --- 147,151 ---- mParentStack.SL().bind(appSock, mParentStack.getSrcIP(), listenPort); mParentStack.SL().listen(appSock); + running = true; printInfo("SNMP agent starts listening on port " + listenPort); //<<-- FIXME!!! } *************** *** 170,173 **** --- 173,177 ---- printInfo("SNMP manager closed socket."); } + running = false; mParentStack.SL().close(appSock); } |
From: QweR <qw...@us...> - 2007-11-17 21:39:06
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8566/core Modified Files: AccessListEngine.java ApplicationLayerDevice.java CommandProcessor.java CommandsTree.java DeviceConfig.java EthernetNetworkInterface.java NetworkInterface.java Node.java PC.java Printer.java SerialNetworkInterface.java Simulation.java Log Message: console, ACLs and TCP fixed Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CommandProcessor.java 23 Oct 2007 20:14:48 -0000 1.8 --- CommandProcessor.java 17 Nov 2007 21:38:57 -0000 1.9 *************** *** 289,294 **** String out = ""; if(params.size()==2){ ! device.getConfig().remove("^arp.*"+params.get(0)+".*$"); ! device.getConfig().add("arp "+ params.get(0)+" "+params.get(1)); device.addToARPStatic(params.get(0), params.get(1)); out += "Created new static ARP entry: " + params.get(0) + " is " + params.get(1) + "\n"; --- 289,295 ---- String out = ""; if(params.size()==2){ ! // device.getConfig().remove("^arp.*"+params.get(0)+".*$"); [...1379 lines suppressed...] --- 2653,2658 ---- if(params.size()==2){ appdevice.addUser(params.get(0), params.get(1)); ! // device.getConfig().remove("^username "+params.get(0)+" "); ! // device.getConfig().add("username "+params.get(0)+" "+params.get(1)); } else{ *************** *** 2375,2379 **** if(params.size()==2){ appdevice.delUser(params.get(0)); ! device.getConfig().remove("^username "+params.get(0)+" "); } else{ --- 2671,2675 ---- if(params.size()==2){ appdevice.delUser(params.get(0)); ! // device.getConfig().remove("^username "+params.get(0)+" "); } else{ Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Node.java 20 Oct 2007 22:54:40 -0000 1.19 --- Node.java 17 Nov 2007 21:38:58 -0000 1.20 *************** *** 765,768 **** --- 765,777 ---- name=inName; } + + public boolean setClock(String date){ + //set new date + return true; + } + + public String getClock(){ + return "00:00:00 1 1 1970"; + } }//EOF Index: SerialNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/SerialNetworkInterface.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SerialNetworkInterface.java 19 Oct 2007 08:52:26 -0000 1.4 --- SerialNetworkInterface.java 17 Nov 2007 21:38:58 -0000 1.5 *************** *** 33,41 **** * FrameRelay ClockRate * */ ! protected int ClockRate; protected SerialNetworkInterface(String inName, Node parent) { super(inName,parent); ! ClockRate = 400000; } --- 33,44 ---- * FrameRelay ClockRate * */ ! protected int ClockRate; ! public final static int DEFAULT_CLOCKRATE = 400000; ! public final static int MAX_CLOCKRATE = 400000; ! public final static int MIN_CLOCKRATE = 0; protected SerialNetworkInterface(String inName, Node parent) { super(inName,parent); ! ClockRate = DEFAULT_CLOCKRATE; } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Simulation.java 20 Oct 2007 20:19:46 -0000 1.25 --- Simulation.java 17 Nov 2007 21:38:58 -0000 1.26 *************** *** 349,354 **** //nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); nld.getConfig().executeCommand("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask); ! nld.getConfig().remove("interface "+inInterface+" ip address ", DeviceConfig.STARTUP_CONFIG); ! nld.getConfig().add("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask, DeviceConfig.STARTUP_CONFIG); } else --- 349,354 ---- //nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); nld.getConfig().executeCommand("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask); ! // nld.getConfig().remove("interface "+inInterface+" ip address ", DeviceConfig.STARTUP_CONFIG); ! // nld.getConfig().add("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask, DeviceConfig.STARTUP_CONFIG); } else *************** *** 388,393 **** //t.setDefaultGateway(inGatewayIPAddress); t.getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0"); ! t.getConfig().remove("^ip route 0.0.0.0 0.0.0.0 ", DeviceConfig.STARTUP_CONFIG); ! t.getConfig().add("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0", DeviceConfig.STARTUP_CONFIG); //t.getConfig().executeCommand("ip route default 0.0.0.0 "+inGatewayIPAddress+" eth0"); } --- 388,393 ---- //t.setDefaultGateway(inGatewayIPAddress); t.getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0"); ! // t.getConfig().remove("^ip route 0.0.0.0 0.0.0.0 ", DeviceConfig.STARTUP_CONFIG); ! // t.getConfig().add("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0", DeviceConfig.STARTUP_CONFIG); //t.getConfig().executeCommand("ip route default 0.0.0.0 "+inGatewayIPAddress+" eth0"); } *************** *** 450,455 **** //t.setIPAddress(inNodeInterface,inIPAddress); t.getConfig().executeCommand("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface)); ! t.getConfig().remove("^interface "+inNodeInterface+" ip address ", DeviceConfig.STARTUP_CONFIG); ! t.getConfig().add("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface), DeviceConfig.STARTUP_CONFIG); macAddress = t.getMACAddress(inNodeInterface); updateARP(inIPAddress, macAddress, inNodeName); --- 450,455 ---- //t.setIPAddress(inNodeInterface,inIPAddress); t.getConfig().executeCommand("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface)); ! // t.getConfig().remove("^interface "+inNodeInterface+" ip address ", DeviceConfig.STARTUP_CONFIG); ! // t.getConfig().add("interface "+inNodeInterface+" ip address "+inIPAddress+" "+t.getSubnetMask(inNodeInterface), DeviceConfig.STARTUP_CONFIG); macAddress = t.getMACAddress(inNodeInterface); updateARP(inIPAddress, macAddress, inNodeName); *************** *** 536,541 **** //tempNet.addToARPStatic(inIPAddress, inMACAddress); tempNet.getConfig().executeCommand("arp "+inIPAddress+" "+inMACAddress); ! tempNet.getConfig().remove("^arp "+inIPAddress+" ", DeviceConfig.STARTUP_CONFIG); ! tempNet.getConfig().add("arp "+inIPAddress+" "+inMACAddress, DeviceConfig.STARTUP_CONFIG); } --- 536,541 ---- //tempNet.addToARPStatic(inIPAddress, inMACAddress); tempNet.getConfig().executeCommand("arp "+inIPAddress+" "+inMACAddress); ! // tempNet.getConfig().remove("^arp "+inIPAddress+" ", DeviceConfig.STARTUP_CONFIG); ! // tempNet.getConfig().add("arp "+inIPAddress+" "+inMACAddress, DeviceConfig.STARTUP_CONFIG); } *************** *** 558,562 **** //tempNet.removeARP(inIPAddress); tempNet.getConfig().executeCommand("no arp "+inIPAddress); ! tempNet.getConfig().add("no arp "+inIPAddress, DeviceConfig.STARTUP_CONFIG); } --- 558,562 ---- //tempNet.removeARP(inIPAddress); tempNet.getConfig().executeCommand("no arp "+inIPAddress); ! // tempNet.getConfig().add("no arp "+inIPAddress, DeviceConfig.STARTUP_CONFIG); } Index: Printer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Printer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Printer.java 20 Oct 2007 20:19:46 -0000 1.1 --- Printer.java 17 Nov 2007 21:38:58 -0000 1.2 *************** *** 28,32 **** ! SNMP snmpAgent = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, 161, 0, core.ProtocolStack.UIDGen++); DHCPC dhcpc = new DHCPC(NodeProtocolStack, core.ProtocolStack.UIDGen++); --- 28,32 ---- ! SNMP snmpAgent = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, SNMP.DEFAULT_PORT, 0, core.ProtocolStack.UIDGen++); DHCPC dhcpc = new DHCPC(NodeProtocolStack, core.ProtocolStack.UIDGen++); Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** NetworkInterface.java 19 Oct 2007 15:57:00 -0000 1.11 --- NetworkInterface.java 17 Nov 2007 21:38:58 -0000 1.12 *************** *** 117,120 **** --- 117,128 ---- protected boolean dhcp; + protected int acl_in = 0; + protected int acl_out = 0; + + public boolean unreachables = true; + public boolean redirects = true; + public boolean maskReplay = true; + public boolean informationReplay = true; + public boolean getDHCP(){ return dhcp; *************** *** 483,486 **** --- 491,520 ---- this.description = description; } + + public int getACLin(){ + return acl_in; + } + + public void setACLin(int acl){ + if(acl<0 || acl>2699){ + acl_in = 0; + } + else{ + acl_in = acl; + } + } + + public int getACLout(){ + return acl_out; + } + + public void setACLout(int acl){ + if(acl<0 || acl>2699){ + acl_out = 0; + } + else{ + acl_out = acl; + } + } }//EOF Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PC.java 19 Oct 2007 17:40:33 -0000 1.17 --- PC.java 17 Nov 2007 21:38:58 -0000 1.18 *************** *** 116,120 **** Echo_tcp echotcpClient = new Echo_tcp(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); ! SNMP snmpAgent = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, 161, 0, core.ProtocolStack.UIDGen++); SNMP snmpManager = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, 0, 1, core.ProtocolStack.UIDGen++); --- 116,120 ---- Echo_tcp echotcpClient = new Echo_tcp(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); ! SNMP snmpAgent = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, SNMP.DEFAULT_PORT, 0, core.ProtocolStack.UIDGen++); SNMP snmpManager = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, 0, 1, core.ProtocolStack.UIDGen++); Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** EthernetNetworkInterface.java 20 Oct 2007 13:27:20 -0000 1.10 --- EthernetNetworkInterface.java 17 Nov 2007 21:38:58 -0000 1.11 *************** *** 29,32 **** --- 29,35 ---- package core; + import core.protocolsuite.tcp_ip.ARP_packet; + import core.protocolsuite.tcp_ip.IP_packet; + //import java.util.*; /** *************** *** 106,112 **** pingInfo.setDescription("Recieved and accepted packet at interface " + MACAddress); Simulation.addLayerInfo(pingInfo); ! Packet temp = tempPacket.getData(); ! ! parentNode.receivePacket(temp, name); }else{ //Packet is not for the Interface Drop Packet and record something in --- 109,123 ---- pingInfo.setDescription("Recieved and accepted packet at interface " + MACAddress); Simulation.addLayerInfo(pingInfo); ! Packet temp = tempPacket.getData(); ! ! boolean allowReceive = true; ! ! NetworkLayerDevice device = (NetworkLayerDevice) parentNode; ! if(device!=null && getACLin()!=0 && temp instanceof IP_packet && !(temp instanceof ARP_packet)){ ! allowReceive = device.getACL().passACL(getACLin(), temp); ! } ! ! if(allowReceive) ! parentNode.receivePacket(temp, name); }else{ //Packet is not for the Interface Drop Packet and record something in Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DeviceConfig.java 23 Oct 2007 20:14:48 -0000 1.8 --- DeviceConfig.java 17 Nov 2007 21:38:58 -0000 1.9 *************** *** 10,14 **** package core; - import core.AccessListEngine.access_list; import java.util.Iterator; import java.util.LinkedList; --- 10,13 ---- *************** *** 17,24 **** import java.util.regex.PatternSyntaxException; import core.CommandInterface.Modes; - import core.protocolsuite.tcp_ip.IPV4Address; import java.util.Enumeration; import java.util.Hashtable; import core.AccessListEngine.access_list; /** --- 16,27 ---- import java.util.regex.PatternSyntaxException; import core.CommandInterface.Modes; import java.util.Enumeration; import java.util.Hashtable; import core.AccessListEngine.access_list; + import core.protocolsuite.tcp_ip.DHCPC; + import core.protocolsuite.tcp_ip.DHCPD; + import core.protocolsuite.tcp_ip.Route_entry; + import core.protocolsuite.tcp_ip.SNMP; + import core.protocolsuite.tcp_ip.Telnet_server; /** *************** *** 43,46 **** --- 46,50 ---- public DeviceConfig(NetworkLayerDevice dev) { initRunningConfig(); + //initStartupConfig(); cmdproc = new CommandProcessor(dev); device = dev; *************** *** 57,61 **** */ public void load(){ ! Iterator<String> it = startup_config.iterator(); initRunningConfig(); --- 61,65 ---- */ public void load(){ ! Iterator<String> it = prepareConfig(startup_config, true).iterator(); initRunningConfig(); *************** *** 65,68 **** --- 69,74 ---- //running_config.add(nextcmd); } + clearStartupConfig(); + writeMemory(); } *************** *** 70,74 **** LinkedList config = null; switch(config_name){ ! case RUNNING_CONFIG: config = prepareConfig(running_config); break; case STARTUP_CONFIG: config = startup_config; break; default: --- 76,90 ---- LinkedList config = null; switch(config_name){ ! case RUNNING_CONFIG: config = prepareConfig(running_config, true); break; ! case STARTUP_CONFIG: config = prepareConfig(startup_config, true); break; ! default: ! } ! return config; ! } ! ! protected LinkedList getRealConfig(int config_name){ ! LinkedList config = null; ! switch(config_name){ ! case RUNNING_CONFIG: config = running_config; break; case STARTUP_CONFIG: config = startup_config; break; default: *************** *** 85,89 **** while(!running_config.isEmpty()) running_config.removeLast(); ! running_config.add("#ACLS"); } --- 101,118 ---- while(!running_config.isEmpty()) running_config.removeLast(); ! running_config.add(EXEC+"COMMON"); ! running_config.add(EXEC+"EXTENDED"); ! running_config.add(EXEC+"ACLS"); ! running_config.add(EXEC+"INTERFACES"); ! running_config.add(EXEC+"ROUTE"); ! running_config.add(EXEC+"IP"); ! running_config.add(EXEC+"ARPS"); ! } ! ! private void initStartupConfig(){ ! clearStartupConfig(); ! startup_config.add(EXEC+"COMMON"); ! startup_config.add(EXEC+"INTERFACES"); ! startup_config.add(EXEC+"ROUTE"); } *************** *** 91,95 **** boolean result = false; if(startup_config.isEmpty()){ ! Iterator<String> it = prepareConfig(running_config).iterator(); while(it.hasNext()){ startup_config.add(it.next()); --- 120,124 ---- boolean result = false; if(startup_config.isEmpty()){ ! Iterator<String> it = prepareConfig(running_config, false).iterator(); while(it.hasNext()){ startup_config.add(it.next()); *************** *** 113,117 **** public boolean addBefore(String command, int config_name, String beforeCommand){ boolean result = false; ! LinkedList config = getConfig(config_name); boolean found = false; int index = -1; --- 142,146 ---- public boolean addBefore(String command, int config_name, String beforeCommand){ boolean result = false; ! LinkedList config = getRealConfig(config_name); boolean found = false; int index = -1; *************** *** 157,161 **** try{ Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext()){ --- 186,190 ---- try{ Pattern p = Pattern.compile(command); ! LinkedList config = getRealConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext()){ *************** *** 184,188 **** try{ Pattern p = Pattern.compile(command); ! LinkedList config = getConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext() && !result){ --- 213,217 ---- try{ Pattern p = Pattern.compile(command); ! LinkedList config = getRealConfig(config_name); Iterator<String> it = config.iterator(); while(it.hasNext() && !result){ *************** *** 221,225 **** } ! private LinkedList prepareConfig(LinkedList in){ LinkedList out = new LinkedList(); Iterator it = in.iterator(); --- 250,254 ---- } ! private LinkedList prepareConfig(LinkedList in, boolean fullConfig){ LinkedList out = new LinkedList(); Iterator it = in.iterator(); *************** *** 231,254 **** fillConfigACLS(out); } ! // else if(nc.equalsIgnoreCase("")){ ! // ! // } ! // else if(nc.equalsIgnoreCase("")){ ! // ! // } ! // else if(nc.equalsIgnoreCase("")){ ! // ! // } ! // else if(nc.equalsIgnoreCase("")){ ! // ! // } ! // else if(nc.equalsIgnoreCase("")){ ! // ! // } ! // else if(nc.equalsIgnoreCase("")){ ! // ! // } else{ ! out.add("#ERROR: unsupported keyword #"+nc); } } --- 260,292 ---- fillConfigACLS(out); } ! else if(nc.equalsIgnoreCase("INTERFACES")){ ! if(fullConfig) ! fillInterfaces(out); ! else ! out.add(EXEC+"INTERFACES"); ! } ! else if(nc.equalsIgnoreCase("ARPS")){ ! fillARP(out); ! } ! else if(nc.equalsIgnoreCase("COMMON")){ ! if(fullConfig) ! fillCommon(out); ! else ! out.add(EXEC+"COMMON"); ! } ! else if(nc.equalsIgnoreCase("IP")){ ! fillIP(out); ! } ! else if(nc.equalsIgnoreCase("ROUTE")){ ! if(fullConfig) ! fillRoute(out); ! else ! out.add(EXEC+"ROUTE"); ! } ! else if(nc.equalsIgnoreCase("EXTENDED")){ ! fillExtended(out); ! } else{ ! out.add(EXEC+"ERROR: unsupported keyword #"+nc); } } *************** *** 260,264 **** } ! private void fillConfigACLS(LinkedList conf){ final int ERROR = 0; final int STANDART = 1; --- 298,302 ---- } ! protected void fillConfigACLS(LinkedList conf){ final int ERROR = 0; final int STANDART = 1; *************** *** 332,346 **** String port = "unsupported_port"; ! if(rule.Port1 == 0){ port = ""; } else{ ! port = "eq "+rule.Port1; } switch(itype){ ! case STANDART: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+hosts1); break; ! case EXTENDED: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+protocol+" "+hosts1+" "+hosts2+" "+port); break; ! default: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+protocol+" "+hosts1+" "+hosts2+" "+rule.Port2); } } --- 370,389 ---- String port = "unsupported_port"; ! if(rule.Port2 == 0){ port = ""; } else{ ! port = "eq "+rule.Port2; ! } ! ! String log = ""; ! if(rule.log){ ! log = "log"; } switch(itype){ ! case STANDART: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+hosts1+" "+log); break; ! case EXTENDED: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+protocol+" "+hosts1+" "+hosts2+" "+port+" "+log); break; ! default: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+protocol+" "+hosts1+" "+hosts2+" "+rule.Port2+" "+log); } } *************** *** 348,350 **** --- 391,531 ---- } + protected void fillInterfaces(LinkedList conf){ + + // commands.add("interface * ip nat", interface__ip_nat_Command, "NAT interface commands"); + + Object[] ins = device.getAllInterfaces(); + + for(int i=0; i<ins.length; i++){ + try { + NetworkInterface ni = device.getNetworkInterface((String)ins[i]); + EthernetNetworkInterface eni = null; + SerialNetworkInterface sni = null; + try{ + eni = (EthernetNetworkInterface) ni; + } catch(ClassCastException e){}; + try{ + sni = (SerialNetworkInterface) ni; + } catch(ClassCastException e){}; + + String intName = (String)ins[i]; + if(ni.getDescription()!=null && !ni.getDescription().equals("")) + conf.add("interface "+intName+" description "+ni.getDescription()); + if(ni.isUP()) + conf.add("no interface "+intName+" shutdown"); + if(eni!=null && !eni.getMACAddress().equalsIgnoreCase(eni.defaultMACAddress)) + conf.add("interface "+intName+" mac-address "+eni.getMACAddress()); + if(eni!=null && device.getIPAddress((String)ins[i])!=null && !device.getIPAddress((String)ins[i]).equals("")) + conf.add("interface "+intName+" ip address "+device.getIPAddress((String)ins[i])+" "+device.getSubnetMask((String)ins[i])); + if(sni!=null && sni.getClockRate()!=sni.DEFAULT_CLOCKRATE) + conf.add("interface "+intName+" clock-rate "+sni.getClockRate()); + if(ni.getACLin()!=0) + conf.add("interface "+intName+" ip access-group "+ni.getACLin()+" in"); + if(ni.getACLout()!=0) + conf.add("interface "+intName+" ip access-group "+ni.getACLout()+" out"); + if(!ni.unreachables) + conf.add("no interface "+intName+" ip unreachables"); + if(!ni.redirects) + conf.add("no interface "+intName+" ip redirects"); + if(!ni.maskReplay) + conf.add("no interface "+intName+" ip mask-replay"); + if(!ni.informationReplay) + conf.add("no interface "+intName+" ip information-replay"); + + if(device instanceof ApplicationLayerDevice){ + DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(PC.DHCP_CLIENT_ID); + if(dhcpc!=null && dhcpc.running){ + conf.add("interface "+intName+" ip dhcp client"); + } + } + } catch (InvalidNetworkInterfaceNameException ex) { + System.out.println("Internal error: "+ex.getMessage()); + ex.printStackTrace(); + } + } + } + + protected void fillARP(LinkedList conf){ + Vector<Vector<String>> ArpTable = device.getARPTable(); + if(ArpTable.size()>0){ + for(int i=0;i<ArpTable.size();i++) + { + conf.add("arp "+ArpTable.get(i).get(0)+" "+ArpTable.get(i).get(1)); + } + } + } + + protected void fillCommon(LinkedList conf){ + conf.add("hostname "+device.getName()); + if(device.location!=null && !device.location.equals("")) + conf.add("location "+device.location); + } + + protected void fillExtended(LinkedList conf){ + conf.add("clock set "+device.getClock()); + + if(device instanceof ApplicationLayerDevice){ + SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); + if(snmpa != null && snmpa.running){ + if(snmpa.getPort()!=snmpa.DEFAULT_PORT){ + conf.add("snmp-server port "+snmpa.getPort()); + } + conf.add("snmp-server community "+snmpa.getPassword()); + } + } + + if(device instanceof ApplicationLayerDevice){ + Telnet_server telnets = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.PC.TELNET_SERVER_ID); + if(telnets != null && telnets.running){ + conf.add("telnet-server "+telnets.getPort()); + } + } + + if(device instanceof ApplicationLayerDevice){ + core.ApplicationLayerDevice appdevice = (core.ApplicationLayerDevice)device; + Enumeration<String> users = appdevice.getUserList(); + if(users!=null){ + String username; + while(users.hasMoreElements()){ + username = users.nextElement(); + conf.add("username "+username+" "+appdevice.getUserPassword(username)); + } + } + } + } + + protected void fillRoute(LinkedList conf){ + String routes[] = device.getRouteTableEntries(); + for(int i=0; i<routes.length - 1; i++){ + Route_entry r = device.getRouteTableEntry(routes[i]); + conf.add("ip route "+routes[i]+" "+r.genMask+" "+r.gateway+" "+r.iFace); + } + } + + protected void fillIP(LinkedList conf){ + //commands.add("ip nat inside destination list", ip_nat_inside_destination_list_Command, "Specify access list describing global addresses"); + //commands.add("ip nat inside source list", ip_nat_inside_source_list_Command, "Specify access list describing local addresses"); + //commands.add("ip nat inside source static", ip_nat_inside_source_static_Command, "Specify static local->global mapping"); + //commands.add("ip nat pool", ip_nat_pool_Command, "Define pool of addresses"); + + if(device instanceof ApplicationLayerDevice){ + DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); + if(dhcpd!=null){ + Enumeration<String> pools = dhcpd.pools.keys(); + while(pools.hasMoreElements()){ + String poolname = pools.nextElement(); + DHCPD.pool pool = (DHCPD.pool) dhcpd.pools.get(poolname); + conf.add("ip dhcp pool "+poolname+" default-router "+pool.Gateway); + conf.add("ip dhcp pool "+poolname+" network "+pool.IP+" "+pool.Genmask); + conf.add("ip dhcp pool "+poolname+" hardware-address "+pool.MAC); + } + Vector<Pair> exclude = dhcpd.getExcludeAddresses(); + for(int i=0; i<exclude.size(); i++){ + Pair lha = exclude.get(i); + conf.add("ip dhcp pool excluded-address "+lha.getFirst()+" "+lha.getSecond()); + } + } + conf.add("ip tcp window-size "+device.NodeProtocolStack.TCP().getWindowSize()); + } + } } Index: AccessListEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/AccessListEngine.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AccessListEngine.java 23 Oct 2007 20:14:48 -0000 1.2 --- AccessListEngine.java 17 Nov 2007 21:38:57 -0000 1.3 *************** *** 4,7 **** --- 4,10 ---- import java.util.Hashtable; import core.protocolsuite.tcp_ip.IPV4Address; + import core.protocolsuite.tcp_ip.IP_packet; + import core.protocolsuite.tcp_ip.TCP_packet; + import core.protocolsuite.tcp_ip.UDP_packet; /** *************** *** 20,36 **** public final static int TCP = 3; ! public int number; ! public int line; ! public short action; ! ! public String IP1; ! public String SubnetMask1; ! public int Port1; ! public String IP2; ! public String SubnetMask2; ! public int Port2; ! public short protocol; } --- 23,39 ---- public final static int TCP = 3; ! public int number = 0; ! public int line = 0; ! public short action = -1; ! public int protocol = -1; ! public boolean log = false; ! public String IP1 = null; ! public String SubnetMask1 = null; ! public int Port1 = 0; ! public String IP2 = null; ! public String SubnetMask2 = null; ! public int Port2 = 0; } *************** *** 43,47 **** } ! public int addACL(int number, int line, short action, String IP1, String SubnetMask1){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); boolean new_acl = false; --- 46,54 ---- } ! public int addACL(int number, int line, short action, String IP1, String SubnetMask1, boolean log){ ! return addACL(number, line, action, -1, IP1, SubnetMask1, null, null, 0, log); ! } ! ! public int addACL(int number, int line, short action, int protocol, String IP1, String SubnetMask1, String IP2, String SubnetMask2, int port, boolean log){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); boolean new_acl = false; *************** *** 71,76 **** --- 78,88 ---- al.line = line; al.action = action; + al.protocol = protocol; al.IP1 = IP1; al.SubnetMask1 = SubnetMask1; + al.IP2 = IP2; + al.SubnetMask2 = SubnetMask2; + al.Port2 = port; + al.log = log; ACLl.put(Integer.valueOf(line), al); *************** *** 120,123 **** --- 132,165 ---- } + public boolean removeACL(int number, int action, int protocol, String IP1, String SubnetMask1, String IP2, String SubnetMask2, int port){ + Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); + boolean found = false; + + if(ACLl == null) return false; + + access_list temp_acl = null; + Enumeration e = ACLl.keys(); + while(e.hasMoreElements()){ + temp_acl = (access_list)ACLl.get((Integer)e.nextElement()); + if(temp_acl.action == action && + (protocol==-1 || temp_acl.protocol == protocol) && + temp_acl.IP1.equals(IP1) && + temp_acl.SubnetMask1.equals(SubnetMask1) && + (IP2==null || temp_acl.IP2.equals(IP2)) && + (SubnetMask2==null || SubnetMask2.equals(temp_acl.SubnetMask2)) && + (port==0 || temp_acl.Port2 == port) + ){ + found = true; + break; + } + } + + if(found) ACLl.remove(Integer.valueOf(temp_acl.line)); + + if(ACLl.size() < 1) ACLs.remove(Integer.valueOf(number)); + + return found; + } + public boolean isACLExists(int number, int line){ Hashtable acllist = (Hashtable)ACLs.get(new Integer(number)); *************** *** 126,130 **** } ! public boolean passStandartACL(int number, String IP){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); --- 168,172 ---- } ! public boolean passACL(int number, Packet packet){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); *************** *** 132,151 **** try{ ! String binIP = IPV4Address.toBinaryString(IP); ! String binNetwork = ""; ! String binMask = ""; ! access_list temp_acl = null; ! Enumeration e = ACLl.keys(); ! while(e.hasMoreElements()){ ! temp_acl = (access_list)ACLl.get((Integer)e.nextElement()); ! ! if(temp_acl.action>0){ ! binNetwork = IPV4Address.toBinaryString(temp_acl.IP1); ! binMask = IPV4Address.toBinaryString(temp_acl.SubnetMask1); ! ! if(IPV4Address.IPandMask(binNetwork, binMask).equals(IPV4Address.IPandMask(binIP,binMask))){ ! if(temp_acl.action == access_list.PERMIT) return true; ! else return false; } } --- 174,243 ---- try{ ! int port1 = 0; ! int port2 = 0; ! int protocol = -1; ! String IP1 = null; ! String IP2 = null; ! if(packet instanceof IP_packet){ ! IP_packet ippacket = (IP_packet) packet; ! IP1 = ippacket.getSourceIPAddress(); ! IP2 = ippacket.getDestIPAddress(); ! protocol = access_list.IP; ! if(ippacket instanceof TCP_packet){ ! protocol = AccessListEngine.access_list.TCP; ! port1 = ((TCP_packet)ippacket).get_srcPort(); ! port2 = ((TCP_packet)ippacket).get_destPort(); ! } ! else if(ippacket instanceof UDP_packet){ ! protocol = AccessListEngine.access_list.UDP; ! port1 = ((UDP_packet)ippacket).get_srcPort(); ! port2 = ((UDP_packet)ippacket).get_destPort(); ! } ! String binIP1 = IPV4Address.toBinaryString(IP1); ! String binNetwork1 = ""; ! String binMask1 = ""; ! String binIP2 = null; ! if(IP2!=null){ ! binIP2 = IPV4Address.toBinaryString(IP2); ! } ! String binNetwork2 = null; ! String binMask2 = null; ! ! access_list temp_acl = null; ! Enumeration e = ACLl.keys(); ! while(e.hasMoreElements()){ ! temp_acl = (access_list)ACLl.get((Integer)e.nextElement()); ! ! if(temp_acl.action>0){ ! binNetwork1 = IPV4Address.toBinaryString(temp_acl.IP1); ! binMask1 = IPV4Address.toBinaryString(temp_acl.SubnetMask1); ! if(temp_acl.IP2!=null && temp_acl.SubnetMask2!=null){ ! binNetwork2 = IPV4Address.toBinaryString(temp_acl.IP2); ! binMask2 = IPV4Address.toBinaryString(temp_acl.SubnetMask2); ! } ! ! if((temp_acl.protocol==-1 || temp_acl.protocol==access_list.IP || temp_acl.protocol==protocol) && ! IPV4Address.IPandMask(binNetwork1, binMask1).equals(IPV4Address.IPandMask(binIP1,binMask1)) && ! (binNetwork2==null || (binIP2!=null || IPV4Address.IPandMask(binNetwork2, binMask2).equals(IPV4Address.IPandMask(binIP2,binMask2)))) && ! (temp_acl.Port2 == 0 || temp_acl.Port2 == port2) ! ){ ! if(temp_acl.log){ ! String src = IP1; ! String dst = IP2; ! if(port1>0 && port2>0){ ! src += ":"+port1; ! dst += ":"+port2; ! } ! if(temp_acl.action == access_list.PERMIT){ ! printLayerInfo("Packet from "+src+" to "+dst+" permited"); ! } ! else{ ! printLayerInfo("Packet from "+src+" to "+dst+" denied"); ! } ! } ! if(temp_acl.action == access_list.PERMIT) return true; ! else return false; ! } } } *************** *** 157,159 **** --- 249,260 ---- return false; } + + protected void printLayerInfo(String s) { + LayerInfo protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(parentNode.getName()); + protInfo.setDataType("ACL rule"); + protInfo.setLayer("ACL"); + protInfo.setDescription(s); + Simulation.addLayerInfo(protInfo); + } } Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ApplicationLayerDevice.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ApplicationLayerDevice.java 20 Oct 2007 22:54:40 -0000 1.7 --- ApplicationLayerDevice.java 17 Nov 2007 21:38:57 -0000 1.8 *************** *** 31,34 **** --- 31,35 ---- public Object getApp(int code){ + if(Apps==null) return null; return Apps.get(code); } *************** *** 72,79 **** --- 73,82 ---- public String getUserPassword(String username){ + if(userlist==null) return null; return (String)userlist.get(username); } public Enumeration<String> getUserList(){ + if(userlist==null) return null; return userlist.keys(); } Index: CommandsTree.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandsTree.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CommandsTree.java 23 Oct 2007 20:14:48 -0000 1.5 --- CommandsTree.java 17 Nov 2007 21:38:58 -0000 1.6 *************** *** 74,78 **** if(nodename.length()>cmdsize) nodename = nodename.substring(0,cmdsize); int cmp = command.compareToIgnoreCase(nodename); ! if(cmp == 0 && modes.isContain(mode)){ nodes.add((CommandNode)tree.get(i)); } --- 74,78 ---- if(nodename.length()>cmdsize) nodename = nodename.substring(0,cmdsize); int cmp = command.compareToIgnoreCase(nodename); ! if(cmp == 0 && node.modes.isContain(mode)){ nodes.add((CommandNode)tree.get(i)); } *************** *** 189,193 **** public boolean add(String command, CommandInterface function, String description){ boolean result = false; ! String cmds[] = command.split(" "); CommandNode node = root; --- 189,193 ---- public boolean add(String command, CommandInterface function, String description){ boolean result = false; ! String cmds[] = command.split(" +"); CommandNode node = root; *************** *** 237,241 **** public void addDescription(String command, String description){ ! String cmds[] = command.split(" "); CommandNode node = root; --- 237,241 ---- public void addDescription(String command, String description){ ! String cmds[] = command.split(" +"); CommandNode node = root; *************** *** 276,280 **** } else{ ! String cmds[] = command.split(" "); CommandInterface func = null; --- 276,280 ---- } else{ ! String cmds[] = command.split(" +"); CommandInterface func = null; *************** *** 307,311 **** } if(func!=null && modes.isContain(mode)){ ! //String sprms[] = params.split(" "); if(node==null) i--; for(; i<cmds.length; i++){ --- 307,311 ---- } if(func!=null && modes.isContain(mode)){ ! //String sprms[] = params.split(" +"); if(node==null) i--; for(; i<cmds.length; i++){ *************** *** 330,334 **** public String complete(String command, Modes mode){ String result = null; ! String cmds[] = command.split(" "); if(command.endsWith(" ")){ --- 330,334 ---- public String complete(String command, Modes mode){ String result = null; ! String cmds[] = command.split(" +"); if(command.endsWith(" ")){ *************** *** 357,361 **** public Vector<Pair> help(String command, Modes mode){ Vector<Pair> result = null; ! String cmds[] = command.split(" "); CommandNode node = root; --- 357,361 ---- public Vector<Pair> help(String command, Modes mode){ Vector<Pair> result = null; ! String cmds[] = command.split(" +"); CommandNode node = root; |
From: QweR <qw...@us...> - 2007-11-11 19:52:07
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19828/core/protocolsuite/tcp_ip Modified Files: TCP_session.java Tcp.java Log Message: TCP bugs fixed Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** Tcp.java 15 Oct 2007 21:41:43 -0000 1.102 --- Tcp.java 11 Nov 2007 19:51:57 -0000 1.103 *************** *** 80,104 **** public void run() { try{ ! LinkedList q_rs = new LinkedList(); ! LinkedList q_nt = new LinkedList(); ! synchronized(tcp_timers_lock){ ! while(!tcp_timers.isEmpty() && current_time > ((Resender)tcp_timers.peek()).getResendTime()){ ! Resender rs = (Resender)tcp_timers.poll(); ! int nt = rs.nextTime(current_time); ! if(nt>0){ ! tcp_timers.add(rs); } ! q_rs.add(rs); ! q_nt.add(new Integer(nt)); ! //printLayerInfo(">>> Timer "+mParentStack.getHostName()+":"+rs.timerID+" was reistalled"); } ! //System.out.println("Host: "+mParentStack.getHostName()+", time: " + current_time); ! } ! while(!q_rs.isEmpty()){ ! Resender rs = (Resender) q_rs.poll(); ! int nt = ((Integer)q_nt.poll()).intValue(); ! rs.resend(nt); ! } ! if(!q_nt.isEmpty()) printLayerInfo(">>> TCP timer: synchronization ERROR!!!!"); }catch(Exception e){ e.printStackTrace(); --- 80,104 ---- public void run() { try{ ! LinkedList q_rs = new LinkedList(); ! LinkedList q_nt = new LinkedList(); ! synchronized(tcp_timers_lock){ ! while(!tcp_timers.isEmpty() && current_time > ((Resender)tcp_timers.peek()).getResendTime()){ ! Resender rs = (Resender)tcp_timers.poll(); ! int nt = rs.nextTime(current_time); ! if(nt>0){ ! tcp_timers.add(rs); ! } ! q_rs.add(rs); ! q_nt.add(new Integer(nt)); ! //printLayerInfo(">>> Timer "+mParentStack.getHostName()+":"+rs.timerID+" was reistalled"); } ! //System.out.println("Host: "+mParentStack.getHostName()+", time: " + current_time); } ! while(!q_rs.isEmpty()){ ! Resender rs = (Resender) q_rs.poll(); ! int nt = ((Integer)q_nt.poll()).intValue(); ! rs.resend(nt); ! } ! if(!q_nt.isEmpty()) printLayerInfo(">>> TCP timer: synchronization ERROR!!!!"); }catch(Exception e){ e.printStackTrace(); *************** *** 133,138 **** try{ IncSentDuplicatesNumber(1); ! getSession(mParentStack.SL().get_socket(sock).genKey()).inc_sent_duplicates(); ! sendPacket(packet, getSession(mParentStack.SL().get_socket(sock).genKey())); }catch(TransportLayerException e){ System.out.println(e.toString()); --- 133,141 ---- try{ IncSentDuplicatesNumber(1); ! TCP_session tcps = getSession(mParentStack.SL().get_socket(sock).genKey()); ! if(tcps!=null){ ! tcps.inc_sent_duplicates(); ! sendPacket(packet, getSession(mParentStack.SL().get_socket(sock).genKey())); ! } }catch(TransportLayerException e){ System.out.println(e.toString()); *************** *** 147,202 **** } else{ ! TCP_session tcps = getSession(mParentStack.SL().get_socket(sock).genKey()); ! tcps.removeSegmentToResend(packet.get_sequence_number()); ! switch(nt){ ! case 0:{ //normal quit, do nothing ! break; ! } ! case -1:{ ! try{ ! removeTimer(getSession(mSL.get_socket(sock).genKey()).last_timer); ! Application app = mSL.get_socket(sock).app; ! mSL.close(sock); ! app.OnDisconnect(sock); ! }catch(TransportLayerException e){ ! System.out.println(e.toString()); } ! break; ! } ! case -2:{ ! try{ ! Application app = mSL.get_socket(sock).app; //connect error ! mSL.close(sock); ! app.OnError(sock, -1); ! }catch(TransportLayerException e){ ! System.out.println(e.toString()); } ! break; ! } ! case -3:{ //acknowledgment have not recieved, close connection ! // send RST segment ! printLayerInfo(">>> Sending RST segment"); ! try{ ! boolean flags[] = genFlags(RST); ! TCP_packet rstpack = getTCPPacket_tosend(sock, "", flags, packet.get_acknowledgment_number(), packet.get_sequence_number()+1); ! sendPacket(rstpack, getSession(mParentStack.SL().get_socket(sock).genKey())); ! }catch(TransportLayerException e){ ! System.out.println(e.toString()); ! }catch(LowLinkException e){ ! System.out.println(e.toString()); ! }catch(CommunicationException e){ ! System.out.println(e.toString()); } ! // close seession ! try{ ! Application app = mSL.get_socket(sock).app; //disconnect on timeout, sending RST ! mSL.close(sock); ! app.OnError(sock, -2); ! }catch(TransportLayerException e){ ! System.out.println(e.toString()); } ! break; } - default: System.out.println("TCP error: unsupported resend time"); } } --- 150,209 ---- } else{ ! TCP_session tcps = getSession(mSL.get_socket(sock).genKey()); ! //TCP_session tcps = getSession(mParentStack.SL().get_socket(sock).genKey()); ! if(tcps!=null){ ! tcps.inc_sent_duplicates(); ! tcps.removeSegmentToResend(packet.get_sequence_number()); ! switch(nt){ ! case 0:{ //normal quit, do nothing ! break; } ! case -1:{ ! try{ ! removeTimer(tcps.last_timer); ! Application app = mSL.get_socket(sock).app; ! mSL.close(sock); ! app.OnDisconnect(sock); ! }catch(TransportLayerException e){ ! System.out.println(e.toString()); ! } ! break; } ! case -2:{ ! try{ ! Application app = mSL.get_socket(sock).app; //connect error ! mSL.close(sock); ! app.OnError(sock, -1); ! }catch(TransportLayerException e){ ! System.out.println(e.toString()); ! } ! break; } ! case -3:{ //acknowledgment have not recieved, close connection ! // send RST segment ! printLayerInfo("Sending RST segment"); ! try{ ! boolean flags[] = genFlags(RST); ! TCP_packet rstpack = getTCPPacket_tosend(sock, "", flags, packet.get_acknowledgment_number(), packet.get_sequence_number()+1); ! sendPacket(rstpack, tcps); ! }catch(TransportLayerException e){ ! System.out.println(e.toString()); ! }catch(LowLinkException e){ ! System.out.println(e.toString()); ! }catch(CommunicationException e){ ! System.out.println(e.toString()); ! } ! // close seession ! try{ ! Application app = mSL.get_socket(sock).app; //disconnect on timeout, sending RST ! mSL.close(sock); ! app.OnError(sock, -2); ! }catch(TransportLayerException e){ ! System.out.println(e.toString()); ! } ! break; } ! default: System.out.println("TCP error: unsupported resend time"); } } } *************** *** 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; --- 248,252 ---- private Timer timer; private PriorityQueue tcp_timers = new PriorityQueue(); ! private int window_size = 2; //tcp window-size for new sessions private Object tcp_timers_lock = new Object(); //for locking queue tcp_timers private int current_time = 0; *************** *** 577,582 **** TCP_session Elm = getSession(jnsock.genKey()); ! Elm.addSendingSegment(tosend, resendtimes); ! trySendSegments(Elm); return true; --- 584,594 ---- TCP_session Elm = getSession(jnsock.genKey()); ! if(!(flags[ACK_flag] || flags[RST_flag])){ ! Elm.addSendingSegment(tosend, resendtimes); ! trySendSegments(Elm); ! } ! else{ ! sendPacket(tosend, Elm); ! } return true; *************** *** 608,614 **** String pack_flags = (packet.get_ACK_flag()?"ACK,":"")+(packet.get_SYN_flag()?"SYN,":"")+(packet.get_FIN_flag()?"FIN,":"")+(packet.get_RST_flag()?"RST":""); System.out.println("|| <<< TCP send pack: src="+pack_src+" dst="+pack_dst+" flags="+pack_flags+" seq="+packet.get_sequence_number()+" ack="+packet.get_acknowledgment_number()+" data='"+packet.getTCP_message()+"'"); ! System.out.println("|| <<<< Host="+mParentStack.getHostName()+" IP="+mParentStack.getSrcIP()+" sock="+Elm.getSocket()+" state="+Elm.getState()); printLayerInfo("TCP packet send to "+pack_dst+" flags="+pack_flags+" seq="+packet.get_sequence_number()+" ack="+packet.get_acknowledgment_number()+" data='"+packet.getTCP_message()+"'"); IncSentSegmentsNumber(1); Elm.inc_sent_segments(); --- 620,635 ---- String pack_flags = (packet.get_ACK_flag()?"ACK,":"")+(packet.get_SYN_flag()?"SYN,":"")+(packet.get_FIN_flag()?"FIN,":"")+(packet.get_RST_flag()?"RST":""); System.out.println("|| <<< TCP send pack: src="+pack_src+" dst="+pack_dst+" flags="+pack_flags+" seq="+packet.get_sequence_number()+" ack="+packet.get_acknowledgment_number()+" data='"+packet.getTCP_message()+"'"); ! System.out.println("|| <<<< Host="+mParentStack.getHostName()+" IP="+mParentStack.getSrcIP()+" sock="+Elm.getSocket()+" state="+Elm.getStateString()); printLayerInfo("TCP packet send to "+pack_dst+" flags="+pack_flags+" seq="+packet.get_sequence_number()+" ack="+packet.get_acknowledgment_number()+" data='"+packet.getTCP_message()+"'"); + // if(packet.get_acknowledgment_number()!=Elm.getNextSequenceNumber()){ + // try{ + // throw new Exception(); + // } + // catch(Exception e){ + // e.printStackTrace(); + // } + // } + IncSentSegmentsNumber(1); Elm.inc_sent_segments(); *************** *** 744,749 **** } if(inPacket.get_ACK_flag() && inPacket.get_acknowledgment_number() > Elm.getLastACK()){ ! long tid = Elm.removeSegmentToResend(inPacket.get_acknowledgment_number()-1); ! removeTimer(tid); Elm.setLastACK(inPacket.get_acknowledgment_number()); trySendSegments(Elm); --- 765,779 ---- } if(inPacket.get_ACK_flag() && inPacket.get_acknowledgment_number() > Elm.getLastACK()){ ! Enumeration<Integer> acks = Elm.getAllSegmentToResendNumbers(); ! long tid; ! int lack = inPacket.get_acknowledgment_number(); ! int cack; ! while(acks.hasMoreElements()){ ! cack = acks.nextElement().intValue(); ! if(cack<lack){ ! tid = Elm.removeSegmentToResend(cack); ! removeTimer(tid); ! } ! } Elm.setLastACK(inPacket.get_acknowledgment_number()); trySendSegments(Elm); *************** *** 755,759 **** } else{ ! System.out.println("|| >>>> Host="+mParentStack.getHostName()+" IP="+mParentStack.getSrcIP()+" sock="+Elm.getSocket()+" state="+Elm.getState()); printLayerInfo("TCP packet received from "+ pack_src +" flags: "+pack_flags+" message: \"" +inPacket.getTCP_message() + "\"."); --- 785,789 ---- } else{ ! System.out.println("|| >>>> Host="+mParentStack.getHostName()+" IP="+mParentStack.getSrcIP()+" sock="+Elm.getSocket()+" state="+Elm.getStateString()); printLayerInfo("TCP packet received from "+ pack_src +" flags: "+pack_flags+" message: \"" +inPacket.getTCP_message() + "\"."); *************** *** 774,778 **** } } - } else { --- 804,807 ---- *************** *** 1010,1017 **** } if(readySegments>0){ - boolean flags[] = genFlags(ACK); - sendTCPSegment(Elm.getSocket(), "", flags, readySegments+1, resendtimes_NULL); mSL.recv(Elm.getSocket(), out); } } --- 1039,1047 ---- } if(readySegments>0){ mSL.recv(Elm.getSocket(), out); } + boolean flags[] = genFlags(ACK); + //sendTCPSegment(Elm.getSocket(), "", flags, readySegments+1, resendtimes_NULL); + sendTCPSegment(Elm.getSocket(), "", flags, Elm.getNextSequenceNumber(), resendtimes_NULL); } Index: TCP_session.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/TCP_session.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TCP_session.java 14 Oct 2007 22:14:52 -0000 1.10 --- TCP_session.java 11 Nov 2007 19:51:57 -0000 1.11 *************** *** 211,215 **** if(!Found){ receivedSegments.add(pack); ! if(next_pass_seq_num == -1) next_pass_seq_num = pack.get_sequence_number(); } } --- 211,216 ---- if(!Found){ receivedSegments.add(pack); ! if(next_pass_seq_num == -1) ! next_pass_seq_num = pack.get_sequence_number(); } } *************** *** 220,224 **** } ! /** * Pop expected segment from buffer * @result null if expected segment have not received yet --- 221,225 ---- } ! /** * Pop expected segment from buffer * @result null if expected segment have not received yet *************** *** 296,299 **** --- 297,304 ---- } + public int getNextSequenceNumber(){ + return next_pass_seq_num; + } + public void inc_received_segments(){ received_segments++; |
From: QweR <qw...@us...> - 2007-11-11 19:52:03
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19828/core Modified Files: EthernetLink.java Log Message: TCP bugs fixed Index: EthernetLink.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetLink.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** EthernetLink.java 10 Nov 2006 08:32:22 -0000 1.12 --- EthernetLink.java 11 Nov 2007 19:51:57 -0000 1.13 *************** *** 41,45 **** public class EthernetLink extends Link { ! /** * Constructor to be used by the Simulation when connecting 2 PC's --- 41,45 ---- public class EthernetLink extends Link { ! java.security.SecureRandom rng; /** * Constructor to be used by the Simulation when connecting 2 PC's *************** *** 58,62 **** NetworkInterfaces.add(inSecondNodeInterface); inFirstNodeInterface.setConnectedLink(this); ! inSecondNodeInterface.setConnectedLink(this); } --- 58,63 ---- NetworkInterfaces.add(inSecondNodeInterface); inFirstNodeInterface.setConnectedLink(this); ! inSecondNodeInterface.setConnectedLink(this); ! rng = new java.security.SecureRandom(); } *************** *** 68,71 **** --- 69,73 ---- inSecondNodeInterface.setConnectedLink(this); this.setSC(sieveCoeff); + rng = new java.security.SecureRandom(); } *************** *** 86,90 **** if (!temp.getSourceName().equals(inSourceName)) { ! if( ((sievingCoefficient)/100)>Math.random()) temp.receivePacket(inPacket); else{ --- 88,93 ---- if (!temp.getSourceName().equals(inSourceName)) { ! //if( ((sievingCoefficient)/100)>Math.random()) ! if((sievingCoefficient)>rng.nextInt(100)) temp.receivePacket(inPacket); else{ |
From: QweR <qw...@us...> - 2007-11-11 19:52:03
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19828/guiUI Modified Files: MainScreen.java Log Message: TCP bugs fixed Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** MainScreen.java 10 Nov 2007 13:25:39 -0000 1.80 --- MainScreen.java 11 Nov 2007 19:51:57 -0000 1.81 *************** *** 1649,1653 **** //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]); } --- 1649,1653 ---- //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]); } |
From: Alexander B. <da...@us...> - 2007-11-10 13:25:44
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv7891/core Modified Files: LayerInfoHandler.java WANNetworkInterface.java WANRMI.java WANRMIServer.java WANSocket.java Added Files: WANCorba.idl WANCorba.java WANCorbaHelper.java WANCorbaHolder.java WANCorbaOperations.java WANCorbaPOA.java WANCorbaServer.java _WANCorbaStub.java Log Message: Fixed critical section in LayerInfo, CORBA mechanisms templates... --- NEW FILE: WANCorbaOperations.java --- package core; /** * core/WANCorbaOperations.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from WANCorba.idl * 8 Íîÿáðü 2007 ã. 21:54:08 MSK */ public interface WANCorbaOperations { void receivePacket (String inPacket); void setServiceName (String inService); void shutdown (); } // interface WANCorbaOperations Index: WANRMIServer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANRMIServer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WANRMIServer.java 14 Oct 2007 17:19:07 -0000 1.1 --- WANRMIServer.java 10 Nov 2007 13:25:38 -0000 1.2 *************** *** 18,27 **** } ! public void recievePacket(Packet inPacket) throws RemoteException{ ! System.out.println("TEST!!!"); } public void setServiceName(String inService) throws RemoteException{ parentInterface.setConnService(inService); } } --- 18,30 ---- } ! public void recievePacket(String inPacket) throws RemoteException{ ! try{ ! parentInterface.receivePacket(inPacket); ! }catch(LowLinkException e){} } public void setServiceName(String inService) throws RemoteException{ parentInterface.setConnService(inService); + //parentInterface.connect(); } } --- NEW FILE: WANCorba.idl --- module core { interface WANCorba { void receivePacket(in string inPacket); void setServiceName(in string inService); oneway void shutdown(); }; }; --- NEW FILE: WANCorbaServer.java --- package core; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; import org.omg.PortableServer.*; import org.omg.PortableServer.POA; import java.util.Properties; class WANCorbaImpl extends WANCorbaPOA { private ORB orb; public void setORB(ORB orb_val) { orb = orb_val; } public void receivePacket (String inPacket){ System.out.println(inPacket); } public void setServiceName (String inService){ System.out.println(inService); } // implement shutdown() method public void shutdown() { orb.shutdown(false); } } public class WANCorbaServer { ORB orb; public WANCorbaServer(String name) { String args[] = {"",""}; orb = ORB.init(args, null); WANCorbaServerHandler wh = new WANCorbaServerHandler(orb, name); wh.start(); } public void close(){ if(orb!=null){ orb.shutdown(false); orb = null; } } class WANCorbaServerHandler extends Thread { ORB orb; WANCorbaServerHandler(ORB orb, String name) { try{ this.orb = orb; POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); WANCorbaImpl wImpl = new WANCorbaImpl(); wImpl.setORB(orb); org.omg.CORBA.Object ref = rootpoa.servant_to_reference(wImpl); WANCorba href = WANCorbaHelper.narrow(ref); org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); NameComponent path[] = ncRef.to_name( name ); ncRef.rebind(path, href); } catch (Exception e) { e.printStackTrace(System.out); } } public void run() { try{ orb.run(); }catch (Exception e) { e.printStackTrace(System.out); } } } } Index: WANRMI.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANRMI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WANRMI.java 14 Oct 2007 17:19:07 -0000 1.1 --- WANRMI.java 10 Nov 2007 13:25:38 -0000 1.2 *************** *** 16,20 **** */ public interface WANRMI extends java.rmi.Remote { ! public void recievePacket(Packet inPacket) throws RemoteException; public void setServiceName(String inService) throws RemoteException; --- 16,20 ---- */ public interface WANRMI extends java.rmi.Remote { ! public void recievePacket(String inPacket) throws RemoteException; public void setServiceName(String inService) throws RemoteException; Index: WANSocket.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANSocket.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WANSocket.java 20 Oct 2007 13:27:20 -0000 1.3 --- WANSocket.java 10 Nov 2007 13:25:38 -0000 1.4 *************** *** 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; /** * --- 11,15 ---- import java.io.*; import java.net.*; ! /** * *************** *** 98,132 **** 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': ! TCP_packet tcp = new TCP_packet("","",0,0); ! tcp.fromBytes(inPacket); ! parentInterface.receivePacket(tcp); ! break; ! case 'U': ! UDP_packet udp = new UDP_packet("","",0,0); ! udp.fromBytes(inPacket); ! parentInterface.receivePacket(udp); ! break; ! } ! } --- 95,99 ---- public void recievePacket(String inPacket) throws LowLinkException{ ! parentInterface.receivePacket(inPacket); } --- NEW FILE: WANCorbaHolder.java --- package core; /** * core/WANCorbaHolder.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from WANCorba.idl * 8 Íîÿáðü 2007 ã. 21:54:08 MSK */ public final class WANCorbaHolder implements org.omg.CORBA.portable.Streamable { public core.WANCorba value = null; public WANCorbaHolder () { } public WANCorbaHolder (core.WANCorba initialValue) { value = initialValue; } public void _read (org.omg.CORBA.portable.InputStream i) { value = core.WANCorbaHelper.read (i); } public void _write (org.omg.CORBA.portable.OutputStream o) { core.WANCorbaHelper.write (o, value); } public org.omg.CORBA.TypeCode _type () { return core.WANCorbaHelper.type (); } } --- NEW FILE: _WANCorbaStub.java --- package core; /** * core/_WANCorbaStub.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from WANCorba.idl * 8 Íîÿáðü 2007 ã. 21:54:08 MSK */ public class _WANCorbaStub extends org.omg.CORBA.portable.ObjectImpl implements core.WANCorba { public void receivePacket (String inPacket) { org.omg.CORBA.portable.InputStream $in = null; try { org.omg.CORBA.portable.OutputStream $out = _request ("receivePacket", true); $out.write_string (inPacket); $in = _invoke ($out); return; } catch (org.omg.CORBA.portable.ApplicationException $ex) { $in = $ex.getInputStream (); String _id = $ex.getId (); throw new org.omg.CORBA.MARSHAL (_id); } catch (org.omg.CORBA.portable.RemarshalException $rm) { receivePacket (inPacket ); } finally { _releaseReply ($in); } } // receivePacket public void setServiceName (String inService) { org.omg.CORBA.portable.InputStream $in = null; try { org.omg.CORBA.portable.OutputStream $out = _request ("setServiceName", true); $out.write_string (inService); $in = _invoke ($out); return; } catch (org.omg.CORBA.portable.ApplicationException $ex) { $in = $ex.getInputStream (); String _id = $ex.getId (); throw new org.omg.CORBA.MARSHAL (_id); } catch (org.omg.CORBA.portable.RemarshalException $rm) { setServiceName (inService ); } finally { _releaseReply ($in); } } // setServiceName public void shutdown () { org.omg.CORBA.portable.InputStream $in = null; try { org.omg.CORBA.portable.OutputStream $out = _request ("shutdown", false); $in = _invoke ($out); return; } catch (org.omg.CORBA.portable.ApplicationException $ex) { $in = $ex.getInputStream (); String _id = $ex.getId (); throw new org.omg.CORBA.MARSHAL (_id); } catch (org.omg.CORBA.portable.RemarshalException $rm) { shutdown ( ); } finally { _releaseReply ($in); } } // shutdown // Type-specific CORBA::Object operations private static String[] __ids = { "IDL:core/WANCorba:1.0"}; public String[] _ids () { return (String[])__ids.clone (); } private void readObject (java.io.ObjectInputStream s) throws java.io.IOException { String str = s.readUTF (); String[] args = null; java.util.Properties props = null; org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str); org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate (); _set_delegate (delegate); } private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException { String[] args = null; java.util.Properties props = null; String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this); s.writeUTF (str); } } // class _WANCorbaStub Index: LayerInfoHandler.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/LayerInfoHandler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LayerInfoHandler.java 20 Nov 2005 20:30:53 -0000 1.2 --- LayerInfoHandler.java 10 Nov 2007 13:25:38 -0000 1.3 *************** *** 50,55 **** --- 50,58 ---- private boolean ended; + private boolean blocked; + /** Constructs a new LayerInfoHandler */ protected LayerInfoHandler() { + blocked = false; infoQueue = new Vector(); ended = false; *************** *** 63,69 **** --- 66,74 ---- */ public void receiveInfo(LayerInfo info) { + block(); if (!ended) { infoQueue.add(info); } + unblock(); } *************** *** 75,84 **** **/ public LayerInfo getNext() { ! if (infoQueue.size() == 0) { ! return null; ! } ! LayerInfo info = (LayerInfo)infoQueue.elementAt(0); ! infoQueue.remove(0); ! return info; } --- 80,92 ---- **/ public LayerInfo getNext() { ! block(); ! if (infoQueue.size() == 0) { ! unblock(); ! return null; ! } ! LayerInfo info = (LayerInfo)infoQueue.elementAt(0); ! infoQueue.remove(0); ! unblock(); ! return info; } *************** *** 110,114 **** --- 118,124 ---- **/ public void clear(){ + block(); infoQueue = new Vector(); + unblock(); } *************** *** 120,125 **** * @version v0.10 **/ ! public Vector getRecordedInfo(){ ! Vector output = new Vector(); Iterator it = infoQueue.iterator(); while(it.hasNext()){ --- 130,136 ---- * @version v0.10 **/ ! public Vector getRecordedInfo(){ ! block(); ! Vector output = new Vector(); Iterator it = infoQueue.iterator(); while(it.hasNext()){ *************** *** 127,131 **** --- 138,155 ---- output.addElement(tempInfo.getRecordedInfo()); } + unblock(); return output; } + + protected void block(){ + try{ + while(blocked) + Thread.sleep(10); + }catch(Exception e){ e.printStackTrace(); } + blocked = true; + } + + protected void unblock(){ + blocked = false; + } }//EOF Index: WANNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANNetworkInterface.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WANNetworkInterface.java 19 Oct 2007 19:38:06 -0000 1.4 --- WANNetworkInterface.java 10 Nov 2007 13:25:38 -0000 1.5 *************** *** 32,35 **** --- 32,39 ---- import java.rmi.*; import java.rmi.Naming; + 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; public class WANNetworkInterface extends NetworkInterface{ *************** *** 97,101 **** public void UP(){ up = listen(); ! up &= connect(); super.UP(); } --- 101,107 ---- public void UP(){ up = listen(); ! if(!server){ ! up &= connect(); ! } super.UP(); } *************** *** 118,123 **** up = false; } ! ! protected void receivePacket(Packet inPacket) throws LowLinkException { // cast the packet to an EthernetPacket //Ethernet_packet tempPacket = (Ethernet_packet)inPacket; --- 124,129 ---- up = false; } ! ! public void receivePacket(Packet inPacket) throws LowLinkException { // cast the packet to an EthernetPacket //Ethernet_packet tempPacket = (Ethernet_packet)inPacket; *************** *** 140,143 **** --- 146,183 ---- parentNode.receivePacket(inPacket, name); } + + public void receivePacket(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); + receivePacket(icmp); + break; + case 'I': + IP_packet ip = new IP_packet(""); + ip.fromBytes(inPacket); + receivePacket(ip); + break; + case 'T': + TCP_packet tcp = new TCP_packet("","",0,0); + tcp.fromBytes(inPacket); + receivePacket(tcp); + break; + case 'U': + UDP_packet udp = new UDP_packet("","",0,0); + udp.fromBytes(inPacket); + receivePacket(udp); + break; + } + + } public int getType(){ *************** *** 147,154 **** protected void sendPacket(Packet inPacket) throws LowLinkException { if(!connected){ ! connect(); } ! ! addLayerInfo("WAN Packet", "Sending packet from interface "+ name); if(connected){ --- 187,193 ---- protected void sendPacket(Packet inPacket) throws LowLinkException { if(!connected){ ! connect(); } ! addLayerInfo("WAN Packet", "Sending packet from interface " + name); if(connected){ *************** *** 156,163 **** switch(type){ case RMI: ! RMIServer.recievePacket(inPacket); break; case SocketTCP: case SocketUDP: s.sendPacket(inPacket); break; --- 195,203 ---- switch(type){ case RMI: ! RMIClient.recievePacket(inPacket.toBytes()); break; case SocketTCP: case SocketUDP: + s.sendPacket(inPacket); break; *************** *** 199,203 **** RMIServer = new WANRMIServer(this); Naming.bind (name, RMIServer); ! return true; } --- 239,243 ---- RMIServer = new WANRMIServer(this); Naming.bind (name, RMIServer); ! return true; } *************** *** 218,222 **** ! protected boolean connect(){ try{ switch(type){ --- 258,262 ---- ! public boolean connect(){ try{ switch(type){ --- NEW FILE: WANCorbaPOA.java --- package core; /** * core/WANCorbaPOA.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from WANCorba.idl * 8 Íîÿáðü 2007 ã. 21:54:08 MSK */ public abstract class WANCorbaPOA extends org.omg.PortableServer.Servant implements core.WANCorbaOperations, org.omg.CORBA.portable.InvokeHandler { // Constructors private static java.util.Hashtable _methods = new java.util.Hashtable (); static { _methods.put ("receivePacket", new java.lang.Integer (0)); _methods.put ("setServiceName", new java.lang.Integer (1)); _methods.put ("shutdown", new java.lang.Integer (2)); } public org.omg.CORBA.portable.OutputStream _invoke (String $method, org.omg.CORBA.portable.InputStream in, org.omg.CORBA.portable.ResponseHandler $rh) { org.omg.CORBA.portable.OutputStream out = null; java.lang.Integer __method = (java.lang.Integer)_methods.get ($method); if (__method == null) throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); switch (__method.intValue ()) { case 0: // core/WANCorba/receivePacket { String inPacket = in.read_string (); this.receivePacket (inPacket); out = $rh.createReply(); break; } case 1: // core/WANCorba/setServiceName { String inService = in.read_string (); this.setServiceName (inService); out = $rh.createReply(); break; } case 2: // core/WANCorba/shutdown { this.shutdown (); out = $rh.createReply(); break; } default: throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); } return out; } // _invoke // Type-specific CORBA::Object operations private static String[] __ids = { "IDL:core/WANCorba:1.0"}; public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId) { return (String[])__ids.clone (); } public WANCorba _this() { return WANCorbaHelper.narrow( super._this_object()); } public WANCorba _this(org.omg.CORBA.ORB orb) { return WANCorbaHelper.narrow( super._this_object(orb)); } } // class WANCorbaPOA --- NEW FILE: WANCorba.java --- package core; /** * core/WANCorba.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from WANCorba.idl * 8 Íîÿáðü 2007 ã. 21:54:08 MSK */ public interface WANCorba extends WANCorbaOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { } // interface WANCorba --- NEW FILE: WANCorbaHelper.java --- package core; /** * core/WANCorbaHelper.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from WANCorba.idl * 8 Íîÿáðü 2007 ã. 21:54:08 MSK */ abstract public class WANCorbaHelper { private static String _id = "IDL:core/WANCorba:1.0"; public static void insert (org.omg.CORBA.Any a, core.WANCorba that) { org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); a.type (type ()); write (out, that); a.read_value (out.create_input_stream (), type ()); } public static core.WANCorba extract (org.omg.CORBA.Any a) { return read (a.create_input_stream ()); } private static org.omg.CORBA.TypeCode __typeCode = null; synchronized public static org.omg.CORBA.TypeCode type () { if (__typeCode == null) { __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (core.WANCorbaHelper.id (), "WANCorba"); } return __typeCode; } public static String id () { return _id; } public static core.WANCorba read (org.omg.CORBA.portable.InputStream istream) { return narrow (istream.read_Object (_WANCorbaStub.class)); } public static void write (org.omg.CORBA.portable.OutputStream ostream, core.WANCorba value) { ostream.write_Object ((org.omg.CORBA.Object) value); } public static core.WANCorba narrow (org.omg.CORBA.Object obj) { if (obj == null) return null; else if (obj instanceof core.WANCorba) return (core.WANCorba)obj; else if (!obj._is_a (id ())) throw new org.omg.CORBA.BAD_PARAM (); else { org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); core._WANCorbaStub stub = new core._WANCorbaStub (); stub._set_delegate(delegate); return stub; } } public static core.WANCorba unchecked_narrow (org.omg.CORBA.Object obj) { if (obj == null) return null; else if (obj instanceof core.WANCorba) return (core.WANCorba)obj; else { org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); core._WANCorbaStub stub = new core._WANCorbaStub (); stub._set_delegate(delegate); return stub; } } } |
From: Alexander B. <da...@us...> - 2007-11-10 13:25:44
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv7891/guiUI Modified Files: GuiNode.java MainScreen.java WANPortProperties.java Log Message: Fixed critical section in LayerInfo, CORBA mechanisms templates... Index: WANPortProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/WANPortProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WANPortProperties.java 19 Oct 2007 19:38:07 -0000 1.1 --- WANPortProperties.java 10 Nov 2007 13:25:39 -0000 1.2 *************** *** 472,478 **** case WANNetworkInterface.RMI: ! cmbRole.setEnabled(false); txtHost.setEnabled(true); ! txtPort.setEnabled(true); txtPort.setText(""); txtService.setEnabled(true); --- 472,478 ---- case WANNetworkInterface.RMI: ! cmbRole.setEnabled(true); txtHost.setEnabled(true); ! txtPort.setEnabled(false); txtPort.setText(""); txtService.setEnabled(true); Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** MainScreen.java 20 Oct 2007 22:54:40 -0000 1.79 --- MainScreen.java 10 Nov 2007 13:25:39 -0000 1.80 *************** *** 211,214 **** --- 211,215 ---- + public boolean LIlocked; String columnNames[] = { "English", "Japanese", "Boolean", "Date", "ImageIcon" }; *************** *** 417,420 **** --- 418,423 ---- buildGUI(); + LIlocked = false; + Timer timer = null; timer=new Timer(); *************** *** 1608,1612 **** public void printLayerInfo(boolean header){ ! //if(header) pnlConsole.append("\n"); --- 1611,1617 ---- public void printLayerInfo(boolean header){ ! if(LIlocked) return; ! LIlocked = true; ! //if(header) pnlConsole.append("\n"); *************** *** 1657,1660 **** --- 1662,1666 ---- } + LIlocked = false; } *************** *** 4032,4042 **** } ! public String TurnDevice(String inNodeName){ try{ if(Sim.getNode(inNodeName).On == true){ ! Sim.getNode(inNodeName).turnOff(); ! return "Turn On"; }else{ Sim.getNode(inNodeName).turnOn(); return "Turn Off"; } --- 4038,4057 ---- } ! public void TurnDevice(String inNodeName){ try{ if(Sim.getNode(inNodeName).On == true){ ! Sim.getNode(inNodeName).turnOff(); }else{ Sim.getNode(inNodeName).turnOn(); + + } + }catch(Exception e){ } + } + + public String DeviceState(String inNodeName){ + try{ + if(Sim.getNode(inNodeName).On == true){ + return "Turn On"; + }else{ return "Turn Off"; } *************** *** 4410,4414 **** public void RunCmd(String inNodeName){ try{ ! if(/*!(Sim.getNode(inNodeName) instanceof core.NetworkLayerDevice) &&*/ !(Sim.getNode(inNodeName) instanceof core.Printer)){ Terminal r = new Terminal(this, (core.NetworkLayerDevice)Sim.getNode(inNodeName)); r.pack(); --- 4425,4429 ---- public void RunCmd(String inNodeName){ try{ ! if(!(Sim.getNode(inNodeName) instanceof core.Printer)){ Terminal r = new Terminal(this, (core.NetworkLayerDevice)Sim.getNode(inNodeName)); r.pack(); Index: GuiNode.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiNode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GuiNode.java 15 Oct 2007 18:25:54 -0000 1.5 --- GuiNode.java 10 Nov 2007 13:25:39 -0000 1.6 *************** *** 358,366 **** GuiNodePopMenu.add(mnuInt); mnuTurn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ //controller.showLinkDialog(lblNodeName.getText()); ! mnuTurn.setText(controller.TurnDevice(lblNodeName.getText())); } --- 358,368 ---- GuiNodePopMenu.add(mnuInt); + mnuTurn.setText(controller.DeviceState(lblNodeName.getText())); mnuTurn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ //controller.showLinkDialog(lblNodeName.getText()); ! controller.TurnDevice(lblNodeName.getText()); ! mnuTurn.setText(controller.DeviceState(lblNodeName.getText())); } |
From: Alexander B. <da...@us...> - 2007-11-10 13:25:42
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv7891 Modified Files: TODO.txt windows.bat Log Message: Fixed critical section in LayerInfo, CORBA mechanisms templates... Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** TODO.txt 20 Oct 2007 20:19:46 -0000 1.27 --- TODO.txt 10 Nov 2007 13:25:38 -0000 1.28 *************** *** 4,8 **** *** Whole Project ! 2. Add (UDP sockets, RMI and Corba mechanisms) to CSU/DSU units 3. DHCP server/clients : re-leasing, MAC-filter and excludes. 4. Socks Proxy(old -- Nat Gateway) to external network. --- 4,8 ---- *** Whole Project ! 2. Add (UDPz sockets, RMI and Corba mechanisms) to CSU/DSU units 3. DHCP server/clients : re-leasing, MAC-filter and excludes. 4. Socks Proxy(old -- Nat Gateway) to external network. Index: windows.bat =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/windows.bat,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** windows.bat 13 Oct 2007 12:57:00 -0000 1.4 --- windows.bat 10 Nov 2007 13:25:38 -0000 1.5 *************** *** 1,2 **** --- 1,3 ---- rem Java > 1.5 java -Xss50m -Xoss100m -jar javaNetSim.jar + rem -Xms100m -Xmx400m -Xss50m -Xoss100m \ No newline at end of file |
From: QweR <qw...@us...> - 2007-10-29 16:10:22
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16733/core/protocolsuite/tcp_ip Modified Files: Tag: STABLE-0_34 Telnet_server.java Log Message: running snmp over telnet bug was fixed Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -C2 -d -r1.17 -r1.17.2.1 *** Telnet_server.java 1 Oct 2007 04:58:12 -0000 1.17 --- Telnet_server.java 29 Oct 2007 16:08:45 -0000 1.17.2.1 *************** *** 325,342 **** try{ snmpa.Close(); - snmpa.Disconnect(); - out+="SNMP agent stoped\r\n"; - snmpa.setPassword(l_pass); - snmpa.setPort(l_port); - try{ - snmpa.Listen(); - out+="Now SNMP agent listen on port " + String.valueOf(l_port) + "\r\n"; - } - catch(TransportLayerException e) { - out+="Unable to open connection on SNMP agent\r\n"; - } } catch(TransportLayerException e) { ! out+="Unable to close connection on SNMP agent\r\n"; } } --- 325,341 ---- try{ snmpa.Close(); } catch(TransportLayerException e) { ! //out+="Unable to close connection on SNMP agent\r\n"; ! } ! out+="SNMP agent stoped\r\n"; ! snmpa.setPassword(l_pass); ! snmpa.setPort(l_port); ! try{ ! snmpa.Listen(); ! out+="Now SNMP agent listen on port " + String.valueOf(l_port) + "\r\n"; ! } ! catch(TransportLayerException e) { ! out+="Unable to open connection on SNMP agent\r\n"; } } |
From: QweR <qw...@us...> - 2007-10-23 20:14:55
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv14031/core Modified Files: AccessListEngine.java CommandProcessor.java CommandsTree.java DeviceConfig.java NetworkLayerDevice.java Log Message: ACLs in configs (ip acc, show acc, show run) works Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NetworkLayerDevice.java 19 Oct 2007 08:52:26 -0000 1.12 --- NetworkLayerDevice.java 23 Oct 2007 20:14:48 -0000 1.13 *************** *** 49,52 **** --- 49,53 ---- private DeviceConfig config = new DeviceConfig(this); + private AccessListEngine acls = new AccessListEngine(this); /** *************** *** 74,78 **** public void turnOff(){ - config.clear(DeviceConfig.RUNNING_CONFIG); super.turnOff(); } --- 75,78 ---- *************** *** 350,352 **** --- 350,355 ---- } + public AccessListEngine getACL(){ + return acls; + } }//EOF Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CommandProcessor.java 20 Oct 2007 22:54:40 -0000 1.7 --- CommandProcessor.java 23 Oct 2007 20:14:48 -0000 1.8 *************** *** 26,29 **** --- 26,30 ---- import java.util.Vector; import core.CommandInterface.Modes; + import core.AccessListEngine.access_list; /** *************** *** 43,47 **** private copy_running_startup_CommandClass copy_running_startup_Command = new copy_running_startup_CommandClass(); private copy_startup_running_CommandClass copy_startup_running_Command = new copy_startup_running_CommandClass(); - private erase_running_config_CommandClass erase_running_config_Command = new erase_running_config_CommandClass(); private erase_startup_config_CommandClass erase_startup_config_Command = new erase_startup_config_CommandClass(); private help_CommandClass help_Command = new help_CommandClass(); --- 44,47 ---- *************** *** 123,127 **** commands.add("copy startup-config running-config", copy_startup_running_Command, "Copy from one file to another"); commands.addDescription("erase","Erase a filesystem"); - commands.add("erase running-config", erase_running_config_Command, "Erase a running-config"); commands.add("erase startup-config", erase_startup_config_Command, "Erase a startup-config"); commands.add("help", help_Command, "Description of the interactive help system"); --- 123,126 ---- *************** *** 343,347 **** } public String call(Vector<String> params){ ! boolean res = device.getConfig().copy(DeviceConfig.RUNNING_CONFIG, DeviceConfig.STARTUP_CONFIG); String out = "Startup-config is not empty!\n"; if(res){ --- 342,346 ---- } public String call(Vector<String> params){ ! boolean res = device.getConfig().writeMemory(); String out = "Startup-config is not empty!\n"; if(res){ *************** *** 372,386 **** } public String call(Vector<String> params){ ! device.getConfig().clear(DeviceConfig.STARTUP_CONFIG); ! return "Config was erased\n"; ! } ! }; ! class erase_running_config_CommandClass extends CommandInterface{ ! public erase_running_config_CommandClass(){ ! modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } ! public String call(Vector<String> params){ ! device.getConfig().clear(DeviceConfig.RUNNING_CONFIG); return "Config was erased\n"; } --- 371,375 ---- } public String call(Vector<String> params){ ! device.getConfig().clearStartupConfig(); return "Config was erased\n"; } *************** *** 944,959 **** public ip_access_list_standart_CommandClass(){ modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); ! call_params = "<1-2699 | WORD> [<line>] (permit|deny) (any|host <ip>|<ip> <mask>)"; ! no_call_params = "<1-2699 | WORD> [<line>] (permit|deny) (any|host <ip>|<ip> <mask>)"; } public String call(Vector<String> params){ String out = ""; ! if(params.size()>=3){ ! device.getConfig().remove("^"); ! device.getConfig().add(""); } ! else{ out += "error: invalid parameters\n"; } return out; } --- 933,993 ---- public ip_access_list_standart_CommandClass(){ modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.NO_CALL); ! call_params = "<1-99> [<line>] (permit|deny) (any|host <ip>|<ip> <mask>)"; ! no_call_params = "<1-99> [<line>] (permit|deny) (any|host <ip>|<ip> <mask>)"; } public String call(Vector<String> params){ String out = ""; ! try{ ! int iacl = Integer.parseInt(params.get(0)); ! if(iacl>=1 && iacl<=2699){ ! int iline = -1; ! int index = 1; ! try{ ! iline = Integer.parseInt(params.get(1)); ! index = 2; ! } catch(NumberFormatException e){ } ! String permit_deny = params.get(index); ! ! short action=-1; ! if(permit_deny.equalsIgnoreCase("permit")){ ! action = AccessListEngine.access_list.PERMIT; ! } ! else if(permit_deny.equalsIgnoreCase("deny")){ ! action = AccessListEngine.access_list.DENY; ! } ! ! if(action>-1){ ! String ip; ! String mask; ! String hosts = params.get(index+1); ! if(hosts.equalsIgnoreCase("any")){ ! ip = "0.0.0.0"; ! mask = "0.0.0.0"; ! } ! else if(hosts.equals("host")){ ! ip = params.get(index+2); ! mask = "255.255.255.255"; ! } ! else{ ! ip = hosts; ! mask = params.get(index+2); ! } ! //device.getConfig().add("ip access-list "+iacl+" "+permit_deny+" "+hosts); ! device.getACL().addACL(iacl, iline, action, ip, mask); ! } ! else{ ! out += "error: invalid parameter: '"+permit_deny+"'\n"; ! } ! } ! else{ ! out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 1 to 2699\n"; ! } } ! catch(ArrayIndexOutOfBoundsException e){ out += "error: invalid parameters\n"; } + catch(NumberFormatException e){ + out += "error: invalid ACL name '"+params.get(0)+"', ACL name must be number from 1 to 2699\n"; + } return out; } *************** *** 972,977 **** public ip_access_list_extended_CommandClass(){ modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); ! call_params = "<1-2699 | WORD> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [(eq|lt|gt|neq) <port>] [established]"; ! no_call_params = "<1-2699 | WORD> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [(eq|lt|gt|neq) <port>] [established]"; } public String call(Vector<String> params){ --- 1006,1011 ---- public ip_access_list_extended_CommandClass(){ modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); ! call_params = "<100-2699> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [(eq|lt|gt|neq) <port>] [established]"; ! no_call_params = "<100-2699> [<line>] (permit|deny) (ip|tcp|udp|icmp) (any|host <ip>|<ip> <mask>) (any|host <ip>|<ip> <mask>) [(eq|lt|gt|neq) <port>] [established]"; } public String call(Vector<String> params){ *************** *** 1524,1533 **** } public String call(Vector<String> params){ ! String out = "Command not supported yet.\n"; ! if(device instanceof ApplicationLayerDevice){ ! ! } ! else{ ! out += "This instruction not supported by device\n"; } return out; --- 1558,1646 ---- } public String call(Vector<String> params){ ! String out = ""; ! final int ERROR = 0; ! final int STANDART = 1; ! final int EXTENDED = 2; ! Hashtable acls = device.getACL().ACLs; ! ! Enumeration<Integer> aclkeys = acls.keys(); ! while(aclkeys.hasMoreElements()){ ! Hashtable acl = (Hashtable)acls.get((Integer)aclkeys.nextElement()); ! ! Enumeration rulekeys = acl.keys(); ! while(rulekeys.hasMoreElements()){ ! access_list rule = (access_list)acl.get((Integer)rulekeys.nextElement()); ! ! String type = "unsupported_acl_type"; ! int itype = 0; ! if(rule.number>=1 && rule.number<=99){ ! type = "standart"; ! itype = STANDART; ! } ! else if(rule.number>=100 && rule.number<=2699){ ! type = "extended"; ! itype = EXTENDED; ! } ! ! String permit_deny = "unsupported_action"; ! if(rule.action==rule.DENY){ ! permit_deny = "deny "; ! } ! else if(rule.action==rule.PERMIT){ ! permit_deny = "permit"; ! } ! ! String hosts1 = "unsupported_hosts_1"; ! if(rule.IP1.equals("0.0.0.0") && rule.SubnetMask1.equals("0.0.0.0")){ ! hosts1 = "any"; ! } ! else if(rule.SubnetMask1.equals("255.255.255.255")){ ! hosts1 = "host "+rule.IP1; ! } ! else{ ! hosts1 = rule.IP1+" "+rule.SubnetMask1; ! } ! ! String hosts2 = "unsupported_hosts_2"; ! if(itype==EXTENDED){ ! if(rule.IP2.equals("0.0.0.0") && rule.SubnetMask2.equals("0.0.0.0")){ ! hosts2 = "any"; ! } ! else if(rule.SubnetMask2.equals("255.255.255.255")){ ! hosts2 = "host "+rule.IP2; ! } ! else{ ! hosts2 = rule.IP2+" "+rule.SubnetMask2; ! } ! } ! ! String protocol = "unsupported_protocol"; ! if(rule.protocol==rule.IP){ ! protocol = "ip "; ! } ! else if(rule.protocol==rule.TCP){ ! protocol = "tcp "; ! } ! else if(rule.protocol==rule.UDP){ ! protocol = "udp "; ! } ! else if(rule.protocol==rule.ICMP){ ! protocol = "icmp"; ! } ! ! String port = "unsupported_port"; ! if(rule.Port1 == 0){ ! port = ""; ! } ! else{ ! port = "eq "+rule.Port1; ! } ! ! switch(itype){ ! case STANDART: out += "ip access-list "+type+" "+rule.number+" "+rule.line+" "+permit_deny+" "+hosts1+"\n"; break; ! case EXTENDED: out += "ip access-list "+type+" "+rule.number+" "+rule.line+" "+permit_deny+" "+protocol+" "+hosts1+" "+hosts2+" "+port+"\n"; break; ! default: out += "ip access-list "+type+" "+rule.number+" "+rule.line+" "+permit_deny+" "+protocol+" "+hosts1+" "+hosts2+" "+rule.Port2+"\n"; ! } ! } } return out; *************** *** 2280,2285 **** } public String call(Vector<String> params){ ! device.getConfig().clear(DeviceConfig.STARTUP_CONFIG); ! boolean res = device.getConfig().copy(DeviceConfig.RUNNING_CONFIG, DeviceConfig.STARTUP_CONFIG); String out = "Startup-config is not empty!\n"; if(res){ --- 2393,2398 ---- } public String call(Vector<String> params){ ! device.getConfig().clearStartupConfig(); ! boolean res = device.getConfig().writeMemory(); String out = "Startup-config is not empty!\n"; if(res){ Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DeviceConfig.java 20 Oct 2007 22:54:40 -0000 1.7 --- DeviceConfig.java 23 Oct 2007 20:14:48 -0000 1.8 *************** *** 10,13 **** --- 10,14 ---- package core; + import core.AccessListEngine.access_list; import java.util.Iterator; import java.util.LinkedList; *************** *** 16,19 **** --- 17,24 ---- import java.util.regex.PatternSyntaxException; import core.CommandInterface.Modes; + import core.protocolsuite.tcp_ip.IPV4Address; + import java.util.Enumeration; + import java.util.Hashtable; + import core.AccessListEngine.access_list; /** *************** *** 25,28 **** --- 30,34 ---- public final static int RUNNING_CONFIG = 1; public final static int STARTUP_CONFIG = 2; + private final static String EXEC = "#"; public int working_config = RUNNING_CONFIG; *************** *** 36,39 **** --- 42,46 ---- /** Creates a new instance of DeviceConfig */ public DeviceConfig(NetworkLayerDevice dev) { + initRunningConfig(); cmdproc = new CommandProcessor(dev); device = dev; *************** *** 51,55 **** public void load(){ Iterator<String> it = startup_config.iterator(); ! clear(RUNNING_CONFIG); while(it.hasNext()){ --- 58,62 ---- public void load(){ Iterator<String> it = startup_config.iterator(); ! initRunningConfig(); while(it.hasNext()){ *************** *** 63,67 **** LinkedList config = null; switch(config_name){ ! case RUNNING_CONFIG: config = running_config; break; case STARTUP_CONFIG: config = startup_config; break; default: --- 70,74 ---- LinkedList config = null; switch(config_name){ ! case RUNNING_CONFIG: config = prepareConfig(running_config); break; case STARTUP_CONFIG: config = startup_config; break; default: *************** *** 70,90 **** } ! public void clear(int config_name){ ! LinkedList config = getConfig(config_name); ! while(!config.isEmpty()) ! config.removeLast(); } ! public boolean copy(int config_out, int config_in){ boolean result = false; ! if(config_out != config_in){ ! LinkedList cnfin = getConfig(config_in); ! if(cnfin.isEmpty()){ ! Iterator<String> it = getConfig(config_out).iterator(); ! while(it.hasNext()){ ! cnfin.add(it.next()); ! } ! result = true; } } return result; --- 77,99 ---- } ! public void clearStartupConfig(){ ! while(!startup_config.isEmpty()) ! startup_config.removeLast(); } ! private void initRunningConfig(){ ! while(!running_config.isEmpty()) ! running_config.removeLast(); ! running_config.add("#ACLS"); ! } ! ! public boolean writeMemory(){ boolean result = false; ! if(startup_config.isEmpty()){ ! Iterator<String> it = prepareConfig(running_config).iterator(); ! while(it.hasNext()){ ! startup_config.add(it.next()); } + result = true; } return result; *************** *** 212,214 **** --- 221,350 ---- } + private LinkedList prepareConfig(LinkedList in){ + LinkedList out = new LinkedList(); + Iterator it = in.iterator(); + while(it.hasNext()){ + String nc = (String)it.next(); + if(nc.startsWith(EXEC)){ + nc = nc.substring(EXEC.length()); + if(nc.equalsIgnoreCase("ACLS")){ + fillConfigACLS(out); + } + // else if(nc.equalsIgnoreCase("")){ + // + // } + // else if(nc.equalsIgnoreCase("")){ + // + // } + // else if(nc.equalsIgnoreCase("")){ + // + // } + // else if(nc.equalsIgnoreCase("")){ + // + // } + // else if(nc.equalsIgnoreCase("")){ + // + // } + // else if(nc.equalsIgnoreCase("")){ + // + // } + else{ + out.add("#ERROR: unsupported keyword #"+nc); + } + } + else{ + out.add(nc); + } + } + return out; + } + + private void fillConfigACLS(LinkedList conf){ + final int ERROR = 0; + final int STANDART = 1; + final int EXTENDED = 2; + Hashtable acls = device.getACL().ACLs; + + Enumeration<Integer> aclkeys = acls.keys(); + while(aclkeys.hasMoreElements()){ + Hashtable acl = (Hashtable)acls.get((Integer)aclkeys.nextElement()); + + Enumeration rulekeys = acl.keys(); + while(rulekeys.hasMoreElements()){ + access_list rule = (access_list)acl.get((Integer)rulekeys.nextElement()); + + String type = "unsupported_acl_type"; + int itype = 0; + if(rule.number>=1 && rule.number<=99){ + type = "standart"; + itype = STANDART; + } + else if(rule.number>=100 && rule.number<=2699){ + type = "extended"; + itype = EXTENDED; + } + + String permit_deny = "unsupported_action"; + if(rule.action==rule.DENY){ + permit_deny = "deny "; + } + else if(rule.action==rule.PERMIT){ + permit_deny = "permit"; + } + + String hosts1 = "unsupported_hosts_1"; + if(rule.IP1.equals("0.0.0.0") && rule.SubnetMask1.equals("0.0.0.0")){ + hosts1 = "any"; + } + else if(rule.SubnetMask1.equals("255.255.255.255")){ + hosts1 = "host "+rule.IP1; + } + else{ + hosts1 = rule.IP1+" "+rule.SubnetMask1; + } + + String hosts2 = "unsupported_hosts_2"; + if(itype==EXTENDED){ + if(rule.IP2.equals("0.0.0.0") && rule.SubnetMask2.equals("0.0.0.0")){ + hosts2 = "any"; + } + else if(rule.SubnetMask2.equals("255.255.255.255")){ + hosts2 = "host "+rule.IP2; + } + else{ + hosts2 = rule.IP2+" "+rule.SubnetMask2; + } + } + + String protocol = "unsupported_protocol"; + if(rule.protocol==rule.IP){ + protocol = "ip "; + } + else if(rule.protocol==rule.TCP){ + protocol = "tcp "; + } + else if(rule.protocol==rule.UDP){ + protocol = "udp "; + } + else if(rule.protocol==rule.ICMP){ + protocol = "icmp"; + } + + String port = "unsupported_port"; + if(rule.Port1 == 0){ + port = ""; + } + else{ + port = "eq "+rule.Port1; + } + + switch(itype){ + case STANDART: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+hosts1); break; + case EXTENDED: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+protocol+" "+hosts1+" "+hosts2+" "+port); break; + default: conf.add("ip access-list "+type+" "+rule.number+" "+permit_deny+" "+protocol+" "+hosts1+" "+hosts2+" "+rule.Port2); + } + } + } + } + } Index: CommandsTree.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandsTree.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CommandsTree.java 20 Oct 2007 22:54:40 -0000 1.4 --- CommandsTree.java 23 Oct 2007 20:14:48 -0000 1.5 *************** *** 21,24 **** --- 21,25 ---- public static final String ANYWORD = "*"; + public static final String COMMENT = "!"; CommandNode root = new CommandNode("."); *************** *** 269,315 **** public String call(String command, Modes mode){ String result = null; ! String cmds[] = command.split(" "); ! ! CommandInterface func = null; ! Modes modes = new Modes(0,0,0); ! String params = ""; ! Vector<String> vprms = new Vector<String>(0); ! ! CommandNode node = root; ! int i; ! for(i=0; i<cmds.length && node!=null && node.modes.isContain(mode); i++){ ! node = node.getNode(cmds[i], mode); ! if(node != null){ ! if(node.getName().equals(ANYWORD)){ ! vprms.add(cmds[i]); ! } ! func = node.getFunction(); ! modes = node.modes; ! if(func!=null){ ! if(cmds[0].equalsIgnoreCase("no")){ ! params = node.getFunction().no_call_params; } else{ ! params = node.getFunction().call_params; } } else{ ! params = ""; } } } - if(func!=null && modes.isContain(mode)){ - //String sprms[] = params.split(" "); - if(node==null) i--; - for(; i<cmds.length; i++){ - vprms.add(cmds[i]); - } - if(cmds[0].equalsIgnoreCase("no")){ - result = func.no_call(vprms); - } - else{ - result = func.call(vprms); - } - } return result; } --- 270,323 ---- public String call(String command, Modes mode){ String result = null; ! if(command.startsWith(COMMENT)){ ! //result = command; ! //result = command.substring(COMMENT.length()); ! result = ""; ! } ! else{ ! String cmds[] = command.split(" "); ! ! CommandInterface func = null; ! Modes modes = new Modes(0,0,0); ! String params = ""; ! Vector<String> vprms = new Vector<String>(0); ! ! CommandNode node = root; ! int i; ! for(i=0; i<cmds.length && node!=null && node.modes.isContain(mode); i++){ ! node = node.getNode(cmds[i], mode); ! if(node != null){ ! if(node.getName().equals(ANYWORD)){ ! vprms.add(cmds[i]); ! } ! func = node.getFunction(); ! modes = node.modes; ! if(func!=null){ ! if(cmds[0].equalsIgnoreCase("no")){ ! params = node.getFunction().no_call_params; ! } ! else{ ! params = node.getFunction().call_params; ! } } else{ ! params = ""; } } + } + if(func!=null && modes.isContain(mode)){ + //String sprms[] = params.split(" "); + if(node==null) i--; + for(; i<cmds.length; i++){ + vprms.add(cmds[i]); + } + if(cmds[0].equalsIgnoreCase("no")){ + result = func.no_call(vprms); + } else{ ! result = func.call(vprms); } } } return result; } Index: AccessListEngine.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/AccessListEngine.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AccessListEngine.java 19 Oct 2007 15:57:01 -0000 1.1 --- AccessListEngine.java 23 Oct 2007 20:14:48 -0000 1.2 *************** *** 37,41 **** Node parentNode; ! Hashtable ACLs; public AccessListEngine(Node inParentNode){ --- 37,41 ---- Node parentNode; ! Hashtable ACLs = new Hashtable(); public AccessListEngine(Node inParentNode){ *************** *** 43,47 **** } ! public boolean addACL(int number, int line, short action, String IP1, String SubnetMask1){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); boolean new_acl = false; --- 43,47 ---- } ! public int addACL(int number, int line, short action, String IP1, String SubnetMask1){ Hashtable ACLl = (Hashtable)ACLs.get(Integer.valueOf(number)); boolean new_acl = false; *************** *** 52,56 **** } ! if(ACLl.get(Integer.valueOf(line)) == null) return false; if(line < 0){ --- 52,56 ---- } ! if(ACLl.get(Integer.valueOf(line)) != null) return -1; if(line < 0){ *************** *** 78,82 **** if(new_acl) ACLs.put(Integer.valueOf(number), ACLl); ! return true; } --- 78,82 ---- if(new_acl) ACLs.put(Integer.valueOf(number), ACLl); ! return line; } *************** *** 119,122 **** --- 119,128 ---- return found; } + + public boolean isACLExists(int number, int line){ + Hashtable acllist = (Hashtable)ACLs.get(new Integer(number)); + if(acllist==null) return false; + return (acllist.containsKey(new Integer(line))); + } public boolean passStandartACL(int number, String IP){ |
From: QweR <qw...@us...> - 2007-10-23 20:14:55
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv14031/guiUI Modified Files: Terminal.java Log Message: ACLs in configs (ip acc, show acc, show run) works Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Terminal.java 20 Oct 2007 22:54:40 -0000 1.6 --- Terminal.java 23 Oct 2007 20:14:48 -0000 1.7 *************** *** 60,65 **** private clear_terminal_CommandClass clear_terminal_Command = new clear_terminal_CommandClass(); ! private configure_replace_CommandClass configure_replace_Command = new configure_replace_CommandClass(); ! private configure_memory_CommandClass configure_memory_Command = new configure_memory_CommandClass(); private configure_terminal_CommandClass configure_terminal_Command = new configure_terminal_CommandClass(); private exit_CommandClass exit_Command = new exit_CommandClass(); --- 60,65 ---- private clear_terminal_CommandClass clear_terminal_Command = new clear_terminal_CommandClass(); ! // private configure_replace_CommandClass configure_replace_Command = new configure_replace_CommandClass(); ! // private configure_memory_CommandClass configure_memory_Command = new configure_memory_CommandClass(); private configure_terminal_CommandClass configure_terminal_Command = new configure_terminal_CommandClass(); private exit_CommandClass exit_Command = new exit_CommandClass(); *************** *** 85,90 **** cmdproc.add("clear terminal", clear_terminal_Command, "Clear screen"); cmdproc.addDescription("configure","Enter configuration mode"); ! cmdproc.add("configure replace", configure_replace_Command, "Replace configure from the terminal"); ! cmdproc.add("configure memory", configure_memory_Command, "Configure from memory"); cmdproc.add("configure terminal", configure_terminal_Command, "Configure from the terminal"); cmdproc.add("exit", exit_Command, "Exit from current mode"); --- 85,90 ---- cmdproc.add("clear terminal", clear_terminal_Command, "Clear screen"); cmdproc.addDescription("configure","Enter configuration mode"); ! // cmdproc.add("configure replace", configure_replace_Command, "Replace configure from the terminal"); ! // cmdproc.add("configure memory", configure_memory_Command, "Configure from memory"); cmdproc.add("configure terminal", configure_terminal_Command, "Configure from the terminal"); cmdproc.add("exit", exit_Command, "Exit from current mode"); *************** *** 326,352 **** } }; ! class configure_replace_CommandClass extends CommandInterface{ ! public configure_replace_CommandClass (){ ! modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } ! public String call(Vector<String> params){ ! device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; ! current_mode.conf_mode = CommandInterface.CONF_MODE; ! device.getConfig().clear(DeviceConfig.RUNNING_CONFIG); ! return "Running-config was erased\nEnter configuration commands, one per line. End with 'exit'"; ! } ! }; ! class configure_memory_CommandClass extends CommandInterface{ ! public configure_memory_CommandClass (){ ! modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! call_params = "<cr>"; ! } ! public String call(Vector<String> params){ ! device.getConfig().working_config = DeviceConfig.STARTUP_CONFIG; ! current_mode.conf_mode = CommandInterface.CONF_MODE; ! return "Starting-config editing\nEnter configuration commands, one per line. End with 'exit'"; ! } ! }; class exit_CommandClass extends CommandInterface{ public exit_CommandClass (){ --- 326,352 ---- } }; ! // class configure_replace_CommandClass extends CommandInterface{ ! // public configure_replace_CommandClass (){ ! // modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! // call_params = "<cr>"; ! // } ! // public String call(Vector<String> params){ ! // device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; ! // current_mode.conf_mode = CommandInterface.CONF_MODE; ! // device.getConfig().clear(DeviceConfig.RUNNING_CONFIG); ! // return "Running-config was erased\nEnter configuration commands, one per line. End with 'exit'"; ! // } ! // }; ! // class configure_memory_CommandClass extends CommandInterface{ ! // public configure_memory_CommandClass (){ ! // modes = new Modes(CommandInterface.STD_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); ! // call_params = "<cr>"; ! // } ! // public String call(Vector<String> params){ ! // device.getConfig().working_config = DeviceConfig.STARTUP_CONFIG; ! // current_mode.conf_mode = CommandInterface.CONF_MODE; ! // return "Starting-config editing\nEnter configuration commands, one per line. End with 'exit'"; ! // } ! // }; class exit_CommandClass extends CommandInterface{ public exit_CommandClass (){ |