40 lines
798 B
Plaintext
40 lines
798 B
Plaintext
# Automatically generated; edit in Sphinx source code, not here.
|
|
module TFTP;
|
|
|
|
public type Packet = unit {
|
|
opcode: uint16;
|
|
|
|
switch ( self.opcode ) {
|
|
1 -> rrq: ReadRequest;
|
|
2 -> wrq: WriteRequest;
|
|
3 -> data: Data;
|
|
4 -> ack: Acknowledgement;
|
|
5 -> error: Error;
|
|
};
|
|
|
|
on %done { print self; }
|
|
};
|
|
|
|
type ReadRequest = unit {
|
|
filename: bytes &until=b"\x00";
|
|
mode: bytes &until=b"\x00";
|
|
};
|
|
|
|
type WriteRequest = unit {
|
|
filename: bytes &until=b"\x00";
|
|
mode: bytes &until=b"\x00";
|
|
};
|
|
|
|
type Data = unit {
|
|
num: uint16;
|
|
data: bytes &eod; # parse until end of data (i.e., packet) is reached
|
|
};
|
|
|
|
type Acknowledgement = unit {
|
|
num: uint16;
|
|
};
|
|
|
|
type Error = unit {
|
|
code: uint16;
|
|
msg: bytes &until=b"\x00";
|
|
}; |