📄 my49bitbip.java
字号:
/*================= * Copyright (C) 2001 Todd Kaplan * * Lisys is a program that monitors TCP SYN packets to detect network * traffic anomalies. * * Licensed under the GNU General Public License (GPL), version 2 or * higher. Please see the COPYING and PATENT files included with the * Lisys distribution, which can be found at: * * http://www.cs.unm.edu/~judd/lisys/ * * Also, the current text of the GPL can be found at: * * http://www.gnu.org/copyleft/gpl.html * * Note that Lisys has NO WARRANTY! *=================*/package edu.unm.cs.lisys.detection.bip;import edu.unm.cs.lisys.debug.*;import edu.unm.cs.lisys.util.*;import java.io.*;import java.util.*;import java.net.*;/**========== * My49BitBIP.java * The basic BIP implementation consists of boiling * * Here are the people who have worked on this code in the order they * have worked on it: * @author Todd Kaplan <kaplan@cs.unm.edu> * @author Justin Balthrop <judd@cs.unm.edu> *==========*/public class My49BitBIP extends BinaryInputPattern implements Serializable{ private static final int NUMBER_OF_BITS = 49; private byte[] localIPMask; private boolean serverFlag; private String tcpDumpString; // Properties read from the constructorString. private String constructorString = new String(); private String timestamp; public My49BitBIP() { } public My49BitBIP(BitSet bits) { super(bits); } /**========== * constructBinaryString: * Creates a random binary string. *==========*/ public BinaryInputPattern constructBinaryString(KnuthRandom random) { BitSet bits = new BitSet(NUMBER_OF_BITS); for (int i = 0; i < NUMBER_OF_BITS; i++) { int value = random.intRange(2); if (value == 1) bits.set(i); } binaryString = bits; return this; } /**========== * constructBinaryString: * Constructs binary string from a string of 0's and 1's. *==========*/ public BinaryInputPattern constructBinaryString(String s) { constructorString = s; packBinaryString(s); return this; } public int getLength() { return NUMBER_OF_BITS; } private void packBinaryString(String s) { binaryString.xor(binaryString); for (int i=0; i<s.length(); i++) { if (s.charAt(i)=='1') { binaryString.set(i); } } } public String toString() { StringBuffer sb = new StringBuffer(); if (tcpDumpString != null) sb.append(tcpDumpString + " "); sb.append("["); for (int i = 0; i < NUMBER_OF_BITS; i++) { if (binaryString.get(i)) sb.append("1"); else sb.append("0"); if (((i+ 1) % 8) == 0) sb.append("."); } sb.append("]"); return sb.toString(); } public String getConstructorString() { return constructorString; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -