Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / netproto / atm / spans / spans_cls.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/sys/netatm/spans/spans_cls.h,v 1.2 1999/08/28 00:48:49 peter Exp $
27  *      @(#) $DragonFly: src/sys/netproto/atm/spans/spans_cls.h,v 1.2 2003/06/17 04:28:49 dillon Exp $
28  *
29  */
30
31 /*
32  * SPANS Signalling Manager
33  * ---------------------------
34  *
35  * SPANS Connectionless Datagram Service (CLS) control blocks
36  *
37  */
38
39 #ifndef _SPANS_SPANSCLS_H
40 #define _SPANS_SPANSCLS_H
41
42 /*
43  * Protocol constants
44  */
45 #define SPANSARP_AGING          (60 * ATM_HZ)   /* ARP aging timer */
46 #define SPANSARP_RETRY          (3 * ATM_HZ)    /* ARP retry timer */
47 #define SPANSARP_MAXAGE         20              /* Max ARP entry age (minutes)*/
48 #define SPANSARP_HASHSIZ        19              /* Hash table size */
49
50
51 /*
52  * SPANS CLS protocol structure.  There will be one such structure for 
53  * each SPANS signalling instance.
54  */
55 struct spanscls {
56         struct spanscls *cls_next;      /* Next attached cls instance */
57         u_char          cls_state;      /* Protocol state (see below) */
58         struct spans    *cls_spans;     /* Spans signalling instance */
59         Atm_connection  *cls_conn;      /* Connection manager token */
60         struct ip_nif   *cls_ipnif;     /* IP network interface */
61 };
62
63 /*
64  * SPANS CLS Protocol States
65  */
66 #define CLS_CLOSED      1               /* CLS PVC is closed */
67 #define CLS_OPEN        2               /* CLS PVC is open */
68
69
70 /*
71  * Structure for SPANS ARP mappings.  Each of these structures will contain 
72  * IP address to SPANS hardware address mappings.  There will be one such
73  * structure for each IP address currently in use.
74  */
75 struct spansarp {
76         struct arpmap   sa_arpmap;      /* Common entry header */
77         struct spanscls *sa_cls;        /* Interface where we learned answer */
78         struct spansarp *sa_next;       /* Hash chain */
79         struct spansarp *sa_rnext;      /* Retry chain */
80         u_char          sa_flags;       /* Flags (see below) */
81         u_char          sa_origin;      /* Origin (see below) */
82         u_short         sa_reftime;     /* Entry reference time (minutes) */
83         struct ipvcc    *sa_ivp;        /* IP VCCs waiting for answer */
84 };
85 #define sa_dstip        sa_arpmap.am_dstip
86 #define sa_dstatm       sa_arpmap.am_dstatm
87 #define sa_dstatmsub    sa_arpmap.am_dstatmsub
88
89 /*
90  * Entry Flags
91  */
92 #define SAF_VALID       ARPF_VALID      /* Entry is valid */
93 #define SAF_REFRESH     ARPF_REFRESH    /* Entry has been refreshed */
94 #define SAF_LOCKED      0x04            /* Entry is locked */
95
96 /*
97  * Entry Origin
98  */
99 #define SAO_PERM        ARP_ORIG_PERM   /* Entry is permanently installed */
100 #define SAO_LOOKUP      20              /* Learned via lookup */
101
102
103 /*
104  * SPANS CLS Packet Header
105  */
106 struct spanscls_hdr {
107         /* IEEE 802.6 MAC header */
108         spans_addr      ch_dst;         /* Destination SPANS address */
109         spans_addr      ch_src;         /* Source SPANS address */
110         u_char          ch_proto;       /* */
111         u_char          ch_extlen;      /* */
112         u_short         ch_bridging;    /* */
113
114         /* LLC SNAP header */
115         u_char          ch_dsap;        /* Destination SAP */
116         u_char          ch_ssap;        /* Source SAP */
117         u_char          ch_ctl;         /* Control field */
118         u_char          ch_oui[3];      /* Organizationally Unique Identifier */
119         u_short         ch_pid;         /* Protocol Identifier */
120 };
121
122 /*
123  * SPANS ARP Packet Format
124  */
125 struct spansarp_hdr {
126         u_short         ah_hrd;         /* Hardware type (see below) */
127         u_short         ah_pro;         /* Protocol type */
128         u_char          ah_hln;         /* Length of hardware address */
129         u_char          ah_pln;         /* Length of protocol address */
130         u_short         ah_op;          /* Operation code (see below) */
131         spans_addr      ah_sha;         /* Source hardware address */
132         u_char          ah_spa[4];      /* Source protocol address */
133         spans_addr      ah_tha;         /* Target hardware address */
134         u_char          ah_tpa[4];      /* Target protocol address */
135 };
136
137 /*
138  * Hardware types
139  */
140 #define ARP_SPANS       0x4040
141
142 /*
143  * Operation types
144  */
145 #define ARP_REQUEST     1               /* SPANSARP request */
146 #define ARP_REPLY       2               /* SPANSARP response */
147
148 #define ARP_PACKET_LEN  \
149         (sizeof(struct spanscls_hdr) + sizeof(struct spansarp_hdr))
150
151 #ifdef ATM_KERNEL
152 /*
153  * Macros for manipulating SPANS ARP tables and entries
154  */
155 #define SPANSARP_HASH(ip)       ((u_long)(ip) % SPANSARP_HASHSIZ)
156
157 #define SPANSARP_ADD(sa)                                                \
158 {                                                               \
159         struct spansarp **h;                                    \
160         h = &spansarp_arptab[SPANSARP_HASH((sa)->sa_dstip.s_addr)];     \
161         LINK2TAIL((sa), struct spansarp, *h, sa_next);          \
162 }
163
164 #define SPANSARP_DELETE(sa)                                     \
165 {                                                               \
166         struct spansarp **h;                                    \
167         h = &spansarp_arptab[SPANSARP_HASH((sa)->sa_dstip.s_addr)];     \
168         UNLINK((sa), struct spansarp, *h, sa_next);             \
169 }
170
171 #define SPANSARP_LOOKUP(ip, sa)                                 \
172 {                                                               \
173         for ((sa) = spansarp_arptab[SPANSARP_HASH(ip)];         \
174                                 (sa); (sa) = (sa)->sa_next) {   \
175                 if ((sa)->sa_dstip.s_addr == (ip))              \
176                         break;                                  \
177         }                                                       \
178 }
179
180
181 /*
182  * External variables
183  */
184 extern struct spanscls          *spanscls_head;
185 extern struct spanscls_hdr      spanscls_hdr;
186
187 #endif  /* ATM_KERNEL */
188
189 #endif  /* _SPANS_SPANSCLS_H */