!iso.inc
! Protocol definitions for ISO Link and Transport levels

%recordformat npduf (%bytearray ddte,sdte(1:6),
                     %half dec pty, iso length,
                     %byte dlsap,slsap,control,
                           null link layer,
                     %bytearray lsdu(1:1497))

%consthalf cs iso = 'CS' {value for DEC PTY field
%constinteger lmt = 10,  {log2 of max TPDU size supported
     max tpdu size = 1<<lmt

%recordformat tpduf (%bytearray byte(1:max tpdusize) %or-
                 %byte li,code, %half dref,
{CR, CC, DR, DC} (%half sref, %byte classopt {CR,CC} %or %byte reason {DR})-
{DT, ED}     %or (%integer e tpdu nr {extended} %or %byte n tpdu nr {normal})-
{AK, EA}     %or ({extended} (%integer e yr tu nr, %half cdt)-
                  {normal} %or %byte n yr tu nr)-
{ER}         %or %byte rejcause)

! Codes for Class/Opt field

%constinteger class2 = 16_20, class4 = 16_40, classmask = 16_fc,
              extended formats = 2, no flow control = 1

%recordformat parmf (%byte code,
                     (%string(255)string %or-
                      %bytearray byte(0:255)))

! Extended/normal EOT (last TPDU of TSDU) markers in DT/ED/AK/EA TPDUs
%constinteger e eot = 16_80000000, n eot = 16_80

! TPDU codes and their fixed header part sizes
%constbyte-
cr tpdu = 16_e0, fhp  cr = 6, { Connect Request
cc tpdu = 16_d0, fhp  cc = 6, { Connect Confirm
dr tpdu = 16_80, fhp  dr = 6, { Disconnect Request
dc tpdu = 16_c0, fhp  dc = 5, { Disconnect Confirm
dt tpdu = 16_f0, fhp ndt = 4, { DaTa (normal format)
                 fhp edt = 7, { Data (extended format)
ed tpdu = 16_10, fhp ned = 4, { Expedited Data (normal)
                 fhp eed = 7, { Expedited Data (extended)
ak tpdu = 16_60, fhp nak = 4, { AcKnowledge (normal)
                 fhp eak = 9, { Acknowledge (extended)
ea tpdu = 16_20, fhp nea = 4, { Expedited Acknowledge (normal)
                 fhp eea = 7, { Expedited Acknowledge (extended)
er tpdu = 16_70, fhp  er = 4, { Error
cdt mask = 16_f

! Reason codes in ER TPDUs
%constbyte-
er ns  = 0, { not specified
er ipc = 1, { invalid parameter code
er itt = 2, { invalid TPDU type
er ipv = 3  { invalid parameter value

! Reason codes in DR TPDUs
%constbyte-
dr ns  = 0,   { not specified
dr apc = 1,   { TS Access Point Congestion
dr sna = 2,   { Session entity Not Attached
dr au  = 3,   { Address Unknown
dr nor = 128, { Normal disconnect requested by session entity
dr tec = 129, { Transport Entity Congested
dr neg = 130, { Negotiation failure
dr dup = 131, { Duplicate source ref
dr mmr = 132, { MisMatched References
dr pro = 133, { Protocol error
dr rov = 134, { Reference overflow
dr net = 135, { TC refused by network
dr ivl = 136  { InValid Length

! Parameter codes
%constbyte-
pc size = 16_c0, { TPDU max size being negotiated
pc cgid = 16_c1, { calling TSAP ID
pc cdid = 16_c2, { called TSAP ID
pc sum  = 16_c3, { Checksum
pc ver  = 16_c4, { Protocol version number
pc sec  = 16_c5, { security
pc opt  = 16_c6, { additional option selection
pc clas = 16_c7, { alternative prot class under negotiation
pc ackt = 16_85, { Acknowledge time
pc rerr = 16_86, { residual error rate
pc prio = 16_87, { TC priority
pc dely = 16_88, { target/max transit delay
pc thru = 16_89, { target/min throughput
pc sseq = 16_8a, { ack sub-sequence number
pc ttr  = 16_8b, { time to try reassignment
pc tpdu = 16_c1, { TPDU in error in ER TPDU
pc info = 16_e0  { extra reason info in DR TPDU
