netfilter-titan/testproject/TCP_Option.ttcn

77 lines
2.1 KiB
Plaintext

/* TCP option parsing/encoding, as this is not handled by * titan.ProtocolModules.TCP itself :(
* (C) 2017 by Harald Welte <laforge@gnumonks.org>
* Licensed under Eclipse Public License - v1.0 or GPLv2, at your choice*/
module TCP_Option {
type integer uint8_t (0..255) with { variant "FIELDLENGTH(8), BYTEORDER(last)" };
type integer uint16_t (0..65535) with { variant "FIELDLENGTH(16), BYTEORDER(last)" };
type integer uint24_t (0..16777215) with { variant "FIELDLENGTH(24), BYTEORDER(last)" };
type integer uint32_t (0..4294967295) with { variant "FIELDLENGTH(32), BYTEORDER(last)" };
type enumerated TCP_Opt_type { end, nop, mss, wscale, sackperm, sack, /* 6..7*/ ts };
type record TCP_Opt_end {
uint8_t id
}
type record TCP_Opt_nop {
uint8_t id
}
type record TCP_Opt_mss {
uint8_t id,
uint8_t len,
uint16_t mss
} with { variant (len) "LENGTHTO(id, len, mss)" }
type record TCP_Opt_wscale {
uint8_t id,
uint8_t len,
uint8_t wscale
} with { variant (len) "LENGTHTO(id, len, wscale)" }
type record TCP_Opt_sackperm {
uint8_t id,
uint8_t len
} with { variant (len) "LENGTHTO(id, len)" }
type record sack_range {
uint32_t begin,
uint32_t end
}
type record of sack_range sack_range_list;
type record TCP_Opt_sack {
uint8_t id,
uint8_t len,
sack_range_list list
} with { variant (len) "LENGTHTO(id, len, list)" }
type record TCP_Opt_ts {
uint8_t id,
uint8_t len,
uint32_t ts,
uint32_t echo_ts
} with { variant (len) "LENGTHTO(id, len, ts, echo_ts)" }
type union TCP_Option {
TCP_Opt_end end,
TCP_Opt_nop nop,
TCP_Opt_mss mss,
TCP_Opt_wscale wscale,
TCP_Opt_sackperm sackperm,
TCP_Opt_sack sack,
TCP_Opt_ts ts
} with { variant "TAG(end, id = 0;
nop, id = 1;
mss, id = 2;
wscale, id = 3;
sackperm, id = 4;
sack, id = 5;
ts, id = 8)" }
external function enc_TCP_option(in TCP_Option opt) return octetstring with { extension "prototype(convert) encode(RAW)" };
external function dec_TCP_option(in octetstring stream) return TCP_Option with { extension "prototype(convert) decode(RAW)" };
} with { encode "RAW" }