AttackRecord.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.io.Serializable;
  3. import android.os.Parcel;
  4. import android.os.Parcelable;
  5. /**
  6. * Holds all necessary information about a single attack.
  7. */
  8. public class AttackRecord implements Parcelable, Serializable {
  9. private static final long serialVersionUID = 6111024905373724227L;
  10. private long attack_id;
  11. private String bssid;
  12. private String protocol;
  13. private String localIP;
  14. private int localPort;
  15. private String remoteIP;
  16. private int remotePort;
  17. private String externalIP;
  18. private int wasInternalAttack; // 1 if attacker ip and local ip were in same subnet, else 0
  19. public static final Parcelable.Creator<AttackRecord> CREATOR = new Parcelable.Creator<AttackRecord>() {
  20. @Override
  21. public AttackRecord createFromParcel(Parcel source) {
  22. return new AttackRecord(source);
  23. }
  24. @Override
  25. public AttackRecord[] newArray(int size) {
  26. return new AttackRecord[size];
  27. }
  28. };
  29. public AttackRecord() {
  30. }
  31. public AttackRecord(Parcel source) {
  32. this.attack_id = source.readLong();
  33. this.protocol = source.readString();
  34. this.localIP = source.readString();
  35. this.localPort = source.readInt();
  36. this.remoteIP = source.readString();
  37. this.remotePort = source.readInt();
  38. this.externalIP = source.readString();
  39. this.wasInternalAttack = source.readInt();
  40. this.bssid = source.readString();
  41. }
  42. @Override
  43. public int describeContents() {
  44. return 0;
  45. }
  46. @Override
  47. public void writeToParcel(Parcel dest, int flags) {
  48. dest.writeLong(attack_id);
  49. dest.writeString(protocol);
  50. dest.writeString(localIP);
  51. dest.writeInt(localPort);
  52. dest.writeString(remoteIP);
  53. dest.writeInt(remotePort);
  54. dest.writeString(externalIP);
  55. dest.writeInt(wasInternalAttack);
  56. dest.writeString(bssid);
  57. }
  58. /**
  59. * @return the attack_id
  60. */
  61. public long getAttack_id() {
  62. return attack_id;
  63. }
  64. /**
  65. * @param attack_id
  66. * the attack_id to set
  67. */
  68. public void setAttack_id(long attack_id) {
  69. this.attack_id = attack_id;
  70. }
  71. /**
  72. * @return the bssid
  73. */
  74. public String getBssid() {
  75. return bssid;
  76. }
  77. /**
  78. * @param bssid
  79. * the bssid to set
  80. */
  81. public void setBssid(String bssid) {
  82. this.bssid = bssid;
  83. }
  84. /**
  85. * @return the protocol
  86. */
  87. public String getProtocol() {
  88. return protocol;
  89. }
  90. /**
  91. * @param protocol
  92. * the protocol to set
  93. */
  94. public void setProtocol(String protocol) {
  95. this.protocol = protocol;
  96. }
  97. /**
  98. * @return the localIP
  99. */
  100. public String getLocalIP() {
  101. return localIP;
  102. }
  103. /**
  104. * @param localIP
  105. * the localIP to set
  106. */
  107. public void setLocalIP(String localIP) {
  108. this.localIP = localIP;
  109. }
  110. /**
  111. * @return the localPort
  112. */
  113. public int getLocalPort() {
  114. return localPort;
  115. }
  116. /**
  117. * @param localPort
  118. * the localPort to set
  119. */
  120. public void setLocalPort(int localPort) {
  121. this.localPort = localPort;
  122. }
  123. /**
  124. * @return the remoteIP
  125. */
  126. public String getRemoteIP() {
  127. return remoteIP;
  128. }
  129. /**
  130. * @param remoteIP
  131. * the remoteIP to set
  132. */
  133. public void setRemoteIP(String remoteIP) {
  134. this.remoteIP = remoteIP;
  135. }
  136. /**
  137. * @return the remotePort
  138. */
  139. public int getRemotePort() {
  140. return remotePort;
  141. }
  142. /**
  143. * @param remotePort
  144. * the remotePort to set
  145. */
  146. public void setRemotePort(int remotePort) {
  147. this.remotePort = remotePort;
  148. }
  149. /**
  150. * @return the externalIP
  151. */
  152. public String getExternalIP() {
  153. return externalIP;
  154. }
  155. /**
  156. * @param externalIP
  157. * the externalIP to set
  158. */
  159. public void setExternalIP(String externalIP) {
  160. this.externalIP = externalIP;
  161. }
  162. public boolean getWasInternalAttack() {return wasInternalAttack == 1;}
  163. public void setWasInternalAttack(boolean b) {wasInternalAttack = b ? 1 : 0;}
  164. }