Record.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.io.Serializable;
  3. import java.net.InetAddress;
  4. import de.tudarmstadt.informatik.hostage.protocol.Protocol;
  5. public class Record implements Serializable {
  6. private static final long serialVersionUID = 1L;
  7. public static enum TYPE {
  8. SEND, RECEIVE
  9. };
  10. private int id;
  11. private long attack_id;
  12. private String protocol;
  13. private TYPE type;
  14. private long timestamp;
  15. private InetAddress localIP;
  16. private int localPort;
  17. private InetAddress remoteIP;
  18. private int remotePort;
  19. private String BSSID;
  20. private String SSID;
  21. private String packet;
  22. /**
  23. * @return the id
  24. */
  25. public int getID() {
  26. return id;
  27. }
  28. /**
  29. * @param id
  30. * the id to set
  31. */
  32. public void setID(int id) {
  33. this.id = id;
  34. }
  35. /**
  36. * @return the attack_id
  37. */
  38. public long getAttack_id() {
  39. return attack_id;
  40. }
  41. /**
  42. * @param attack_id
  43. * the attack_id to set
  44. */
  45. public void setAttack_id(long attack_id) {
  46. this.attack_id = attack_id;
  47. }
  48. /**
  49. * @return the protocol
  50. */
  51. public String getProtocol() {
  52. return protocol;
  53. }
  54. /**
  55. * @param string the protocol to set
  56. */
  57. public void setProtocol(String string) {
  58. this.protocol = string;
  59. }
  60. public TYPE getType() {
  61. return type;
  62. }
  63. public void setType(TYPE type) {
  64. this.type = type;
  65. }
  66. public long getTimestamp() {
  67. return timestamp;
  68. }
  69. public void setTimestamp(long timestamp) {
  70. this.timestamp = timestamp;
  71. }
  72. public InetAddress getLocalIP() {
  73. return localIP;
  74. }
  75. public void setLocalIP(InetAddress localIP) {
  76. this.localIP = localIP;
  77. }
  78. public int getLocalPort() {
  79. return localPort;
  80. }
  81. public void setLocalPort(int localPort) {
  82. this.localPort = localPort;
  83. }
  84. public InetAddress getRemoteIP() {
  85. return remoteIP;
  86. }
  87. public void setRemoteIP(InetAddress remoteIP) {
  88. this.remoteIP = remoteIP;
  89. }
  90. public int getRemotePort() {
  91. return remotePort;
  92. }
  93. public void setRemotePort(int remotePort) {
  94. this.remotePort = remotePort;
  95. }
  96. /**
  97. * @return the bSSID
  98. */
  99. public String getBSSID() {
  100. return BSSID;
  101. }
  102. /**
  103. * @param bSSID the bSSID to set
  104. */
  105. public void setBSSID(String bSSID) {
  106. BSSID = bSSID;
  107. }
  108. /**
  109. * @return the sSID
  110. */
  111. public String getSSID() {
  112. return SSID;
  113. }
  114. /**
  115. * @param sSID the sSID to set
  116. */
  117. public void setSSID(String sSID) {
  118. SSID = sSID;
  119. }
  120. public String getPacket() {
  121. return packet;
  122. }
  123. public void setPacket(String packet) {
  124. this.packet = packet;
  125. }
  126. @Override
  127. public String toString() {
  128. return String.format("%d %s [%d,%s:%d,%s:%d,%s]", attack_id,
  129. ((type == TYPE.SEND) ? "SEND" : "RECEIVE"), timestamp,
  130. localIP.getHostAddress(), localPort, remoteIP.getHostAddress(),
  131. remotePort, packet);
  132. }
  133. public String toString(int format){
  134. // Choose String Format
  135. // Add additional case for your own Format. Also add format Name to /res/values/export_formats/
  136. switch (format){
  137. case 1:
  138. return String.format("{ \"src\":{\"IP\": %s, \"Port\": %d} \"dst\": {\"IP\": %s, \"Port\": %d} \"type\": 0 \"name\": \"HOsTaGe\" }", localIP.getHostAddress(), localPort, remoteIP.getHostAddress(),
  139. remotePort);
  140. default:
  141. return toString();
  142. }
  143. }
  144. }