1 /* lat.h
2  *
3  */
4 
5 // Our LAT version (5.2)
6 
7 #define LAT_VERSION     5
8 #define LAT_VERSION_ECO 2
9 
10 #define MAX_LAT_MTU     1500            // max ethernet packet
11 
12 // Name of the /dev/lat directory for local "ports"
13 #define LAT_DIRECTORY "/dev/lat"
14 
15 /* Command types */
16 // NOTE: Bit 0 is "Response Requested"
17 //       Bit 1 is "To Host"
18 #define LAT_CCMD_SREPLY   0x00 // From Host
19 #define LAT_CCMD_SDATA    0x01 // From Host: Response required
20 #define LAT_CCMD_SESSION  0x02 // To Host
21 #define LAT_CCMD_CONNECT  0x06
22 #define LAT_CCMD_CONREF   0x08 // Disconnect from Host end
23 #define LAT_CCMD_CONACK   0x04
24 #define LAT_CCMD_DISCON   0x0A
25 #define LAT_CCMD_SERVICE  0x28
26 #define LAT_CCMD_COMMAND  0x30 // Used by Queued Connect
27 #define LAT_CCMD_STATUS   0x34 // Status of Queued Connect
28 #define LAT_CCMD_ENQUIRE  0x38
29 #define LAT_CCMD_ENQREPLY 0x3C
30 
31 /* Structure of a LAT header */
32 typedef struct
33 {
34 	unsigned char  cmd;
35 	unsigned char  num_slots;
36 	unsigned short remote_connid   __attribute__ ((packed));
37 	unsigned short local_connid    __attribute__ ((packed));
38 	unsigned char  sequence_number;
39 	unsigned char  ack_number;
40 
41 } LAT_Header;
42 
43 typedef struct
44 {
45 	unsigned char  cmd;
46 	unsigned char  dummy;
47 	unsigned char  hiver;      // Highest protocol version
48 	unsigned char  lover;      // Lowest protocol version
49 	unsigned char  latver;     // LAT version No. (5)
50 	unsigned char  latver_eco; // LAT version No. (LSB)
51 	unsigned short mtu             __attribute__ ((packed)); // 1500
52 	unsigned short id              __attribute__ ((packed));
53 	unsigned short retrans_timer   __attribute__ ((packed));
54 
55 } LAT_Enquiry;
56 
57 typedef struct
58 {
59 	unsigned char  cmd;
60 	unsigned char  dummy;
61 	unsigned char  hiver;
62 	unsigned char  lover;
63 	unsigned char  latver;     // LAT version No. (5)
64 	unsigned char  latver_eco; // LAT version No. (LSB)
65 	unsigned short mtu             __attribute__ ((packed)); // 1500
66 	unsigned short id              __attribute__ ((packed));
67 	unsigned short retrans_timer   __attribute__ ((packed));
68 
69 } LAT_Enqreply;
70 
71 
72 // Service Announcement message
73 typedef struct
74 {
75 	unsigned char  cmd             ; // always 0x28
76 	unsigned char  circuit_timer   ; // in 10s milliseconds
77 	unsigned char  hiver           ; // Highest protocol version
78 	unsigned char  lover           ; // Lowest protocol version
79 	unsigned char  latver          ; // LAT version No. (5)
80 	unsigned char  latver_eco      ; // LAT version No. (LSB)
81 	unsigned char  incarnation     ; // Message incarnation
82 	unsigned char  flags           ; // Change flags
83 	unsigned short mtu             __attribute__ ((packed)); // 1500
84 	unsigned char  multicast_timer ; // Multicast timer (seconds)
85 	unsigned char  node_status     ; // 2 (accepting connections)
86 	unsigned char  group_length    ;
87 
88   // Following:
89   // Node groups
90   //...other stuff!
91 } LAT_ServiceAnnounce;
92 
93 
94 // LAT Start message
95 typedef struct
96 {
97 	LAT_Header header;
98 	unsigned short maxsize     __attribute__ ((packed)); // Max message size
99 	unsigned char  latver;
100 	unsigned char  latver_eco;
101 	unsigned char  maxsessions;
102 	unsigned char  exqueued;  // Extra data link buffer queued
103 	unsigned char  circtimer; // in 10s of milliseconds
104 	unsigned char  keepalive; // in seconds
105 	unsigned short facility    __attribute__ ((packed));
106 	unsigned char  prodtype;
107 	unsigned char  prodver;
108 
109 	// Following:
110 	// ASCIC Destination Service
111 	// ASCIC Source Node
112 } LAT_Start;
113 
114 // LAT Connect message
115 typedef struct
116 {
117 	LAT_Header header;
118 	unsigned short maxsize     __attribute__ ((packed));
119 	unsigned char  latver;
120 	unsigned char  latver_eco;
121 	unsigned char  maxsessions;
122 	unsigned char  exqueued;
123 	unsigned char  circtimer;
124 	unsigned char  keepalive;
125 	unsigned short facility    __attribute__ ((packed));
126 	unsigned char  prodtype;
127 	unsigned char  prodver;
128 
129 	// Following:
130 	// ASCIC Destination Node
131 	// ASCIC Source Node
132 	// ASCIC Local description (NUL terminated)
133 } LAT_StartResponse;
134 
135 // LAT Slot command - follows the header - may be more than one
136 // in a packet. Word-aligned
137 typedef struct
138 {
139 	unsigned char local_session;
140 	unsigned char remote_session;
141 	unsigned char length;
142 	unsigned char cmd;
143 } LAT_SlotCmd;
144 
145 
146 typedef struct
147 {
148 	LAT_Header  header;
149 	LAT_SlotCmd slot;
150 } LAT_SessionCmd;
151 
152 typedef struct
153 {
154 	LAT_Header    header;
155 	LAT_SlotCmd   slot;
156 	unsigned char serviceclass;
157 	unsigned char attslotsize;
158 	unsigned char dataslotsize;
159 } LAT_SessionStartCmd;
160 
161 typedef struct
162 {
163 	unsigned char  cmd;
164 	unsigned char  format;
165 	unsigned char  hiver;
166 	unsigned char  lover;
167 	unsigned char  latver;
168 	unsigned char  latver_eco;
169 	unsigned short maxsize       __attribute__ ((packed));
170 	unsigned short request_id    __attribute__ ((packed));
171 	unsigned short entry_id      __attribute__ ((packed));
172 	unsigned char  opcode;
173 	unsigned char  modifier;
174 	// ASCIC Destination node name
175 	// ASCIC Source node name
176 	// ASCIC Source node port name (usually NUL)
177 	// ASCIC Source description (usually NUL)
178 	// ASCIC Destination port name
179 	// Parameters
180 } LAT_Command;
181 
182 // A Status message can contain one or more of these entries.
183 typedef struct
184 {
185 	unsigned short length        __attribute__ ((packed));
186 	unsigned short status        __attribute__ ((packed));
187 	unsigned short request_id    __attribute__ ((packed));
188 	unsigned short session_id    __attribute__ ((packed));
189 	unsigned short elapsed_time  __attribute__ ((packed)); // set to -1? seconds
190 	unsigned short min_que_pos   __attribute__ ((packed));
191 	unsigned short max_que_pos   __attribute__ ((packed));
192 	// ASCIC Service Name
193 	// ASCIC Port Name
194 	// ASCIC Service description
195 
196 } LAT_StatusEntry;
197 
198 typedef struct
199 {
200 	unsigned char  cmd;
201 	unsigned char  format;
202 	unsigned char  hiver;
203 	unsigned char  lover;
204 	unsigned char  latver;
205 	unsigned char  latver_eco;
206 	unsigned short maxsize       __attribute__ ((packed));
207 	unsigned short retrans_timer __attribute__ ((packed));
208 	unsigned char  entry_count;
209 	//ASCIC Subject node name
210 	// Array of LAT_StatusEntry structs
211 
212 } LAT_Status;
213 
214 typedef LAT_SessionCmd LAT_SessionReply;
215 typedef LAT_SessionCmd LAT_SessionData; // Unsolicited output
216 
217 // Slot disconnect reasons (0xd(x) & 0xc(x) slot messages):
218 // 0x0 Unknown
219 // 0x1 User requested disconnect
220 // 0x2 System shutdown in progress
221 // 0x3 Invalid slot received
222 // 0x4 Invalid service class
223 // 0x5 Insufficient resources
224 // 0x6 Service in use
225 // 0x7 No such service
226 // 0x8 Service is disabled
227 // 0x9 Service is not offered by requested port
228 // 0xa Port name is unknown
229 // 0xb Invalid password
230 // 0xc Entry is not in the queue
231 // 0xd Immediate access rejected
232 // 0xe Access denied
233 // 0xf Corrupted solicit request
234 
235 
236 // Circuit disconnect reasons (first byte of 0x0A/0x08 message)
237 // 0x00 Unknown
238 // 0x01 No more slots on circuit
239 // 0x02 Illegal message or slot format received
240 // 0x03 VC_Halt from user
241 // 0x04 No progress being made
242 // 0x05 Time limit expired
243 // 0x06 Retransmission limit reached
244 // 0x07 Insufficient resources to satisfy request
245 // 0x08 Server circuit timer out of range
246 // 0x09 Number of virtual circuits exceeded
247 
248 
249