package de.tudarmstadt.informatik.hostage.logging; import java.io.Serializable; import java.net.InetAddress; public class Record implements Serializable { private static final long serialVersionUID = 1L; public static enum TYPE { SEND, RECEIVE }; private int id; private long attack_id; private String protocol; private TYPE type; private long timestamp; private InetAddress localIP; private int localPort; private InetAddress remoteIP; private int remotePort; private String BSSID; private String SSID; private String packet; /** * @return the id */ public int getID() { return id; } /** * @param id * the id to set */ public void setID(int id) { this.id = id; } /** * @return the attack_id */ public long getAttack_id() { return attack_id; } /** * @param attack_id * the attack_id to set */ public void setAttack_id(long attack_id) { this.attack_id = attack_id; } /** * @return the protocol */ public String getProtocol() { return protocol; } /** * @param string the protocol to set */ public void setProtocol(String string) { this.protocol = string; } public TYPE getType() { return type; } public void setType(TYPE type) { this.type = type; } public long getTimestamp() { return timestamp; } public void setTimestamp(long timestamp) { this.timestamp = timestamp; } public InetAddress getLocalIP() { return localIP; } public void setLocalIP(InetAddress localIP) { this.localIP = localIP; } public int getLocalPort() { return localPort; } public void setLocalPort(int localPort) { this.localPort = localPort; } public InetAddress getRemoteIP() { return remoteIP; } public void setRemoteIP(InetAddress remoteIP) { this.remoteIP = remoteIP; } public int getRemotePort() { return remotePort; } public void setRemotePort(int remotePort) { this.remotePort = remotePort; } /** * @return the bSSID */ public String getBSSID() { return BSSID; } /** * @param bSSID the bSSID to set */ public void setBSSID(String bSSID) { BSSID = bSSID; } /** * @return the sSID */ public String getSSID() { return SSID; } /** * @param sSID the sSID to set */ public void setSSID(String sSID) { SSID = sSID; } public String getPacket() { return packet; } public void setPacket(String packet) { this.packet = packet; } @Override public String toString() { return String.format("%d %s [%d,%s:%d,%s:%d,%s]", attack_id, ((type == TYPE.SEND) ? "SEND" : "RECEIVE"), timestamp, localIP.getHostAddress(), localPort, remoteIP.getHostAddress(), remotePort, packet); } public String toString(int format){ // Choose String Format // Add additional case for your own Format. Also add format Name to /res/values/export_formats/ switch (format){ case 1: return String.format("{ \"src\":{\"IP\": %s, \"Port\": %d} \"dst\": {\"IP\": %s, \"Port\": %d} \"type\": 0 \"name\": \"HOsTaGe\" }", localIP.getHostAddress(), localPort, remoteIP.getHostAddress(), remotePort); case 2: return String.format("%d: %s in %s(%s) from [%s:%d] to [%s:%d]", attack_id, protocol, SSID, BSSID, remoteIP.getHostAddress(), remotePort, localIP.getHostAddress(), localPort); default: return toString(); } } }