]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netatm/uni/uniip_var.h
This commit was generated by cvs2svn to compensate for changes in r155290,
[FreeBSD/FreeBSD.git] / sys / netatm / uni / uniip_var.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$
27  *
28  */
29
30 /*
31  * ATM Forum UNI Support
32  * ---------------------
33  *
34  * IP interface control blocks
35  *
36  */
37
38 #ifndef _UNI_UNIIP_VAR_H
39 #define _UNI_UNIIP_VAR_H
40
41 #ifdef _KERNEL
42 /*
43  * UNI IP network interface structure.  There will be one such structure for 
44  * each IP network interface attached via a UNI signalling instance.
45  */
46 struct uniip {
47         struct uniip    *uip_next;      /* Next attached IP interface */
48         struct ip_nif   *uip_ipnif;     /* IP network interface */
49         u_char          uip_flags;      /* Interface flags (see below) */
50
51         /* ATMARP (RFC1577) */
52         u_char          uip_arpstate;   /* ARP interface state (see below) */
53         struct arpmap   uip_arpsvrmap;  /* ATMARP server map info */
54         struct ipvcc    *uip_arpsvrvcc; /* ATMARP server's VCC */
55         u_int           uip_nprefix;    /* Count of IP prefixes (server only) */
56         struct uniarp_prf *uip_prefix;  /* Array of IP prefixes (server only) */
57         struct atm_time uip_arptime;    /* ARP timer controls */
58 };
59 #define uip_arpsvrip    uip_arpsvrmap.am_dstip
60 #define uip_arpsvratm   uip_arpsvrmap.am_dstatm
61 #define uip_arpsvrsub   uip_arpsvrmap.am_dstatmsub
62 #endif  /* _KERNEL */
63
64 /*
65  * UNI Interface Flags
66  */
67 #define UIF_IFADDR      0x01            /* Interface address is set */
68
69 /*
70  * UNI ARP Interface States
71  */
72 #define UIAS_NOTCONF            1       /* Not configured */
73 #define UIAS_SERVER_ACTIVE      2       /* Server - active */
74 #define UIAS_CLIENT_PADDR       3       /* Client - pending ATM address */
75 #define UIAS_CLIENT_POPEN       4       /* Client - pending server vcc open */
76 #define UIAS_CLIENT_REGISTER    5       /* Client - registering with server */
77 #define UIAS_CLIENT_ACTIVE      6       /* Client - active */
78
79
80 #ifdef _KERNEL
81 /*
82  * Structure for allowable IP prefixes for ATMARP server registration
83  */
84 struct uniarp_prf {
85         struct in_addr  upf_addr;       /* Prefix address */
86         struct in_addr  upf_mask;       /* Prefix mask */
87 };
88
89
90 /*
91  * UNI ARP protocol constants
92  */
93 #define UNIARP_AGING            (60 * ATM_HZ)   /* Aging timer tick */
94 #define UNIARP_HASHSIZ          19      /* Hash table size */
95 #define UNIARP_REGIS_REFRESH    (15 * 60 * ATM_HZ)
96                                         /* Client registration refresh timer */
97 #define UNIARP_REGIS_RETRY      (60 * ATM_HZ)
98                                         /* Client registration retry timer */
99 #define UNIARP_ARP_RETRY        (3 * ATM_HZ)    /* ARP command retry timer */
100 #define UNIARP_CLIENT_AGE       12      /* Client validation timeout */
101 #define UNIARP_CLIENT_RETRY     3       /* Client validation retrys */
102 #define UNIARP_SERVER_AGE       17      /* Server validation timeout */
103 #define UNIARP_SERVER_RETRY     3       /* Server validation retrys */
104 #define UNIARP_RETRY_AGE        1       /* Retry timeout */
105 #define UNIARP_REVALID_AGE      2       /* Revalidation timeout */
106 #define UNIARP_MIN_REFRESH      10      /* Minimum entry refresh time */
107
108
109 /*
110  * Structure for ATMARP mappings.  Each of these structures will contain
111  * IP address to ATM hardware address mappings.  There will be one such
112  * structure for each IP address and for each unresolved ATM address
113  * currently in use.
114  */
115 struct uniarp {
116         struct arpmap   ua_arpmap;      /* Common entry header */
117         struct uniip    *ua_intf;       /* Interface where we learned answer */
118         struct uniarp   *ua_next;       /* Hash chain link */
119         u_char          ua_flags;       /* Flags (see below) */
120         u_char          ua_origin;      /* Source of mapping (see below) */
121         u_char          ua_retry;       /* Retry counter */
122         u_char          ua_aging;       /* Aging timeout value (minutes) */
123         struct ipvcc    *ua_ivp;        /* Head of IP VCC chain */
124         struct atm_time ua_time;        /* Timer controls */
125 };
126 #define ua_dstip        ua_arpmap.am_dstip
127 #define ua_dstatm       ua_arpmap.am_dstatm
128 #define ua_dstatmsub    ua_arpmap.am_dstatmsub
129 #endif  /* _KERNEL */
130
131 /*
132  * UNIARP Entry Flags
133  */
134 #define UAF_VALID       ARPF_VALID      /* Entry is valid */
135 #define UAF_REFRESH     ARPF_REFRESH    /* Entry has been refreshed */
136 #define UAF_LOCKED      0x04            /* Entry is locked */
137 #define UAF_USED        0x08            /* Entry has been used recently */
138
139 /*
140  * UNIARP Entry Origin
141  *
142  * The origin values are ranked according to the source precedence.  
143  * Larger values are more preferred.
144  */
145 #define UAO_LOCAL       100             /* Local address */
146 #define UAO_PERM        ARP_ORIG_PERM   /* Permanently installed */
147 #define UAO_REGISTER    40              /* Learned via client registration */
148 #define UAO_SCSP        30              /* Learned via SCSP */
149 #define UAO_LOOKUP      20              /* Learned via server lookup */
150 #define UAO_PEER_RSP    15              /* Learned from peer - inarp rsp */
151 #define UAO_PEER_REQ    10              /* Learned from peer - inarp req */
152
153 /*
154  * ATMARP/InATMARP Packet Format
155  */
156 struct atmarp_hdr {
157         u_short         ah_hrd;         /* Hardware type (see below) */
158         u_short         ah_pro;         /* Protocol type */
159         u_char          ah_shtl;        /* Type/len of source ATM address */
160         u_char          ah_sstl;        /* Type/len of source ATM subaddress */
161         u_short         ah_op;          /* Operation code (see below) */
162         u_char          ah_spln;        /* Length of source protocol address */
163         u_char          ah_thtl;        /* Type/len of target ATM address */
164         u_char          ah_tstl;        /* Type/len of target ATM subaddress */
165         u_char          ah_tpln;        /* Length of target protocol address */
166 #ifdef notdef
167         /* Variable size fields */
168         u_char          ah_sha[];       /* Source ATM address */
169         u_char          ah_ssa[];       /* Source ATM subaddress */
170         u_char          ah_spa[];       /* Source protocol address */
171         u_char          ah_tha[];       /* Target ATM subaddress */
172         u_char          ah_tsa[];       /* Target ATM address */
173         u_char          ah_tpa[];       /* Target protocol subaddress */
174 #endif
175 };
176
177 /*
178  * Hardware types
179  */
180 #define ARP_ATMFORUM    19
181
182 /*
183  * Operation types
184  */
185 #define ARP_REQUEST     1               /* ATMARP request */
186 #define ARP_REPLY       2               /* ATMARP response */
187 #define INARP_REQUEST   8               /* InATMARP request */
188 #define INARP_REPLY     9               /* InATMARP response */
189 #define ARP_NAK         10              /* ATMARP negative ack */
190
191 /*
192  * Type/length fields
193  */
194 #define ARP_TL_TMASK    0x40            /* Type mask */
195 #define ARP_TL_NSAPA    0x00            /* Type = ATM Forum NSAPA */
196 #define ARP_TL_E164     0x40            /* Type = E.164 */
197 #define ARP_TL_LMASK    0x3f            /* Length mask */
198
199
200 #ifdef _KERNEL
201 /*
202  * Timer macros
203  */
204 #define UNIIP_ARP_TIMER(s, t)   atm_timeout(&(s)->uip_arptime, (t), uniarp_iftimeout)
205 #define UNIIP_ARP_CANCEL(s)     atm_untimeout(&(s)->uip_arptime)
206 #define UNIARP_TIMER(s, t)      atm_timeout(&(s)->ua_time, (t), uniarp_timeout)
207 #define UNIARP_CANCEL(s)        atm_untimeout(&(s)->ua_time)
208
209
210 /*
211  * Macros for manipulating UNIARP tables and entries
212  */
213 #define UNIARP_HASH(ip) ((u_long)(ip) % UNIARP_HASHSIZ)
214
215 #define UNIARP_ADD(ua)                                          \
216 {                                                               \
217         struct uniarp   **h;                                    \
218         h = &uniarp_arptab[UNIARP_HASH((ua)->ua_dstip.s_addr)]; \
219         LINK2TAIL((ua), struct uniarp, *h, ua_next);            \
220 }
221
222 #define UNIARP_DELETE(ua)                                       \
223 {                                                               \
224         struct uniarp   **h;                                    \
225         h = &uniarp_arptab[UNIARP_HASH((ua)->ua_dstip.s_addr)]; \
226         UNLINK((ua), struct uniarp, *h, ua_next);               \
227 }
228
229 #define UNIARP_LOOKUP(ip, ua)                                   \
230 {                                                               \
231         for ((ua) = uniarp_arptab[UNIARP_HASH(ip)];             \
232                                 (ua); (ua) = (ua)->ua_next) {   \
233                 if ((ua)->ua_dstip.s_addr == (ip))              \
234                         break;                                  \
235         }                                                       \
236 }
237
238
239 /*
240  * Global UNIARP Statistics
241  */
242 struct uniarp_stat {
243         u_long          uas_rcvdrop;    /* Input packets dropped */
244 };
245
246
247 /*
248  * External variables
249  */
250 extern struct uniip             *uniip_head;
251 extern struct ip_serv           uniip_ipserv;
252 extern struct uniarp            *uniarp_arptab[];
253 extern struct uniarp            *uniarp_nomaptab;
254 extern struct uniarp            *uniarp_pvctab;
255 extern uma_zone_t       uniarp_zone;
256 extern struct atm_time          uniarp_timer;
257 extern int                      uniarp_print;
258 extern Atm_endpoint             uniarp_endpt;
259 extern struct uniarp_stat       uniarp_stat;
260
261
262 /*
263  * Global function declarations
264  */
265         /* uniarp.c */
266 int             uniarp_start(void);
267 void            uniarp_stop(void);
268 void            uniarp_ipact(struct uniip *);
269 void            uniarp_ipdact(struct uniip *);
270 void            uniarp_ifaddr(struct siginst *);
271 void            uniarp_iftimeout(struct atm_time *);
272 int             uniarp_ioctl(int, caddr_t, caddr_t);
273 caddr_t         uniarp_getname(void *);
274
275         /* uniarp_cache.c */
276 int             uniarp_cache_svc(struct uniip *, struct in_addr *,
277                         Atm_addr *, Atm_addr *, u_int);
278 void            uniarp_cache_pvc(struct ipvcc *, struct in_addr *,
279                         Atm_addr *, Atm_addr *);
280 int             uniarp_validate_ip(struct uniip *, struct in_addr *, u_int);
281
282         /* uniarp_input.c */
283 void            uniarp_cpcs_data(void *, KBuffer *);
284 void            uniarp_pdu_print(const struct ipvcc *,
285                     const KBuffer *, const char *);
286
287         /* uniarp_output.c */
288 int             uniarp_arp_req(struct uniip *, struct in_addr *);
289 int             uniarp_arp_rsp(struct uniip *, struct arpmap *,
290                         struct in_addr *, Atm_addr *,
291                         Atm_addr *, struct ipvcc *);
292 int             uniarp_arp_nak(struct uniip *, KBuffer *, struct ipvcc *);
293 int             uniarp_inarp_req(struct uniip *, Atm_addr *,
294                         Atm_addr *, struct ipvcc *);
295 int             uniarp_inarp_rsp(struct uniip *, struct in_addr *,
296                         Atm_addr *, Atm_addr *, struct ipvcc *);
297
298         /* uniarp_timer.c */
299 void            uniarp_timeout(struct atm_time *);
300 void            uniarp_aging(struct atm_time *);
301
302         /* uniarp_vcm.c */
303 int             uniarp_pvcopen(struct ipvcc *);
304 int             uniarp_svcout(struct ipvcc *, struct in_addr *);
305 int             uniarp_svcin(struct ipvcc *, Atm_addr *, Atm_addr *);
306 int             uniarp_svcactive(struct ipvcc *);
307 void            uniarp_vcclose(struct ipvcc *);
308 void            uniarp_connected(void *);
309 void            uniarp_cleared(void *, struct t_atm_cause *);
310
311         /* uniip.c */
312 int             uniip_start(void);
313 int             uniip_stop(void);
314
315
316 #endif  /* _KERNEL */
317
318 #endif  /* _UNI_UNIIP_VAR_H */