469ed8b4d35a533ed6c47690d1e65f1ac801e244
[pingpong.git] / Code / Projects / SmartPlugDetector / src / main / java / edu / uci / iotproject / Ipv6Packet.java
1 // This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
2 package edu.uci.iotproject;
3
4 import io.kaitai.struct.ByteBufferKaitaiStream;
5 import io.kaitai.struct.KaitaiStruct;
6 import io.kaitai.struct.KaitaiStream;
7 import java.io.IOException;
8
9 public class Ipv6Packet extends KaitaiStruct {
10     public static Ipv6Packet fromFile(String fileName) throws IOException {
11         return new Ipv6Packet(new ByteBufferKaitaiStream(fileName));
12     }
13
14     public Ipv6Packet(KaitaiStream _io) {
15         this(_io, null, null);
16     }
17
18     public Ipv6Packet(KaitaiStream _io, KaitaiStruct _parent) {
19         this(_io, _parent, null);
20     }
21
22     public Ipv6Packet(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
23         super(_io);
24         this._parent = _parent;
25         this._root = _root == null ? this : _root;
26         _read();
27     }
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()) {
39         case 17: {
40             this.nextHeader = new UdpDatagram(this._io);
41             break;
42         }
43         case 0: {
44             this.nextHeader = new OptionHopByHop(this._io, this, _root);
45             break;
46         }
47         case 4: {
48             this.nextHeader = new Ipv4Packet(this._io);
49             break;
50         }
51         case 6: {
52             this.nextHeader = new TcpSegment(this._io);
53             break;
54         }
55         case 59: {
56             this.nextHeader = new NoNextHeader(this._io, this, _root);
57             break;
58         }
59         }
60         this.rest = this._io.readBytesFull();
61     }
62     public static class NoNextHeader extends KaitaiStruct {
63         public static NoNextHeader fromFile(String fileName) throws IOException {
64             return new NoNextHeader(new ByteBufferKaitaiStream(fileName));
65         }
66
67         public NoNextHeader(KaitaiStream _io) {
68             this(_io, null, null);
69         }
70
71         public NoNextHeader(KaitaiStream _io, KaitaiStruct _parent) {
72             this(_io, _parent, null);
73         }
74
75         public NoNextHeader(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
76             super(_io);
77             this._parent = _parent;
78             this._root = _root;
79             _read();
80         }
81         private void _read() {
82         }
83         private Ipv6Packet _root;
84         private KaitaiStruct _parent;
85         public Ipv6Packet _root() { return _root; }
86         public KaitaiStruct _parent() { return _parent; }
87     }
88     public static class OptionHopByHop extends KaitaiStruct {
89         public static OptionHopByHop fromFile(String fileName) throws IOException {
90             return new OptionHopByHop(new ByteBufferKaitaiStream(fileName));
91         }
92
93         public OptionHopByHop(KaitaiStream _io) {
94             this(_io, null, null);
95         }
96
97         public OptionHopByHop(KaitaiStream _io, KaitaiStruct _parent) {
98             this(_io, _parent, null);
99         }
100
101         public OptionHopByHop(KaitaiStream _io, KaitaiStruct _parent, Ipv6Packet _root) {
102             super(_io);
103             this._parent = _parent;
104             this._root = _root;
105             _read();
106         }
107         private void _read() {
108             this.nextHeaderType = this._io.readU1();
109             this.hdrExtLen = this._io.readU1();
110             this.body = this._io.readBytes((hdrExtLen() - 1));
111             switch (nextHeaderType()) {
112             case 0: {
113                 this.nextHeader = new OptionHopByHop(this._io, this, _root);
114                 break;
115             }
116             case 6: {
117                 this.nextHeader = new TcpSegment(this._io);
118                 break;
119             }
120             case 59: {
121                 this.nextHeader = new NoNextHeader(this._io, this, _root);
122                 break;
123             }
124             }
125         }
126         private int nextHeaderType;
127         private int hdrExtLen;
128         private byte[] body;
129         private KaitaiStruct nextHeader;
130         private Ipv6Packet _root;
131         private KaitaiStruct _parent;
132         public int nextHeaderType() { return nextHeaderType; }
133         public int hdrExtLen() { return hdrExtLen; }
134         public byte[] body() { return body; }
135         public KaitaiStruct nextHeader() { return nextHeader; }
136         public Ipv6Packet _root() { return _root; }
137         public KaitaiStruct _parent() { return _parent; }
138     }
139     private long version;
140     private long trafficClass;
141     private long flowLabel;
142     private int payloadLength;
143     private int nextHeaderType;
144     private int hopLimit;
145     private byte[] srcIpv6Addr;
146     private byte[] dstIpv6Addr;
147     private KaitaiStruct nextHeader;
148     private byte[] rest;
149     private Ipv6Packet _root;
150     private KaitaiStruct _parent;
151     public long version() { return version; }
152     public long trafficClass() { return trafficClass; }
153     public long flowLabel() { return flowLabel; }
154     public int payloadLength() { return payloadLength; }
155     public int nextHeaderType() { return nextHeaderType; }
156     public int hopLimit() { return hopLimit; }
157     public byte[] srcIpv6Addr() { return srcIpv6Addr; }
158     public byte[] dstIpv6Addr() { return dstIpv6Addr; }
159     public KaitaiStruct nextHeader() { return nextHeader; }
160     public byte[] rest() { return rest; }
161     public Ipv6Packet _root() { return _root; }
162     public KaitaiStruct _parent() { return _parent; }
163 }