ipinspector-1.0/0000755000175000017500000000000007616576620013266 5ustar julienjulienipinspector-1.0/AUTHORS0000444000175000017500000000037007557646232014335 0ustar julienjulienIPInspector http://gicl.mcs.drexel.edu/sevy/airport Jon Sevy Geometric and Intelligent Computing Laboratory Department of Mathematics and Computer Science Drexel University http://gicl.mcs.drexel.edu/sevy ipinspector-1.0/COPYING0000444000175000017500000004363107531714362014317 0ustar julienjulien GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ipinspector-1.0/airport/0000755000175000017500000000000007616576640014750 5ustar julienjulienipinspector-1.0/airport/IPInspectorAirportInfo.java0000644000175000017500000002042207534012100022136 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package airport; import java.util.*; import java.io.*; public class IPInspectorAirportInfo extends Hashtable { public static final int MAX_NUM_MAC_ADDRESSES = 256; public static final int MAX_NUM_PORT_MAPS = 20; public static final int MAX_NUM_SNMP_ACCESS_ENTRIES = 5; public static final int MAX_NUM_LOGIN_CHARS = 127; public IPInspectorAirportInfo() { initializeHashtable(); } public IPInspectorAirportInfo(byte[] retrievedBytes) throws IllegalArgumentException { int count = 0; byte[] invalidBytes = {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xF6}; ByteArrayInputStream byteStream = new ByteArrayInputStream(retrievedBytes); initializeHashtable(); while (byteStream.available() > 0) { // read the tag byte[] tagBytes = new byte[4]; byteStream.read(tagBytes, 0, 4); String tag = new String(tagBytes); // break if tag is all zeros: end of info in array if (tag.equals("\0\0\0\0")) break; // get the corresponding element AirportInfoRecord element = this.get(tag); // increment count; used at end to determine if we got any valid info count++; // check to make sure the element's not null, in case have received // unknown tag: just ignore if null if (element != null) { //read the encryption byte[] encryptionBytes = new byte[4]; byteStream.read(encryptionBytes, 0, 4); element.encryption = getIntegerValue(encryptionBytes); //read the length byte[] lengthBytes = new byte[4]; byteStream.read(lengthBytes, 0, 4); int length = getIntegerValue(lengthBytes); //read the value byte[] valueBytes = new byte[length]; byteStream.read(valueBytes, 0, length); if (element.encryption == AirportInfoRecord.ENCRYPTED) valueBytes = AirportInfoRecord.decryptBytes(AirportInfoRecord.cipherBytes, valueBytes); // check if the value being sent is 0xFFFFFF6; this indicates // the current value is invalid - just leave as 0. Ignore for // IP addresses, though... if (!arraysEqual(valueBytes, invalidBytes) || (element.dataType == AirportInfoRecord.IP_ADDRESS)) element.value = valueBytes; //System.out.println("Tag " + tag + ": " + element.toString()); } else { // just add an entry in hashtable element = new AirportInfoRecord(); // assign the tag element.tag = tag; //read the encryption byte[] encryptionBytes = new byte[4]; byteStream.read(encryptionBytes, 0, 4); element.encryption = getIntegerValue(encryptionBytes); //read the length byte[] lengthBytes = new byte[4]; byteStream.read(lengthBytes, 0, 4); int length = getIntegerValue(lengthBytes); element.maxLength = length; //read the value byte[] valueBytes = new byte[length]; byteStream.read(valueBytes, 0, length); if (element.encryption == AirportInfoRecord.ENCRYPTED) valueBytes = AirportInfoRecord.decryptBytes(AirportInfoRecord.cipherBytes, valueBytes); // check if the value being sent is 0xFFFFFF6; this indicates // the current value is invalid - just leave as 0. Ignore for // IP addresses, though... if (!arraysEqual(valueBytes, invalidBytes) || (element.dataType == AirportInfoRecord.IP_ADDRESS)) element.value = valueBytes; else element.value = new byte[element.maxLength]; // add the element this.put(tag, element); //System.out.println("Unused tag " + tag + ": " + element.toString()); } } if (count == 0) { // no data retrieved; throw exception! throw new IllegalArgumentException("No information retrieved from base station!"); } } private void initializeHashtable() { // populate the hashtable int maxSize; int dataType; int encryption; String description; String tag; // Configuration mode switch: // Modem config: 00 00 09 00 // Ethernet manual: 00 00 04 00 // Ethernet DHCP: 00 00 03 00 // Ethernet PPPoE: 00 00 09 00 // maxSize = 4; dataType = AirportInfoRecord.BYTE_STRING; encryption = AirportInfoRecord.UNENCRYPTED; description = "Configuration mode"; tag = "waCV"; this.put(tag, new AirportInfoRecord(tag, description, dataType, encryption, maxSize)); // Base station IP address: 0x46A maxSize = 4; dataType = AirportInfoRecord.IP_ADDRESS; encryption = AirportInfoRecord.ENCRYPTED; description = "Base station IP address"; tag = "waIP"; this.put(tag, new AirportInfoRecord(tag, description, dataType, encryption, maxSize)); // Name of base station maxSize = 32; dataType = AirportInfoRecord.CHAR_STRING; encryption = AirportInfoRecord.ENCRYPTED; description = "Base station name"; tag = "syNm"; this.put(tag, new AirportInfoRecord(tag, description, dataType, encryption, maxSize)); // Base station location: maxSize = 32; dataType = AirportInfoRecord.CHAR_STRING; encryption = AirportInfoRecord.ENCRYPTED; description = "Base station location"; tag = "syLo"; this.put(tag, new AirportInfoRecord(tag, description, dataType, encryption, maxSize)); } public AirportInfoRecord get(String name) { //System.out.println("Get info record " + name); return (AirportInfoRecord)super.get(name); } public byte[] getUpdateBytes() { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Enumeration elementEnumeration = this.elements(); while (elementEnumeration.hasMoreElements()) { AirportInfoRecord nextElement = (AirportInfoRecord)elementEnumeration.nextElement(); try { outStream.write(nextElement.getUpdateBytes()); //System.out.println("Update bytes: tag " + nextElement.tag + ": " + nextElement.toString()); } catch (IOException e) { // can't happen } } return outStream.toByteArray(); } public byte[] getRequestBytes() { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Enumeration elementEnumeration = this.elements(); while (elementEnumeration.hasMoreElements()) { AirportInfoRecord nextElement = (AirportInfoRecord)elementEnumeration.nextElement(); try { outStream.write(nextElement.getRequestBytes()); } catch (IOException e) { // can't happen } } return outStream.toByteArray(); } public String toString() { String returnText = new String(); Enumeration elementEnumeration = this.elements(); while (elementEnumeration.hasMoreElements()) { AirportInfoRecord theElement = (AirportInfoRecord)elementEnumeration.nextElement(); returnText += theElement.toString(); returnText += "\n"; } return returnText; } private int getIntegerValue(byte[] valueBytes) { int value = 0; for (int i = 0; i < valueBytes.length; i++) { int absValue = valueBytes[i]; if (absValue < 0) absValue += 256; value = value*256 + absValue; } return value; } private static boolean arraysEqual(byte[] a, byte[] b) { if (a.length != b.length) { return false; } else { for (int i = 0; i < a.length; i++) { if (a[i] != b[i]) return false; } } return true; } }ipinspector-1.0/airport/AirportDiscoverer.java0000644000175000017500000001725707534012076021260 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package airport; import java.util.*; import java.net.*; import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; /** * Broadcasts discovery packet, waits for responses. Displays responding devices' IP addresses, * names, and device-type identifying strings. */ public class AirportDiscoverer extends JFrame implements ActionListener, Runnable { JButton stopDiscoveryButton, closeButton; JTextArea theArea; Thread discoveryThread; public AirportDiscoverer() { setUpDisplay(); this.pack(); this.show(); discoveryThread = new Thread(this); discoveryThread.start(); } private void setUpDisplay() { this.setTitle("Base Station Discovery"); stopDiscoveryButton = new JButton("Stop Discovery"); stopDiscoveryButton.setActionCommand("stop discovery"); stopDiscoveryButton.addActionListener(this); closeButton = new JButton("Close"); closeButton.setActionCommand("close"); closeButton.addActionListener(this); theArea = new JTextArea(20,70); theArea.setLineWrap(true); theArea.setFont(new Font("Monospaced", Font.PLAIN, 10)); JScrollPane messagesScroll = new JScrollPane(theArea); // set params for layout manager GridBagLayout theLayout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.NONE; c.ipadx = 0; c.ipady = 0; Insets theMargin = new Insets(2,2,2,2); c.insets = theMargin; c.anchor = GridBagConstraints.CENTER; c.weightx = .5; c.weighty = .5; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(theLayout); c.gridx = 1; c.gridy = 1; theLayout.setConstraints(stopDiscoveryButton, c); buttonPanel.add(stopDiscoveryButton); c.gridx = 2; c.gridy = 1; theLayout.setConstraints(closeButton, c); buttonPanel.add(closeButton); this.getContentPane().setLayout(new BorderLayout(5,5)); this.getContentPane().add("North", buttonPanel); this.getContentPane().add("Center", messagesScroll); } public void actionPerformed(ActionEvent theEvent) // respond to button pushes, menu selections { String command = theEvent.getActionCommand(); try { if (command == "close") { discoveryThread.interrupt(); this.hide(); this.dispose(); } if (command == "stop discovery") { discoveryThread.interrupt(); } } catch (Exception e) { } } public void run() { try { DatagramSocket dSocket = new DatagramSocket(); dSocket.setSoTimeout(1000); //1 second int AIRPORT_PORT = 192; InetAddress broadcastAddress = InetAddress.getByName("255.255.255.255"); byte[] bytes = new byte[116]; // from sniffs bytes[0] = (byte)0x01; DatagramPacket outPacket = new DatagramPacket(bytes, bytes.length, broadcastAddress, AIRPORT_PORT); dSocket.send(outPacket); while(! discoveryThread.interrupted()) { //bytes = new byte[116]; // from sniffs DatagramPacket inPacket = new DatagramPacket(bytes, bytes.length); try { dSocket.receive(inPacket); bytes = inPacket.getData(); String sourceAddress = inPacket.getAddress().getHostAddress(); // parse info in response packet /* System.out.println("Returned Message bytes:"); for (int i = 0; i < bytes.length; ++i) System.out.print(hexByte(bytes[i]) + " "); */ AirportDiscoveryInfo theInfo = new AirportDiscoveryInfo(bytes); long upTime = Long.parseLong(theInfo.get("Base station uptime").toString()); upTime = upTime / 100; // put into seconds // change to days:hours:minutes format long days = upTime / (3600 * 24); long hours = (upTime / 3600) % 24; long minutes = (upTime / 60) % 60; long seconds = upTime % 60; String dayString = new String(); dayString += days; String hourString = new String(); hourString += hours; if (hourString.length() < 2) hourString = "0" + hourString; // make hours, minutes and seconds have 2 digits String minuteString = new String(); minuteString += minutes; if (minuteString.length() < 2) minuteString = "0" + minuteString; String secondString = new String(); secondString += seconds; if (secondString.length() < 2) secondString = "0" + secondString; String timeString = dayString + ":" + hourString + ":" + minuteString; theArea.append("Access point found:\n"); theArea.append(" Local LAN IP address: " + theInfo.get("Base station IP address").toString() + "\n"); //theArea.append(" External IP address: " + sourceAddress + "\n"); theArea.append(" MAC address: " + theInfo.get("Base station Mac address").toString() + "\n"); theArea.append(" Device name: " + theInfo.get("System name").toString() + "\n"); theArea.append(" Device type: " + theInfo.get("Device identifying string").toString() + "\n"); theArea.append(" Uptime (days:hrs:mins): " + timeString + "\n"); /* // now send out some SNMP requests to retrieve additional info from // the responding station; would really like to ARP on the MAC address // in case the returned IP address is unhappy (e.g., 0.0.0.0).... try { String community = "public"; int version = 0; // SNMPv1 InetAddress hostAddress = InetAddress.getByName(theInfo.get("waIP").toString()); SNMPv1CommunicationInterface comInterface = new SNMPv1CommunicationInterface(version, hostAddress, community); String itemID = ""; SNMPVarBindList newVars = comInterface.getMIBEntry(itemID); SNMPSequence pair = (SNMPSequence)(newVars.getSNMPObjectAt(0)); SNMPObject snmpValue = pair.getSNMPObjectAt(1); theArea.append("External IP adress: " + snmpValue.toString() + "\n"); } catch(Exception e) { // do nothing; problem getting SNMP stuff... } */ theArea.append("\n"); } catch (InterruptedIOException e) { // will get here if nothing received in 1 second; used to check if interrupted // by user! } } } catch(Exception e) { theArea.append("Exception during discovery: " + e + "\n"); } theArea.append("Discovery finished.\n"); } private String hexByte(byte b) { int pos = b; if (pos < 0) pos += 256; String returnString = new String(); returnString += Integer.toHexString(pos/16); returnString += Integer.toHexString(pos%16); return returnString; } }ipinspector-1.0/airport/AirportDiscoveryInfo.java0000644000175000017500000000727207534012076021732 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package airport; import java.util.*; /** * Collects together information about the location of pieces of information * in the 116-byte Discovery memory block, and creates appropriate AirportInfoRecords * (with ByteBlockWindows into the underlying ByteBlock) to read and write * the information. */ public class AirportDiscoveryInfo extends Hashtable { /** * Create new */ public AirportDiscoveryInfo(byte[] baseBlock) { int baseStartIndex; int maxSize; int dataType; int encryption; byte[] bytes; String name; /** * Base station MAC address */ baseStartIndex = 0x024; maxSize = 6; bytes = new byte[maxSize]; for (int i = 0; i < maxSize; i++) bytes[i] = baseBlock[baseStartIndex + i]; encryption = AirportInfoRecord.UNENCRYPTED; dataType = AirportInfoRecord.BYTE_STRING; name = "Base station Mac address"; this.put(name, new AirportInfoRecord(name, name, dataType, encryption, maxSize, bytes)); /** * Base station IP address: byte 2*16 + 13 */ baseStartIndex = 0x02C; maxSize = 4; bytes = new byte[maxSize]; for (int i = 0; i < maxSize; i++) bytes[i] = baseBlock[baseStartIndex + i]; encryption = AirportInfoRecord.UNENCRYPTED; dataType = AirportInfoRecord.IP_ADDRESS; name = "Base station IP address"; this.put(name, new AirportInfoRecord(name, name, dataType, encryption, maxSize, bytes)); /** * Base station name: byte 3*16 + 1 */ baseStartIndex = 0x030; maxSize = 32; bytes = new byte[maxSize]; for (int i = 0; i < maxSize; i++) bytes[i] = baseBlock[baseStartIndex + i]; encryption = AirportInfoRecord.UNENCRYPTED; dataType = AirportInfoRecord.CHAR_STRING; name = "System name"; this.put(name, new AirportInfoRecord(name, name, dataType, encryption, maxSize, bytes)); /** * Base station uptime: byte 5*16 + 1 */ baseStartIndex = 0x050; maxSize = 4; bytes = new byte[maxSize]; for (int i = 0; i < maxSize; i++) bytes[i] = baseBlock[baseStartIndex + i]; encryption = AirportInfoRecord.UNENCRYPTED; dataType = AirportInfoRecord.UNSIGNED_INTEGER; name = "Base station uptime"; this.put(name, new AirportInfoRecord(name, name, dataType, encryption, maxSize, bytes)); /** * Device identifying string: byte 5*16 + 5 */ baseStartIndex = 0x054; maxSize = 32; bytes = new byte[maxSize]; for (int i = 0; i < maxSize; i++) bytes[i] = baseBlock[baseStartIndex + i]; encryption = AirportInfoRecord.UNENCRYPTED; dataType = AirportInfoRecord.CHAR_STRING; name = "Device identifying string"; this.put(name, new AirportInfoRecord(name, name, dataType, encryption, maxSize, bytes)); } public AirportInfoRecord get(String name) { return (AirportInfoRecord)super.get(name); } }ipinspector-1.0/airport/AirportInfoComponent.java0000644000175000017500000000241407534012077021717 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package airport; /** * Interface for all components which display and edit Airport configuration information. */ public interface AirportInfoComponent { /** * Component should re-read data from the AirportInfoRecord containing its data. */ public void refreshDisplay(); /** * Component should write data to the AirportInfoRecord containing its data. */ public void writeValue() throws ValueFormatException; }ipinspector-1.0/airport/AirportInfoRecord.java0000644000175000017500000003713207534012077021200 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package airport; import java.math.*; import java.util.*; import java.io.*; /** * This class defines a structure to hold information about the location and format (type) * of a piece of information in the Airport memory block. Location is specified by a triple: * the object identifier number (1 to 68), row in the block (0 to 15), and column (0 to 15), * where the ByteBlockWindow begins; size of the window is specified by giving the number of * rows and columns in the window; and the datatype is specified as one of the class's constants. * * The class also implements a toString() method which provides a pretty-printed representation * of the value in the window based on its datatype, and a setBytesFromString() method which * writes a value to the window given an appropriately formatted String representation. */ public class AirportInfoRecord { public static final int CHAR_STRING = 0; public static final int IP_ADDRESS = 1; public static final int BYTE_STRING = 2; public static final int PHONE_NUMBER = 3; public static final int UNSIGNED_INTEGER = 4; public static final int BYTE = 5; public static final int LITTLE_ENDIAN_UNSIGNED_INTEGER = 6; public static final int UNENCRYPTED = 0; public static final int ENCRYPTED = 2; public String tag; public String description; public int dataType; public int encryption; public int maxLength; public byte[] value; public static byte[] cipherBytes = { (byte)0x0e, (byte)0x39, (byte)0xf8, (byte)0x05, (byte)0xc4, (byte)0x01, (byte)0x55, (byte)0x4f, (byte)0x0c, (byte)0xac, (byte)0x85, (byte)0x7d, (byte)0x86, (byte)0x8a, (byte)0xb5, (byte)0x17, (byte)0x3e, (byte)0x09, (byte)0xc8, (byte)0x35, (byte)0xf4, (byte)0x31, (byte)0x65, (byte)0x7f, (byte)0x3c, (byte)0x9c, (byte)0xb5, (byte)0x6d, (byte)0x96, (byte)0x9a, (byte)0xa5, (byte)0x07, (byte)0x2e, (byte)0x19, (byte)0xd8, (byte)0x25, (byte)0xe4, (byte)0x21, (byte)0x75, (byte)0x6f, (byte)0x2c, (byte)0x8c, (byte)0xa5, (byte)0x9d, (byte)0x66, (byte)0x6a, (byte)0x55, (byte)0xf7, (byte)0xde, (byte)0xe9, (byte)0x28, (byte)0xd5, (byte)0x14, (byte)0xd1, (byte)0x85, (byte)0x9f, (byte)0xdc, (byte)0x7c, (byte)0x55, (byte)0x8d, (byte)0x76, (byte)0x7a, (byte)0x45, (byte)0xe7, (byte)0xce, (byte)0xf9, (byte)0x38, (byte)0xc5, (byte)0x04, (byte)0xc1, (byte)0x95, (byte)0x8f, (byte)0xcc, (byte)0x6c, (byte)0x45, (byte)0xbd, (byte)0x46, (byte)0x4a, (byte)0x75, (byte)0xd7, (byte)0xfe, (byte)0xc9, (byte)0x08, (byte)0xf5, (byte)0x34, (byte)0xf1, (byte)0xa5, (byte)0xbf, (byte)0xfc, (byte)0x5c, (byte)0x75, (byte)0xad, (byte)0x56, (byte)0x5a, (byte)0x65, (byte)0xc7, (byte)0xee, (byte)0xd9, (byte)0x18, (byte)0xe5, (byte)0x24, (byte)0xe1, (byte)0xb5, (byte)0xaf, (byte)0xec, (byte)0x4c, (byte)0x65, (byte)0xdd, (byte)0x26, (byte)0x2a, (byte)0x15, (byte)0xb7, (byte)0x9e, (byte)0xa9, (byte)0x68, (byte)0x95, (byte)0x54, (byte)0x91, (byte)0xc5, (byte)0xdf, (byte)0x9c, (byte)0x3c, (byte)0x15, (byte)0xcd, (byte)0x36, (byte)0x3a, (byte)0x05, (byte)0xa7, (byte)0x8e, (byte)0xb9, (byte)0x78, (byte)0x85, (byte)0x44, (byte)0x81, (byte)0xd5, (byte)0xcf, (byte)0x8c, (byte)0x2c, (byte)0x05, (byte)0xfd, (byte)0x06, (byte)0x0a, (byte)0x35, (byte)0x97, (byte)0xbe, (byte)0x89, (byte)0x48, (byte)0xb5, (byte)0x74, (byte)0xb1, (byte)0xe5, (byte)0xff, (byte)0xbc, (byte)0x1c, (byte)0x35, (byte)0xed, (byte)0x16, (byte)0x1a, (byte)0x25, (byte)0x87, (byte)0xae, (byte)0x99, (byte)0x58, (byte)0xa5, (byte)0x64, (byte)0xa1, (byte)0xf5, (byte)0xef, (byte)0xac, (byte)0x0c, (byte)0x25, (byte)0x1d, (byte)0xe6, (byte)0xea, (byte)0xd5, (byte)0x77, (byte)0x5e, (byte)0x69, (byte)0xa8, (byte)0x55, (byte)0x94, (byte)0x51, (byte)0x05, (byte)0x1f, (byte)0x5c, (byte)0xfc, (byte)0xd5, (byte)0x0d, (byte)0xf6, (byte)0xfa, (byte)0xc5, (byte)0x67, (byte)0x4e, (byte)0x79, (byte)0xb8, (byte)0x45, (byte)0x84, (byte)0x41, (byte)0x15, (byte)0x0f, (byte)0x4c, (byte)0xec, (byte)0xc5, (byte)0x3d, (byte)0xc6, (byte)0xca, (byte)0xf5, (byte)0x57, (byte)0x7e, (byte)0x49, (byte)0x88, (byte)0x75, (byte)0xb4, (byte)0x71, (byte)0x25, (byte)0x3f, (byte)0x7c, (byte)0xdc, (byte)0xf5, (byte)0x2d, (byte)0xd6, (byte)0xda, (byte)0xe5, (byte)0x47, (byte)0x6e, (byte)0x59, (byte)0x98, (byte)0x65, (byte)0xa4, (byte)0x61, (byte)0x35, (byte)0x2f, (byte)0x6c, (byte)0xcc, (byte)0xe5, (byte)0x5d, (byte)0xa6, (byte)0xaa, (byte)0x95, (byte)0x37, (byte)0x1e, (byte)0x29, (byte)0xe8, (byte)0x15, (byte)0xd4, (byte)0x11, (byte)0x45, (byte)0x5f, (byte)0x1c, (byte)0xbc, (byte)0x95, (byte)0x4d, (byte)0xb6, (byte)0xba, (byte)0x85, (byte)0x27 }; /** * Create a new record with the specified parameters */ public AirportInfoRecord(String tag, String description, int dataType, int encryption, int maxLength, byte[] value) { this.tag = tag; this.description = description; this.dataType = dataType; this.encryption = encryption; this.maxLength = maxLength; this.value = value; } public AirportInfoRecord(String tag, String description, int dataType, int encryption, int maxLength) { this.tag = tag; this.description = description; this.maxLength = maxLength; this.dataType = dataType; this.encryption = encryption; this.value = new byte[maxLength]; } public AirportInfoRecord() { this.tag = ""; this.description = ""; this.dataType = CHAR_STRING; this.encryption = UNENCRYPTED; this.maxLength = 0; this.value = new byte[0]; } /** * Clear all bytes in the underlying ByteBlockWindow. */ public void clearWindow() { this.value = new byte[0]; } /** * Method which provides a pretty-printed representation of the value bytes * based on its datatype. */ public String toString() { String returnString = new String(); byte[] bytes = value; switch (dataType) { case UNSIGNED_INTEGER: { try { returnString = convertToUnsignedInteger(bytes); } catch (NumberFormatException e) { returnString = hexBytes(bytes); } break; } case LITTLE_ENDIAN_UNSIGNED_INTEGER: { try { bytes = reverseBytes(bytes); returnString = convertToUnsignedInteger(bytes); } catch (NumberFormatException e) { returnString = hexBytes(bytes); } break; } case CHAR_STRING: case PHONE_NUMBER: { returnString = convertToCharString(bytes); break; } case IP_ADDRESS: { returnString = convertToIPAddress(bytes); break; } case BYTE: case BYTE_STRING: default: { returnString = hexBytes(bytes); break; } } return returnString; } private String convertToCharString(byte[] bytes) { String charString; if (bytes.length == 0) { charString = ""; } else { charString = new String(bytes); // trim 0's int endIndex = charString.indexOf('\0'); if (endIndex >= 0) charString = charString.substring(0, endIndex); } return charString; } private String convertToUnsignedInteger(byte[] bytes) { BigInteger bigInt = new BigInteger(1, bytes); return bigInt.toString(); } private String convertToIPAddress(byte[] bytes) { String returnString = new String(); int value; for (int i = 0; i < bytes.length - 1; i++) { value = bytes[i]; if (value < 0) value += 256; returnString += value + "."; } value = bytes[bytes.length - 1]; if (value < 0) value += 256; returnString += value; return returnString; } /** * Writes value bytes given an appropriately formatted String representation for * the value. */ public void setBytesFromString(String valueString) throws ValueFormatException { byte[] bytes; switch (dataType) { case UNSIGNED_INTEGER: { bytes = convertFromUnsignedInteger(valueString); break; } case LITTLE_ENDIAN_UNSIGNED_INTEGER: { bytes = convertFromUnsignedInteger(valueString); bytes = reverseBytes(bytes); break; } case CHAR_STRING: case PHONE_NUMBER: { if (valueString.length() > maxLength - 1) { // System.out.println("Value format exception at " + OIDNum + " " + OIDRow + " " + OIDCol); throw new ValueFormatException("Maximum " + (maxLength - 1) + " characters."); } else bytes = valueString.getBytes(); break; } case IP_ADDRESS: { bytes = convertFromIPv4Address(valueString); break; } case BYTE: case BYTE_STRING: default: { bytes = convertFromHexString(valueString); break; } } this.value = bytes; } private byte[] convertFromIPv4Address(String addressString) throws ValueFormatException { // might be partial address byte[] bytes = new byte[maxLength]; int i = 0; int value; StringTokenizer st = new StringTokenizer(addressString, "."); if (st.countTokens() != maxLength) { if (st.countTokens() == 4) throw new ValueFormatException("Bad IP address: must be of form a.b.c.d, with a,b,c and d between 0 and 255."); else throw new ValueFormatException("Bad dotted address supplied: should have " + maxLength + " components."); } while (st.hasMoreTokens()) { try { String component = st.nextToken(); value = Integer.parseInt(component); if ((value < 0) || (value > 255)) throw new ValueFormatException("Bad IP address: must be of form a.b.c.d, with a,b,c and d between 0 and 255."); else { bytes[i] = (byte)value; i++; } } catch (NumberFormatException e) { throw new ValueFormatException("Bad IP address: must be of form a.b.c.d, with a,b,c and d between 0 and 255."); } } return bytes; } private byte[] convertFromUnsignedInteger(String valueString) throws ValueFormatException { int length = maxLength; byte[] bytes = new byte[length]; try { int minValue = 0; long maxValue = 1; for (int i = 0; i < length; i++) { maxValue *= 256; } maxValue -= 1; long value = Long.parseLong(valueString); if ((value < minValue) || (value > maxValue)) throw new ValueFormatException("Value must be between " + minValue + " and " + maxValue + "."); for (int i = 0; i < length; i++) { bytes[length - i - 1] = (byte)(value%256); value = value/256; } } catch (NumberFormatException e) { throw new ValueFormatException("Bad number format."); } return bytes; } private byte[] convertFromHexString(String hexString) throws ValueFormatException { byte[] bytes = new byte[this.maxLength]; // eliminate spaces in string hexString.trim(); int index; while((index = hexString.indexOf(' ')) != -1) { hexString = hexString.substring(0,index) + hexString.substring(index+1); } // make sure have even number of hex digits if (2 * (hexString.length()/2) != hexString.length()) throw new ValueFormatException("Must have an even number of hexadecimal digits."); // make sure don't have wrong number of bytes if ((this.maxLength > 0) && (hexString.length() / 2 != maxLength)) throw new ValueFormatException("Too many hexadecimal digits (must have " + 2*maxLength + " hex digits)."); for (int i = 0; i < (hexString.length()/2); i++) { // get next pair of digits String digitString = hexString.substring(2*i,2*i+2); try { int value = Integer.parseInt(digitString, 16); bytes[i] = (byte)value; } catch (NumberFormatException e) { throw new ValueFormatException("Entries must be hexadecimal digits (0 through 9 and a through f or A through F) or spaces."); } } return bytes; } private byte[] reverseBytes(byte[] inBytes) { int length = inBytes.length; byte[] outBytes = new byte[length]; for (int i = 0; i < length; i++) { outBytes[i] = inBytes[length - i - 1]; } return outBytes; } public byte[] getValue() { return value; } public void setValue(byte[] bytes) { // just set value array value = bytes; } public byte[] getUpdateBytes() { // serialize all the fields ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); DataOutputStream outStream = new DataOutputStream(byteStream); try { outStream.writeBytes(tag); outStream.writeInt(encryption); outStream.writeInt(value.length); if (value.length > 0) { // encrypt bytes if needed if (this.encryption == ENCRYPTED) { outStream.write(encryptBytes(cipherBytes, value)); } else { outStream.write(value); } } } catch(IOException e) { // IOException should never occur... } return byteStream.toByteArray(); } public byte[] getRequestBytes() { // serialize all the fields ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128); DataOutputStream outStream = new DataOutputStream(byteStream); try { outStream.writeBytes(tag); outStream.writeInt(encryption); outStream.writeInt(0); } catch(IOException e) { // IOException should never occur... } return byteStream.toByteArray(); } public static byte[] decryptBytes(byte[] cipherString, byte[] encryptedString) { byte[] returnBytes = new byte[encryptedString.length]; // just xor each byte in encryptedString with cipherString int length = encryptedString.length; for (int i = 0; i < length; i++) { returnBytes[i] = (byte)(encryptedString[i] ^ cipherString[i%256]); } return returnBytes; } public static byte[] encryptBytes(byte[] cipherString, byte[] encryptedString) { return decryptBytes(cipherString, encryptedString); } private int getIntegerValue(byte[] valueBytes) { int value = 0; for (int i = 0; i < valueBytes.length; i++) { int absValue = valueBytes[i]; if (absValue < 0) absValue += 256; value = value*256 + absValue; } return value; } private String hexByte(byte b) { int pos = b; if (pos < 0) pos += 256; String returnString = new String(); returnString += Integer.toHexString(pos/16); returnString += Integer.toHexString(pos%16); return returnString; } private String hexBytes(byte[] bytes) { String returnString = new String(); for(int i = 0; i < bytes.length; i++) { returnString += hexByte(bytes[i]); } return returnString; } }ipinspector-1.0/airport/AirportInfoTextField.java0000644000175000017500000000705307534012100021634 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package airport; import java.awt.*; import javax.swing.*; /** * Creates a text box to display and edit information in an AirportInfoRecord. * Size of textfield is set automatically according to datatype. */ public class AirportInfoTextField extends JTextField implements AirportInfoComponent { private AirportInfoRecord theRecord; /** * Creates new textfield to display and edit information in an AirportInfoRecord. * Size of textfield is set automatically according to datatype. */ public AirportInfoTextField(AirportInfoRecord theRecord) { super(); this.theRecord = theRecord; //determine how large the text field should be to display the value int fieldSize = theRecord.maxLength; switch (theRecord.dataType) { case AirportInfoRecord.CHAR_STRING: { // do nothing; field size OK as number of bytes break; } case AirportInfoRecord.PHONE_NUMBER: { fieldSize = 20; // should be enough for all digits and spaces break; } case AirportInfoRecord.IP_ADDRESS: { fieldSize = 15; break; } case AirportInfoRecord.UNSIGNED_INTEGER: case AirportInfoRecord.BYTE: case AirportInfoRecord.BYTE_STRING: default: { fieldSize *= 3; // to hold hex string: 2 chars per byte, plus space break; // or integer value } } if (fieldSize > 40) fieldSize = 40; this.setColumns(fieldSize); refreshDisplay(); } /** * Creates new textfield to display and edit information in an AirportInfoRecord. * Size of textfield is supplied as argument. */ public AirportInfoTextField(AirportInfoRecord theRecord, int fieldSize) { super(); this.theRecord = theRecord; this.setColumns(fieldSize); refreshDisplay(); } public void setAirportInfoRecord(AirportInfoRecord theRecord) { this.theRecord = theRecord; refreshDisplay(); } /** * Read value from associated AirportInfoRecord window, and display value. */ public void refreshDisplay() { setText(theRecord.toString()); } /** * Write value currently displayed into associated AirportInfoRecord window. */ public void writeValue() throws ValueFormatException { try { theRecord.setBytesFromString(getText()); } catch (ValueFormatException e) { this.selectAll(); this.requestFocus(); throw e; } } /** * Write supplied value, rather than that currently displayed, into associated * AirportInfoRecord window. */ public void writeValue(String newValue) throws ValueFormatException { setText(newValue); writeValue(); refreshDisplay(); } }ipinspector-1.0/airport/ValueFormatException.java0000644000175000017500000000225407534012100021671 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package airport; /** * Used to report incorrect value format messages, when inappropriate string has been supplied * in a textfield. */ public class ValueFormatException extends Exception { /** * Construct new exception with specified error message. */ public ValueFormatException(String specifics) { super(specifics); } }ipinspector-1.0/airport/Airport2InfoElement.java0000644000175000017500000001237607557644032021447 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.io.*; public class Airport2InfoElement { public String tag; public int dataType; public int encryption; public int length; public byte[] value; public static byte[] cipherBytes = {(byte)0x0e, (byte)0x39, (byte)0xf8, (byte)0x05, (byte)0xc4, (byte)0x01, (byte)0x55, (byte)0x4f, (byte)0x0c, (byte)0xac, (byte)0x85, (byte)0x7d, (byte)0x86, (byte)0x8a, (byte)0xb5, (byte)0x17, (byte)0x3e, (byte)0x09, (byte)0xc8, (byte)0x35, (byte)0xf4, (byte)0x31, (byte)0x65, (byte)0x7f, (byte)0x3c, (byte)0x9c, (byte)0xb5, (byte)0x6d, (byte)0x96, (byte)0x9a, (byte)0xa5, (byte)0x07, (byte)0x2e, (byte)0x19, (byte)0xd8, (byte)0x25, (byte)0xe4, (byte)0x21, (byte)0x75, (byte)0x6f, (byte)0x2c, (byte)0x8c, (byte)0xa5, (byte)0x9d, (byte)0x66, (byte)0x6a, (byte)0x55, (byte)0xf7, (byte)0xde, (byte)0xe9, (byte)0x28, (byte)0xd5, (byte)0x14, (byte)0xd1, (byte)0x85, (byte)0x9f, (byte)0xdc, (byte)0x7c, (byte)0x55, (byte)0x8d, (byte)0x76, (byte)0x7a, (byte)0x45, (byte)0xe7}; public Airport2InfoElement(String tag, int encryption, int length, byte[] value) { this.tag = tag; this.encryption = encryption; this.length = length; this.value = value; } public Airport2InfoElement(String tag, int encryption, String stringValue) { this.tag = tag; this.encryption = encryption; this.length = stringValue.length(); this.value = stringValue.getBytes(); if (encryption == 2) { this.value = encryptBytes(cipherBytes, this.value); } } public Airport2InfoElement() { this.tag = ""; this.encryption = 0; this.length = 0; this.value = null; } public int getSize() { int size = tag.length() + 4 + 4; if (value != null) size += value.length; return (size); } public byte[] getBytes() { // serialize all the fields ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128); DataOutputStream outStream = new DataOutputStream(byteStream); try { outStream.writeBytes(tag); outStream.writeInt(encryption); outStream.writeInt(length); if (value != null) outStream.write(value); } catch(IOException e) { // IOException should never occur... } return byteStream.toByteArray(); } public String toString() { String returnText = new String(); returnText += "Name: " + this.tag + "\n"; returnText += " encryption: " + this.encryption + "\n"; returnText += " length: " + this.length + "\n"; if (this.length == 0) { returnText += " value: \n"; } else { if (this.encryption == 2) { returnText += " value (hex): " + new String(hexBytes(decryptBytes(cipherBytes, this.value))) + "\n"; returnText += " value (char): " + new String(decryptBytes(cipherBytes, this.value)) + "\n"; } else { returnText += " value (hex): " + new String(hexBytes(this.value)) + "\n"; returnText += " value (char): " + new String(this.value) + "\n"; } } returnText += "\n"; return returnText; } public static byte[] decryptBytes(byte[] cipherString, byte[] encryptedString) { byte[] returnBytes = new byte[encryptedString.length]; // just xor each byte in encryptedString with cipherString int length = encryptedString.length; if(cipherString.length < encryptedString.length) length = cipherString.length; for (int i = 0; i < length; i++) { returnBytes[i] = (byte)(encryptedString[i] ^ cipherString[i]); } return returnBytes; } public static byte[] encryptBytes(byte[] cipherString, byte[] encryptedString) { return decryptBytes(cipherString, encryptedString); } private int getIntegerValue(byte[] valueBytes) { int value = 0; for (int i = 0; i < valueBytes.length; i++) { int absValue = valueBytes[i]; if (absValue < 0) absValue += 256; value = value*256 + absValue; } return value; } private String hexByte(byte b) { int pos = b; if (pos < 0) pos += 256; String returnString = new String(); returnString += Integer.toHexString(pos/16); returnString += Integer.toHexString(pos%16); return returnString; } private String hexBytes(byte[] bytes) { String returnString = new String(); for(int i = 0; i < bytes.length; i++) { returnString += hexByte(bytes[i]) + " "; } return returnString; } }ipinspector-1.0/airport/Airport2ProtocolMessage.java0000644000175000017500000000574207531714364022345 0ustar julienjulien package airport; import java.io.*; public class Airport2ProtocolMessage { public String messageTag = "acpp"; public int unknownField1 = 1; public int messageChecksum = 0; public int payloadChecksum = 0; public int payloadSize; public byte[] unknownField2 = new byte[8]; public int messageType; // download = 0x14, upload = 0x15 public byte[] unknownField3 = new byte[16]; public byte[] password = new byte[32]; public byte[] unknownField4 = new byte[48]; public static final int READ = 0x14; public static final int WRITE = 0x15; public Airport2ProtocolMessage(int messageType, String password, byte[] payloadBytes, int payloadSize) { // set payload size and checksum if (messageType == READ) { this.payloadSize = payloadSize; this.payloadChecksum = computeChecksum(payloadBytes, payloadSize); } else { this.payloadSize = -1; this.payloadChecksum = 1; } // set message type this.messageType = messageType; // set encrypted password bytes byte[] passwordBytes = password.getBytes(); int length = passwordBytes.length; if (length > 32) length = 32; for (int i = 0; i < length; i++) { this.password[i] = passwordBytes[i]; } this.password = AirportInfoRecord.encryptBytes(AirportInfoRecord.cipherBytes, this.password); // get current message bytes, and use to compute checksum (including magic number) this.messageChecksum = computeChecksum(this.getBytes(), 128); } public byte[] getBytes() { // serialize all the fields ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128); DataOutputStream outStream = new DataOutputStream(byteStream); try { outStream.writeBytes(messageTag); outStream.writeInt(unknownField1); outStream.writeInt(messageChecksum); outStream.writeInt(payloadChecksum); outStream.writeInt(payloadSize); outStream.write(unknownField2); outStream.writeInt(messageType); outStream.write(unknownField3); outStream.write(password); outStream.write(unknownField4); } catch(IOException e) { } return byteStream.toByteArray(); } private int computeChecksum(byte[] fileBytes, int length) { int checksum; // just multiply each byte by descending sequence //int length = fileBytes.length; int weightedChecksum = 0; int ordinaryChecksum = 0; for (int i = 0; i < length; i++) { int byteValue = fileBytes[i]; if (byteValue < 0) byteValue += 256; ordinaryChecksum += byteValue; weightedChecksum += byteValue * (length - i); } ordinaryChecksum += 1; weightedChecksum += length; ordinaryChecksum = ordinaryChecksum & 0x0000FFFF; // boil checksum down to 16 bits while (weightedChecksum > 0x0000FFFF) { int upperHalf = (weightedChecksum & 0xFFFF0000) >> 16; int lowerHalf = (weightedChecksum & 0x0000FFFF); weightedChecksum = lowerHalf + (upperHalf * 0x0F); } checksum = ordinaryChecksum | (weightedChecksum << 16); return checksum; } }ipinspector-1.0/IPInspector.java0000644000175000017500000004471307616304530016326 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.util.*; import java.net.*; import java.awt.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.*; import java.awt.event.*; import java.io.*; import airport.*; public class IPInspector extends JFrame implements ActionListener, Runnable { JButton newPreferencesButton, discoverDevicesButton; JTextField airportInternalIPField; AirportInfoTextField airportExternalIPField, airportNameField, airportLocationField; JPanel hostPanel; MenuBar theMenubar; Menu fileMenu; MenuItem quitItem, aboutItem, savePreferencesItem; JTextArea messagesArea; JTextField statusArea; JTextAreaWriter messagesAreaWriter; Thread inspectionThread; IPInspectorAirportInfo airportInfo; Preferences preferences; boolean preferencesSaved = true; InetAddress airportInternalIPAddress; private Vector changeListeners; AirportInfoChangeEmailer changeEmailer; // WindowCloseAdapter to catch window close-box closings private class WindowCloseAdapter extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(0); } } public IPInspector() { airportInfo = new IPInspectorAirportInfo(); changeListeners = new Vector(); // create thread, but don't start it inspectionThread = new Thread(this); setUpDisplay(); // create Writer interface into messages area for use by mailer thread messagesAreaWriter = new JTextAreaWriter(messagesArea); this.pack(); // tweak app size to make it a little larger than necessary, to address the // "shrunken textfields" problem arising from the layout manager packing stuff // a little too tightly. Dimension dim = this.getSize(); dim.height += 20; dim.width += 20; this.setSize(dim); this.show(); // set up preferences // read any settings that have previously been saved readSettings(); // put up dialog if (getPreferences() == false) { messagesArea.setText("Problem with supplied information; set options again"); } } public void addChangeListener(AirportInfoChangeListener changeListener) { if (!changeListeners.contains(changeListener)) changeListeners.add(changeListener); } public void removeChangeListener(AirportInfoChangeListener changeListener) { if (changeListeners.contains(changeListener)) changeListeners.remove(changeListener); } private void setUpDisplay() { // set fonts to smaller-than-normal size, for compaction! UIManager manager = new UIManager(); FontUIResource appFont = new FontUIResource("SansSerif", Font.PLAIN, 10); UIDefaults defaults = manager.getLookAndFeelDefaults(); Enumeration keys = defaults.keys(); while (keys.hasMoreElements()) { String nextKey = (String)(keys.nextElement()); if ((nextKey.indexOf("font") > -1) || (nextKey.indexOf("Font") > -1)) { manager.put(nextKey, appFont); } } // add WindowCloseAdapter to catch window close-box closings addWindowListener(new WindowCloseAdapter()); this.setTitle("AirPort IP Inspector"); this.getRootPane().setBorder(new BevelBorder(BevelBorder.RAISED)); theMenubar = new MenuBar(); this.setMenuBar(theMenubar); fileMenu = new Menu("File"); aboutItem = new MenuItem("About..."); aboutItem.setActionCommand("about"); aboutItem.addActionListener(this); fileMenu.add(aboutItem); savePreferencesItem = new MenuItem("Save settings"); savePreferencesItem.setActionCommand("save preferences"); savePreferencesItem.addActionListener(this); fileMenu.add(savePreferencesItem); fileMenu.addSeparator(); quitItem = new MenuItem("Quit"); quitItem.setShortcut(new MenuShortcut('q')); quitItem.setActionCommand("quit"); quitItem.addActionListener(this); fileMenu.add(quitItem); theMenubar.add(fileMenu); JLabel airportInternalIPLabel = new JLabel("Base station LAN address:"); airportInternalIPField = new JTextField(10); airportInternalIPField.setText("10.0.1.1"); airportInternalIPField.setEditable(false); JLabel airportExternalIPLabel = new JLabel("Base station WAN address:"); airportExternalIPField = new AirportInfoTextField((AirportInfoRecord)airportInfo.get("waIP")); airportExternalIPField.setEditable(false); JLabel airportNameLabel = new JLabel("Base station name:"); airportNameField = new AirportInfoTextField((AirportInfoRecord)airportInfo.get("syNm")); airportNameField.setEditable(false); JLabel airportLocationLabel = new JLabel("Base station location:"); airportLocationField = new AirportInfoTextField((AirportInfoRecord)airportInfo.get("syLo")); airportLocationField.setEditable(false); newPreferencesButton = new JButton("New settings"); newPreferencesButton.setActionCommand("new preferences"); newPreferencesButton.addActionListener(this); discoverDevicesButton = new JButton("Discover devices"); discoverDevicesButton.setActionCommand("discover devices"); discoverDevicesButton.addActionListener(this); // set params for layout manager GridBagLayout theLayout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.NONE; c.ipadx = 0; c.ipady = 0; Insets theMargin = new Insets(2,2,2,2); c.insets = theMargin; c.anchor = GridBagConstraints.CENTER; c.weightx = .5; c.weighty = .5; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(theLayout); c.gridx = 1; c.gridy = 1; theLayout.setConstraints(newPreferencesButton, c); buttonPanel.add(newPreferencesButton); c.gridx = 2; c.gridy = 1; theLayout.setConstraints(discoverDevicesButton, c); buttonPanel.add(discoverDevicesButton); hostPanel = new JPanel(); hostPanel.setLayout(theLayout); c.gridx = 1; c.gridy = 1; theLayout.setConstraints(airportInternalIPLabel, c); hostPanel.add(airportInternalIPLabel); c.gridx = 2; c.gridy = 1; theLayout.setConstraints(airportInternalIPField, c); hostPanel.add(airportInternalIPField); c.gridx = 1; c.gridy = 2; theLayout.setConstraints(airportExternalIPLabel, c); hostPanel.add(airportExternalIPLabel); c.gridx = 2; c.gridy = 2; theLayout.setConstraints(airportExternalIPField, c); hostPanel.add(airportExternalIPField); c.gridx = 1; c.gridy = 3; theLayout.setConstraints(airportNameLabel, c); hostPanel.add(airportNameLabel); c.gridx = 2; c.gridy = 3; theLayout.setConstraints(airportNameField, c); hostPanel.add(airportNameField); c.gridx = 1; c.gridy = 4; theLayout.setConstraints(airportLocationLabel, c); hostPanel.add(airportLocationLabel); c.gridx = 2; c.gridy = 4; theLayout.setConstraints(airportLocationField, c); hostPanel.add(airportLocationField); JPanel messagesPanel = new JPanel(); messagesPanel.setLayout(theLayout); statusArea = new JTextField(50); messagesArea = new JTextArea(6,50); JScrollPane messagesScroll = new JScrollPane(messagesArea); c.gridx = 1; c.gridy = 1; JLabel messagesLabel = new JLabel("Messages:"); theLayout.setConstraints(messagesLabel, c); messagesPanel.add(messagesLabel); c.gridx = 1; c.gridy = 2; theLayout.setConstraints(statusArea, c); messagesPanel.add(statusArea); c.gridx = 1; c.gridy = 3; theLayout.setConstraints(messagesScroll, c); messagesPanel.add(messagesScroll); this.getContentPane().setLayout(theLayout); c.gridx = 1; c.gridy = 1; theLayout.setConstraints(hostPanel, c); this.getContentPane().add(hostPanel); c.gridx = 1; c.gridy = 2; theLayout.setConstraints(buttonPanel, c); this.getContentPane().add(buttonPanel); c.gridx = 1; c.gridy = 4; theLayout.setConstraints(messagesPanel, c); this.getContentPane().add(messagesPanel); c.gridx = 1; c.gridy = 5; JLabel authorLabel = new JLabel(" Version 1.0 J. Sevy, February 2003 "); authorLabel.setFont(new Font("SansSerif", Font.ITALIC, 8)); theLayout.setConstraints(authorLabel, c); this.getContentPane().add(authorLabel); } public void actionPerformed(ActionEvent theEvent) // respond to button pushes, menu selections { String command = theEvent.getActionCommand(); if (command.equals("quit")) { if (preferencesSaved == false) { // put up dialog to ask if settings should be saved if (JOptionPane.showConfirmDialog(this, "Save current settings?","Save settings?",JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { saveSettings(); } } System.exit(0); } if (command == "about") { AboutDialog aboutDialog = new AboutDialog(this); } if (command.equals("discover devices")) { AirportDiscoverer discoverer = new AirportDiscoverer(); } if (command == "new preferences") { getPreferences(); } if (command.equals("save preferences")) { saveSettings(); } } private boolean getPreferences() { PreferencesDialog theDialog = new PreferencesDialog(this, preferences); if (!theDialog.isCancelled()) { // stop thread if needed if (inspectionThread.isAlive()) { inspectionThread.interrupt(); } // get preferences Preferences newPreferences = theDialog.getPreferences(); try { if (!newPreferences.equals(preferences)) preferencesSaved = false; airportInternalIPAddress = InetAddress.getByName(newPreferences.ipAddress); airportInternalIPField.setText(newPreferences.ipAddress); // remove current action object this.removeChangeListener(changeEmailer); // create and add new action object changeEmailer = new AirportInfoChangeEmailer(newPreferences.emailAddress, newPreferences.smtpHost, messagesAreaWriter); changeListeners.add(changeEmailer); preferences = newPreferences; inspectionThread = new Thread(this); inspectionThread.start(); return true; } catch(UnknownHostException e) { JOptionPane.showMessageDialog(this, "Unknown host name supplied."); } catch(Exception e) { JOptionPane.showMessageDialog(this, "Error setting new preferences: " + e); } } return false; } private IPInspectorAirportInfo getInfo() { try { IPInspectorAirportInfo newInfo; byte[] requestPayload = airportInfo.getRequestBytes(); Airport2ProtocolMessage requestMessage = new Airport2ProtocolMessage(Airport2ProtocolMessage.READ, preferences.password, requestPayload, requestPayload.length); // open socket int port = 5009; Socket configSocket = new Socket(airportInternalIPAddress, port); // set socket timeout to 5 seconds configSocket.setSoTimeout(5000); DataInputStream inputStream = new DataInputStream(configSocket.getInputStream()); OutputStream outputStream = configSocket.getOutputStream(); outputStream.write(requestMessage.getBytes()); /* System.out.println("Request header bytes:"); System.out.println(printHexBytes(requestMessage.getBytes())); */ outputStream.write(requestPayload); // get and process response byte[] responseHeader = new byte[128]; inputStream.readFully(responseHeader); //int numBytes = inputStream.read(responseHeader); // create temp buffer to hold retrieved config; 4k should suffice... byte[] responsePayload = new byte[4096]; // read info try { inputStream.readFully(responsePayload); } catch (EOFException e) { // this is expected; we _should_ reach the end of the stream before filling the buffer } /* numBytes = 0; int newNumBytes = 0; while( ((newNumBytes = inputStream.read(responsePayload, numBytes, responsePayload.length - numBytes)) >= 0 ) && (numBytes < responsePayload.length) ) { System.out.println("Read " + newNumBytes + " bytes."); numBytes += newNumBytes; } */ //System.out.println("done."); //System.out.println("Read " + numBytes + " bytes total."); inputStream.close(); outputStream.close(); configSocket.close(); // check to see if we retrieved valid data from the base station try { statusArea.setText("Information retrieved (" + (new Date()).toString() + ")."); return new IPInspectorAirportInfo(responsePayload); } catch(IllegalArgumentException ex) { // thrown by AirportInfo constructor if no data retrieved statusArea.setText("Error retrieving information (check password)"); } } catch(SocketException e) { statusArea.setText("Error retrieving information: " + e + "."); } catch(IOException e) { statusArea.setText("Error retrieving information: timed out waiting for response."); } catch (Exception e) { statusArea.setText("Error retrieving information: " + e.getMessage() + "."); } // if get here, didn't get valid stuff; return a blank structure return new IPInspectorAirportInfo(); } private void refreshInfoDisplay(IPInspectorAirportInfo newInfo) { // update displayed info airportExternalIPField.setAirportInfoRecord(newInfo.get("waIP")); airportNameField.setAirportInfoRecord(newInfo.get("syNm")); airportLocationField.setAirportInfoRecord(newInfo.get("syLo")); } private String hexByte(byte b) { int pos = b; if (pos < 0) pos += 256; String returnString = new String(); returnString += Integer.toHexString(pos/16); returnString += Integer.toHexString(pos%16); return returnString; } private String printHexBytes(byte[] bytes) { String returnString = new String(); for(int i = 0; i < bytes.length; i++) { returnString += hexByte(bytes[i]) + " "; if (((i+1)%16) == 0) returnString += "\n"; } return returnString; } /* private static boolean arraysEqual(byte[] a, byte[] b) { if (a.length != b.length) { return false; } else { for (int i = 0; i < a.length; i++) { if (a[i] != b[i]) return false; } } return true; } private static byte[] maskBytes(byte[] inBytes, byte[] mask) { byte[] maskedBytes = new byte[inBytes.length]; for (int i = 0; i < inBytes.length; i++) { maskedBytes[i] = (byte)(inBytes[i] & mask[i % inBytes.length]); } return maskedBytes; } */ private void invokeChangeListeners(IPInspectorAirportInfo oldInfo, IPInspectorAirportInfo newInfo) { // just call the processInfoChange method of each listener for (int i = 0; i < changeListeners.size(); i++) { ((AirportInfoChangeListener)changeListeners.elementAt(i)).processInfoChange(oldInfo, newInfo); } } public void run() { IPInspectorAirportInfo newInfo; while(!Thread.currentThread().isInterrupted()) { // retrieve current info from base station newInfo = getInfo(); // now refresh display refreshInfoDisplay(newInfo); // see if info has changed; if so, take action if (!newInfo.get("waIP").toString().equals(airportInfo.get("waIP").toString())) { invokeChangeListeners(airportInfo, newInfo); } airportInfo = newInfo; try { // sleep for inspection interval seconds Thread.currentThread().sleep(1000 * preferences.queryInterval); } catch(InterruptedException e) { // don't bother informing of interruption Thread.currentThread().interrupt(); } } } private void saveSettings() { // save into file IpInspector.ini ObjectOutputStream outStream; try { outStream = new ObjectOutputStream(new FileOutputStream("IPInspector.ini")); outStream.writeObject(preferences); outStream.close(); preferencesSaved = true; } catch (Exception e) { // oh well... messagesArea.setText("Couldn't write settings: " + e.toString()); preferencesSaved = false; } } private void readSettings() { // read from file IpInspector.ini try { ObjectInputStream inStream = new ObjectInputStream(new FileInputStream("IPInspector.ini")); preferences = (Preferences)inStream.readObject(); inStream.close(); preferencesSaved = true; } catch (Exception e) { // couldn't read; just return empty settings messagesArea.setText("Couldn't read settings: " + e.toString()); preferences = new Preferences(); preferencesSaved = false; } } public static void main(String args[]) { try { IPInspector theApp = new IPInspector(); } catch (Exception e) {} } }ipinspector-1.0/AirportInfoChangeListener.java0000644000175000017500000000201607557646123021200 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import airport.*; public interface AirportInfoChangeListener { // do whatever in response to a change in the retrieved info public void processInfoChange(IPInspectorAirportInfo oldInfo, IPInspectorAirportInfo newInfo); }ipinspector-1.0/POPWeasel.java0000644000175000017500000002146407557643601015735 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* class POPWeasel Defines object that will communicate with POP and SMTP servers to get and send e-mail (pardon the name) Defines methods: public Vector getMessages(UserInfo user, String mailHost) Retrieves messages from specified POP host, using supplied user ID and password. Return as vector of Strings (one per message) public void sendMessages(UserInfo user, Vector messages, String mailHost) Send the messages corresponding to the Vector supplied of Message objects, using the specified SMTP host */ import java.util.*; import java.net.*; import java.io.*; public class POPWeasel { public static final int POPPORT = 110; public static final int SMTPPORT = 25; public static final boolean debug = false; public POPWeasel() { } public Vector getMessages(String userName, String password, String mailHost) throws Exception { Socket mailSocket; BufferedReader istream; BufferedWriter ostream; Vector messageList = new Vector(); mailSocket = new Socket(mailHost, POPWeasel.POPPORT); istream = new BufferedReader(new InputStreamReader(mailSocket.getInputStream())); ostream = new BufferedWriter(new OutputStreamWriter(mailSocket.getOutputStream())); establishPOPSession(userName, password, istream, ostream); messageList = retrieveMessages(istream, ostream); closePOPSession(istream, ostream); istream.close(); ostream.close(); mailSocket.close(); return messageList; } public void sendMessages(String userEmailAddress, String mailHost, Vector messages) throws Exception { Socket mailSocket; BufferedReader istream; BufferedWriter ostream; mailSocket = new Socket(mailHost, POPWeasel.SMTPPORT); istream = new BufferedReader(new InputStreamReader(mailSocket.getInputStream())); ostream = new BufferedWriter(new OutputStreamWriter(mailSocket.getOutputStream())); establishSMTPSession(mailHost, istream, ostream); sendMessages(userEmailAddress, messages, istream, ostream); closeSMTPSession(istream, ostream); istream.close(); ostream.close(); mailSocket.close(); return; } // Utility method for sending a single email message public void sendMessage(String userEmailAddress, String mailHost, Message message) throws Exception { Vector messageVector = new Vector(); messageVector.add(message); this.sendMessages(userEmailAddress, mailHost, messageVector); } private void checkPOPResponse(String response) throws IOException // utility method, to see if POP server sends happy response; throws a "fit" // (also known as an Exception) if response doesn't begin with "+OK" { StringTokenizer st; debugPrintln("Server: " + response); st = new StringTokenizer(response); if (!st.nextToken().equals("+OK")) throw new IOException(response); } private void establishPOPSession(String userName, String password, BufferedReader istream, BufferedWriter ostream) throws IOException // Send username and password to establish POP session { checkPOPResponse(istream.readLine()); ostream.write("USER " + userName); ostream.newLine(); ostream.flush(); debugPrintln("Client: USER " + userName); checkPOPResponse(istream.readLine()); ostream.write("PASS " + password); ostream.newLine(); ostream.flush(); debugPrintln("Client: PASS (hidden)"); checkPOPResponse(istream.readLine()); return; } private Vector retrieveMessages(BufferedReader istream, BufferedWriter ostream) throws IOException, NumberFormatException // Get waiting messages, sending STAT and RETR messages to POP host { Vector retrievedMessages = new Vector(); StringTokenizer st; String nextLine; String nextToken; int numMessages; ostream.write("STAT"); ostream.newLine(); ostream.flush(); debugPrintln("Client: STAT"); nextLine = istream.readLine(); debugPrintln("Server: " + nextLine); st = new StringTokenizer(nextLine); if (!st.nextToken().equals("+OK")) throw new IOException(nextLine); nextToken = st.nextToken(); // will be number of messages to retrieve numMessages = Integer.parseInt(nextToken); for (int i=1; i <= numMessages; ++i) { // get waiting messages String newMessage = new String(); ostream.write("RETR " + i) ; ostream.newLine(); ostream.flush(); debugPrintln("Client: RETR " + i); checkPOPResponse(istream.readLine()); while (!(nextLine = istream.readLine()).equals(".")) { // add each line of message to message string newMessage += nextLine + "\n"; } // add message to vector to be returned retrievedMessages.insertElementAt(newMessage, retrievedMessages.size()); } return retrievedMessages; } private void closePOPSession(BufferedReader istream, BufferedWriter ostream) throws IOException { ostream.write("QUIT"); ostream.newLine(); ostream.flush(); } private void checkSMTPResponse(String response, String expected) throws IOException // See if SMTP host returns string expected at current stage of communication; // if not, throw a fit (exception) { StringTokenizer st; debugPrintln("Server: " + response); st = new StringTokenizer(response); if (!st.nextToken().equals(expected)) throw new IOException(response); } private void establishSMTPSession(String domainName, BufferedReader istream, BufferedWriter ostream) throws IOException { checkSMTPResponse(istream.readLine(), "220"); ostream.write("HELO " + domainName); //ostream.newLine(); ostream.write("\r\n"); ostream.flush(); debugPrintln("Client: HELO " + domainName); checkSMTPResponse(istream.readLine(), "250"); return; } private void sendMessages(String userEmailAddress, Vector messages, BufferedReader istream, BufferedWriter ostream) throws IOException { Enumeration e = messages.elements(); while (e.hasMoreElements()) { // send next message Message m = (Message)e.nextElement(); //try //{ ostream.write("MAIL FROM:" + "<" + userEmailAddress + ">"); //ostream.newLine(); ostream.write("\r\n"); ostream.flush(); debugPrintln("Client: MAIL FROM:" + "<" + userEmailAddress + ">"); checkSMTPResponse(istream.readLine(), "250"); Enumeration addresses = (m.recipients).elements(); while(addresses.hasMoreElements()) { String recipient = (String)addresses.nextElement(); ostream.write("RCPT TO:" + "<" + recipient + ">"); //ostream.newLine(); ostream.write("\r\n"); ostream.flush(); debugPrintln("Client: RCPT TO:" + "<" + recipient + ">"); checkSMTPResponse(istream.readLine(), "250"); } ostream.write("DATA"); //ostream.newLine(); ostream.write("\r\n"); ostream.flush(); debugPrintln("Client: DATA"); checkSMTPResponse(istream.readLine(), "354"); ostream.write(m.text); //ostream.newLine(); ostream.write("\r\n"); //ostream.flush(); debugPrintln("Message text sent"); ostream.write("."); // CR-LF = 0x0D 0x0A = octal 015 012 //ostream.newLine(); ostream.write("\r\n"); //ostream.newLine(); ostream.flush(); //debugPrintln("."); checkSMTPResponse(istream.readLine(), "250"); //} //catch (Exception except) //{ // debugPrintln("Problem sending email message: " + except); //} } return; } private void closeSMTPSession(BufferedReader istream, BufferedWriter ostream) throws IOException { ostream.write("QUIT"); //ostream.newLine(); ostream.write("\r\n"); ostream.flush(); debugPrintln("Client: QUIT"); } private void debugPrintln(String message) { if (this.debug) System.out.println(message); } }ipinspector-1.0/AboutDialog.java0000644000175000017500000001241207616046607016320 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class AboutDialog extends JDialog implements Runnable, ActionListener { private JLabel aboutLabel1 = new JLabel(" "); private JLabel aboutLabel2 = new JLabel(" "); private JLabel aboutLabel3 = new JLabel(" "); private JLabel aboutLabel4 = new JLabel(" "); private String aboutString1 = "Airport IP Inspector "; private String aboutString2 = "Version 1.0 "; private String aboutString3 = "J. Sevy "; private String aboutString4 = "February 2003 "; private JButton okButton; Thread displayThread; public AboutDialog(JFrame parent) { super(parent, "About...", true /*modal*/); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setUpDisplay(); this.setLocation(Math.round((parent.getSize().width - this.getSize().width)/2), Math.round((parent.getSize().height - this.getSize().height)/2)); // create and start display thread displayThread = new Thread(this); displayThread.start(); this.show(); } public void hide() { super.hide(); // interrupt thread so it can exit.. displayThread.interrupt(); } private void setUpDisplay() { // set params for layout manager GridBagLayout theLayout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.NONE; c.ipadx = 0; c.ipady = 0; c.insets = new Insets(2,2,2,2); c.anchor = GridBagConstraints.CENTER; c.weightx = 0; c.weighty = 0; Font titleFont = new Font("SansSerif",Font.BOLD + Font.ITALIC, 12); Font labelFont = new Font("SansSerif",Font.PLAIN, 10); aboutLabel1.setText(aboutString1); aboutLabel2.setText(aboutString2); aboutLabel3.setText(aboutString3); aboutLabel4.setText(aboutString4); aboutLabel1.setFont(titleFont); aboutLabel2.setFont(labelFont); aboutLabel3.setFont(labelFont); aboutLabel4.setFont(labelFont); aboutLabel1.setForeground(aboutLabel1.getBackground()); aboutLabel2.setForeground(aboutLabel2.getBackground()); aboutLabel3.setForeground(aboutLabel3.getBackground()); aboutLabel4.setForeground(aboutLabel4.getBackground()); JPanel aboutPanel = new JPanel(); aboutPanel.setLayout(theLayout); c.gridx = 1; c.gridy = 1; theLayout.setConstraints(aboutLabel1, c); aboutPanel.add(aboutLabel1); c.gridx = 1; c.gridy = 2; theLayout.setConstraints(aboutLabel2, c); aboutPanel.add(aboutLabel2); c.gridx = 1; c.gridy = 3; theLayout.setConstraints(aboutLabel3, c); aboutPanel.add(aboutLabel3); c.gridx = 1; c.gridy = 4; theLayout.setConstraints(aboutLabel4, c); aboutPanel.add(aboutLabel4); okButton = new JButton("OK"); okButton.setActionCommand("ok"); okButton.addActionListener(this); this.getRootPane().setDefaultButton(okButton); this.getContentPane().setLayout(theLayout); c.gridx = 1; c.gridy = 1; theLayout.setConstraints(aboutPanel, c); this.getContentPane().add(aboutPanel); c.gridx = 1; c.gridy = 2; theLayout.setConstraints(okButton, c); this.getContentPane().add(okButton); this.pack(); this.setSize(300, 180); } public void actionPerformed(ActionEvent theEvent) // respond to button pushes, menu selections { String command = theEvent.getActionCommand(); if (command.equals("ok")) { this.hide(); } } public void run() { try { Color textColor = new Color(255, 0, 255); // write message out a character at a time... int numChars = aboutString1.length(); aboutLabel1.setSize(0, 30); aboutLabel1.setForeground(textColor); for (int i = 0; i < this.getWidth() - 20; i++) { aboutLabel1.setSize(i, 30); Thread.currentThread().sleep(6); } // change color of other strings... int numSteps = 255; for (int i = 0; i < numSteps; i++) { textColor = new Color(255, 255-i, i); aboutLabel2.setForeground(textColor); aboutLabel3.setForeground(textColor); aboutLabel4.setForeground(textColor); Thread.currentThread().sleep(20); } } catch(Exception e) { // don't bother informing of exception; just exit... //System.out.println(e); } // later! } }ipinspector-1.0/AirportInfoChangeEmailer.java0000644000175000017500000000447607557643764021015 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.io.*; import java.util.*; import airport.*; public class AirportInfoChangeEmailer implements AirportInfoChangeListener { String userEmailAddress; String mailHost; MailerThread mailerThread; Writer errorWriter; public AirportInfoChangeEmailer(String userEmailAddress, String mailHost, Writer errorWriter) { this.userEmailAddress = userEmailAddress; this.mailHost = mailHost; this.errorWriter = errorWriter; } // do whatever in response to a change in the retrieved info public synchronized void processInfoChange(IPInspectorAirportInfo oldInfo, IPInspectorAirportInfo newInfo) { // create message String messageText = "To: " + userEmailAddress + "\r\n"; messageText = "From: Airport base station (" + newInfo.get("syNm").toString() + ")\r\n"; messageText = "Date: " + (new Date()).toString() + "\r\n"; messageText = "Subject: Change in Airport base station info\r\n\r\n\r\n"; messageText += "Name: " + newInfo.get("syNm").toString() + "\r\n"; messageText += "Location: " + newInfo.get("syLo").toString() + "\r\n"; messageText += "Old WAN address: " + oldInfo.get("waIP").toString() + "\r\n"; messageText += "New WAN address: " + newInfo.get("waIP").toString() + "\r\n"; // start mailer thread mailerThread = new MailerThread(userEmailAddress, mailHost, messageText, errorWriter); mailerThread.start(); } }ipinspector-1.0/Message.java0000644000175000017500000000204707557643645015526 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* Message class Just a utility class */ import java.util.*; public class Message { public Vector recipients; public String text; public Message() { recipients = new Vector(); text = ""; } }ipinspector-1.0/MailerThread.java0000644000175000017500000000470307616305551016467 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.io.*; import java.util.*; public class MailerThread extends Thread { String userEmailAddress; String mailHost; String messageText; POPWeasel mailman; Writer errorWriter; public MailerThread(String userEmailAddress, String mailHost, String messageText, Writer errorWriter) { this.userEmailAddress = userEmailAddress; this.mailHost = mailHost; this.messageText = messageText; this.errorWriter = errorWriter; mailman = new POPWeasel(); } public void run() { Message changeMessage = new Message(); changeMessage.recipients.add(userEmailAddress); changeMessage.text = messageText; try { mailman.sendMessage(userEmailAddress, mailHost, changeMessage); } catch (Exception e) { try { errorWriter.write("Error sending message: " + e.toString() + " (" + (new Date()).toString() + ").\n"); } catch (IOException ex) { // print to System out System.out.println("Error sending message: " + e.toString() + " (" + (new Date()).toString() + ")."); } } try { errorWriter.write("Sent notification of change to " + userEmailAddress + " (" + (new Date()).toString() + ").\n"); } catch (IOException ex) { // print to System out System.out.println("Sent notification of change to " + userEmailAddress + " (" + (new Date()).toString() + ")."); } } }ipinspector-1.0/PreferencesDialog.java0000644000175000017500000001302707616046014017502 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.io.*; public class PreferencesDialog extends JDialog implements ActionListener { JTextField ipAddressField = new JTextField(10); JPasswordField passwordField = new JPasswordField(10); JTextField smtpHostField = new JTextField(20); JTextField emailAddressField = new JTextField(20); JTextField intervalField = new JTextField(10); JLabel ipAddressLabel = new JLabel("Base station address:"); JLabel passwordLabel = new JLabel("Base station password:"); JLabel smtpHostLabel = new JLabel("SMTP (email) host:"); JLabel emailAddressLabel = new JLabel("Email address for notices:"); JLabel intervalLabel = new JLabel("Base station query interval (seconds):"); JButton okButton, cancelButton; boolean cancelled = false; Preferences newPrefs; public PreferencesDialog(Frame owner, Preferences currentPreferences) { // create as modal dialog super(owner, "Preferences", true); // set new prefs to current newPrefs = currentPreferences; ipAddressField.setText(currentPreferences.ipAddress); passwordField.setText(""); smtpHostField.setText(currentPreferences.smtpHost); emailAddressField.setText(currentPreferences.emailAddress); intervalField.setText("" + currentPreferences.queryInterval); okButton = new JButton("OK"); okButton.setActionCommand("ok"); okButton.addActionListener(this); this.getRootPane().setDefaultButton(okButton); cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); // set params for layout manager GridBagLayout theLayout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.NONE; c.ipadx = 0; c.ipady = 0; Insets theMargin = new Insets(2,2,2,2); c.insets = theMargin; c.anchor = GridBagConstraints.CENTER; c.weightx = .5; c.weighty = .5; this.getContentPane().setLayout(theLayout); c.gridx = 1; c.gridy = 1; theLayout.setConstraints(ipAddressLabel, c); this.getContentPane().add(ipAddressLabel); c.gridx = 2; c.gridy = 1; theLayout.setConstraints(ipAddressField, c); this.getContentPane().add(ipAddressField); c.gridx = 1; c.gridy = 2; theLayout.setConstraints(passwordLabel, c); this.getContentPane().add(passwordLabel); c.gridx = 2; c.gridy = 2; theLayout.setConstraints(passwordField, c); this.getContentPane().add(passwordField); c.gridx = 1; c.gridy = 3; theLayout.setConstraints(emailAddressLabel, c); this.getContentPane().add(emailAddressLabel); c.gridx = 2; c.gridy = 3; theLayout.setConstraints(emailAddressField, c); this.getContentPane().add(emailAddressField); c.gridx = 1; c.gridy = 4; theLayout.setConstraints(smtpHostLabel, c); this.getContentPane().add(smtpHostLabel); c.gridx = 2; c.gridy = 4; theLayout.setConstraints(smtpHostField, c); this.getContentPane().add(smtpHostField); c.gridx = 1; c.gridy = 5; theLayout.setConstraints(okButton, c); this.getContentPane().add(okButton); c.gridx = 2; c.gridy = 5; theLayout.setConstraints(cancelButton, c); this.getContentPane().add(cancelButton); this.pack(); this.show(); } public void actionPerformed(ActionEvent theEvent) // respond to button pushes, menu selections { String command = theEvent.getActionCommand(); if (command.equals("ok")) { if (validateNewPreferences()) this.hide(); } if (command == "cancel") { cancelled = true; this.hide(); } } private boolean validateNewPreferences() { int interval; // check the interval parameter try { interval = Integer.parseInt(intervalField.getText()); if (interval <= 0) throw new NumberFormatException(); newPrefs = new Preferences(); newPrefs.ipAddress = ipAddressField.getText(); newPrefs.password = passwordField.getText(); newPrefs.smtpHost = smtpHostField.getText(); newPrefs.emailAddress = emailAddressField.getText(); newPrefs.queryInterval = interval; return true; } catch(NumberFormatException e) { JOptionPane.showMessageDialog(this, "Value supplied must be a positive integer."); return false; } } public Preferences getPreferences() { return newPrefs; } public boolean isCancelled() { return cancelled; } }ipinspector-1.0/Preferences.java0000644000175000017500000000347507557643630016403 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* Preferences class Just a utility class */ import java.io.*; import java.net.*; public class Preferences implements Serializable { public String ipAddress; public String password; public String emailAddress; public String smtpHost; public int queryInterval; public Preferences() { ipAddress = ""; password = ""; emailAddress = ""; smtpHost = ""; queryInterval = 5; } public boolean equals(Object otherPrefsObject) { Preferences otherPrefs = (Preferences)otherPrefsObject; // compare all fields but passwords if ( (this.ipAddress.equals(otherPrefs.ipAddress)) && (this.emailAddress.equals(otherPrefs.emailAddress)) && (this.smtpHost.equals(otherPrefs.smtpHost)) && (this.queryInterval == otherPrefs.queryInterval) ) { return true; } else { return false; } } }ipinspector-1.0/JTextAreaWriter.java0000644000175000017500000000300607557643736017163 0ustar julienjulien/* * IPInspector * * Copyright (C) 2002, Jonathan Sevy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.io.*; import javax.swing.text.*; public class JTextAreaWriter extends Writer { private JTextComponent textArea; public JTextAreaWriter(JTextComponent textArea) { this.textArea = textArea; } public void flush() { // do nothing } public void close() { // ditto } public void write (char[] charArray, int start, int end) { String messageString = new String(charArray); messageString = messageString.substring(start, end); textArea.setText(messageString); } public void write (String messageString) { textArea.setText(messageString); } }