⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpconnection.java

📁 sifi-0.1.6.tar.gz 出自http://www.ifi.unizh.ch/ikm/SINUS/firewall/ 一个linux的防火墙工具。
💻 JAVA
字号:
/* ----------------------------------------------------------------------   The SINUS Firewall -- a TCP/IP packet filter for Linux   Written within the SINUS project at the University of Zurich,   SWITCH, Telekurs Payserv AG, ETH Zurich.   originally based on the sf Firewall Software (C) 1996 by Robert   Muchsel and Roland Schmid.   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., 675 Mass Ave, Cambridge, MA 02139, USA.   SINUS Firewall resources:   SINUS Homepage: http://www.ifi.unizh.ch/ikm/SINUS/   Firewall Homepage: http://www.ifi.unizh.ch/ikm/SINUS/firewall.html   Frequently asked questions: http://www.ifi.unizh.ch/ikm/SINUS/sf_faq.html   Mailing list for comments, questions, bug reports: firewall@ifi.unizh.ch   ----------------------------------------------------------------------  */package sfclasses;import java.util.*;/** * Objects of this class represent TCP connections. They are used * to display the TCP connection list of a firewall. * @version 1.0 24 Jan 1997 * @author Roland E. Schmid */public class TcpConnection {  /**   * This method returns a string to display in the given column of   * the TCP connection list.   * @param col Column   * @return String to display   */  public String getString(int col) {    switch (col) {      case 0: // ID        return Integer.toString(id);      case 1: // State        switch (state) {          case SF_TCP_ACCEPT_SYN:            return "No SYNs yet";          case SF_TCP_CLIENT_SYN:            return "Client-SYN";          case SF_TCP_SYN_ACK:            return "SYN_ACK";          case SF_TCP_ESTABLISHED3:            return "Established";          case SF_TCP_ESTABLISHEDFTP:            return "Establ. FTP";          case SF_TCP_CLIENT_FIN | SF_TCP_SYN_ACK:          case SF_TCP_CLIENT_FIN | SF_TCP_ESTABLISHED3:          case SF_TCP_CLIENT_FIN | SF_TCP_ESTABLISHEDFTP:            return "Client-FIN";          case SF_TCP_SERVER_FIN | SF_TCP_SYN_ACK:          case SF_TCP_SERVER_FIN | SF_TCP_ESTABLISHED3:          case SF_TCP_SERVER_FIN | SF_TCP_ESTABLISHEDFTP:            return "Server-FIN";          case SF_TCP_TERMINATED & ~SF_TCP_SYN_ACK:          case SF_TCP_TERMINATED:          case SF_TCP_TERMINATED | SF_TCP_FTP:            return "Terminated";          default:            return "??? huh ???";        }       case 2: // Created        return Utils.timeString(created);      case 3: // Last use        return Utils.timeString(lastuse);      case 4: // Timeout        if (timeout.after(new Date(0)))          return Utils.timeString(timeout);        else          return "None";      case 5: // Source        return Communicator.resolveIP(fromaddr)+          ":"+(allpsource ? "*" : Communicator.resolvePort(fromport, "tcp", true));      case 6: // Destination        return Communicator.resolveIP(toaddr)+          ":"+Communicator.resolvePort(toport, "tcp", true);      default:        return "";    }  }  /**   * This method returns the color of the ball that is drawn to    * indicate the state of the connection.   * @return RED, YELLOW or GREEN   */  public int stateColor() {    switch (state) {      case SF_TCP_ACCEPT_SYN:        return RED;      case SF_TCP_CLIENT_SYN:      case SF_TCP_SYN_ACK:        return YELLOW;      case SF_TCP_ESTABLISHED3:      case SF_TCP_ESTABLISHEDFTP:        return GREEN;      case SF_TCP_CLIENT_FIN | SF_TCP_SYN_ACK:      case SF_TCP_CLIENT_FIN | SF_TCP_ESTABLISHED3:      case SF_TCP_CLIENT_FIN | SF_TCP_ESTABLISHEDFTP:      case SF_TCP_SERVER_FIN | SF_TCP_SYN_ACK:      case SF_TCP_SERVER_FIN | SF_TCP_ESTABLISHED3:      case SF_TCP_SERVER_FIN | SF_TCP_ESTABLISHEDFTP:        return YELLOW;      case SF_TCP_TERMINATED & ~SF_TCP_SYN_ACK:      case SF_TCP_TERMINATED:      case SF_TCP_TERMINATED | SF_TCP_FTP:        return RED;      default:        return 0;    }   }  public static final int RED = 1;  public static final int YELLOW = 2;  public static final int GREEN = 3;  public int id;  public int key;  public int created_jiffies;  public Date created;  public Date lastuse;  public Date timeout;  public byte fromaddr[];  public int fromport;  public byte toaddr[];  public int toport;  public boolean allpsource;  public int state;  public static final int SF_TCP_ACCEPT_SYN       = 0x00;    /* accept client SYN   */  public static final int SF_TCP_CLIENT_SYN       = 0x01;    /* client has sent SYN */  public static final int SF_TCP_SERVER_SYN       = 0x02;    /* server has sent SYN ACK */  public static final int SF_TCP_SYN_ACK          = 0x03;    /* both of the above */  public static final int SF_TCP_CLIENT_ACK       = 0x04;    /* client ACK of SYN ACK */  public static final int SF_TCP_ESTABLISHED3     = 0x07;    /* connection is up */  public static final int SF_TCP_FTP              = 0x08;    /* is ftp control session */  public static final int SF_TCP_ESTABLISHEDFTP   = 0x0F;    /* ftp control connection is up */  public static final int SF_TCP_CLIENT_FIN       = 0x10;    /* client has sent FIN */  public static final int SF_TCP_SERVER_FIN       = 0x20;    /* server has sent FIN */  public static final int SF_TCP_TERMINATED       = 0x37;    /* both of the above */} // TcpConnection

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -