Record.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import android.os.Parcel;
  3. import android.os.Parcelable;
  4. import de.tudarmstadt.informatik.hostage.logging.formatter.Formatter;
  5. public class Record implements Parcelable {
  6. public static enum TYPE {
  7. SEND, RECEIVE
  8. };
  9. // attack
  10. private int id;
  11. private long attack_id;
  12. private long timestamp;
  13. private String protocol;
  14. private TYPE type;
  15. private String packet;
  16. // network
  17. private String localIP;
  18. private int localPort;
  19. private String remoteIP;
  20. private int remotePort;
  21. private String externalIP;
  22. private String bssid;
  23. private String ssid;
  24. // location
  25. private long timestampLocation;
  26. private double latitude;
  27. private double longitude;
  28. private float accuracy;
  29. public static final Parcelable.Creator<Record> CREATOR = new Parcelable.Creator<Record>() {
  30. @Override
  31. public Record createFromParcel(Parcel source) {
  32. return new Record(source);
  33. }
  34. @Override
  35. public Record[] newArray(int size) {
  36. return new Record[size];
  37. }
  38. };
  39. public Record() {
  40. }
  41. public Record(Parcel source) {
  42. // attack
  43. this.id = source.readInt();
  44. this.attack_id = source.readLong();
  45. this.timestamp = source.readLong();
  46. this.protocol = source.readString();
  47. this.type = TYPE.valueOf(source.readString());
  48. this.packet = source.readString();
  49. // network
  50. this.localIP = source.readString();
  51. this.localPort = source.readInt();
  52. this.remoteIP = source.readString();
  53. this.remotePort = source.readInt();
  54. this.externalIP = source.readString();
  55. this.bssid = source.readString();
  56. this.ssid = source.readString();
  57. // location
  58. this.timestampLocation = source.readLong();
  59. this.latitude = source.readDouble();
  60. this.longitude = source.readDouble();
  61. this.accuracy = source.readFloat();
  62. }
  63. @Override
  64. public int describeContents() {
  65. return 0;
  66. }
  67. public float getAccuracy() {
  68. return accuracy;
  69. }
  70. public long getAttack_id() {
  71. return attack_id;
  72. }
  73. public String getBssid() {
  74. return bssid;
  75. }
  76. public String getExternalIP() {
  77. return externalIP;
  78. }
  79. public int getId() {
  80. return id;
  81. }
  82. public double getLatitude() {
  83. return latitude;
  84. }
  85. public String getLocalIP() {
  86. return localIP;
  87. }
  88. public int getLocalPort() {
  89. return localPort;
  90. }
  91. public double getLongitude() {
  92. return longitude;
  93. }
  94. public String getPacket() {
  95. return packet;
  96. }
  97. public String getProtocol() {
  98. return protocol;
  99. }
  100. public String getRemoteIP() {
  101. return remoteIP;
  102. }
  103. public int getRemotePort() {
  104. return remotePort;
  105. }
  106. public String getSsid() {
  107. return ssid;
  108. }
  109. public long getTimestamp() {
  110. return timestamp;
  111. }
  112. public long getTimestampLocation() {
  113. return timestampLocation;
  114. }
  115. public TYPE getType() {
  116. return type;
  117. }
  118. public void setAccuracy(float accuracy) {
  119. this.accuracy = accuracy;
  120. }
  121. public void setAttack_id(long attack_id) {
  122. this.attack_id = attack_id;
  123. }
  124. public void setBssid(String bssid) {
  125. this.bssid = bssid;
  126. }
  127. public void setExternalIP(String externalIP) {
  128. this.externalIP = externalIP;
  129. }
  130. public void setId(int id) {
  131. this.id = id;
  132. }
  133. public void setLatitude(double latitude) {
  134. this.latitude = latitude;
  135. }
  136. public void setLocalIP(String localIP) {
  137. this.localIP = localIP;
  138. }
  139. public void setLocalPort(int localPort) {
  140. this.localPort = localPort;
  141. }
  142. public void setLongitude(double longitude) {
  143. this.longitude = longitude;
  144. }
  145. public void setPacket(String packet) {
  146. this.packet = packet;
  147. }
  148. public void setProtocol(String protocol) {
  149. this.protocol = protocol;
  150. }
  151. public void setRemoteIP(String remoteIP) {
  152. this.remoteIP = remoteIP;
  153. }
  154. public void setRemotePort(int remotePort) {
  155. this.remotePort = remotePort;
  156. }
  157. public void setSsid(String ssid) {
  158. this.ssid = ssid;
  159. }
  160. public void setTimestamp(long timestamp) {
  161. this.timestamp = timestamp;
  162. }
  163. public void setTimestampLocation(long timestampLocation) {
  164. this.timestampLocation = timestampLocation;
  165. }
  166. public void setType(TYPE type) {
  167. this.type = type;
  168. }
  169. @Override
  170. public String toString() {
  171. return toString(null);
  172. }
  173. public String toString(Formatter formatter) {
  174. if (null == formatter) {
  175. return Formatter.getDefault().format(this);
  176. }
  177. return formatter.format(this);
  178. }
  179. @Override
  180. public void writeToParcel(Parcel dest, int flags) {
  181. // attack
  182. dest.writeInt(id);
  183. dest.writeLong(attack_id);
  184. dest.writeLong(timestamp);
  185. dest.writeString(protocol);
  186. dest.writeString(type.name());
  187. dest.writeString(packet);
  188. // network
  189. dest.writeString(localIP);
  190. dest.writeInt(localPort);
  191. dest.writeString(remoteIP);
  192. dest.writeInt(remotePort);
  193. dest.writeString(externalIP);
  194. dest.writeString(bssid);
  195. dest.writeString(ssid);
  196. // location
  197. dest.writeLong(timestampLocation);
  198. dest.writeDouble(latitude);
  199. dest.writeDouble(longitude);
  200. dest.writeFloat(accuracy);
  201. }
  202. }