9133029fd080cf48b3abaf041766f1e9f6556c26
[pingpong.git] / Code / Projects / SmartPlugDetector / src / main / java / edu / uci / iotproject / UdpDatagram.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
10 /**
11  * UDP is a simple stateless transport layer (AKA OSI layer 4)
12  * protocol, one of the core Internet protocols. It provides source and
13  * destination ports, basic checksumming, but provides not guarantees
14  * of delivery, order of packets, or duplicate delivery.
15  */
16 public class UdpDatagram extends KaitaiStruct {
17     public static UdpDatagram fromFile(String fileName) throws IOException {
18         return new UdpDatagram(new ByteBufferKaitaiStream(fileName));
19     }
20
21     public UdpDatagram(KaitaiStream _io) {
22         this(_io, null, null);
23     }
24
25     public UdpDatagram(KaitaiStream _io, KaitaiStruct _parent) {
26         this(_io, _parent, null);
27     }
28
29     public UdpDatagram(KaitaiStream _io, KaitaiStruct _parent, UdpDatagram _root) {
30         super(_io);
31         this._parent = _parent;
32         this._root = _root == null ? this : _root;
33         _read();
34     }
35     private void _read() {
36         this.srcPort = this._io.readU2be();
37         this.dstPort = this._io.readU2be();
38         this.length = this._io.readU2be();
39         this.checksum = this._io.readU2be();
40         this.body = this._io.readBytesFull();
41     }
42     private int srcPort;
43     private int dstPort;
44     private int length;
45     private int checksum;
46     private byte[] body;
47     private UdpDatagram _root;
48     private KaitaiStruct _parent;
49     public int srcPort() { return srcPort; }
50     public int dstPort() { return dstPort; }
51     public int length() { return length; }
52     public int checksum() { return checksum; }
53     public byte[] body() { return body; }
54     public UdpDatagram _root() { return _root; }
55     public KaitaiStruct _parent() { return _parent; }
56 }