[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip DNS.java, 1.6, 1.7 ProtocolStack.java, 1.75,
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2008-10-26 22:03:03
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32599/core/protocolsuite/tcp_ip Modified Files: DNS.java ProtocolStack.java socketLayer.java Log Message: Added commands ip name-server int * databits int * flowcontrol int * parity int * speed int * stopbits Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** ProtocolStack.java 26 Oct 2008 15:37:40 -0000 1.75 --- ProtocolStack.java 26 Oct 2008 22:02:46 -0000 1.76 *************** *** 59,62 **** --- 59,63 ---- import java.util.Vector; + import core.ApplicationLayerDevice; import core.CommunicationException; import core.InvalidDefaultGatewayException; *************** *** 668,684 **** LowLinkException { ICMP_packet pingPacket = null; ! if(!IPV4Address.isValidIp(inDestIPAddress)){ if(mParentNode instanceof core.ApplicationLayerDevice){ ! //inDestIPAddress = ResolveDNS } } ! if (IPV4Address.validateDecIP(inDestIPAddress)) { ! pingPacket = mICMPprotocol.sendPing(inDestIPAddress); sendPacket(pingPacket); } else throw new CommunicationException("Packet dropped host unreachable " ! + inDestIPAddress); return pingPacket; } --- 669,692 ---- LowLinkException { ICMP_packet pingPacket = null; ! String dest = null; ! if(!IPV4Address.isValidIp(inDestIPAddress)){ if(mParentNode instanceof core.ApplicationLayerDevice){ ! Vector<String> addrs = ((ApplicationLayerDevice)mParentNode).resolve(inDestIPAddress); ! if(addrs.size()>0){ ! dest = addrs.get(0); ! } } } + else{ + dest = inDestIPAddress; + } ! if (dest!="") { ! pingPacket = mICMPprotocol.sendPing(dest); sendPacket(pingPacket); } else throw new CommunicationException("Packet dropped host unreachable " ! + dest); return pingPacket; } Index: DNS.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DNS.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DNS.java 24 Oct 2008 17:46:42 -0000 1.6 --- DNS.java 26 Oct 2008 22:02:46 -0000 1.7 *************** *** 167,172 **** if (Connect (host, port)) { ! SendData(mess.toLowerCase()+":"+Integer.toString(qType)); ! return last_sent_id; } return 0; --- 167,174 ---- if (Connect (host, port)) { ! if(DNS.isValidName(mess)){ ! SendData(mess.toLowerCase()+":"+Integer.toString(qType)); ! return last_sent_id; ! } } return 0; Index: socketLayer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/socketLayer.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** socketLayer.java 26 Oct 2008 15:37:40 -0000 1.16 --- socketLayer.java 26 Oct 2008 22:02:46 -0000 1.17 *************** *** 2,6 **** --- 2,8 ---- import java.util.Hashtable; + import java.util.Vector; + import core.ApplicationLayerDevice; import core.CommunicationException; import core.LowLinkException; *************** *** 61,81 **** public boolean connect(int sock, String ipaddr, int port) throws LowLinkException, CommunicationException, TransportLayerException{ boolean result = false; if(!IPV4Address.isValidIp(ipaddr)){ ! //inDestIPAddress = ResolveDNS } ! jnSocket jnsock = get_socket(sock); ! if(jnsock.type == jnSocket.TCP_socket){ ! jnsock.open_state = true; ! jnsock.dst_IP = ipaddr; ! jnsock.dst_port = port; ! result = mParentStack.TCP().connect(sock, ipaddr, port); ! } ! else if(jnsock.type == jnSocket.UDP_socket){ ! jnsock.dst_IP = ipaddr; ! jnsock.dst_port = port; ! result = true; ! } return result; } --- 63,92 ---- public boolean connect(int sock, String ipaddr, int port) throws LowLinkException, CommunicationException, TransportLayerException{ boolean result = false; + String dest = null; if(!IPV4Address.isValidIp(ipaddr)){ ! Vector<String> addrs = ((ApplicationLayerDevice)mParentStack.getParentNode()).resolve(ipaddr); ! if(addrs.size()>0){ ! dest = addrs.get(0); ! } ! } ! else{ ! dest = ipaddr; } ! if(dest != null){ ! jnSocket jnsock = get_socket(sock); ! if(jnsock.type == jnSocket.TCP_socket){ ! jnsock.open_state = true; ! jnsock.dst_IP = dest; ! jnsock.dst_port = port; ! result = mParentStack.TCP().connect(sock, dest, port); ! } ! else if(jnsock.type == jnSocket.UDP_socket){ ! jnsock.dst_IP = dest; ! jnsock.dst_port = port; ! result = true; ! } ! } return result; } *************** *** 113,126 **** public void writeTo(int sock, String data, String IP, int port) throws LowLinkException, TransportLayerException{ ! if(!IPV4Address.isValidIp(IP)){ ! //inDestIPAddress = ResolveDNS } - // - //if() - // udp only write!!! - (sockTable.get(sock)).dst_IP = IP; - (sockTable.get(sock)).dst_port = port; - (sockTable.get(sock)).open_state = true; - mParentStack.UDP().sendUDPPacket(sock, IP, port, data); } --- 124,145 ---- public void writeTo(int sock, String data, String IP, int port) throws LowLinkException, TransportLayerException{ ! String dest = null; ! ! if(!IPV4Address.isValidIp(IP)){ ! Vector<String> addrs = ((ApplicationLayerDevice)mParentStack.getParentNode()).resolve(IP); ! if(addrs.size()>0){ ! dest = addrs.get(0); ! } ! } ! else{ ! dest = IP; ! } ! ! if(dest != null){ ! (sockTable.get(sock)).dst_IP = dest; ! (sockTable.get(sock)).dst_port = port; ! (sockTable.get(sock)).open_state = true; ! mParentStack.UDP().sendUDPPacket(sock, dest, port, data); } } |