Converted IP to hostname map from Map<String,List<String>> to Map<String,Set<String...
authorJanus Varmarken <varmarken@gmail.com>
Fri, 27 Apr 2018 23:56:44 +0000 (16:56 -0700)
committerJanus Varmarken <varmarken@gmail.com>
Fri, 27 Apr 2018 23:56:44 +0000 (16:56 -0700)
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/DnsPacket.java [deleted file]
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/EthernetFrame.java [deleted file]
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/IcmpPacket.java [deleted file]
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Ipv4Packet.java [deleted file]
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Ipv6Packet.java [deleted file]
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/PacketPpi.java [deleted file]
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Pcap.java [deleted file]
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/TcpSegment.java [deleted file]
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/UdpDatagram.java [deleted file]

diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/DnsPacket.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/DnsPacket.java
deleted file mode 100644 (file)
index f15d0d7..0000000
+++ /dev/null
@@ -1,522 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.nio.charset.Charset;
-
-import java.nio.BufferUnderflowException;
-
-
-/**
- * (No support for Auth-Name + Add-Name for simplicity)
- */
-public class DnsPacket extends KaitaiStruct {
-    public static DnsPacket fromFile(String fileName) throws IOException {
-        return new DnsPacket(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public enum ClassType {
-        IN_CLASS(1),
-        CS(2),
-        CH(3),
-        HS(4);
-
-        private final long id;
-        ClassType(long id) { this.id = id; }
-        public long id() { return id; }
-        private static final Map<Long, ClassType> byId = new HashMap<Long, ClassType>(4);
-        static {
-            for (ClassType e : ClassType.values())
-                byId.put(e.id(), e);
-        }
-        public static ClassType byId(long id) { return byId.get(id); }
-    }
-
-    public enum TypeType {
-        A(1),
-        NS(2),
-        MD(3),
-        MF(4),
-        CNAME(5),
-        SOE(6),
-        MB(7),
-        MG(8),
-        MR(9),
-        NULL(10),
-        WKS(11),
-        PTR(12),
-        HINFO(13),
-        MINFO(14),
-        MX(15),
-        TXT(16);
-
-        private final long id;
-        TypeType(long id) { this.id = id; }
-        public long id() { return id; }
-        private static final Map<Long, TypeType> byId = new HashMap<Long, TypeType>(16);
-        static {
-            for (TypeType e : TypeType.values())
-                byId.put(e.id(), e);
-        }
-        public static TypeType byId(long id) { return byId.get(id); }
-    }
-
-    public DnsPacket(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public DnsPacket(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public DnsPacket(KaitaiStream _io, KaitaiStruct _parent, DnsPacket _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.transactionId = this._io.readU2be();
-        this.flags = new PacketFlags(this._io, this, _root);
-        this.qdcount = this._io.readU2be();
-        this.ancount = this._io.readU2be();
-        this.nscount = this._io.readU2be();
-        this.arcount = this._io.readU2be();
-        queries = new ArrayList<Query>((int) (qdcount()));
-        for (int i = 0; i < qdcount(); i++) {
-            this.queries.add(new Query(this._io, this, _root));
-        }
-        answers = new ArrayList<Answer>((int) (ancount()));
-        for (int i = 0; i < ancount(); i++) {
-            this.answers.add(new Answer(this._io, this, _root));
-        }
-    }
-    public static class PointerStruct extends KaitaiStruct {
-        public static PointerStruct fromFile(String fileName) throws IOException {
-            return new PointerStruct(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public PointerStruct(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public PointerStruct(KaitaiStream _io, DnsPacket.Label _parent) {
-            this(_io, _parent, null);
-        }
-
-        public PointerStruct(KaitaiStream _io, DnsPacket.Label _parent, DnsPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.value = this._io.readU1();
-        }
-        private DomainName contents;
-        public DomainName contents() {
-            if (this.contents != null)
-                return this.contents;
-            KaitaiStream io = _root._io();
-            long _pos = io.pos();
-            io.seek(value());
-            this.contents = new DomainName(io, this, _root);
-            io.seek(_pos);
-            return this.contents;
-        }
-        private int value;
-        private DnsPacket _root;
-        private DnsPacket.Label _parent;
-
-        /**
-         * Read one byte, then offset to that position, read one domain-name and return
-         */
-        public int value() { return value; }
-        public DnsPacket _root() { return _root; }
-        public DnsPacket.Label _parent() { return _parent; }
-    }
-    public static class Label extends KaitaiStruct {
-        public static Label fromFile(String fileName) throws IOException {
-            return new Label(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Label(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Label(KaitaiStream _io, DnsPacket.DomainName _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Label(KaitaiStream _io, DnsPacket.DomainName _parent, DnsPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.length = this._io.readU1();
-            if (isPointer()) {
-                this.pointer = new PointerStruct(this._io, this, _root);
-            }
-            // TODO: This part causes BufferUnderflowException
-            if (!(isPointer())) {
-                try {
-                    this.name = new String(this._io.readBytes(length()), Charset.forName("ASCII"));
-                } catch (BufferUnderflowException ex) {
-                    //ex.printStackTrace();
-                    this.name = null;
-                }
-            }
-        }
-        private Boolean isPointer;
-        public Boolean isPointer() {
-            if (this.isPointer != null)
-                return this.isPointer;
-            boolean _tmp = (boolean) (length() == 192);
-            this.isPointer = _tmp;
-            return this.isPointer;
-        }
-        private int length;
-        private PointerStruct pointer;
-        private String name;
-        private DnsPacket _root;
-        private DnsPacket.DomainName _parent;
-
-        /**
-         * RFC1035 4.1.4: If the first two bits are raised it's a pointer-offset to a previously defined name
-         */
-        public int length() { return length; }
-        public PointerStruct pointer() { return pointer; }
-
-        /**
-         * Otherwise its a string the length of the length value
-         */
-        public String name() { return name; }
-        public DnsPacket _root() { return _root; }
-        public DnsPacket.DomainName _parent() { return _parent; }
-    }
-    public static class Query extends KaitaiStruct {
-        public static Query fromFile(String fileName) throws IOException {
-            return new Query(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Query(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Query(KaitaiStream _io, DnsPacket _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Query(KaitaiStream _io, DnsPacket _parent, DnsPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.name = new DomainName(this._io, this, _root);
-            this.type = DnsPacket.TypeType.byId(this._io.readU2be());
-            this.queryClass = DnsPacket.ClassType.byId(this._io.readU2be());
-        }
-        private DomainName name;
-        private TypeType type;
-        private ClassType queryClass;
-        private DnsPacket _root;
-        private DnsPacket _parent;
-        public DomainName name() { return name; }
-        public TypeType type() { return type; }
-        public ClassType queryClass() { return queryClass; }
-        public DnsPacket _root() { return _root; }
-        public DnsPacket _parent() { return _parent; }
-    }
-    public static class DomainName extends KaitaiStruct {
-        public static DomainName fromFile(String fileName) throws IOException {
-            return new DomainName(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public DomainName(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public DomainName(KaitaiStream _io, KaitaiStruct _parent) {
-            this(_io, _parent, null);
-        }
-
-        public DomainName(KaitaiStream _io, KaitaiStruct _parent, DnsPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.name = new ArrayList<Label>();
-            {
-                Label _it;
-                int i = 0;
-                do {
-                    _it = new Label(this._io, this, _root);
-                    this.name.add(_it);
-                    i++;
-                } while (!( ((_it.length() == 0) || (_it.length() == 192)) ));
-            }
-        }
-        private ArrayList<Label> name;
-        private DnsPacket _root;
-        private KaitaiStruct _parent;
-
-        /**
-         * Repeat until the length is 0 or it is a pointer (bit-hack to get around lack of OR operator)
-         */
-        public ArrayList<Label> name() { return name; }
-        public DnsPacket _root() { return _root; }
-        public KaitaiStruct _parent() { return _parent; }
-    }
-    public static class Address extends KaitaiStruct {
-        public static Address fromFile(String fileName) throws IOException {
-            return new Address(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Address(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Address(KaitaiStream _io, DnsPacket.Answer _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Address(KaitaiStream _io, DnsPacket.Answer _parent, DnsPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            ip = new ArrayList<Integer>((int) (4));
-            for (int i = 0; i < 4; i++) {
-                this.ip.add(this._io.readU1());
-            }
-        }
-        private ArrayList<Integer> ip;
-        private DnsPacket _root;
-        private DnsPacket.Answer _parent;
-        public ArrayList<Integer> ip() { return ip; }
-        public DnsPacket _root() { return _root; }
-        public DnsPacket.Answer _parent() { return _parent; }
-    }
-    public static class Answer extends KaitaiStruct {
-        public static Answer fromFile(String fileName) throws IOException {
-            return new Answer(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Answer(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Answer(KaitaiStream _io, DnsPacket _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Answer(KaitaiStream _io, DnsPacket _parent, DnsPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.name = new DomainName(this._io, this, _root);
-            this.type = DnsPacket.TypeType.byId(this._io.readU2be());
-            this.answerClass = DnsPacket.ClassType.byId(this._io.readU2be());
-            this.ttl = this._io.readS4be();
-            this.rdlength = this._io.readU2be();
-            if (type() == DnsPacket.TypeType.PTR) {
-                this.ptrdname = new DomainName(this._io, this, _root);
-            }
-            if (type() == DnsPacket.TypeType.A) {
-                this.address = new Address(this._io, this, _root);
-            }
-        }
-        private DomainName name;
-        private TypeType type;
-        private ClassType answerClass;
-        private int ttl;
-        private int rdlength;
-        private DomainName ptrdname;
-        private Address address;
-        private DnsPacket _root;
-        private DnsPacket _parent;
-        public DomainName name() { return name; }
-        public TypeType type() { return type; }
-        public ClassType answerClass() { return answerClass; }
-
-        /**
-         * Time to live (in seconds)
-         */
-        public int ttl() { return ttl; }
-
-        /**
-         * Length in octets of the following payload
-         */
-        public int rdlength() { return rdlength; }
-        public DomainName ptrdname() { return ptrdname; }
-        public Address address() { return address; }
-        public DnsPacket _root() { return _root; }
-        public DnsPacket _parent() { return _parent; }
-    }
-    public static class PacketFlags extends KaitaiStruct {
-        public static PacketFlags fromFile(String fileName) throws IOException {
-            return new PacketFlags(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public PacketFlags(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public PacketFlags(KaitaiStream _io, DnsPacket _parent) {
-            this(_io, _parent, null);
-        }
-
-        public PacketFlags(KaitaiStream _io, DnsPacket _parent, DnsPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.flag = this._io.readU2be();
-        }
-        private Integer qr;
-        public Integer qr() {
-            if (this.qr != null)
-                return this.qr;
-            int _tmp = (int) (((flag() & 32768) >> 15));
-            this.qr = _tmp;
-            return this.qr;
-        }
-        private Integer ra;
-        public Integer ra() {
-            if (this.ra != null)
-                return this.ra;
-            int _tmp = (int) (((flag() & 128) >> 7));
-            this.ra = _tmp;
-            return this.ra;
-        }
-        private Integer tc;
-        public Integer tc() {
-            if (this.tc != null)
-                return this.tc;
-            int _tmp = (int) (((flag() & 512) >> 9));
-            this.tc = _tmp;
-            return this.tc;
-        }
-        private Integer rcode;
-        public Integer rcode() {
-            if (this.rcode != null)
-                return this.rcode;
-            int _tmp = (int) (((flag() & 15) >> 0));
-            this.rcode = _tmp;
-            return this.rcode;
-        }
-        private Integer opcode;
-        public Integer opcode() {
-            if (this.opcode != null)
-                return this.opcode;
-            int _tmp = (int) (((flag() & 30720) >> 11));
-            this.opcode = _tmp;
-            return this.opcode;
-        }
-        private Integer aa;
-        public Integer aa() {
-            if (this.aa != null)
-                return this.aa;
-            int _tmp = (int) (((flag() & 1024) >> 10));
-            this.aa = _tmp;
-            return this.aa;
-        }
-        private Integer z;
-        public Integer z() {
-            if (this.z != null)
-                return this.z;
-            int _tmp = (int) (((flag() & 64) >> 6));
-            this.z = _tmp;
-            return this.z;
-        }
-        private Integer rd;
-        public Integer rd() {
-            if (this.rd != null)
-                return this.rd;
-            int _tmp = (int) (((flag() & 256) >> 8));
-            this.rd = _tmp;
-            return this.rd;
-        }
-        private Integer cd;
-        public Integer cd() {
-            if (this.cd != null)
-                return this.cd;
-            int _tmp = (int) (((flag() & 16) >> 4));
-            this.cd = _tmp;
-            return this.cd;
-        }
-        private Integer ad;
-        public Integer ad() {
-            if (this.ad != null)
-                return this.ad;
-            int _tmp = (int) (((flag() & 32) >> 5));
-            this.ad = _tmp;
-            return this.ad;
-        }
-        private int flag;
-        private DnsPacket _root;
-        private DnsPacket _parent;
-        public int flag() { return flag; }
-        public DnsPacket _root() { return _root; }
-        public DnsPacket _parent() { return _parent; }
-    }
-    private int transactionId;
-    private PacketFlags flags;
-    private int qdcount;
-    private int ancount;
-    private int nscount;
-    private int arcount;
-    private ArrayList<Query> queries;
-    private ArrayList<Answer> answers;
-    private DnsPacket _root;
-    private KaitaiStruct _parent;
-
-    /**
-     * ID to keep track of request/responces
-     */
-    public int transactionId() { return transactionId; }
-    public PacketFlags flags() { return flags; }
-
-    /**
-     * How many questions are there
-     */
-    public int qdcount() { return qdcount; }
-
-    /**
-     * Number of resource records answering the question
-     */
-    public int ancount() { return ancount; }
-
-    /**
-     * Number of resource records pointing toward an authority
-     */
-    public int nscount() { return nscount; }
-
-    /**
-     * Number of resource records holding additional information
-     */
-    public int arcount() { return arcount; }
-    public ArrayList<Query> queries() { return queries; }
-    public ArrayList<Answer> answers() { return answers; }
-    public DnsPacket _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-}
diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/EthernetFrame.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/EthernetFrame.java
deleted file mode 100644 (file)
index 6e3deec..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-
-public class EthernetFrame extends KaitaiStruct {
-    private static int counter = 0;
-    public static EthernetFrame fromFile(String fileName) throws IOException {
-        return new EthernetFrame(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public enum EtherTypeEnum {
-        IPV4(2048),
-        X_75_INTERNET(2049),
-        NBS_INTERNET(2050),
-        ECMA_INTERNET(2051),
-        CHAOSNET(2052),
-        X_25_LEVEL_3(2053),
-        ARP(2054),
-        IPV6(34525);
-
-        private final long id;
-        EtherTypeEnum(long id) { this.id = id; }
-        public long id() { return id; }
-        private static final Map<Long, EtherTypeEnum> byId = new HashMap<Long, EtherTypeEnum>(8);
-        static {
-            for (EtherTypeEnum e : EtherTypeEnum.values())
-                byId.put(e.id(), e);
-        }
-        public static EtherTypeEnum byId(long id) { return byId.get(id); }
-    }
-
-    public EthernetFrame(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public EthernetFrame(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public EthernetFrame(KaitaiStream _io, KaitaiStruct _parent, EthernetFrame _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.dstMac = this._io.readBytes(6);
-        this.srcMac = this._io.readBytes(6);
-        this.etherType = EtherTypeEnum.byId(this._io.readU2be());
-        // We skip if etherType is NULL
-        // Some packets, e.g. EAPOL and XID do not have etherType
-        //      and we are not interested in these packets
-        if(etherType() != null) {
-            switch (etherType()) {
-                case IPV4: {
-                    this._raw_body = this._io.readBytesFull();
-                    KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-                    this.body = new Ipv4Packet(_io__raw_body);
-                    break;
-                }
-                // TODO: Skip IPV6 for now and perhaps do it later
-                //case IPV6: {
-                //    this._raw_body = this._io.readBytesFull();
-                //    KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-                //    this.body = new Ipv6Packet(_io__raw_body);
-                //    break;
-                //}
-                default: {
-                    this.body = this._io.readBytesFull();
-                    break;
-                }
-            }
-        }
-    }
-    private byte[] dstMac;
-    private byte[] srcMac;
-    private EtherTypeEnum etherType;
-    private Object body;
-    private EthernetFrame _root;
-    private KaitaiStruct _parent;
-    private byte[] _raw_body;
-    public byte[] dstMac() { return dstMac; }
-    public byte[] srcMac() { return srcMac; }
-    public EtherTypeEnum etherType() { return etherType; }
-    public Object body() { return body; }
-    public EthernetFrame _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-    public byte[] _raw_body() { return _raw_body; }
-}
diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/IcmpPacket.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/IcmpPacket.java
deleted file mode 100644 (file)
index 0c9a899..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-
-public class IcmpPacket extends KaitaiStruct {
-    public static IcmpPacket fromFile(String fileName) throws IOException {
-        return new IcmpPacket(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public enum IcmpTypeEnum {
-        ECHO_REPLY(0),
-        DESTINATION_UNREACHABLE(3),
-        SOURCE_QUENCH(4),
-        REDIRECT(5),
-        ECHO(8),
-        TIME_EXCEEDED(11);
-
-        private final long id;
-        IcmpTypeEnum(long id) { this.id = id; }
-        public long id() { return id; }
-        private static final Map<Long, IcmpTypeEnum> byId = new HashMap<Long, IcmpTypeEnum>(6);
-        static {
-            for (IcmpTypeEnum e : IcmpTypeEnum.values())
-                byId.put(e.id(), e);
-        }
-        public static IcmpTypeEnum byId(long id) { return byId.get(id); }
-    }
-
-    public IcmpPacket(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public IcmpPacket(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public IcmpPacket(KaitaiStream _io, KaitaiStruct _parent, IcmpPacket _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.icmpType = IcmpTypeEnum.byId(this._io.readU1());
-        if (icmpType() == IcmpTypeEnum.DESTINATION_UNREACHABLE) {
-            this.destinationUnreachable = new DestinationUnreachableMsg(this._io, this, _root);
-        }
-        if (icmpType() == IcmpTypeEnum.TIME_EXCEEDED) {
-            this.timeExceeded = new TimeExceededMsg(this._io, this, _root);
-        }
-        if ( ((icmpType() == IcmpTypeEnum.ECHO) || (icmpType() == IcmpTypeEnum.ECHO_REPLY)) ) {
-            this.echo = new EchoMsg(this._io, this, _root);
-        }
-    }
-    public static class DestinationUnreachableMsg extends KaitaiStruct {
-        public static DestinationUnreachableMsg fromFile(String fileName) throws IOException {
-            return new DestinationUnreachableMsg(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public enum DestinationUnreachableCode {
-            NET_UNREACHABLE(0),
-            HOST_UNREACHABLE(1),
-            PROTOCOL_UNREACHABLE(2),
-            PORT_UNREACHABLE(3),
-            FRAGMENTATION_NEEDED_AND_DF_SET(4),
-            SOURCE_ROUTE_FAILED(5),
-            DST_NET_UNKOWN(6),
-            SDT_HOST_UNKOWN(7),
-            SRC_ISOLATED(8),
-            NET_PROHIBITED_BY_ADMIN(9),
-            HOST_PROHIBITED_BY_ADMIN(10),
-            NET_UNREACHABLE_FOR_TOS(11),
-            HOST_UNREACHABLE_FOR_TOS(12),
-            COMMUNICATION_PROHIBITED_BY_ADMIN(13),
-            HOST_PRECEDENCE_VIOLATION(14),
-            PRECEDENCE_CUTTOFF_IN_EFFECT(15);
-
-            private final long id;
-            DestinationUnreachableCode(long id) { this.id = id; }
-            public long id() { return id; }
-            private static final Map<Long, DestinationUnreachableCode> byId = new HashMap<Long, DestinationUnreachableCode>(16);
-            static {
-                for (DestinationUnreachableCode e : DestinationUnreachableCode.values())
-                    byId.put(e.id(), e);
-            }
-            public static DestinationUnreachableCode byId(long id) { return byId.get(id); }
-        }
-
-        public DestinationUnreachableMsg(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public DestinationUnreachableMsg(KaitaiStream _io, IcmpPacket _parent) {
-            this(_io, _parent, null);
-        }
-
-        public DestinationUnreachableMsg(KaitaiStream _io, IcmpPacket _parent, IcmpPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.code = DestinationUnreachableCode.byId(this._io.readU1());
-            this.checksum = this._io.readU2be();
-        }
-        private DestinationUnreachableCode code;
-        private int checksum;
-        private IcmpPacket _root;
-        private IcmpPacket _parent;
-        public DestinationUnreachableCode code() { return code; }
-        public int checksum() { return checksum; }
-        public IcmpPacket _root() { return _root; }
-        public IcmpPacket _parent() { return _parent; }
-    }
-    public static class TimeExceededMsg extends KaitaiStruct {
-        public static TimeExceededMsg fromFile(String fileName) throws IOException {
-            return new TimeExceededMsg(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public enum TimeExceededCode {
-            TIME_TO_LIVE_EXCEEDED_IN_TRANSIT(0),
-            FRAGMENT_REASSEMBLY_TIME_EXCEEDED(1);
-
-            private final long id;
-            TimeExceededCode(long id) { this.id = id; }
-            public long id() { return id; }
-            private static final Map<Long, TimeExceededCode> byId = new HashMap<Long, TimeExceededCode>(2);
-            static {
-                for (TimeExceededCode e : TimeExceededCode.values())
-                    byId.put(e.id(), e);
-            }
-            public static TimeExceededCode byId(long id) { return byId.get(id); }
-        }
-
-        public TimeExceededMsg(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public TimeExceededMsg(KaitaiStream _io, IcmpPacket _parent) {
-            this(_io, _parent, null);
-        }
-
-        public TimeExceededMsg(KaitaiStream _io, IcmpPacket _parent, IcmpPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.code = TimeExceededCode.byId(this._io.readU1());
-            this.checksum = this._io.readU2be();
-        }
-        private TimeExceededCode code;
-        private int checksum;
-        private IcmpPacket _root;
-        private IcmpPacket _parent;
-        public TimeExceededCode code() { return code; }
-        public int checksum() { return checksum; }
-        public IcmpPacket _root() { return _root; }
-        public IcmpPacket _parent() { return _parent; }
-    }
-    public static class EchoMsg extends KaitaiStruct {
-        public static EchoMsg fromFile(String fileName) throws IOException {
-            return new EchoMsg(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public EchoMsg(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public EchoMsg(KaitaiStream _io, IcmpPacket _parent) {
-            this(_io, _parent, null);
-        }
-
-        public EchoMsg(KaitaiStream _io, IcmpPacket _parent, IcmpPacket _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.code = this._io.ensureFixedContents(new byte[] { 0 });
-            this.checksum = this._io.readU2be();
-            this.identifier = this._io.readU2be();
-            this.seqNum = this._io.readU2be();
-            this.data = this._io.readBytesFull();
-        }
-        private byte[] code;
-        private int checksum;
-        private int identifier;
-        private int seqNum;
-        private byte[] data;
-        private IcmpPacket _root;
-        private IcmpPacket _parent;
-        public byte[] code() { return code; }
-        public int checksum() { return checksum; }
-        public int identifier() { return identifier; }
-        public int seqNum() { return seqNum; }
-        public byte[] data() { return data; }
-        public IcmpPacket _root() { return _root; }
-        public IcmpPacket _parent() { return _parent; }
-    }
-    private IcmpTypeEnum icmpType;
-    private DestinationUnreachableMsg destinationUnreachable;
-    private TimeExceededMsg timeExceeded;
-    private EchoMsg echo;
-    private IcmpPacket _root;
-    private KaitaiStruct _parent;
-    public IcmpTypeEnum icmpType() { return icmpType; }
-    public DestinationUnreachableMsg destinationUnreachable() { return destinationUnreachable; }
-    public TimeExceededMsg timeExceeded() { return timeExceeded; }
-    public EchoMsg echo() { return echo; }
-    public IcmpPacket _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-}
diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Ipv4Packet.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Ipv4Packet.java
deleted file mode 100644 (file)
index b1ff070..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-
-public class Ipv4Packet extends KaitaiStruct {
-    public static Ipv4Packet fromFile(String fileName) throws IOException {
-        return new Ipv4Packet(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public enum ProtocolEnum {
-        HOPOPT(0),
-        ICMP(1),
-        IGMP(2),
-        GGP(3),
-        IPV4(4),
-        ST(5),
-        TCP(6),
-        CBT(7),
-        EGP(8),
-        IGP(9),
-        BBN_RCC_MON(10),
-        NVP_II(11),
-        PUP(12),
-        ARGUS(13),
-        EMCON(14),
-        XNET(15),
-        CHAOS(16),
-        UDP(17),
-        MUX(18),
-        DCN_MEAS(19),
-        HMP(20),
-        PRM(21),
-        XNS_IDP(22),
-        TRUNK_1(23),
-        TRUNK_2(24),
-        LEAF_1(25),
-        LEAF_2(26),
-        RDP(27),
-        IRTP(28),
-        ISO_TP4(29),
-        NETBLT(30),
-        MFE_NSP(31),
-        MERIT_INP(32),
-        DCCP(33),
-        X_3PC(34),
-        IDPR(35),
-        XTP(36),
-        DDP(37),
-        IDPR_CMTP(38),
-        TP_PLUS_PLUS(39),
-        IL(40),
-        IPV6(41),
-        SDRP(42),
-        IPV6_ROUTE(43),
-        IPV6_FRAG(44),
-        IDRP(45),
-        RSVP(46),
-        GRE(47),
-        DSR(48),
-        BNA(49),
-        ESP(50),
-        AH(51),
-        I_NLSP(52),
-        SWIPE(53),
-        NARP(54),
-        MOBILE(55),
-        TLSP(56),
-        SKIP(57),
-        IPV6_ICMP(58),
-        IPV6_NONXT(59),
-        IPV6_OPTS(60),
-        ANY_HOST_INTERNAL_PROTOCOL(61),
-        CFTP(62),
-        ANY_LOCAL_NETWORK(63),
-        SAT_EXPAK(64),
-        KRYPTOLAN(65),
-        RVD(66),
-        IPPC(67),
-        ANY_DISTRIBUTED_FILE_SYSTEM(68),
-        SAT_MON(69),
-        VISA(70),
-        IPCV(71),
-        CPNX(72),
-        CPHB(73),
-        WSN(74),
-        PVP(75),
-        BR_SAT_MON(76),
-        SUN_ND(77),
-        WB_MON(78),
-        WB_EXPAK(79),
-        ISO_IP(80),
-        VMTP(81),
-        SECURE_VMTP(82),
-        VINES(83),
-        IPTM(84),
-        NSFNET_IGP(85),
-        DGP(86),
-        TCF(87),
-        EIGRP(88),
-        OSPFIGP(89),
-        SPRITE_RPC(90),
-        LARP(91),
-        MTP(92),
-        AX_25(93),
-        IPIP(94),
-        MICP(95),
-        SCC_SP(96),
-        ETHERIP(97),
-        ENCAP(98),
-        ANY_PRIVATE_ENCRYPTION_SCHEME(99),
-        GMTP(100),
-        IFMP(101),
-        PNNI(102),
-        PIM(103),
-        ARIS(104),
-        SCPS(105),
-        QNX(106),
-        A_N(107),
-        IPCOMP(108),
-        SNP(109),
-        COMPAQ_PEER(110),
-        IPX_IN_IP(111),
-        VRRP(112),
-        PGM(113),
-        ANY_0_HOP(114),
-        L2TP(115),
-        DDX(116),
-        IATP(117),
-        STP(118),
-        SRP(119),
-        UTI(120),
-        SMP(121),
-        SM(122),
-        PTP(123),
-        ISIS_OVER_IPV4(124),
-        FIRE(125),
-        CRTP(126),
-        CRUDP(127),
-        SSCOPMCE(128),
-        IPLT(129),
-        SPS(130),
-        PIPE(131),
-        SCTP(132),
-        FC(133),
-        RSVP_E2E_IGNORE(134),
-        MOBILITY_HEADER(135),
-        UDPLITE(136),
-        MPLS_IN_IP(137),
-        MANET(138),
-        HIP(139),
-        SHIM6(140),
-        WESP(141),
-        ROHC(142),
-        RESERVED_255(255);
-
-        private final long id;
-        ProtocolEnum(long id) { this.id = id; }
-        public long id() { return id; }
-        private static final Map<Long, ProtocolEnum> byId = new HashMap<Long, ProtocolEnum>(144);
-        static {
-            for (ProtocolEnum e : ProtocolEnum.values())
-                byId.put(e.id(), e);
-        }
-        public static ProtocolEnum byId(long id) { return byId.get(id); }
-    }
-
-    public Ipv4Packet(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public Ipv4Packet(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public Ipv4Packet(KaitaiStream _io, KaitaiStruct _parent, Ipv4Packet _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.b1 = this._io.readU1();
-        this.b2 = this._io.readU1();
-        this.totalLength = this._io.readU2be();
-        this.identification = this._io.readU2be();
-        this.b67 = this._io.readU2be();
-        this.ttl = this._io.readU1();
-        this.protocol = ProtocolEnum.byId(this._io.readU1());
-        this.headerChecksum = this._io.readU2be();
-        this.srcIpAddr = this._io.readBytes(4);
-        this.dstIpAddr = this._io.readBytes(4);
-        this._raw_options = this._io.readBytes((ihlBytes() - 20));
-        KaitaiStream _io__raw_options = new ByteBufferKaitaiStream(_raw_options);
-        this.options = new Ipv4Options(_io__raw_options, this, _root);
-        switch (protocol()) {
-        case TCP: {
-            this._raw_body = this._io.readBytes((totalLength() - ihlBytes()));
-            KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-            this.body = new TcpSegment(_io__raw_body);
-            break;
-        }
-        case ICMP: {
-            this._raw_body = this._io.readBytes((totalLength() - ihlBytes()));
-            KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-            this.body = new IcmpPacket(_io__raw_body);
-            break;
-        }
-        case UDP: {
-            this._raw_body = this._io.readBytes((totalLength() - ihlBytes()));
-            KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-            this.body = new UdpDatagram(_io__raw_body);
-            break;
-        }
-        case IPV6: {
-            this._raw_body = this._io.readBytes((totalLength() - ihlBytes()));
-            KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-            this.body = new Ipv6Packet(_io__raw_body);
-            break;
-        }
-        default: {
-            this.body = this._io.readBytes((totalLength() - ihlBytes()));
-            break;
-        }
-        }
-    }
-    public static class Ipv4Options extends KaitaiStruct {
-        public static Ipv4Options fromFile(String fileName) throws IOException {
-            return new Ipv4Options(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Ipv4Options(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Ipv4Options(KaitaiStream _io, Ipv4Packet _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Ipv4Options(KaitaiStream _io, Ipv4Packet _parent, Ipv4Packet _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.entries = new ArrayList<Ipv4Option>();
-            {
-                int i = 0;
-                while (!this._io.isEof()) {
-                    this.entries.add(new Ipv4Option(this._io, this, _root));
-                    i++;
-                }
-            }
-        }
-        private ArrayList<Ipv4Option> entries;
-        private Ipv4Packet _root;
-        private Ipv4Packet _parent;
-        public ArrayList<Ipv4Option> entries() { return entries; }
-        public Ipv4Packet _root() { return _root; }
-        public Ipv4Packet _parent() { return _parent; }
-    }
-    public static class Ipv4Option extends KaitaiStruct {
-        public static Ipv4Option fromFile(String fileName) throws IOException {
-            return new Ipv4Option(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Ipv4Option(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Ipv4Option(KaitaiStream _io, Ipv4Packet.Ipv4Options _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Ipv4Option(KaitaiStream _io, Ipv4Packet.Ipv4Options _parent, Ipv4Packet _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.b1 = this._io.readU1();
-            this.len = this._io.readU1();
-            this.body = this._io.readBytes((len() > 2 ? (len() - 2) : 0));
-        }
-        private Integer copy;
-        public Integer copy() {
-            if (this.copy != null)
-                return this.copy;
-            int _tmp = (int) (((b1() & 128) >> 7));
-            this.copy = _tmp;
-            return this.copy;
-        }
-        private Integer optClass;
-        public Integer optClass() {
-            if (this.optClass != null)
-                return this.optClass;
-            int _tmp = (int) (((b1() & 96) >> 5));
-            this.optClass = _tmp;
-            return this.optClass;
-        }
-        private Integer number;
-        public Integer number() {
-            if (this.number != null)
-                return this.number;
-            int _tmp = (int) ((b1() & 31));
-            this.number = _tmp;
-            return this.number;
-        }
-        private int b1;
-        private int len;
-        private byte[] body;
-        private Ipv4Packet _root;
-        private Ipv4Packet.Ipv4Options _parent;
-        public int b1() { return b1; }
-        public int len() { return len; }
-        public byte[] body() { return body; }
-        public Ipv4Packet _root() { return _root; }
-        public Ipv4Packet.Ipv4Options _parent() { return _parent; }
-    }
-    private Integer version;
-    public Integer version() {
-        if (this.version != null)
-            return this.version;
-        int _tmp = (int) (((b1() & 240) >> 4));
-        this.version = _tmp;
-        return this.version;
-    }
-    private Integer ihl;
-    public Integer ihl() {
-        if (this.ihl != null)
-            return this.ihl;
-        int _tmp = (int) ((b1() & 15));
-        this.ihl = _tmp;
-        return this.ihl;
-    }
-    private Integer ihlBytes;
-    public Integer ihlBytes() {
-        if (this.ihlBytes != null)
-            return this.ihlBytes;
-        int _tmp = (int) ((ihl() * 4));
-        this.ihlBytes = _tmp;
-        return this.ihlBytes;
-    }
-    private int b1;
-    private int b2;
-    private int totalLength;
-    private int identification;
-    private int b67;
-    private int ttl;
-    private ProtocolEnum protocol;
-    private int headerChecksum;
-    private byte[] srcIpAddr;
-    private byte[] dstIpAddr;
-    private Ipv4Options options;
-    private Object body;
-    private Ipv4Packet _root;
-    private KaitaiStruct _parent;
-    private byte[] _raw_options;
-    private byte[] _raw_body;
-    public int b1() { return b1; }
-    public int b2() { return b2; }
-    public int totalLength() { return totalLength; }
-    public int identification() { return identification; }
-    public int b67() { return b67; }
-    public int ttl() { return ttl; }
-    public ProtocolEnum protocol() { return protocol; }
-    public int headerChecksum() { return headerChecksum; }
-    public byte[] srcIpAddr() { return srcIpAddr; }
-    public byte[] dstIpAddr() { return dstIpAddr; }
-    public Ipv4Options options() { return options; }
-    public Object body() { return body; }
-    public Ipv4Packet _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-    public byte[] _raw_options() { return _raw_options; }
-    public byte[] _raw_body() { return _raw_body; }
-}
diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Ipv6Packet.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Ipv6Packet.java
deleted file mode 100644 (file)
index c71c7b2..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-
-public class Ipv6Packet extends KaitaiStruct {
-    public static Ipv6Packet fromFile(String fileName) throws IOException {
-        return new Ipv6Packet(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public Ipv6Packet(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public Ipv6Packet(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public Ipv6Packet(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.version = this._io.readBitsInt(4);
-        this.trafficClass = this._io.readBitsInt(8);
-        this.flowLabel = this._io.readBitsInt(20);
-        this._io.alignToByte();
-        this.payloadLength = this._io.readU2be();
-        this.nextHeaderType = this._io.readU1();
-        this.hopLimit = this._io.readU1();
-        this.srcIpv6Addr = this._io.readBytes(16);
-        this.dstIpv6Addr = this._io.readBytes(16);
-        switch (nextHeaderType()) {
-        case 17: {
-            this.nextHeader = new UdpDatagram(this._io);
-            break;
-        }
-        case 0: {
-            this.nextHeader = new OptionHopByHop(this._io, this, _root);
-            break;
-        }
-        case 4: {
-            this.nextHeader = new Ipv4Packet(this._io);
-            break;
-        }
-        case 6: {
-            this.nextHeader = new TcpSegment(this._io);
-            break;
-        }
-        case 59: {
-            this.nextHeader = new NoNextHeader(this._io, this, _root);
-            break;
-        }
-        }
-        this.rest = this._io.readBytesFull();
-    }
-    public static class NoNextHeader extends KaitaiStruct {
-        public static NoNextHeader fromFile(String fileName) throws IOException {
-            return new NoNextHeader(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public NoNextHeader(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public NoNextHeader(KaitaiStream _io, KaitaiStruct _parent) {
-            this(_io, _parent, null);
-        }
-
-        public NoNextHeader(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-        }
-        private Ipv6Packet _root;
-        private KaitaiStruct _parent;
-        public Ipv6Packet _root() { return _root; }
-        public KaitaiStruct _parent() { return _parent; }
-    }
-    public static class OptionHopByHop extends KaitaiStruct {
-        public static OptionHopByHop fromFile(String fileName) throws IOException {
-            return new OptionHopByHop(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public OptionHopByHop(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public OptionHopByHop(KaitaiStream _io, KaitaiStruct _parent) {
-            this(_io, _parent, null);
-        }
-
-        public OptionHopByHop(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.nextHeaderType = this._io.readU1();
-            this.hdrExtLen = this._io.readU1();
-            switch (nextHeaderType()) {
-            case 0: {
-                this.nextHeader = new OptionHopByHop(this._io, this, _root);
-                break;
-            }
-            case 6: {
-                this.nextHeader = new TcpSegment(this._io);
-                break;
-            }
-            case 59: {
-                this.nextHeader = new NoNextHeader(this._io, this, _root);
-                break;
-            }
-            }
-        }
-        private int nextHeaderType;
-        private int hdrExtLen;
-        private byte[] body;
-        private KaitaiStruct nextHeader;
-        private Ipv6Packet _root;
-        private KaitaiStruct _parent;
-        public int nextHeaderType() { return nextHeaderType; }
-        public int hdrExtLen() { return hdrExtLen; }
-        public byte[] body() { return body; }
-        public KaitaiStruct nextHeader() { return nextHeader; }
-        public Ipv6Packet _root() { return _root; }
-        public KaitaiStruct _parent() { return _parent; }
-    }
-    private long version;
-    private long trafficClass;
-    private long flowLabel;
-    private int payloadLength;
-    private int nextHeaderType;
-    private int hopLimit;
-    private byte[] srcIpv6Addr;
-    private byte[] dstIpv6Addr;
-    private KaitaiStruct nextHeader;
-    private byte[] rest;
-    private Ipv6Packet _root;
-    private KaitaiStruct _parent;
-    public long version() { return version; }
-    public long trafficClass() { return trafficClass; }
-    public long flowLabel() { return flowLabel; }
-    public int payloadLength() { return payloadLength; }
-    public int nextHeaderType() { return nextHeaderType; }
-    public int hopLimit() { return hopLimit; }
-    public byte[] srcIpv6Addr() { return srcIpv6Addr; }
-    public byte[] dstIpv6Addr() { return dstIpv6Addr; }
-    public KaitaiStruct nextHeader() { return nextHeader; }
-    public byte[] rest() { return rest; }
-    public Ipv6Packet _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-}
index b8dbeca62a598c36da1871a4db46d07ecff94660..d82e134bc9e351851873a3e2d5f51471b0d68486 100644 (file)
@@ -9,12 +9,8 @@ import org.pcap4j.packet.namednumber.DnsResourceRecordType;
 import java.io.EOFException;
 import java.net.Inet4Address;
 import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.TimeoutException;
-import java.util.function.Consumer;
 
 /**
  * This is a system that reads PCAP files to compare
@@ -32,10 +28,18 @@ public class Main {
     public static void main(String[] args) throws PcapNativeException, NotOpenException, EOFException, TimeoutException, UnknownHostException {
         final String fileName = "/users/varmarken/Desktop/wlan1.local.dns.pcap";
         List<DnsPacket> dnsPackets = extractDnsAnswerPackets(fileName);
-        Map<String, List<String>> ipToHostnameMap = constructIpToHostnameMap(dnsPackets);
+        Map<String, Set<String>> ipToHostnameMap = constructIpToHostnameMap(dnsPackets);
         ipToHostnameMap.forEach((k,v) -> System.out.println(String.format("%s => %s", k, v.toString())));
     }
 
+    /**
+     * Opens a PCAP file and extracts all DNS reply packets with non-empty answer sections.
+     * @param pcapFileName The name of the PCAP file.
+     * @return A list of DNS reply packets.
+     * @throws PcapNativeException
+     * @throws NotOpenException
+     * @throws TimeoutException
+     */
     private static List<DnsPacket> extractDnsAnswerPackets(String pcapFileName) throws PcapNativeException, NotOpenException, TimeoutException {
         PcapHandle handle;
         try {
@@ -64,8 +68,16 @@ public class Main {
         return result;
     }
 
-    private static Map<String, List<String>> constructIpToHostnameMap(List<DnsPacket> dnsPackets) throws UnknownHostException {
-        HashMap<String, List<String>> result = new HashMap<>();
+    /**
+     * Based on the information found in a list of DNS replies, this method constructs a {@link Map} that maps from an
+     * IP to a {@link Set} of hostnames associated with that IP.
+     *
+     * @param dnsPackets A list of DNS <em>reply</em> packets.
+     * @return A {@link Map} that maps from an IP to a {@link Set} of hostnames associated with that IP
+     * @throws UnknownHostException If an IP found in a {@code DnsPacket} is of incorrect length.
+     */
+    private static Map<String, Set<String>> constructIpToHostnameMap(List<DnsPacket> dnsPackets) throws UnknownHostException {
+        HashMap<String, Set<String>> result = new HashMap<>();
         for(DnsPacket dnsPacket : dnsPackets) {
             // The hostname that this DNS reply provides answers for.
             // TODO: safe to assume only one question?
@@ -85,12 +97,12 @@ public class Main {
                 byte[] ipBytes = answer.getRData().getRawData();
                 // Convert to string representation.
                 String ip = Inet4Address.getByAddress(ipBytes).getHostAddress();
-                List<String> hostnameList = new ArrayList<>();
-                hostnameList.add(hostname);
+                HashSet<String> hostnameSet = new HashSet<>();
+                hostnameSet.add(hostname);
                 // Update or insert depending on presence of key:
-                // Concat the existing list and the new list if ip already present as key,
-                // otherwise add an entry for ip pointing to new list.
-                result.merge(ip, hostnameList, (v1, v2) -> { v1.addAll(v2); return v1; });
+                // Concat the existing set and the new set if ip already present as key,
+                // otherwise add an entry for ip pointing to new set.
+                result.merge(ip, hostnameSet, (v1, v2) -> { v1.addAll(v2); return v1; });
             }
         }
         return result;
diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/PacketPpi.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/PacketPpi.java
deleted file mode 100644 (file)
index 9704da5..0000000
+++ /dev/null
@@ -1,777 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-
-
-/**
- * PPI is a standard for link layer packet encapsulation, proposed as
- * generic extensible container to store both captured in-band data and
- * out-of-band data. Originally it was developed to provide 802.11n
- * radio information, but can be used for other purposes as well.
- * 
- * Sample capture: https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=Http.cap  
- * @see <a href="https://www.cacetech.com/documents/PPI_Header_format_1.0.1.pdf">PPI header format spec, section 3</a>
- */
-public class PacketPpi extends KaitaiStruct {
-    public static PacketPpi fromFile(String fileName) throws IOException {
-        return new PacketPpi(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public enum PfhType {
-        RADIO_802_11_COMMON(2),
-        RADIO_802_11N_MAC_EXT(3),
-        RADIO_802_11N_MAC_PHY_EXT(4),
-        SPECTRUM_MAP(5),
-        PROCESS_INFO(6),
-        CAPTURE_INFO(7);
-
-        private final long id;
-        PfhType(long id) { this.id = id; }
-        public long id() { return id; }
-        private static final Map<Long, PfhType> byId = new HashMap<Long, PfhType>(6);
-        static {
-            for (PfhType e : PfhType.values())
-                byId.put(e.id(), e);
-        }
-        public static PfhType byId(long id) { return byId.get(id); }
-    }
-
-    public enum Linktype {
-        NULL_LINKTYPE(0),
-        ETHERNET(1),
-        AX25(3),
-        IEEE802_5(6),
-        ARCNET_BSD(7),
-        SLIP(8),
-        PPP(9),
-        FDDI(10),
-        PPP_HDLC(50),
-        PPP_ETHER(51),
-        ATM_RFC1483(100),
-        RAW(101),
-        C_HDLC(104),
-        IEEE802_11(105),
-        FRELAY(107),
-        LOOP(108),
-        LINUX_SLL(113),
-        LTALK(114),
-        PFLOG(117),
-        IEEE802_11_PRISM(119),
-        IP_OVER_FC(122),
-        SUNATM(123),
-        IEEE802_11_RADIOTAP(127),
-        ARCNET_LINUX(129),
-        APPLE_IP_OVER_IEEE1394(138),
-        MTP2_WITH_PHDR(139),
-        MTP2(140),
-        MTP3(141),
-        SCCP(142),
-        DOCSIS(143),
-        LINUX_IRDA(144),
-        USER0(147),
-        USER1(148),
-        USER2(149),
-        USER3(150),
-        USER4(151),
-        USER5(152),
-        USER6(153),
-        USER7(154),
-        USER8(155),
-        USER9(156),
-        USER10(157),
-        USER11(158),
-        USER12(159),
-        USER13(160),
-        USER14(161),
-        USER15(162),
-        IEEE802_11_AVS(163),
-        BACNET_MS_TP(165),
-        PPP_PPPD(166),
-        GPRS_LLC(169),
-        GPF_T(170),
-        GPF_F(171),
-        LINUX_LAPD(177),
-        BLUETOOTH_HCI_H4(187),
-        USB_LINUX(189),
-        PPI(192),
-        IEEE802_15_4(195),
-        SITA(196),
-        ERF(197),
-        BLUETOOTH_HCI_H4_WITH_PHDR(201),
-        AX25_KISS(202),
-        LAPD(203),
-        PPP_WITH_DIR(204),
-        C_HDLC_WITH_DIR(205),
-        FRELAY_WITH_DIR(206),
-        IPMB_LINUX(209),
-        IEEE802_15_4_NONASK_PHY(215),
-        USB_LINUX_MMAPPED(220),
-        FC_2(224),
-        FC_2_WITH_FRAME_DELIMS(225),
-        IPNET(226),
-        CAN_SOCKETCAN(227),
-        IPV4(228),
-        IPV6(229),
-        IEEE802_15_4_NOFCS(230),
-        DBUS(231),
-        DVB_CI(235),
-        MUX27010(236),
-        STANAG_5066_D_PDU(237),
-        NFLOG(239),
-        NETANALYZER(240),
-        NETANALYZER_TRANSPARENT(241),
-        IPOIB(242),
-        MPEG_2_TS(243),
-        NG40(244),
-        NFC_LLCP(245),
-        INFINIBAND(247),
-        SCTP(248),
-        USBPCAP(249),
-        RTAC_SERIAL(250),
-        BLUETOOTH_LE_LL(251),
-        NETLINK(253),
-        BLUETOOTH_LINUX_MONITOR(254),
-        BLUETOOTH_BREDR_BB(255),
-        BLUETOOTH_LE_LL_WITH_PHDR(256),
-        PROFIBUS_DL(257),
-        PKTAP(258),
-        EPON(259),
-        IPMI_HPM_2(260),
-        ZWAVE_R1_R2(261),
-        ZWAVE_R3(262),
-        WATTSTOPPER_DLM(263),
-        ISO_14443(264);
-
-        private final long id;
-        Linktype(long id) { this.id = id; }
-        public long id() { return id; }
-        private static final Map<Long, Linktype> byId = new HashMap<Long, Linktype>(104);
-        static {
-            for (Linktype e : Linktype.values())
-                byId.put(e.id(), e);
-        }
-        public static Linktype byId(long id) { return byId.get(id); }
-    }
-
-    public PacketPpi(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public PacketPpi(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public PacketPpi(KaitaiStream _io, KaitaiStruct _parent, PacketPpi _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.header = new PacketPpiHeader(this._io, this, _root);
-        this._raw_fields = this._io.readBytes((header().pphLen() - 8));
-        KaitaiStream _io__raw_fields = new ByteBufferKaitaiStream(_raw_fields);
-        this.fields = new PacketPpiFields(_io__raw_fields, this, _root);
-        switch (header().pphDlt()) {
-        case PPI: {
-            this._raw_body = this._io.readBytesFull();
-            KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-            this.body = new PacketPpi(_io__raw_body);
-            break;
-        }
-        case ETHERNET: {
-            this._raw_body = this._io.readBytesFull();
-            KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-            this.body = new EthernetFrame(_io__raw_body);
-            break;
-        }
-        default: {
-            this.body = this._io.readBytesFull();
-            break;
-        }
-        }
-    }
-    public static class PacketPpiFields extends KaitaiStruct {
-        public static PacketPpiFields fromFile(String fileName) throws IOException {
-            return new PacketPpiFields(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public PacketPpiFields(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public PacketPpiFields(KaitaiStream _io, PacketPpi _parent) {
-            this(_io, _parent, null);
-        }
-
-        public PacketPpiFields(KaitaiStream _io, PacketPpi _parent, PacketPpi _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.entries = new ArrayList<PacketPpiField>();
-            {
-                int i = 0;
-                while (!this._io.isEof()) {
-                    this.entries.add(new PacketPpiField(this._io, this, _root));
-                    i++;
-                }
-            }
-        }
-        private ArrayList<PacketPpiField> entries;
-        private PacketPpi _root;
-        private PacketPpi _parent;
-        public ArrayList<PacketPpiField> entries() { return entries; }
-        public PacketPpi _root() { return _root; }
-        public PacketPpi _parent() { return _parent; }
-    }
-
-    /**
-     * @see <a href="https://www.cacetech.com/documents/PPI_Header_format_1.0.1.pdf">PPI header format spec, section 4.1.3</a>
-     */
-    public static class Radio80211nMacExtBody extends KaitaiStruct {
-        public static Radio80211nMacExtBody fromFile(String fileName) throws IOException {
-            return new Radio80211nMacExtBody(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Radio80211nMacExtBody(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Radio80211nMacExtBody(KaitaiStream _io, PacketPpi.PacketPpiField _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Radio80211nMacExtBody(KaitaiStream _io, PacketPpi.PacketPpiField _parent, PacketPpi _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.flags = new MacFlags(this._io, this, _root);
-            this.aMpduId = this._io.readU4le();
-            this.numDelimiters = this._io.readU1();
-            this.reserved = this._io.readBytes(3);
-        }
-        private MacFlags flags;
-        private long aMpduId;
-        private int numDelimiters;
-        private byte[] reserved;
-        private PacketPpi _root;
-        private PacketPpi.PacketPpiField _parent;
-        public MacFlags flags() { return flags; }
-        public long aMpduId() { return aMpduId; }
-        public int numDelimiters() { return numDelimiters; }
-        public byte[] reserved() { return reserved; }
-        public PacketPpi _root() { return _root; }
-        public PacketPpi.PacketPpiField _parent() { return _parent; }
-    }
-    public static class MacFlags extends KaitaiStruct {
-        public static MacFlags fromFile(String fileName) throws IOException {
-            return new MacFlags(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public MacFlags(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public MacFlags(KaitaiStream _io, KaitaiStruct _parent) {
-            this(_io, _parent, null);
-        }
-
-        public MacFlags(KaitaiStream _io, KaitaiStruct _parent, PacketPpi _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.unused1 = this._io.readBitsInt(1) != 0;
-            this.aggregateDelimiter = this._io.readBitsInt(1) != 0;
-            this.moreAggregates = this._io.readBitsInt(1) != 0;
-            this.aggregate = this._io.readBitsInt(1) != 0;
-            this.dupRx = this._io.readBitsInt(1) != 0;
-            this.rxShortGuard = this._io.readBitsInt(1) != 0;
-            this.isHt40 = this._io.readBitsInt(1) != 0;
-            this.greenfield = this._io.readBitsInt(1) != 0;
-            this._io.alignToByte();
-            this.unused2 = this._io.readBytes(3);
-        }
-        private boolean unused1;
-        private boolean aggregateDelimiter;
-        private boolean moreAggregates;
-        private boolean aggregate;
-        private boolean dupRx;
-        private boolean rxShortGuard;
-        private boolean isHt40;
-        private boolean greenfield;
-        private byte[] unused2;
-        private PacketPpi _root;
-        private KaitaiStruct _parent;
-        public boolean unused1() { return unused1; }
-
-        /**
-         * Aggregate delimiter CRC error after this frame
-         */
-        public boolean aggregateDelimiter() { return aggregateDelimiter; }
-
-        /**
-         * More aggregates
-         */
-        public boolean moreAggregates() { return moreAggregates; }
-
-        /**
-         * Aggregate
-         */
-        public boolean aggregate() { return aggregate; }
-
-        /**
-         * Duplicate RX
-         */
-        public boolean dupRx() { return dupRx; }
-
-        /**
-         * RX short guard interval (SGI)
-         */
-        public boolean rxShortGuard() { return rxShortGuard; }
-
-        /**
-         * true = HT40, false = HT20
-         */
-        public boolean isHt40() { return isHt40; }
-
-        /**
-         * Greenfield
-         */
-        public boolean greenfield() { return greenfield; }
-        public byte[] unused2() { return unused2; }
-        public PacketPpi _root() { return _root; }
-        public KaitaiStruct _parent() { return _parent; }
-    }
-
-    /**
-     * @see <a href="https://www.cacetech.com/documents/PPI_Header_format_1.0.1.pdf">PPI header format spec, section 3.1</a>
-     */
-    public static class PacketPpiHeader extends KaitaiStruct {
-        public static PacketPpiHeader fromFile(String fileName) throws IOException {
-            return new PacketPpiHeader(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public PacketPpiHeader(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public PacketPpiHeader(KaitaiStream _io, PacketPpi _parent) {
-            this(_io, _parent, null);
-        }
-
-        public PacketPpiHeader(KaitaiStream _io, PacketPpi _parent, PacketPpi _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.pphVersion = this._io.readU1();
-            this.pphFlags = this._io.readU1();
-            this.pphLen = this._io.readU2le();
-            this.pphDlt = PacketPpi.Linktype.byId(this._io.readU4le());
-        }
-        private int pphVersion;
-        private int pphFlags;
-        private int pphLen;
-        private Linktype pphDlt;
-        private PacketPpi _root;
-        private PacketPpi _parent;
-        public int pphVersion() { return pphVersion; }
-        public int pphFlags() { return pphFlags; }
-        public int pphLen() { return pphLen; }
-        public Linktype pphDlt() { return pphDlt; }
-        public PacketPpi _root() { return _root; }
-        public PacketPpi _parent() { return _parent; }
-    }
-
-    /**
-     * @see <a href="https://www.cacetech.com/documents/PPI_Header_format_1.0.1.pdf">PPI header format spec, section 4.1.2</a>
-     */
-    public static class Radio80211CommonBody extends KaitaiStruct {
-        public static Radio80211CommonBody fromFile(String fileName) throws IOException {
-            return new Radio80211CommonBody(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Radio80211CommonBody(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Radio80211CommonBody(KaitaiStream _io, PacketPpi.PacketPpiField _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Radio80211CommonBody(KaitaiStream _io, PacketPpi.PacketPpiField _parent, PacketPpi _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.tsfTimer = this._io.readU8le();
-            this.flags = this._io.readU2le();
-            this.rate = this._io.readU2le();
-            this.channelFreq = this._io.readU2le();
-            this.channelFlags = this._io.readU2le();
-            this.fhssHopset = this._io.readU1();
-            this.fhssPattern = this._io.readU1();
-            this.dbmAntsignal = this._io.readS1();
-            this.dbmAntnoise = this._io.readS1();
-        }
-        private long tsfTimer;
-        private int flags;
-        private int rate;
-        private int channelFreq;
-        private int channelFlags;
-        private int fhssHopset;
-        private int fhssPattern;
-        private byte dbmAntsignal;
-        private byte dbmAntnoise;
-        private PacketPpi _root;
-        private PacketPpi.PacketPpiField _parent;
-        public long tsfTimer() { return tsfTimer; }
-        public int flags() { return flags; }
-        public int rate() { return rate; }
-        public int channelFreq() { return channelFreq; }
-        public int channelFlags() { return channelFlags; }
-        public int fhssHopset() { return fhssHopset; }
-        public int fhssPattern() { return fhssPattern; }
-        public byte dbmAntsignal() { return dbmAntsignal; }
-        public byte dbmAntnoise() { return dbmAntnoise; }
-        public PacketPpi _root() { return _root; }
-        public PacketPpi.PacketPpiField _parent() { return _parent; }
-    }
-
-    /**
-     * @see <a href="https://www.cacetech.com/documents/PPI_Header_format_1.0.1.pdf">PPI header format spec, section 3.1</a>
-     */
-    public static class PacketPpiField extends KaitaiStruct {
-        public static PacketPpiField fromFile(String fileName) throws IOException {
-            return new PacketPpiField(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public PacketPpiField(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public PacketPpiField(KaitaiStream _io, PacketPpi.PacketPpiFields _parent) {
-            this(_io, _parent, null);
-        }
-
-        public PacketPpiField(KaitaiStream _io, PacketPpi.PacketPpiFields _parent, PacketPpi _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.pfhType = PacketPpi.PfhType.byId(this._io.readU2le());
-            this.pfhDatalen = this._io.readU2le();
-            switch (pfhType()) {
-            case RADIO_802_11_COMMON: {
-                this._raw_body = this._io.readBytes(pfhDatalen());
-                KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-                this.body = new Radio80211CommonBody(_io__raw_body, this, _root);
-                break;
-            }
-            case RADIO_802_11N_MAC_EXT: {
-                this._raw_body = this._io.readBytes(pfhDatalen());
-                KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-                this.body = new Radio80211nMacExtBody(_io__raw_body, this, _root);
-                break;
-            }
-            case RADIO_802_11N_MAC_PHY_EXT: {
-                this._raw_body = this._io.readBytes(pfhDatalen());
-                KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-                this.body = new Radio80211nMacPhyExtBody(_io__raw_body, this, _root);
-                break;
-            }
-            default: {
-                this.body = this._io.readBytes(pfhDatalen());
-                break;
-            }
-            }
-        }
-        private PfhType pfhType;
-        private int pfhDatalen;
-        private Object body;
-        private PacketPpi _root;
-        private PacketPpi.PacketPpiFields _parent;
-        private byte[] _raw_body;
-        public PfhType pfhType() { return pfhType; }
-        public int pfhDatalen() { return pfhDatalen; }
-        public Object body() { return body; }
-        public PacketPpi _root() { return _root; }
-        public PacketPpi.PacketPpiFields _parent() { return _parent; }
-        public byte[] _raw_body() { return _raw_body; }
-    }
-
-    /**
-     * @see <a href="https://www.cacetech.com/documents/PPI_Header_format_1.0.1.pdf">PPI header format spec, section 4.1.4</a>
-     */
-    public static class Radio80211nMacPhyExtBody extends KaitaiStruct {
-        public static Radio80211nMacPhyExtBody fromFile(String fileName) throws IOException {
-            return new Radio80211nMacPhyExtBody(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Radio80211nMacPhyExtBody(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Radio80211nMacPhyExtBody(KaitaiStream _io, PacketPpi.PacketPpiField _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Radio80211nMacPhyExtBody(KaitaiStream _io, PacketPpi.PacketPpiField _parent, PacketPpi _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.flags = new MacFlags(this._io, this, _root);
-            this.aMpduId = this._io.readU4le();
-            this.numDelimiters = this._io.readU1();
-            this.mcs = this._io.readU1();
-            this.numStreams = this._io.readU1();
-            this.rssiCombined = this._io.readU1();
-            rssiAntCtl = new ArrayList<Integer>((int) (4));
-            for (int i = 0; i < 4; i++) {
-                this.rssiAntCtl.add(this._io.readU1());
-            }
-            rssiAntExt = new ArrayList<Integer>((int) (4));
-            for (int i = 0; i < 4; i++) {
-                this.rssiAntExt.add(this._io.readU1());
-            }
-            this.extChannelFreq = this._io.readU2le();
-            this.extChannelFlags = new ChannelFlags(this._io, this, _root);
-            rfSignalNoise = new ArrayList<SignalNoise>((int) (4));
-            for (int i = 0; i < 4; i++) {
-                this.rfSignalNoise.add(new SignalNoise(this._io, this, _root));
-            }
-            evm = new ArrayList<Long>((int) (4));
-            for (int i = 0; i < 4; i++) {
-                this.evm.add(this._io.readU4le());
-            }
-        }
-        public static class ChannelFlags extends KaitaiStruct {
-            public static ChannelFlags fromFile(String fileName) throws IOException {
-                return new ChannelFlags(new ByteBufferKaitaiStream(fileName));
-            }
-
-            public ChannelFlags(KaitaiStream _io) {
-                this(_io, null, null);
-            }
-
-            public ChannelFlags(KaitaiStream _io, PacketPpi.Radio80211nMacPhyExtBody _parent) {
-                this(_io, _parent, null);
-            }
-
-            public ChannelFlags(KaitaiStream _io, PacketPpi.Radio80211nMacPhyExtBody _parent, PacketPpi _root) {
-                super(_io);
-                this._parent = _parent;
-                this._root = _root;
-                _read();
-            }
-            private void _read() {
-                this.spectrum2ghz = this._io.readBitsInt(1) != 0;
-                this.ofdm = this._io.readBitsInt(1) != 0;
-                this.cck = this._io.readBitsInt(1) != 0;
-                this.turbo = this._io.readBitsInt(1) != 0;
-                this.unused = this._io.readBitsInt(8);
-                this.gfsk = this._io.readBitsInt(1) != 0;
-                this.dynCckOfdm = this._io.readBitsInt(1) != 0;
-                this.onlyPassiveScan = this._io.readBitsInt(1) != 0;
-                this.spectrum5ghz = this._io.readBitsInt(1) != 0;
-            }
-            private boolean spectrum2ghz;
-            private boolean ofdm;
-            private boolean cck;
-            private boolean turbo;
-            private long unused;
-            private boolean gfsk;
-            private boolean dynCckOfdm;
-            private boolean onlyPassiveScan;
-            private boolean spectrum5ghz;
-            private PacketPpi _root;
-            private PacketPpi.Radio80211nMacPhyExtBody _parent;
-
-            /**
-             * 2 GHz spectrum
-             */
-            public boolean spectrum2ghz() { return spectrum2ghz; }
-
-            /**
-             * OFDM (Orthogonal Frequency-Division Multiplexing)
-             */
-            public boolean ofdm() { return ofdm; }
-
-            /**
-             * CCK (Complementary Code Keying)
-             */
-            public boolean cck() { return cck; }
-            public boolean turbo() { return turbo; }
-            public long unused() { return unused; }
-
-            /**
-             * Gaussian Frequency Shift Keying
-             */
-            public boolean gfsk() { return gfsk; }
-
-            /**
-             * Dynamic CCK-OFDM
-             */
-            public boolean dynCckOfdm() { return dynCckOfdm; }
-
-            /**
-             * Only passive scan allowed
-             */
-            public boolean onlyPassiveScan() { return onlyPassiveScan; }
-
-            /**
-             * 5 GHz spectrum
-             */
-            public boolean spectrum5ghz() { return spectrum5ghz; }
-            public PacketPpi _root() { return _root; }
-            public PacketPpi.Radio80211nMacPhyExtBody _parent() { return _parent; }
-        }
-
-        /**
-         * RF signal + noise pair at a single antenna
-         */
-        public static class SignalNoise extends KaitaiStruct {
-            public static SignalNoise fromFile(String fileName) throws IOException {
-                return new SignalNoise(new ByteBufferKaitaiStream(fileName));
-            }
-
-            public SignalNoise(KaitaiStream _io) {
-                this(_io, null, null);
-            }
-
-            public SignalNoise(KaitaiStream _io, PacketPpi.Radio80211nMacPhyExtBody _parent) {
-                this(_io, _parent, null);
-            }
-
-            public SignalNoise(KaitaiStream _io, PacketPpi.Radio80211nMacPhyExtBody _parent, PacketPpi _root) {
-                super(_io);
-                this._parent = _parent;
-                this._root = _root;
-                _read();
-            }
-            private void _read() {
-                this.signal = this._io.readS1();
-                this.noise = this._io.readS1();
-            }
-            private byte signal;
-            private byte noise;
-            private PacketPpi _root;
-            private PacketPpi.Radio80211nMacPhyExtBody _parent;
-
-            /**
-             * RF signal, dBm
-             */
-            public byte signal() { return signal; }
-
-            /**
-             * RF noise, dBm
-             */
-            public byte noise() { return noise; }
-            public PacketPpi _root() { return _root; }
-            public PacketPpi.Radio80211nMacPhyExtBody _parent() { return _parent; }
-        }
-        private MacFlags flags;
-        private long aMpduId;
-        private int numDelimiters;
-        private int mcs;
-        private int numStreams;
-        private int rssiCombined;
-        private ArrayList<Integer> rssiAntCtl;
-        private ArrayList<Integer> rssiAntExt;
-        private int extChannelFreq;
-        private ChannelFlags extChannelFlags;
-        private ArrayList<SignalNoise> rfSignalNoise;
-        private ArrayList<Long> evm;
-        private PacketPpi _root;
-        private PacketPpi.PacketPpiField _parent;
-        public MacFlags flags() { return flags; }
-        public long aMpduId() { return aMpduId; }
-        public int numDelimiters() { return numDelimiters; }
-
-        /**
-         * Modulation Coding Scheme (MCS)
-         */
-        public int mcs() { return mcs; }
-
-        /**
-         * Number of spatial streams (0 = unknown)
-         */
-        public int numStreams() { return numStreams; }
-
-        /**
-         * RSSI (Received Signal Strength Indication), combined from all active antennas / channels
-         */
-        public int rssiCombined() { return rssiCombined; }
-
-        /**
-         * RSSI (Received Signal Strength Indication) for antennas 0-3, control channel
-         */
-        public ArrayList<Integer> rssiAntCtl() { return rssiAntCtl; }
-
-        /**
-         * RSSI (Received Signal Strength Indication) for antennas 0-3, extension channel
-         */
-        public ArrayList<Integer> rssiAntExt() { return rssiAntExt; }
-
-        /**
-         * Extension channel frequency (MHz)
-         */
-        public int extChannelFreq() { return extChannelFreq; }
-
-        /**
-         * Extension channel flags
-         */
-        public ChannelFlags extChannelFlags() { return extChannelFlags; }
-
-        /**
-         * Signal + noise values for antennas 0-3
-         */
-        public ArrayList<SignalNoise> rfSignalNoise() { return rfSignalNoise; }
-
-        /**
-         * EVM (Error Vector Magnitude) for chains 0-3
-         */
-        public ArrayList<Long> evm() { return evm; }
-        public PacketPpi _root() { return _root; }
-        public PacketPpi.PacketPpiField _parent() { return _parent; }
-    }
-    private PacketPpiHeader header;
-    private PacketPpiFields fields;
-    private Object body;
-    private PacketPpi _root;
-    private KaitaiStruct _parent;
-    private byte[] _raw_fields;
-    private byte[] _raw_body;
-    public PacketPpiHeader header() { return header; }
-    public PacketPpiFields fields() { return fields; }
-    public Object body() { return body; }
-    public PacketPpi _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-    public byte[] _raw_fields() { return _raw_fields; }
-    public byte[] _raw_body() { return _raw_body; }
-}
diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Pcap.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Pcap.java
deleted file mode 100644 (file)
index c052090..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-
-
-/**
- * @see <a href="http://wiki.wireshark.org/Development/LibpcapFileFormat">Source</a>
- */
-public class Pcap extends KaitaiStruct {
-    public static Pcap fromFile(String fileName) throws IOException {
-        return new Pcap(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public enum Linktype {
-        NULL_LINKTYPE(0),
-        ETHERNET(1),
-        AX25(3),
-        IEEE802_5(6),
-        ARCNET_BSD(7),
-        SLIP(8),
-        PPP(9),
-        FDDI(10),
-        PPP_HDLC(50),
-        PPP_ETHER(51),
-        ATM_RFC1483(100),
-        RAW(101),
-        C_HDLC(104),
-        IEEE802_11(105),
-        FRELAY(107),
-        LOOP(108),
-        LINUX_SLL(113),
-        LTALK(114),
-        PFLOG(117),
-        IEEE802_11_PRISM(119),
-        IP_OVER_FC(122),
-        SUNATM(123),
-        IEEE802_11_RADIOTAP(127),
-        ARCNET_LINUX(129),
-        APPLE_IP_OVER_IEEE1394(138),
-        MTP2_WITH_PHDR(139),
-        MTP2(140),
-        MTP3(141),
-        SCCP(142),
-        DOCSIS(143),
-        LINUX_IRDA(144),
-        USER0(147),
-        USER1(148),
-        USER2(149),
-        USER3(150),
-        USER4(151),
-        USER5(152),
-        USER6(153),
-        USER7(154),
-        USER8(155),
-        USER9(156),
-        USER10(157),
-        USER11(158),
-        USER12(159),
-        USER13(160),
-        USER14(161),
-        USER15(162),
-        IEEE802_11_AVS(163),
-        BACNET_MS_TP(165),
-        PPP_PPPD(166),
-        GPRS_LLC(169),
-        GPF_T(170),
-        GPF_F(171),
-        LINUX_LAPD(177),
-        BLUETOOTH_HCI_H4(187),
-        USB_LINUX(189),
-        PPI(192),
-        IEEE802_15_4(195),
-        SITA(196),
-        ERF(197),
-        BLUETOOTH_HCI_H4_WITH_PHDR(201),
-        AX25_KISS(202),
-        LAPD(203),
-        PPP_WITH_DIR(204),
-        C_HDLC_WITH_DIR(205),
-        FRELAY_WITH_DIR(206),
-        IPMB_LINUX(209),
-        IEEE802_15_4_NONASK_PHY(215),
-        USB_LINUX_MMAPPED(220),
-        FC_2(224),
-        FC_2_WITH_FRAME_DELIMS(225),
-        IPNET(226),
-        CAN_SOCKETCAN(227),
-        IPV4(228),
-        IPV6(229),
-        IEEE802_15_4_NOFCS(230),
-        DBUS(231),
-        DVB_CI(235),
-        MUX27010(236),
-        STANAG_5066_D_PDU(237),
-        NFLOG(239),
-        NETANALYZER(240),
-        NETANALYZER_TRANSPARENT(241),
-        IPOIB(242),
-        MPEG_2_TS(243),
-        NG40(244),
-        NFC_LLCP(245),
-        INFINIBAND(247),
-        SCTP(248),
-        USBPCAP(249),
-        RTAC_SERIAL(250),
-        BLUETOOTH_LE_LL(251),
-        NETLINK(253),
-        BLUETOOTH_LINUX_MONITOR(254),
-        BLUETOOTH_BREDR_BB(255),
-        BLUETOOTH_LE_LL_WITH_PHDR(256),
-        PROFIBUS_DL(257),
-        PKTAP(258),
-        EPON(259),
-        IPMI_HPM_2(260),
-        ZWAVE_R1_R2(261),
-        ZWAVE_R3(262),
-        WATTSTOPPER_DLM(263),
-        ISO_14443(264);
-
-        private final long id;
-        Linktype(long id) { this.id = id; }
-        public long id() { return id; }
-        private static final Map<Long, Linktype> byId = new HashMap<Long, Linktype>(104);
-        static {
-            for (Linktype e : Linktype.values())
-                byId.put(e.id(), e);
-        }
-        public static Linktype byId(long id) { return byId.get(id); }
-    }
-
-    public Pcap(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public Pcap(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public Pcap(KaitaiStream _io, KaitaiStruct _parent, Pcap _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.hdr = new Header(this._io, this, _root);
-        this.packets = new ArrayList<Packet>();
-        {
-            int i = 0;
-            while (!this._io.isEof()) {
-                this.packets.add(new Packet(this._io, this, _root));
-                i++;
-            }
-        }
-    }
-
-    /**
-     * @see <a href="https://wiki.wireshark.org/Development/LibpcapFileFormat#Global_Header">Source</a>
-     */
-    public static class Header extends KaitaiStruct {
-        public static Header fromFile(String fileName) throws IOException {
-            return new Header(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Header(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Header(KaitaiStream _io, Pcap _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Header(KaitaiStream _io, Pcap _parent, Pcap _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.magicNumber = this._io.ensureFixedContents(new byte[] { -44, -61, -78, -95 });
-            this.versionMajor = this._io.readU2le();
-            this.versionMinor = this._io.readU2le();
-            this.thiszone = this._io.readS4le();
-            this.sigfigs = this._io.readU4le();
-            this.snaplen = this._io.readU4le();
-            this.network = Pcap.Linktype.byId(this._io.readU4le());
-        }
-        private byte[] magicNumber;
-        private int versionMajor;
-        private int versionMinor;
-        private int thiszone;
-        private long sigfigs;
-        private long snaplen;
-        private Linktype network;
-        private Pcap _root;
-        private Pcap _parent;
-        public byte[] magicNumber() { return magicNumber; }
-        public int versionMajor() { return versionMajor; }
-        public int versionMinor() { return versionMinor; }
-
-        /**
-         * Correction time in seconds between UTC and the local
-         * timezone of the following packet header timestamps.
-         */
-        public int thiszone() { return thiszone; }
-
-        /**
-         * In theory, the accuracy of time stamps in the capture; in
-         * practice, all tools set it to 0.
-         */
-        public long sigfigs() { return sigfigs; }
-
-        /**
-         * The "snapshot length" for the capture (typically 65535 or
-         * even more, but might be limited by the user), see: incl_len
-         * vs. orig_len.
-         */
-        public long snaplen() { return snaplen; }
-
-        /**
-         * Link-layer header type, specifying the type of headers at
-         * the beginning of the packet.
-         */
-        public Linktype network() { return network; }
-        public Pcap _root() { return _root; }
-        public Pcap _parent() { return _parent; }
-    }
-
-    /**
-     * @see <a href="https://wiki.wireshark.org/Development/LibpcapFileFormat#Record_.28Packet.29_Header">Source</a>
-     */
-    public static class Packet extends KaitaiStruct {
-        public static Packet fromFile(String fileName) throws IOException {
-            return new Packet(new ByteBufferKaitaiStream(fileName));
-        }
-
-        public Packet(KaitaiStream _io) {
-            this(_io, null, null);
-        }
-
-        public Packet(KaitaiStream _io, Pcap _parent) {
-            this(_io, _parent, null);
-        }
-
-        public Packet(KaitaiStream _io, Pcap _parent, Pcap _root) {
-            super(_io);
-            this._parent = _parent;
-            this._root = _root;
-            _read();
-        }
-        private void _read() {
-            this.tsSec = this._io.readU4le();
-            this.tsUsec = this._io.readU4le();
-            this.inclLen = this._io.readU4le();
-            this.origLen = this._io.readU4le();
-            switch (_root.hdr().network()) {
-            case PPI: {
-                this._raw_body = this._io.readBytes(inclLen());
-                KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-                this.body = new PacketPpi(_io__raw_body);
-                break;
-            }
-            case ETHERNET: {
-                this._raw_body = this._io.readBytes(inclLen());
-                KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
-                this.body = new EthernetFrame(_io__raw_body);
-                break;
-            }
-            default: {
-                this.body = this._io.readBytes(inclLen());
-                break;
-            }
-            }
-        }
-        private long tsSec;
-        private long tsUsec;
-        private long inclLen;
-        private long origLen;
-        private Object body;
-        private Pcap _root;
-        private Pcap _parent;
-        private byte[] _raw_body;
-        public long tsSec() { return tsSec; }
-        public long tsUsec() { return tsUsec; }
-
-        /**
-         * Number of bytes of packet data actually captured and saved in the file.
-         */
-        public long inclLen() { return inclLen; }
-
-        /**
-         * Length of the packet as it appeared on the network when it was captured.
-         */
-        public long origLen() { return origLen; }
-
-        /**
-         * @see <a href="https://wiki.wireshark.org/Development/LibpcapFileFormat#Packet_Data">Source</a>
-         */
-        public Object body() { return body; }
-        public Pcap _root() { return _root; }
-        public Pcap _parent() { return _parent; }
-        public byte[] _raw_body() { return _raw_body; }
-    }
-    private Header hdr;
-    private ArrayList<Packet> packets;
-    private Pcap _root;
-    private KaitaiStruct _parent;
-    public Header hdr() { return hdr; }
-    public ArrayList<Packet> packets() { return packets; }
-    public Pcap _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-}
diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/TcpSegment.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/TcpSegment.java
deleted file mode 100644 (file)
index 80ec76e..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-
-public class TcpSegment extends KaitaiStruct {
-    public static TcpSegment fromFile(String fileName) throws IOException {
-        return new TcpSegment(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public TcpSegment(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public TcpSegment(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public TcpSegment(KaitaiStream _io, KaitaiStruct _parent, TcpSegment _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.srcPort = this._io.readU2be();
-        this.dstPort = this._io.readU2be();
-        this.seqNum = this._io.readU4be();
-        this.ackNum = this._io.readU4be();
-        this.b12 = this._io.readU1();
-        this.b13 = this._io.readU1();
-        this.windowSize = this._io.readU2be();
-        this.checksum = this._io.readU2be();
-        this.urgentPointer = this._io.readU2be();
-        this.body = this._io.readBytesFull();
-    }
-    private int srcPort;
-    private int dstPort;
-    private long seqNum;
-    private long ackNum;
-    private int b12;
-    private int b13;
-    private int windowSize;
-    private int checksum;
-    private int urgentPointer;
-    private byte[] body;
-    private TcpSegment _root;
-    private KaitaiStruct _parent;
-    public int srcPort() { return srcPort; }
-    public int dstPort() { return dstPort; }
-    public long seqNum() { return seqNum; }
-    public long ackNum() { return ackNum; }
-    public int b12() { return b12; }
-    public int b13() { return b13; }
-    public int windowSize() { return windowSize; }
-    public int checksum() { return checksum; }
-    public int urgentPointer() { return urgentPointer; }
-    public byte[] body() { return body; }
-    public TcpSegment _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-}
diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/UdpDatagram.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/UdpDatagram.java
deleted file mode 100644 (file)
index 9133029..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
-package edu.uci.iotproject;
-
-import io.kaitai.struct.ByteBufferKaitaiStream;
-import io.kaitai.struct.KaitaiStruct;
-import io.kaitai.struct.KaitaiStream;
-import java.io.IOException;
-
-
-/**
- * UDP is a simple stateless transport layer (AKA OSI layer 4)
- * protocol, one of the core Internet protocols. It provides source and
- * destination ports, basic checksumming, but provides not guarantees
- * of delivery, order of packets, or duplicate delivery.
- */
-public class UdpDatagram extends KaitaiStruct {
-    public static UdpDatagram fromFile(String fileName) throws IOException {
-        return new UdpDatagram(new ByteBufferKaitaiStream(fileName));
-    }
-
-    public UdpDatagram(KaitaiStream _io) {
-        this(_io, null, null);
-    }
-
-    public UdpDatagram(KaitaiStream _io, KaitaiStruct _parent) {
-        this(_io, _parent, null);
-    }
-
-    public UdpDatagram(KaitaiStream _io, KaitaiStruct _parent, UdpDatagram _root) {
-        super(_io);
-        this._parent = _parent;
-        this._root = _root == null ? this : _root;
-        _read();
-    }
-    private void _read() {
-        this.srcPort = this._io.readU2be();
-        this.dstPort = this._io.readU2be();
-        this.length = this._io.readU2be();
-        this.checksum = this._io.readU2be();
-        this.body = this._io.readBytesFull();
-    }
-    private int srcPort;
-    private int dstPort;
-    private int length;
-    private int checksum;
-    private byte[] body;
-    private UdpDatagram _root;
-    private KaitaiStruct _parent;
-    public int srcPort() { return srcPort; }
-    public int dstPort() { return dstPort; }
-    public int length() { return length; }
-    public int checksum() { return checksum; }
-    public byte[] body() { return body; }
-    public UdpDatagram _root() { return _root; }
-    public KaitaiStruct _parent() { return _parent; }
-}