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