[Javanetsim-cvs] javaNetSim/core ApplicationLayerDevice.java, 1.10, 1.11 CommandProcessor.java, 1.2
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2008-10-18 19:55:56
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9668/core Modified Files: ApplicationLayerDevice.java CommandProcessor.java DeviceConfig.java Log Message: DNS works! Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** CommandProcessor.java 13 Oct 2008 22:52:07 -0000 1.25 --- CommandProcessor.java 18 Oct 2008 19:55:31 -0000 1.26 *************** *** 12,15 **** --- 12,17 ---- import core.protocolsuite.tcp_ip.DHCPC; import core.protocolsuite.tcp_ip.DHCPD; + import core.protocolsuite.tcp_ip.DNS; + import core.protocolsuite.tcp_ip.DNS_Message; import core.protocolsuite.tcp_ip.IPV4Address; import core.protocolsuite.tcp_ip.InvalidIPAddressException; *************** *** 82,85 **** --- 84,91 ---- private ip_dhcp_pool__network_CommandClass ip_dhcp_pool__network_Command = new ip_dhcp_pool__network_CommandClass(); private ip_dhcp_excluded_address_CommandClass ip_dhcp_excluded_address_Command = new ip_dhcp_excluded_address_CommandClass(); + private ip_dns_primary_CommandClass ip_dns_primary_Command = new ip_dns_primary_CommandClass(); + private ip_dns_server_CommandClass ip_dns_server_Command = new ip_dns_server_CommandClass(); + private ip_host_CommandClass ip_host_Command = new ip_host_CommandClass(); + private ip_host_hinfo_CommandClass ip_host_hinfo_Command = new ip_host_hinfo_CommandClass(); private ip_nat_inside_destination_list_CommandClass ip_nat_inside_destination_list_Command = new ip_nat_inside_destination_list_CommandClass(); private ip_nat_inside_source_list_CommandClass ip_nat_inside_source_list_Command = new ip_nat_inside_source_list_CommandClass(); *************** *** 123,127 **** private telnet_CommandClass telnet_Command = new telnet_CommandClass(); private telnet_server_CommandClass telnet_server_Command = new telnet_server_CommandClass(); - private traceroute_CommandClass traceroute_Command = new traceroute_CommandClass(); private username_CommandClass username_Command = new username_CommandClass(); private write_memory_CommandClass write_memory_Command = new write_memory_CommandClass(); --- 129,132 ---- *************** *** 186,189 **** --- 191,199 ---- commands.add("ip dhcp pool * default-router", ip_dhcp_pool__default_router_Command, "Default routers"); commands.add("ip dhcp excluded-address", ip_dhcp_excluded_address_Command, "Prevent DHCP from assigning certain addresses"); + commands.addDescription("ip dns","Configure DNS server for a zone"); + commands.add("ip dns primary", ip_dns_primary_Command, "Configure primary DNS server"); + commands.add("ip dns server", ip_dns_server_Command, "Enable DNS server"); + commands.add("ip host", ip_host_Command, "Add an entry to the ip hostname table"); + commands.add("ip host hinfo", ip_host_hinfo_Command, "Set system information record"); commands.addDescription("ip nat","NAT configuration commands"); commands.addDescription("ip nat inside","Inside address translation"); *************** *** 245,249 **** commands.add("telnet-server", telnet_server_Command, "Enable TELNET server; Specify server port"); commands.add("no telnet-server", telnet_server_Command, "Disable TELNET server"); - commands.add("traceroute", traceroute_Command, "Trace route to destination"); commands.add("username", username_Command, "Add User"); commands.addDescription("write","Write running configuration to memory or terminal"); --- 255,258 ---- *************** *** 1214,1218 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(PC.DHCP_CLIENT_ID); if(dhcpc!=null){ if(params.size()==1){ --- 1223,1227 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_CLIENT_ID); if(dhcpc!=null){ if(params.size()==1){ *************** *** 1250,1254 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(PC.DHCP_CLIENT_ID); if(dhcpc!=null){ if(params.size()==1){ --- 1259,1263 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPC dhcpc = (DHCPC)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_CLIENT_ID); if(dhcpc!=null){ if(params.size()==1){ *************** *** 1755,1759 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==2){ --- 1764,1768 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==2){ *************** *** 1787,1791 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==1){ --- 1796,1800 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==1){ *************** *** 1822,1826 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==2){ --- 1831,1835 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==2){ *************** *** 1854,1858 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==1){ --- 1863,1867 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==1){ *************** *** 1889,1893 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==3){ --- 1898,1902 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==3){ *************** *** 1929,1933 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==1){ --- 1938,1942 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==1){ *************** *** 1970,1974 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==2){ --- 1979,1983 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==2){ *************** *** 1998,2002 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(PC.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==2){ --- 2007,2011 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! DHCPD dhcpd = (DHCPD)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DHCP_SERVER_ID); if(dhcpd!=null){ if(params.size()==2){ *************** *** 2024,2027 **** --- 2033,2384 ---- } }; + class ip_dns_primary_CommandClass extends CommandInterface{ + public ip_dns_primary_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); + call_params = "<DNS domain name> soa <DNS primary name server> <DNS mailbox of responsible person> <Refresh time> <Refresh retry time> <Authority expire time> <Minimum TTL for zone info>"; + no_call_params = "<cr>"; + } + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + DNS dns = (DNS)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DNS_SERVER_ID); + if(dns!=null){ + if(params.size()==8){ + String DomainName = params.get(0); + String soa = params.get(1); + String PrimaryNameServer = params.get(2); + String MailboxResponsiblePerson = params.get(3); + int RefreshTime = 0; + int RefreshRetryTime = 0; + int AuthorityExpireTime = 0; + int MinimumTTLZoneInfo = 0; + try{RefreshTime = Integer.parseInt(params.get(4));}catch(NumberFormatException e){} + try{RefreshRetryTime = Integer.parseInt(params.get(5));}catch(NumberFormatException e){} + try{AuthorityExpireTime = Integer.parseInt(params.get(6));}catch(NumberFormatException e){} + try{MinimumTTLZoneInfo = Integer.parseInt(params.get(7));}catch(NumberFormatException e){} + if(DNS.isValidName(DomainName)){ + if(soa.equalsIgnoreCase("soa")){ + if(DNS.isValidName(PrimaryNameServer)){ + if(DNS.isValidMail(MailboxResponsiblePerson)){ + if(DNS.isValidMail(MailboxResponsiblePerson)){ + if(RefreshTime>0){ + if(RefreshRetryTime>0){ + if(AuthorityExpireTime>0){ + if(MinimumTTLZoneInfo>0){ + dns.DomainName = DomainName; + dns.PrimaryNameServer = PrimaryNameServer; + dns.MailboxResponsiblePerson = MailboxResponsiblePerson; + dns.RefreshTime = RefreshTime; + dns.RefreshRetryTime = RefreshRetryTime; + dns.AuthorityExpireTime = AuthorityExpireTime; + dns.MinimumTTLZoneInfo = MinimumTTLZoneInfo; + } + else{ + out += "error: invalid Minimum TTL for zone info (must be between 1 and 2147483647)\n"; + } + } + else{ + out += "error: invalid Authority expire time (must be between 1 and 2147483647)\n"; + } + } + else{ + out += "error: invalid Refresh retry time (must be between 1 and 2147483647)\n"; + } + } + else{ + out += "error: invalid Refresh time (must be between 1 and 2147483647)\n"; + } + } + else{ + out += "error: invalid DNS mailbox of responsible person\n"; + } + } + else{ + out += "error: invalid DNS mailbox of responsible person\n"; + } + } + else{ + out += "error: invalid DNS primary name server\n"; + } + } + else{ + out += "error: keyword 'soa' expected\n"; + } + } + else{ + out += "error: invalid DNS domain name\n"; + } + } + else{ + out += "error: invalid parameters\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + return out; + } + public String no_call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + DNS dns = (DNS)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DNS_SERVER_ID); + if(dns!=null){ + if(params.size()==0){ + dns.DomainName = ""; + dns.PrimaryNameServer = ""; + dns.MailboxResponsiblePerson = ""; + dns.RefreshTime = 86400; + dns.RefreshRetryTime = 3600; + dns.AuthorityExpireTime = 1209600; + dns.MinimumTTLZoneInfo = 86400; + } + else{ + out += "error: invalid parameters\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + return out; + } + }; + class ip_dns_server_CommandClass extends CommandInterface{ + public ip_dns_server_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); + call_params = "(<port>|<cr>)"; + no_call_params = "<cr>"; + } + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + DNS dns = (DNS)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DNS_SERVER_ID); + if(dns!=null){ + if(params.size()==0 || params.size()==1){ + int port = 53; + if(params.size()==1) port = Integer.parseInt(params.get(0)); + dns.setPort(port); + try { + dns.Listen(); + } catch (TransportLayerException e) { + out += "error: DNS server couldn't stated\n"; + } + } + else{ + out += "error: invalid parameters\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + return out; + } + public String no_call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + DNS dns = (DNS)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DNS_SERVER_ID); + if(dns!=null){ + if(params.size()==0){ + try { + dns.Close(); + } catch (TransportLayerException e) { + out += "error: DNS server couldn't stopped\n"; + } + } + else{ + out += "error: invalid parameters\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + return out; + } + }; + class ip_host_CommandClass extends CommandInterface{ + public ip_host_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); + call_params = "(<name of host> <IP address>|<IP address> <name of host>|<name of domain> mx <priority> <name of host>|<name of host> cname <name of host>)"; + no_call_params = "(<name of host> <IP address>|<IP address> <name of host>|<name of domain> mx <priority> <name of host>|<name of host> cname <name of host>)"; + } + public String call(Vector<String> params){ + return parse(params,true); + } + public String no_call(Vector<String> params){ + return parse(params,false); + } + private String parse(Vector<String> params, boolean add){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + DNS dns = (DNS)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DNS_SERVER_ID); + if(dns!=null){ + if(params.size()>=2 && params.size()<=4){ + switch(params.size()){ + case 2:{ + String first = params.get(0); + String second = params.get(1); + if(IPV4Address.validateDecIP(first) && DNS.isValidName(second)){ + if(add) + dns.addRecord(DNS.toInAddrArpa(first), second, DNS_Message.PTR_QUERY_TYPE); + else + dns.removeRecord(DNS.toInAddrArpa(first), second, DNS_Message.PTR_QUERY_TYPE); + } + else if(IPV4Address.validateDecIP(second) && DNS.isValidName(first)){ + if(add) + dns.addRecord(first, second, DNS_Message.A_QUERY_TYPE); + else + dns.removeRecord(first, second, DNS_Message.A_QUERY_TYPE); + } + else{ + out += "error: invalid A or PTR record\n"; + } + break; + } + case 3:{ + String host1 = params.get(0); + String cname = params.get(1); + String host2 = params.get(2); + if(cname.equalsIgnoreCase("cname")){ + if(DNS.isValidName(host1) && DNS.isValidName(host2)){ + if(add) + dns.addRecord(host1, host2, DNS_Message.CNAME_QUERY_TYPE); + else + dns.removeRecord(host1, host2, DNS_Message.CNAME_QUERY_TYPE); + } + else{ + out += "error: invalid host name\n"; + } + } + else{ + out += "error: keyword 'cname' expected\n"; + } + break; + } + case 4:{ + String domain = params.get(0); + String mx = params.get(1); + String priority = params.get(2); + String host = params.get(3); + if(mx.equalsIgnoreCase("mx")){ + if(DNS.isValidName(domain) && DNS.isValidName(host)){ + try{ + int pr = Integer.parseInt(priority); + if(pr>0 && pr<65536) + if(add) + dns.addRecord(domain, host+":"+priority, DNS_Message.MX_QUERY_TYPE); + else + dns.removeRecord(domain, host, DNS_Message.MX_QUERY_TYPE); + else + out += "error: priority must be between 1 and 65535\n"; + } + catch(NumberFormatException e){ + out += "error: priority must be between 1 and 65535\n"; + } + } + else{ + out += "error: invalid host name\n"; + } + } + else{ + out += "error: keyword 'mx' expected\n"; + } + break; + } + } + } + else{ + out += "error: invalid parameters\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + return out; + } + }; + class ip_host_hinfo_CommandClass extends CommandInterface{ + public ip_host_hinfo_CommandClass(){ + modes = new Modes(CommandInterface.CONF_MODE, CommandInterface.APPLICATION_LAYER, CommandInterface.NO_CALL); + call_params = "<name of host> <description>"; + no_call_params = "<name of host>"; + } + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + DNS dns = (DNS)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DNS_SERVER_ID); + if(dns!=null){ + if(params.size()>1){ + String dname = params.get(0); + if(DNS.isValidName(dname)){ + String info = params.get(1); + for(int i=2; i<params.size(); i++){ + info += " "+params.get(i); + } + dns.addRecord(dname, info, DNS_Message.HINFO_QUERY_TYPE); + } + else{ + out += "error: invalid domain name\n"; + } + } + else{ + out += "error: invalid parameters\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + return out; + } + public String no_call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + DNS dns = (DNS)((ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.DNS_SERVER_ID); + if(dns!=null){ + if(params.size()==1){ + String dname = params.get(0); + if(DNS.isValidName(dname)){ + dns.removeRecord(dname, null, DNS_Message.HINFO_QUERY_TYPE); + } + else{ + out += "error: invalid domain name\n"; + } + } + else{ + out += "error: invalid parameters\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + } + else{ + out += "This instruction not supported by device\n"; + } + return out; + } + }; class ip_nat_inside_destination_list_CommandClass extends CommandInterface{ public ip_nat_inside_destination_list_CommandClass(){ *************** *** 3032,3036 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! Telnet_server telser = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.PC.TELNET_SERVER_ID); if(telser != null){ if(params.size()==0){ --- 3389,3393 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! Telnet_server telser = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.TELNET_SERVER_ID); if(telser != null){ if(params.size()==0){ *************** *** 3070,3074 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); if(snmpa != null){ out += "SNMP Community: "; --- 3427,3431 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.SNMP_AGENT_ID); if(snmpa != null){ out += "SNMP Community: "; *************** *** 3099,3103 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); if(snmpa != null){ out += "SNMP mibs:\n"; --- 3456,3460 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.SNMP_AGENT_ID); if(snmpa != null){ out += "SNMP mibs:\n"; *************** *** 3269,3273 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); if(snmpa != null){ if(params.size()==1){ --- 3626,3630 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.SNMP_AGENT_ID); if(snmpa != null){ if(params.size()==1){ *************** *** 3299,3303 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); if(snmpa != null){ if(params.size() == 0){ --- 3656,3660 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.SNMP_AGENT_ID); if(snmpa != null){ if(params.size() == 0){ *************** *** 3329,3333 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); if(snmpa != null){ if(params.size()==1){ --- 3686,3690 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.SNMP_AGENT_ID); if(snmpa != null){ if(params.size()==1){ *************** *** 3366,3370 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.PC.SNMP_AGENT_ID); if(snmpa != null){ if(params.size()==0){ --- 3723,3727 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! SNMP snmpa = (SNMP) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.SNMP_AGENT_ID); if(snmpa != null){ if(params.size()==0){ *************** *** 3425,3429 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! Telnet_server telnets = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.PC.TELNET_SERVER_ID); if(telnets != null){ if(params.size()==1){ --- 3782,3786 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! Telnet_server telnets = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.TELNET_SERVER_ID); if(telnets != null){ if(params.size()==1){ *************** *** 3460,3464 **** String out = ""; if(device instanceof ApplicationLayerDevice){ ! Telnet_server telnets = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.PC.TELNET_SERVER_ID); if(telnets != null){ if(params.size()==0){ --- 3817,3821 ---- String out = ""; if(device instanceof ApplicationLayerDevice){ ! Telnet_server telnets = (Telnet_server) ((core.ApplicationLayerDevice)device).getApp(core.ApplicationLayerDevice.TELNET_SERVER_ID); if(telnets != null){ if(params.size()==0){ *************** *** 3481,3493 **** } }; - class traceroute_CommandClass extends CommandInterface{ - public traceroute_CommandClass(){ - modes = new Modes(CommandInterface.STD_CONF_MODE, CommandInterface.NETWORK_LAYER, CommandInterface.CALL_ONLY); - call_params = "<IP>"; - } - public String call(Vector<String> params){ - return "Command not supported yet.\n"; - } - }; class username_CommandClass extends CommandInterface{ public username_CommandClass(){ --- 3838,3841 ---- Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** DeviceConfig.java 13 Oct 2008 20:04:25 -0000 1.21 --- DeviceConfig.java 18 Oct 2008 19:55:31 -0000 1.22 *************** *** 23,26 **** --- 23,27 ---- import core.protocolsuite.tcp_ip.DHCPC; import core.protocolsuite.tcp_ip.DHCPD; + import core.protocolsuite.tcp_ip.DNS; import core.protocolsuite.tcp_ip.RIP; import core.protocolsuite.tcp_ip.Route_entry; *************** *** 510,569 **** conf.add("location "+device.location); } - protected void fillExtended(LinkedList conf){ - conf.add("clock set "+device.getClock()); - - if(device instanceof ApplicationLayerDevice){ - core.ApplicationLayerDevice appdevice = (core.ApplicationLayerDevice)device; - //SNMP - SNMP snmpa = (SNMP) appdevice.getApp(core.ApplicationLayerDevice.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()); - } - - //TELNET - Telnet_server telnets = (Telnet_server) appdevice.getApp(core.ApplicationLayerDevice.TELNET_SERVER_ID); - if(telnets != null && telnets.running){ - conf.add("telnet-server "+telnets.getPort()); - } - - //username - Enumeration<String> users = appdevice.getUserList(); - if(users!=null){ - String username; - while(users.hasMoreElements()){ - username = users.nextElement(); - conf.add("username "+username+" "+appdevice.getUserPassword(username)); - } - } - - //router rip - RIP rip = (RIP) appdevice.getApp(core.ApplicationLayerDevice.RIP_SERVER_ID); - if(rip != null){ - Enumeration<String> rip_ifaces = rip.getInterfaces().elements(); - if(rip_ifaces.hasMoreElements()){ - conf.add("router rip"); - while(rip_ifaces.hasMoreElements()){ - String riface = rip_ifaces.nextElement(); - conf.add("router rip network "+riface); - } - } - else conf.add("no router rip"); - } - } - } - - protected void fillRoute(LinkedList conf){ - if(device instanceof NetworkLayerDevice){ - 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); - } - } - } --- 511,516 ---- conf.add("location "+device.location); } + *************** *** 623,625 **** --- 570,681 ---- } } + + protected void fillExtended(LinkedList conf){ + conf.add("clock set "+device.getClock()); + + if(device instanceof ApplicationLayerDevice){ + core.ApplicationLayerDevice appdevice = (core.ApplicationLayerDevice)device; + //SNMP + SNMP snmpa = (SNMP) appdevice.getApp(core.ApplicationLayerDevice.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()); + } + + //TELNET + Telnet_server telnets = (Telnet_server) appdevice.getApp(core.ApplicationLayerDevice.TELNET_SERVER_ID); + if(telnets != null && telnets.running){ + conf.add("telnet-server "+telnets.getPort()); + } + + //username + Enumeration<String> users = appdevice.getUserList(); + if(users!=null){ + String username; + while(users.hasMoreElements()){ + username = users.nextElement(); + conf.add("username "+username+" "+appdevice.getUserPassword(username)); + } + } + + //router rip + RIP rip = (RIP) appdevice.getApp(core.ApplicationLayerDevice.RIP_SERVER_ID); + if(rip != null){ + Enumeration<String> rip_ifaces = rip.getInterfaces().elements(); + if(rip_ifaces.hasMoreElements()){ + conf.add("router rip"); + while(rip_ifaces.hasMoreElements()){ + String riface = rip_ifaces.nextElement(); + conf.add("router rip network "+riface); + } + } + else conf.add("no router rip"); + } + + //DNS + DNS dns = (DNS) appdevice.getApp(core.ApplicationLayerDevice.DNS_SERVER_ID); + if(dns != null){ + if(dns.listening){ + conf.add("ip dns server "+dns.getPort()); + } + if(DNS.isValidName(dns.DomainName) + && DNS.isValidName(dns.PrimaryNameServer) + && DNS.isValidMail(dns.MailboxResponsiblePerson)){ + conf.add("ip dns primary "+dns.DomainName+" soa "+dns.PrimaryNameServer+" " + +dns.MailboxResponsiblePerson+" "+dns.RefreshTime+" "+dns.RefreshRetryTime+" " + +dns.AuthorityExpireTime+" "+dns.MinimumTTLZoneInfo); + } + Hashtable<String,Vector<String>> rec = dns.records_a; + Enumeration<String> domains = rec.keys(); + while(domains.hasMoreElements()){ + String dname = domains.nextElement(); + Vector<String> vals = rec.get(dname); + for(int i=0; i<vals.size(); i++) + conf.add("ip host "+dname+" "+vals.get(i)); + } + rec = dns.records_ptr; + domains = rec.keys(); + while(domains.hasMoreElements()){ + String dname = domains.nextElement(); + Vector<String> vals = rec.get(dname); + for(int i=0; i<vals.size(); i++) + conf.add("ip host "+DNS.fromInAddrArpa(dname)+" "+vals.get(i)); + } + rec = dns.records_cname; + domains = rec.keys(); + while(domains.hasMoreElements()){ + String dname = domains.nextElement(); + Vector<String> vals = rec.get(dname); + for(int i=0; i<vals.size(); i++) + conf.add("ip host "+dname+" cname "+vals.get(i)); + } + Hashtable<String,Vector<Pair>> recm = dns.records_mx; + domains = recm.keys(); + while(domains.hasMoreElements()){ + String dname = domains.nextElement(); + Vector<Pair> vals = recm.get(dname); + for(int i=0; i<vals.size(); i++) + conf.add("ip host "+dname+" mx "+vals.get(i).getSecond()+" "+vals.get(i).getFirst()); + } + Hashtable<String,String> rech = dns.records_hinfo; + domains = rech.keys(); + while(domains.hasMoreElements()){ + String dname = domains.nextElement(); + conf.add("ip host hinfo "+dname+" "+rech.get(dname)); + } + } + } + } + + protected void fillRoute(LinkedList conf){ + if(device instanceof NetworkLayerDevice){ + 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); + } + } + } } Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ApplicationLayerDevice.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ApplicationLayerDevice.java 13 Oct 2008 22:52:07 -0000 1.10 --- ApplicationLayerDevice.java 18 Oct 2008 19:55:31 -0000 1.11 *************** *** 69,72 **** --- 69,73 ---- // } } + userlist.clear(); super.turnOff(); } |