1 // This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
2 package edu.uci.iotproject;
4 import io.kaitai.struct.ByteBufferKaitaiStream;
5 import io.kaitai.struct.KaitaiStruct;
6 import io.kaitai.struct.KaitaiStream;
7 import java.io.IOException;
9 import java.util.HashMap;
11 public class EthernetFrame extends KaitaiStruct {
12 public static EthernetFrame fromFile(String fileName) throws IOException {
13 return new EthernetFrame(new ByteBufferKaitaiStream(fileName));
16 public enum EtherTypeEnum {
26 private final long id;
27 EtherTypeEnum(long id) { this.id = id; }
28 public long id() { return id; }
29 private static final Map<Long, EtherTypeEnum> byId = new HashMap<Long, EtherTypeEnum>(8);
31 for (EtherTypeEnum e : EtherTypeEnum.values())
34 public static EtherTypeEnum byId(long id) { return byId.get(id); }
37 public EthernetFrame(KaitaiStream _io) {
38 this(_io, null, null);
41 public EthernetFrame(KaitaiStream _io, KaitaiStruct _parent) {
42 this(_io, _parent, null);
45 public EthernetFrame(KaitaiStream _io, KaitaiStruct _parent, EthernetFrame _root) {
47 this._parent = _parent;
48 this._root = _root == null ? this : _root;
51 private void _read() {
52 this.dstMac = this._io.readBytes(6);
53 this.srcMac = this._io.readBytes(6);
54 this.etherType = EtherTypeEnum.byId(this._io.readU2be());
55 switch (etherType()) {
57 this._raw_body = this._io.readBytesFull();
58 KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
59 this.body = new Ipv4Packet(_io__raw_body);
63 this._raw_body = this._io.readBytesFull();
64 KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body);
65 this.body = new Ipv6Packet(_io__raw_body);
69 this.body = this._io.readBytesFull();
74 private byte[] dstMac;
75 private byte[] srcMac;
76 private EtherTypeEnum etherType;
78 private EthernetFrame _root;
79 private KaitaiStruct _parent;
80 private byte[] _raw_body;
81 public byte[] dstMac() { return dstMac; }
82 public byte[] srcMac() { return srcMac; }
83 public EtherTypeEnum etherType() { return etherType; }
84 public Object body() { return body; }
85 public EthernetFrame _root() { return _root; }
86 public KaitaiStruct _parent() { return _parent; }
87 public byte[] _raw_body() { return _raw_body; }