Initial import from FreeBSD RELENG_4:
[games.git] / usr.sbin / atm / scspd / scsp_msg.h
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/usr.sbin/atm/scspd/scsp_msg.h,v 1.2 1999/08/28 01:15:33 peter Exp $
27  *
28  */
29
30 /*
31  * Server Cache Synchronization Protocol (SCSP) Support
32  * ----------------------------------------------------
33  *
34  * SCSP message formats
35  *
36  */
37
38 #ifndef _SCSP_SCSP_MSG_H
39 #define _SCSP_SCSP_MSG_H
40
41
42 /*
43  * ATMARP constants
44  */
45 #define ARP_ATMFORUM    19
46 #define ARP_TL_TMASK    0x40            /* Type mask */
47 #define ARP_TL_NSAPA    0x00            /* Type = ATM Forum NSAPA */
48 #define ARP_TL_E164     0x40            /* Type = E.164 */
49 #define ARP_TL_LMASK    0x3f            /* Length mask */
50
51
52 /*
53  * SCSP version number
54  */
55 #define SCSP_VER_1      1
56
57
58 /*
59  * SCSP message types
60  */
61 #define SCSP_CA_MSG             1
62 #define SCSP_CSU_REQ_MSG        2
63 #define SCSP_CSU_REPLY_MSG      3
64 #define SCSP_CSUS_MSG           4
65 #define SCSP_HELLO_MSG          5
66
67
68 /*
69  * SCSP Client Protocol IDs
70  */
71 #define SCSP_PROTO_ATMARP       1
72 #define SCSP_PROTO_NHRP         2
73 #define SCSP_PROTO_MARS         3
74 #define SCSP_PROTO_DHCP         4
75 #define SCSP_PROTO_LNNI         5
76
77
78 /*
79  * Extension types
80  */
81 #define SCSP_EXT_END    0
82 #define SCSP_EXT_AUTH   1
83 #define SCSP_EXT_VENDOR 2
84
85 /*
86  * Sequence number bounds
87  */
88 #define SCSP_CSA_SEQ_MIN        0x80000001
89 #define SCSP_CSA_SEQ_MAX        0x7FFFFFFF
90
91
92 /*
93  * Sender, Receiver, or Originator ID lengths
94  */
95 #define SCSP_ATMARP_ID_LEN      4
96 #define SCSP_NHRP_ID_LEN        4
97 #define SCSP_MAX_ID_LEN         4
98
99
100 /*
101  * Cache Key lengths
102  */
103 #define SCSP_ATMARP_KEY_LEN     4
104 #define SCSP_NHRP_KEY_LEN       4
105 #define SCSP_MAX_KEY_LEN        4
106
107
108 /*
109  * Fixed header
110  */
111 struct scsp_nhdr {
112         u_char  sh_ver;                 /* SCSP version */
113         u_char  sh_type;                /* Message type */
114         u_short sh_len;                 /* Message length */
115         u_short sh_checksum;            /* IP checksum over message */
116         u_short sh_ext_off;             /* Offset of first extension */
117 };
118
119
120 /*
121  * Mandatory common part
122  */
123 struct scsp_nmcp {
124         u_short sm_pid;                 /* Protocol ID */
125         u_short sm_sgid;                /* Server group ID */
126         u_short sm_fill_0;              /* Unused */
127         u_short sm_flags;               /* Flags--see below */
128         u_char  sm_sid_len;             /* Sender ID length */
129         u_char  sm_rid_len;             /* Receiver ID length */
130         u_short sm_rec_cnt;             /* Number of records */
131 #ifdef  NOTDEF
132         /* Variable length fields */
133         u_char  sm_sid[];               /* Sender ID (variable) */
134         u_char  sm_rid[];               /* Receiver ID (variable) */
135 #endif
136 };
137
138
139 /*
140  * Extensions part
141  */
142 struct scsp_next {
143         u_short se_type;                /* Extension type */
144         u_short se_len;                 /* Length */
145 #ifdef  NOTDEF
146         /* Variable length fields */
147         u_char  se_value[];             /* Extension value */
148 #endif
149 };
150
151
152 /*
153  * Cache State Advertisement record or
154  *    Cache State Advertisement Summary record
155  */
156 struct scsp_ncsa {
157         u_short scs_hop_cnt;            /* Hop count */
158         u_short scs_len;                /* Record length */
159         u_char  scs_ck_len;             /* Cache key length */
160         u_char  scs_oid_len;            /* Originator ID length */
161         u_short scs_nfill;              /* Null bit and filler */
162         long    scs_seq;                /* Sequence number */
163 #ifdef NOTDEF
164         /* Variable length fields */
165         u_char  scs_ckey[];             /* Cache key */
166         u_char  scs_oid[];              /* Originator ID */
167         u_char  scs_proto[];            /* Protocol-specific (in CSA) */
168 #endif
169 };
170
171 #define SCSP_CSAS_NULL  0x8000
172
173
174 /*
175  * Cache Alignment message
176  */
177 struct scsp_nca {
178         long                    sca_seq;        /* Sequence number */
179         struct scsp_nmcp        sca_mcp;        /* Mandatory common */
180 #ifdef NOTDEF
181         /* Variable length fields */
182         struct scsp_ncsa        sca_rec[];      /* CSASs */
183 #endif
184 };
185
186 #define SCSP_CA_M       0x8000          /* Master/Slave bit */
187 #define SCSP_CA_I       0x4000          /* Initialization bit */
188 #define SCSP_CA_O       0x2000          /* More bit */
189
190
191 /*
192  * Cache State Update Request, Cache State Update Reply, or
193  * Cache State Update Solicit message
194  */
195 struct scsp_ncsu_msg {
196         struct scsp_nmcp        scr_mcp;        /* Mandatory common */
197 #ifdef NOTDEF
198         /* Variable length fields */
199         struct scsp_ncsa        scr_rec[];      /* CSAs */
200 #endif
201 };
202
203
204 /*
205  * Hello message
206  */
207 struct scsp_nhello {
208         u_short                 sch_hi;         /* Hello interval */
209         u_short                 sch_df;         /* Dead factor */
210         u_short                 sch_fill_0;     /* Unused */
211         u_short                 sch_fid;        /* Family ID */
212         struct scsp_nmcp        sch_mcp;        /* Mandatory common */
213 #ifdef NOTDEF
214         /* Variable-length fields */
215         struct scsp_nrid        sch_rid[];      /* Receiver IDs */
216 #endif
217 };
218
219
220 /*
221  * ATMARP-specific Cache State Advertisement record
222  */
223 struct scsp_atmarp_ncsa {
224         u_short sa_hrd;                 /* Hardware type -- 0x0013 */
225         u_short sa_pro;                 /* Protocol type -- 0x0800 */
226         u_char  sa_shtl;                /* Src ATM addr type/len */
227         u_char  sa_sstl;                /* Src ATM subaddr type/len */
228         u_char  sa_state;               /* State */
229         u_char  sa_fill1;               /* Unused */
230         u_char  sa_spln;                /* Src proto addr type */
231         u_char  sa_thtl;                /* Tgt ATM addr type/len */
232         u_char  sa_tstl;                /* Tgt ATM subaddr type/len */
233         u_char  sa_tpln;                /* Tgt proto addr len */
234 #ifdef NOTDEF
235         /* Variable-length fields */
236         u_char  sa_sha[];               /* Source ATM addr */
237         u_char  sa_ssa[];               /* Source ATM subaddr */
238         u_char  sa_spa[];               /* Source IP addr */
239         u_char  sa_tha[];               /* Target ATM addr */
240         u_char  sa_tsa[];               /* Target ATM subaddr */
241         u_char  sa_tpa[];               /* Target IP addr */
242 #endif
243 };
244
245
246 /*
247  * NHRP-specific Cache State Advertisement record
248  */
249 struct scsp_nhrp_ncsa {
250         u_short sn_af;                  /* Address family */
251         u_short sn_pro;                 /* NHRP protocol type */
252         u_char  sn_snap[5];             /* SNAP header */
253         u_char  sn_ver;                 /* NHRP version no. */
254         u_short sn_flags;               /* Flags */
255         u_long  sn_rid;                 /* Request ID */
256         u_char  sn_state;               /* State */
257         u_char  sn_pln;                 /* Prefix length */
258         u_short sn_fill1;               /* Unused */
259         u_short sn_mtu;                 /* MTU */
260         u_short sn_hold;                /* Holding time */
261         u_char  sn_csatl;               /* Client addr type/len */
262         u_char  sn_csstl;               /* Client subaddr type/len */
263         u_char  sn_cpln;                /* Client proto addr len */
264         u_char  sn_pref;                /* Preference for next hop */
265 #ifdef NOTDEF
266         /* Variable-length fields */
267         u_char  sn_csa[];               /* Client subnetwork addr */
268         u_char  sn_css[];               /* Client subnetwork subaddr */
269         u_char  sn_cpa[];               /* Client protocol addr */
270 #endif
271 };
272
273
274 /*
275  * SCSP messages in internal format
276  *
277  *
278  * Fixed message header
279  */
280 struct scsp_hdr {
281         u_char  msg_type;               /* Message type */
282 };
283 typedef struct scsp_hdr Scsp_hdr;
284
285
286 /*
287  * Sender or Receiver ID structure
288  */
289 struct scsp_id {
290         struct scsp_id  *next;                  /* Next ID */
291         u_char          id_len;                 /* ID length */
292         u_char          id[SCSP_MAX_ID_LEN];    /* ID */
293 };
294 typedef struct scsp_id  Scsp_id;
295
296
297 /*
298  * Cacke Key structure
299  */
300 struct scsp_ckey {
301         u_char          key_len;                /* Cache key length */
302         u_char          key[SCSP_MAX_KEY_LEN];  /* Cache key */
303 };
304 typedef struct scsp_ckey        Scsp_ckey;
305
306
307 /*
308  * Mandatory  common part
309  */
310 struct scsp_mcp {
311         u_short         pid;            /* Protocol ID */
312         u_short         sgid;           /* Server group ID */
313         u_short         flags;          /* Flags */
314         u_short         rec_cnt;        /* No. of records attached */
315         Scsp_id         sid;            /* Sender ID */
316         Scsp_id         rid;            /* Receiver ID */
317 };
318 typedef struct scsp_mcp Scsp_mcp;
319
320
321 /*
322  * Extensions part
323  */
324 struct scsp_ext {
325         struct scsp_ext *next;          /* Next extension */
326         u_short         type;           /* Extension type */
327         u_short         len;            /* Length */
328 #ifdef  NOTDEF
329         /* Variable length fields */
330         u_char          value[];        /* Extension value */
331 #endif
332 };
333 typedef struct scsp_ext Scsp_ext;
334
335
336 /*
337  * Cache State Advertisement record or
338  *    Cache State Advertisement Summary record
339  */
340 struct scsp_csa {
341         struct scsp_csa *next;          /* Next CSAS record */
342         u_short         hops;           /* Hop count */
343         u_char          null;           /* Null flag */
344         u_long          seq;            /* CSA seq. no. */
345         Scsp_ckey       key;            /* Cache key */
346         Scsp_id         oid;            /* Originator ID */
347         int             trans_ct;       /* No. of times CSA sent */
348         struct scsp_atmarp_csa  *atmarp_data;   /* ATMARP data */
349 #ifdef NOTDEF
350         struct scsp_nhrp_csa    *nhrp_data;     /* NHRP data */
351 #endif
352 };
353 typedef struct scsp_csa Scsp_csa;
354
355 /*
356  * Macro to free a CSA and any associated protocol-specific data
357  */
358 #define SCSP_FREE_CSA(c)                                        \
359 {                                                               \
360         if ((c)->atmarp_data) {                                 \
361                 UM_FREE((c)->atmarp_data);                      \
362         }                                                       \
363         UM_FREE((c));                                           \
364 }
365
366
367 /*
368  * Cache Alignment message
369  */
370 struct scsp_ca {
371         long            ca_seq;         /* CA msg sequence no. */
372         u_char          ca_m;           /* Master/slave bit */
373         u_char          ca_i;           /* Initialization bit */
374         u_char          ca_o;           /* More bit */
375         Scsp_mcp        ca_mcp;         /* Mandatory common part */
376         Scsp_csa        *ca_csa_rec;    /* Ptr. to CSAS records */
377 };
378 typedef struct scsp_ca  Scsp_ca;
379
380
381 /*
382  * Cache State Update Request, Cache State Update Reply, or
383  * Cache State Update Solicit message
384  */
385 struct scsp_csu_msg {
386         Scsp_mcp        csu_mcp;        /* Mandatory common part */
387         Scsp_csa        *csu_csa_rec;   /* Ptr. to CSA records */
388 };
389 typedef struct scsp_csu_msg     Scsp_csu_msg;
390
391
392 /*
393  * Hello message
394  */
395 struct scsp_hello {
396         u_short         hello_int;      /* Hello interval */
397         u_short         dead_factor;    /* When is DCS dead? */
398         u_short         family_id;      /* Family ID */
399         Scsp_mcp        hello_mcp;      /* Mandatory common part */
400 };
401 typedef struct scsp_hello       Scsp_hello;
402
403
404 /*
405  * NHRP-specific Cache State Advertisement record
406  */
407 struct scsp_nhrp_csa {
408         u_char  req_id;                 /* Request ID */
409         u_char  state;                  /* State */
410         u_char  pref_len;               /* Prefix length */
411         u_short flags;                  /* See below */
412         u_short mtu;                    /* Maximim transmission unit */
413         u_short hold_time;              /* Entry holding time */
414         u_char  caddr_tlen;             /* Client addr type/length */
415         u_char  csaddr_tlen;            /* Client subaddr type/length */
416         u_char  cproto_len;             /* Client proto addr length */
417         u_char  pref;                   /* Preference */
418         Atm_addr        caddr;          /* Client address */
419         Atm_addr        csaddr;         /* Client subaddress */
420         struct in_addr  cproto_addr;    /* Client protocol address */
421 };
422 typedef struct scsp_nhrp        Scsp_nhrp;
423
424 #define SCSP_NHRP_UNIQ  0x8000
425 #define SCSP_NHRP_ARP   0x4000
426
427
428 /*
429  * ATMARP-specific Cache State Advertisement record
430  */
431 struct scsp_atmarp_csa {
432         u_char          sa_state;       /* State */
433         Atm_addr        sa_sha;         /* Source ATM addr */
434         Atm_addr        sa_ssa;         /* Source ATM subaddr */
435         struct in_addr  sa_spa;         /* Source IP addr */
436         Atm_addr        sa_tha;         /* Target ATM addr */
437         Atm_addr        sa_tsa;         /* Target ATM subaddr */
438         struct in_addr  sa_tpa;         /* Target IP addr */
439 };
440 typedef struct scsp_atmarp_csa  Scsp_atmarp_csa;
441
442
443 /*
444  * SCSP message
445  */
446 struct scsp_msg {
447         Scsp_hdr        sc_hdr;
448         union {
449                 Scsp_ca         *sc_u_ca;
450                 Scsp_csu_msg    *sc_u_csu_msg;
451                 Scsp_hello      *sc_u_hello;
452         } sc_msg_u;
453         Scsp_ext        *sc_ext;
454 };
455 typedef struct scsp_msg Scsp_msg;
456
457 #define sc_msg_type     sc_hdr.msg_type
458 #define sc_ca           sc_msg_u.sc_u_ca
459 #define sc_csu_msg      sc_msg_u.sc_u_csu_msg
460 #define sc_hello        sc_msg_u.sc_u_hello
461
462 #endif  /* _SCSP_SCSP_MSG_H */