]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/sys/netatm/ipatm/ipatm_var.h
Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
[FreeBSD/FreeBSD.git] / 6 / sys / netatm / ipatm / ipatm_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  * IP Over ATM Support
32  * -------------------
33  *
34  * Protocol control blocks
35  *
36  */
37
38 #ifndef _IPATM_IPATM_VAR_H
39 #define _IPATM_IPATM_VAR_H
40
41 #ifdef _KERNEL
42 /*
43  * Structure containing information for each VCC, both SVC and PVC, which
44  * supports IP traffic.
45  */
46 struct ipvcc {
47         Qelem_t         iv_elem;        /* ip_nif queueing links */
48         u_short         iv_flags;       /* VCC flags (see below) */
49         u_char          iv_state;       /* VCC state (see below) */
50         Atm_connection  *iv_conn;       /* Connection manager token */
51         struct in_addr  iv_dst;         /* Peer's IP address */
52         struct ip_nif   *iv_ipnif;      /* IP network interface */
53         struct atm_time iv_time;        /* Timer controls */
54         short           iv_idle;        /* VCC idle timer */
55         u_char          iv_parmx;       /* Index into provider's vcc params */ 
56         KBuffer         *iv_queue;      /* Packet waiting for VCC */
57         struct arpmap   *iv_arpent;     /* ARP entry for VCC */
58         struct ipvcc    *iv_arpnext;    /* ARP link field */
59         Atm_connection  *iv_arpconn;    /* ARP connection manager token */
60 };
61 #define iv_forw         iv_elem.q_forw
62 #define iv_back         iv_elem.q_back
63 #endif  /* _KERNEL */
64
65 /*
66  * VCC Flags
67  */
68 #define IVF_PVC         0x0001          /* PVC */
69 #define IVF_SVC         0x0002          /* SVC */
70 #define IVF_LLC         0x0004          /* VCC uses LLC/SNAP encapsulation */
71 #define IVF_MAPOK       0x0008          /* VCC ARP mapping is valid */
72 #define IVF_NOIDLE      0x0010          /* Do not idle-timeout this VCC */
73
74 /*
75  * VCC States
76  */
77 #define IPVCC_FREE      0               /* No VCC associated with entry */
78 #define IPVCC_PMAP      1               /* SVC waiting for ARP mapping */
79 #define IPVCC_POPEN     2               /* Pending SVC open completion */
80 #define IPVCC_PACCEPT   3               /* Pending SVC accept completion */
81 #define IPVCC_ACTPENT   4               /* PVC open - waiting for ARP entry */
82 #define IPVCC_ACTIVE    5               /* VCC open - available */
83 #define IPVCC_CLOSED    6               /* VCC has been closed */
84
85
86 #ifdef _KERNEL
87 /*
88  * Structure containing IP-specific information for each ATM network
89  * interface in the system.
90  */
91 struct ip_nif {
92         struct ip_nif   *inf_next;      /* Next on interface chain */
93         struct atm_nif  *inf_nif;       /* ATM network interface */
94         u_short         inf_state;      /* Interface state (see below) */
95         struct in_ifaddr *inf_addr;     /* Interface's IP address */
96         Queue_t         inf_vcq;        /* VCC connections queue */
97         struct ip_serv  *inf_serv;      /* Interface service provider */
98
99 /* For use by IP interface service provider (ie signalling manager) */
100         caddr_t         inf_isintf;     /* Interface control block */
101
102 /* IP/ATM provided interface services */
103         void            (*inf_arpnotify)/* ARP event notification */
104                                 (struct ipvcc *, int);
105         int             (*inf_ipinput)  /* IP packet input */
106                                 (struct ip_nif *, KBuffer *);
107         int             (*inf_createsvc)/* Create an IP SVC */
108                                 (struct ifnet *, u_short, caddr_t,
109                                      struct ipvcc **);
110 };
111
112 /*
113  * Network Interface States
114  */
115 #define IPNIF_ADDR      1               /* Waiting for i/f address */
116 #define IPNIF_SIGMGR    2               /* Waiting for sigmgr attach */
117 #define IPNIF_ACTIVE    3               /* Active */
118
119
120 /*
121  * Global IP/ATM Statistics
122  */
123 struct ipatm_stat {
124         u_long          ias_rcvstate;   /* Packets received, bad vcc state */
125         u_long          ias_rcvnobuf;   /* Packets received, no buf avail */
126 };
127
128
129 /*
130  * Structure to pass parameters for ipatm_openpvc()
131  */
132 struct ipatmpvc {
133         struct ip_nif   *ipp_ipnif;     /* PVC's IP network interface */
134         u_short         ipp_vpi;        /* VPI value */
135         u_short         ipp_vci;        /* VCI value */
136         Aal_t           ipp_aal;        /* AAL type */
137         Encaps_t        ipp_encaps;     /* VCC encapsulation */
138         struct sockaddr_in ipp_dst;     /* Destination's IP address */
139         uint8_t         ipp_traffic_type;       /* CBR, UBR, ... */
140         struct t_atm_traffic ipp_traffic;       /* traffic parameters */
141 };
142
143
144 /*
145  * Timer macros
146  */
147 #define IPVCC_TIMER(s, t)       atm_timeout(&(s)->iv_time, (t), ipatm_timeout)
148 #define IPVCC_CANCEL(s)         atm_untimeout(&(s)->iv_time)
149
150 /*
151  * Misc useful macros
152  */
153 #define SATOSIN(sa)     ((struct sockaddr_in *)(sa))
154
155
156 /*
157  * Global function declarations
158  */
159         /* ipatm_event.c */
160 void            ipatm_timeout(struct atm_time *);
161 void            ipatm_connected(void *);
162 void            ipatm_cleared(void *, struct t_atm_cause *);
163 void            ipatm_arpnotify(struct ipvcc *, int);
164 void            ipatm_itimeout(struct atm_time *);
165
166         /* ipatm_if.c */
167 int             ipatm_nifstat(int, struct atm_nif *, intptr_t);
168
169         /* ipatm_input.c */
170 void            ipatm_cpcs_data(void *, KBuffer *);
171 int             ipatm_ipinput(struct ip_nif *, KBuffer *);
172
173         /* ipatm_load.c */
174
175         /* ipatm_output.c */
176 int             ipatm_ifoutput(struct ifnet *, KBuffer *, struct sockaddr *);
177
178         /* ipatm_usrreq.c */
179 int             ipatm_ioctl(int, caddr_t, caddr_t);
180 caddr_t         ipatm_getname(void *);
181
182         /* ipatm_vcm.c */
183 int             ipatm_openpvc(struct ipatmpvc *, struct ipvcc **);
184 int             ipatm_createsvc(struct ifnet *, u_short, caddr_t,
185                         struct ipvcc **);
186 int             ipatm_opensvc(struct ipvcc *);
187 int             ipatm_retrysvc(struct ipvcc *);
188 void            ipatm_activate(struct ipvcc *);
189 int             ipatm_incoming(void *, Atm_connection *, Atm_attributes *,
190                         void **);
191 int             ipatm_closevc(struct ipvcc *, int);
192 int             ipatm_chknif(struct in_addr, struct ip_nif *);
193 struct ipvcc    *ipatm_iptovc(struct sockaddr_in *, struct atm_nif *);
194  
195
196 /*
197  * External variables
198  */
199 extern int              ipatm_vccnt;
200 extern int              ipatm_vcidle;
201 extern int              ipatm_print;
202 extern u_long           last_map_ipdst;
203 extern struct ipvcc     *last_map_ipvcc;
204 extern struct ip_nif    *ipatm_nif_head;
205 extern uma_zone_t       ipatm_vc_zone;
206 extern struct ipatm_stat        ipatm_stat;
207 extern struct atm_time  ipatm_itimer;
208 extern Atm_endpoint     ipatm_endpt;
209 extern Atm_attributes   ipatm_aal5llc;
210 extern Atm_attributes   ipatm_aal5null;
211 extern Atm_attributes   ipatm_aal4null;
212
213 #ifdef SYSCTL_DECL
214 SYSCTL_DECL(_net_harp_ip);
215 #endif
216
217 #endif  /* _KERNEL */
218
219 #endif  /* _IPATM_IPATM_VAR_H */