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;
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.
16 public class UdpDatagram extends KaitaiStruct {
17 public static UdpDatagram fromFile(String fileName) throws IOException {
18 return new UdpDatagram(new ByteBufferKaitaiStream(fileName));
21 public UdpDatagram(KaitaiStream _io) {
22 this(_io, null, null);
25 public UdpDatagram(KaitaiStream _io, KaitaiStruct _parent) {
26 this(_io, _parent, null);
29 public UdpDatagram(KaitaiStream _io, KaitaiStruct _parent, UdpDatagram _root) {
31 this._parent = _parent;
32 this._root = _root == null ? this : _root;
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();
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; }