Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / netproto / atm / uni / unisig_proto.c
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/uni/unisig_proto.c,v 1.5 2000/01/17 20:49:57 mks Exp $
27  *      @(#) $DragonFly: src/sys/netproto/atm/uni/unisig_proto.c,v 1.2 2003/06/17 04:28:49 dillon Exp $
28  */
29
30 /*
31  * ATM Forum UNI 3.0/3.1 Signalling Manager
32  * ----------------------------------------
33  *
34  * Protocol processing module.
35  *
36  */
37
38 #include <netatm/kern_include.h>
39
40 #include <netatm/uni/unisig_var.h>
41
42 /*
43  * Process a UNISIG timeout
44  *
45  * Called when a previously scheduled protocol instance control block
46  * timer expires.  This routine passes a timeout event to the UNISIG
47  * signalling manager state machine.
48  *
49  * Called at splnet.
50  *
51  * Arguments:
52  *      tip     pointer to UNISIG timer control block
53  *
54  * Returns:
55  *      none
56  *
57  */
58 void
59 unisig_timer(tip)
60         struct atm_time *tip;
61 {
62         struct unisig   *usp;
63
64         /*
65          * Back-off to UNISIG control block
66          */
67         usp = (struct unisig *)
68                 ((caddr_t)tip - (int)(&((struct unisig *)0)->us_time));
69
70         ATM_DEBUG2("unisig_timer: usp=%p,state=%d\n",
71                         usp, usp->us_state);
72
73         /*
74          * Pass the timeout to the signalling manager state machine
75          */
76         (void) unisig_sigmgr_state(usp,
77                         UNISIG_SIGMGR_TIMEOUT,
78                         (KBuffer *) 0);
79 }
80
81
82 /*
83  * Process a UNISIG VCC timeout
84  *
85  * Called when a previously scheduled UNISIG VCCB timer expires.
86  * Processing will based on the current VCC state.
87  *
88  * Called at splnet.
89  *
90  * Arguments:
91  *      tip     pointer to vccb timer control block
92  *
93  * Returns:
94  *      none
95  *
96  */
97 void
98 unisig_vctimer(tip)
99         struct atm_time *tip;
100 {
101         struct unisig           *usp;
102         struct unisig_vccb      *uvp;
103
104         /*
105          * Get VCCB and UNISIG control block addresses
106          */
107         uvp = (struct unisig_vccb *) ((caddr_t)tip -
108                         (int)(&((struct vccb *)0)->vc_time));
109         usp = (struct unisig *)uvp->uv_pif->pif_siginst;
110
111         ATM_DEBUG3("unisig_vctimer: uvp=%p, sstate=%d, ustate=%d\n",
112                         uvp, uvp->uv_sstate, uvp->uv_ustate);
113
114         /*
115          * Hand the timeout to the VC finite state machine
116          */
117         if (uvp->uv_ustate == VCCU_ABORT) {
118                 /*
119                  * If we're aborting, this is an ABORT call
120                  */
121                 (void) unisig_vc_state(usp, uvp, UNI_VC_ABORT_CALL,
122                                 (struct unisig_msg *) 0);
123         } else {
124                 /*
125                  * If we're not aborting, it's a timeout
126                  */
127                 (void) unisig_vc_state(usp, uvp, UNI_VC_TIMEOUT,
128                                 (struct unisig_msg *) 0);
129         }
130 }
131
132
133 /*
134  * UNISIG SAAL Control Handler
135  *
136  * This is the module which receives data on the UNISIG signalling
137  * channel.  Processing is based on the indication received from the
138  * SSCF and the protocol state.
139  *
140  * Arguments:
141  *      cmd     command code
142  *      tok     session token (pointer to UNISIG protocol control block)
143  *      a1      argument 1
144  *
145  * Returns:
146  *      none
147  *
148  */
149 void
150 unisig_saal_ctl(cmd, tok, a1)
151         int             cmd;
152         void            *tok;
153         void            *a1;
154 {
155         struct unisig   *usp = tok;
156
157         ATM_DEBUG4("unisig_upper: usp=%p,state=%d,cmd=%d,a1=0x%lx,\n",
158                         usp, usp->us_state, cmd, (u_long)a1);
159
160         /*
161          * Process command
162          */
163         switch (cmd) {
164
165         case SSCF_UNI_ESTABLISH_IND:
166                 (void) unisig_sigmgr_state(usp,
167                                 UNISIG_SIGMGR_SSCF_EST_IND,
168                                 (KBuffer *) 0);
169                 break;
170
171         case SSCF_UNI_ESTABLISH_CNF:
172                 (void) unisig_sigmgr_state(usp,
173                                 UNISIG_SIGMGR_SSCF_EST_CNF,
174                                 (KBuffer *) 0);
175                 break;
176
177         case SSCF_UNI_RELEASE_IND:
178                 (void) unisig_sigmgr_state(usp,
179                                 UNISIG_SIGMGR_SSCF_RLS_IND,
180                                 (KBuffer *) 0);
181                 break;
182
183         case SSCF_UNI_RELEASE_CNF:
184                 (void) unisig_sigmgr_state(usp,
185                                 UNISIG_SIGMGR_SSCF_RLS_CNF,
186                                 (KBuffer *) 0);
187                 break;
188
189         default:
190                 log(LOG_ERR,
191                         "unisig: unknown SAAL cmd: usp=%p, state=%d, cmd=%d\n",
192                         usp, usp->us_state, cmd);
193         }
194 }
195
196
197 /*
198  * UNISIG SAAL Data Handler
199  *
200  * This is the module which receives data on the UNISIG signalling
201  * channel.  Processing is based on the protocol state.
202  *
203  * Arguments:
204  *      tok     session token (pointer to UNISIG protocol control block)
205  *      m       pointer to data
206  *
207  * Returns:
208  *      none
209  *
210  */
211 void
212 unisig_saal_data(tok, m)
213         void            *tok;
214         KBuffer         *m;
215 {
216         struct unisig   *usp = tok;
217
218         ATM_DEBUG3("unisig_saal_data: usp=%p,state=%d,m=%p,\n",
219                         usp, usp->us_state, m);
220
221         /*
222          * Pass data to signalling manager state machine
223          */
224         (void) unisig_sigmgr_state(usp,
225                         UNISIG_SIGMGR_SSCF_DATA_IND,
226                         m);
227 }
228
229
230 /*
231  * Get Connection's Application/Owner Name
232  *
233  * Arguments:
234  *      tok     UNI signalling connection token (pointer to protocol instance)
235  *
236  * Returns:
237  *      addr    pointer to string containing our name
238  *
239  */
240 caddr_t
241 unisig_getname(tok)
242         void            *tok;
243 {
244         struct unisig   *usp = tok;
245
246         if (usp->us_proto == ATM_SIG_UNI30)
247                 return ("UNI3.0");
248         else if (usp->us_proto == ATM_SIG_UNI31)
249                 return ("UNI3.1");
250         else if (usp->us_proto == ATM_SIG_UNI40)
251                 return ("UNI4.0");
252         else
253                 return ("UNI");
254 }
255
256
257 /*
258  * Process a VCC connection notification
259  *
260  * Should never be called.
261  *
262  * Arguments:
263  *      tok     user's connection token (unisig protocol block)
264  *
265  * Returns:
266  *      none
267  *
268  */
269 void
270 unisig_connected(tok)
271         void            *tok;
272 {
273         struct unisig           *usp = tok;
274
275         ATM_DEBUG2("unisig_connected: usp=%p,state=%d\n",
276                         usp, usp->us_state);
277
278         /*
279          * Connected routine shouldn't ever get called for a PVC
280          */
281         log(LOG_ERR, "unisig: connected notification, usp=%p\n",
282                         usp);
283 }
284
285
286 /*
287  * Process a VCC closed notification
288  *
289  * Called when UNISIG signalling channel is closed.
290  *
291  * Arguments:
292  *      tok     user's connection token (unisig protocol block)
293  *      cp      pointer to cause structure
294  *
295  * Returns:
296  *      none
297  *
298  */
299 void
300 unisig_cleared(tok, cp)
301         void                    *tok;
302         struct t_atm_cause      *cp;
303 {
304         struct unisig           *usp = tok;
305
306         ATM_DEBUG3("unisig_cleared: usp=%p, state=%d, cause=%d\n",
307                         usp, usp->us_state, cp->cause_value);
308
309         /*
310          * VCC has been closed.  Notify the signalling
311          * manager state machine.
312          */
313         (void) unisig_sigmgr_state(usp,
314                         UNISIG_SIGMGR_CALL_CLEARED,
315                         (KBuffer *) 0);
316 }