this.dstMac = this._io.readBytes(6);
this.srcMac = this._io.readBytes(6);
this.etherType = EtherTypeEnum.byId(this._io.readU2be());
- 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;
- }
- 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;
- }
+
+ // 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;
+ }
+ 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;
public static void main(String[] args) throws Exception {
System.out.println("it works");
- String file = "/home/rtrimana/pcap_processing/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcapdump";
+ //String file = "/home/rtrimana/pcap_processing/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/gre-sample.pcap";
+ String file = "/home/rtrimana/pcap_processing/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcap";
try {
Pcap data = Pcap.fromFile(file);
- //data.hdr();
+ data.hdr();
} catch (Exception e) {
e.printStackTrace();
}