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 public class Ipv6Packet extends KaitaiStruct {
10 public static Ipv6Packet fromFile(String fileName) throws IOException {
11 return new Ipv6Packet(new ByteBufferKaitaiStream(fileName));
14 public Ipv6Packet(KaitaiStream _io) {
15 this(_io, null, null);
18 public Ipv6Packet(KaitaiStream _io, KaitaiStruct _parent) {
19 this(_io, _parent, null);
22 public Ipv6Packet(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
24 this._parent = _parent;
25 this._root = _root == null ? this : _root;
28 private void _read() {
29 this.version = this._io.readBitsInt(4);
30 this.trafficClass = this._io.readBitsInt(8);
31 this.flowLabel = this._io.readBitsInt(20);
32 this._io.alignToByte();
33 this.payloadLength = this._io.readU2be();
34 this.nextHeaderType = this._io.readU1();
35 this.hopLimit = this._io.readU1();
36 this.srcIpv6Addr = this._io.readBytes(16);
37 this.dstIpv6Addr = this._io.readBytes(16);
38 switch (nextHeaderType()) {
40 this.nextHeader = new UdpDatagram(this._io);
44 this.nextHeader = new OptionHopByHop(this._io, this, _root);
48 this.nextHeader = new Ipv4Packet(this._io);
52 this.nextHeader = new TcpSegment(this._io);
56 this.nextHeader = new NoNextHeader(this._io, this, _root);
60 this.rest = this._io.readBytesFull();
62 public static class NoNextHeader extends KaitaiStruct {
63 public static NoNextHeader fromFile(String fileName) throws IOException {
64 return new NoNextHeader(new ByteBufferKaitaiStream(fileName));
67 public NoNextHeader(KaitaiStream _io) {
68 this(_io, null, null);
71 public NoNextHeader(KaitaiStream _io, KaitaiStruct _parent) {
72 this(_io, _parent, null);
75 public NoNextHeader(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
77 this._parent = _parent;
81 private void _read() {
83 private Ipv6Packet _root;
84 private KaitaiStruct _parent;
85 public Ipv6Packet _root() { return _root; }
86 public KaitaiStruct _parent() { return _parent; }
88 public static class OptionHopByHop extends KaitaiStruct {
89 public static OptionHopByHop fromFile(String fileName) throws IOException {
90 return new OptionHopByHop(new ByteBufferKaitaiStream(fileName));
93 public OptionHopByHop(KaitaiStream _io) {
94 this(_io, null, null);
97 public OptionHopByHop(KaitaiStream _io, KaitaiStruct _parent) {
98 this(_io, _parent, null);
101 public OptionHopByHop(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
103 this._parent = _parent;
107 private void _read() {
108 this.nextHeaderType = this._io.readU1();
109 this.hdrExtLen = this._io.readU1();
110 switch (nextHeaderType()) {
112 this.nextHeader = new OptionHopByHop(this._io, this, _root);
116 this.nextHeader = new TcpSegment(this._io);
120 this.nextHeader = new NoNextHeader(this._io, this, _root);
125 private int nextHeaderType;
126 private int hdrExtLen;
128 private KaitaiStruct nextHeader;
129 private Ipv6Packet _root;
130 private KaitaiStruct _parent;
131 public int nextHeaderType() { return nextHeaderType; }
132 public int hdrExtLen() { return hdrExtLen; }
133 public byte[] body() { return body; }
134 public KaitaiStruct nextHeader() { return nextHeader; }
135 public Ipv6Packet _root() { return _root; }
136 public KaitaiStruct _parent() { return _parent; }
138 private long version;
139 private long trafficClass;
140 private long flowLabel;
141 private int payloadLength;
142 private int nextHeaderType;
143 private int hopLimit;
144 private byte[] srcIpv6Addr;
145 private byte[] dstIpv6Addr;
146 private KaitaiStruct nextHeader;
148 private Ipv6Packet _root;
149 private KaitaiStruct _parent;
150 public long version() { return version; }
151 public long trafficClass() { return trafficClass; }
152 public long flowLabel() { return flowLabel; }
153 public int payloadLength() { return payloadLength; }
154 public int nextHeaderType() { return nextHeaderType; }
155 public int hopLimit() { return hopLimit; }
156 public byte[] srcIpv6Addr() { return srcIpv6Addr; }
157 public byte[] dstIpv6Addr() { return dstIpv6Addr; }
158 public KaitaiStruct nextHeader() { return nextHeader; }
159 public byte[] rest() { return rest; }
160 public Ipv6Packet _root() { return _root; }
161 public KaitaiStruct _parent() { return _parent; }