package de.tudarmstadt.informatik.hostage.logging;
import android.os.Parcel;
import android.os.Parcelable;
import de.tudarmstadt.informatik.hostage.logging.formatter.Formatter;
/**
* This class defines the attributes of a record.
* A Record is a single message exchanged between the application and an
* attacker.
* The class has no own functionality except for getter and setter methods. To
* change the logging mechanism you have to to change the logger in
* {@link de.tudarmstadt.informatik.hostage.HoneyService HoneyService} and
* {@link de.tudarmstadt.informatik.hostage.ui.ViewLog ViewLog}
*
* @author Mihai Plasoianu
* @author Lars Pandikow
*/
public class Record implements Parcelable {
public static enum TYPE {
SEND, RECEIVE
};
// attack
private int id;
private long attack_id;
private long timestamp;
private String protocol;
private TYPE type;
private String packet;
// network
private String localIP;
private String localHost;
private int localPort;
private String remoteIP;
private String remoteHost;
private int remotePort;
private String externalIP;
private String bssid;
private String ssid;
// location
private long timestampLocation;
private double latitude;
private double longitude;
private float accuracy;
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
// attack
dest.writeInt(id);
dest.writeLong(attack_id);
dest.writeLong(timestamp);
dest.writeString(protocol);
dest.writeString(type.name());
dest.writeString(packet);
// network
dest.writeString(localIP);
dest.writeString(localHost);
dest.writeInt(localPort);
dest.writeString(remoteIP);
dest.writeString(remoteHost);
dest.writeInt(remotePort);
dest.writeString(externalIP);
dest.writeString(bssid);
dest.writeString(ssid);
// location
dest.writeLong(timestampLocation);
dest.writeDouble(latitude);
dest.writeDouble(longitude);
dest.writeFloat(accuracy);
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
@Override
public Record createFromParcel(Parcel source) {
return new Record(source);
}
@Override
public Record[] newArray(int size) {
return new Record[size];
}
};
public Record() {
}
public Record(Parcel source) {
// attack
this.id = source.readInt();
this.attack_id = source.readLong();
this.timestamp = source.readLong();
this.protocol = source.readString();
this.type = TYPE.valueOf(source.readString());
this.packet = source.readString();
// network
this.localIP = source.readString();
this.localHost = source.readString();
this.localPort = source.readInt();
this.remoteIP = source.readString();
this.remoteHost = source.readString();
this.remotePort = source.readInt();
this.externalIP = source.readString();
this.bssid = source.readString();
this.ssid = source.readString();
// location
this.timestampLocation = source.readLong();
this.latitude = source.readDouble();
this.longitude = source.readDouble();
this.accuracy = source.readFloat();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public long getAttack_id() {
return attack_id;
}
public void setAttack_id(long attack_id) {
this.attack_id = attack_id;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public String getProtocol() {
return protocol;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
public TYPE getType() {
return type;
}
public void setType(TYPE type) {
this.type = type;
}
public String getPacket() {
return packet;
}
public void setPacket(String packet) {
this.packet = packet;
}
public String getLocalIP() {
return localIP;
}
public void setLocalIP(String localIP) {
this.localIP = localIP;
}
public String getLocalHost() {
return localHost;
}
public void setLocalHost(String localHost) {
this.localHost = localHost;
}
public int getLocalPort() {
return localPort;
}
public void setLocalPort(int localPort) {
this.localPort = localPort;
}
public String getRemoteIP() {
return remoteIP;
}
public void setRemoteIP(String remoteIP) {
this.remoteIP = remoteIP;
}
public String getRemoteHost() {
return remoteHost;
}
public void setRemoteHost(String remoteHost) {
this.remoteHost = remoteHost;
}
public int getRemotePort() {
return remotePort;
}
public void setRemotePort(int remotePort) {
this.remotePort = remotePort;
}
public String getExternalIP() {
return externalIP;
}
public void setExternalIP(String externalIP) {
this.externalIP = externalIP;
}
public String getBssid() {
return bssid;
}
public void setBssid(String bssid) {
this.bssid = bssid;
}
public String getSsid() {
return ssid;
}
public void setSsid(String ssid) {
this.ssid = ssid;
}
public long getTimestampLocation() {
return timestampLocation;
}
public void setTimestampLocation(long timestampLocation) {
this.timestampLocation = timestampLocation;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public float getAccuracy() {
return accuracy;
}
public void setAccuracy(float accuracy) {
this.accuracy = accuracy;
}
@Override
public String toString() {
return toString(null);
}
public String toString(Formatter formatter) {
if (null == formatter) {
return Formatter.getDefault().format(this);
}
return formatter.format(this);
}
}