]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/i4b/layer2/i4b_lme.c
This commit was generated by cvs2svn to compensate for changes in r53809,
[FreeBSD/FreeBSD.git] / sys / i4b / layer2 / i4b_lme.c
1 /*
2  * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  *---------------------------------------------------------------------------
26  *
27  *      i4b_lme.c - layer management entity
28  *      -------------------------------------
29  *
30  * $FreeBSD$ 
31  *
32  *      last edit-date: [Sun Feb 14 10:31:55 1999]
33  *
34  *---------------------------------------------------------------------------*/
35
36 #ifdef __FreeBSD__
37 #include "i4bq921.h"
38 #else
39 #define NI4BQ921        1
40 #endif
41 #if NI4BQ921 > 0
42
43 #include <sys/param.h>
44 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
45 #include <sys/ioccom.h>
46 #else
47 #include <sys/ioctl.h>
48 #endif
49 #include <sys/kernel.h>
50 #include <sys/systm.h>
51 #include <sys/mbuf.h>
52 #include <sys/socket.h>
53 #include <net/if.h>
54
55 #ifdef __FreeBSD__
56 #include <machine/i4b_debug.h>
57 #include <machine/i4b_ioctl.h>
58 #else
59 #include <i4b/i4b_debug.h>
60 #include <i4b/i4b_ioctl.h>
61 #endif
62
63 #include <i4b/include/i4b_l1l2.h>
64 #include <i4b/include/i4b_l2l3.h>
65 #include <i4b/include/i4b_isdnq931.h>
66 #include <i4b/include/i4b_mbuf.h>
67
68 #include <i4b/layer2/i4b_l2.h>
69 #include <i4b/layer2/i4b_l2fsm.h>
70
71 /*---------------------------------------------------------------------------*
72  *      mdl assign indication handler
73  *---------------------------------------------------------------------------*/
74 void
75 i4b_mdl_assign_ind(l2_softc_t *l2sc)
76 {
77         DBGL2(L2_PRIM, "MDL-ASSIGN-IND", ("unit %d\n", l2sc->unit));
78         
79         i4b_l1_activate(l2sc);
80         
81         if(l2sc->tei_valid == TEI_VALID)
82         {
83                 l2sc->T202func = (void(*)(void*))i4b_tei_verify;
84                 l2sc->N202 = N202DEF;
85                 i4b_tei_verify(l2sc);
86         }
87         else
88         {
89                 l2sc->T202func = (void(*)(void*))i4b_tei_assign;
90                 l2sc->N202 = N202DEF;
91                 i4b_tei_assign(l2sc);
92         }               
93 }
94
95 /*---------------------------------------------------------------------------*
96  *      i4b_mdl_error_ind handler (Q.921 01/94 pp 156)
97  *---------------------------------------------------------------------------*/
98 void
99 i4b_mdl_error_ind(l2_softc_t *l2sc, char *where, int errorcode)
100 {
101         static char *error_text[] = {
102                 "MDL_ERR_A: rx'd unsolicited response - supervisory (F=1)",
103                 "MDL_ERR_B: rx'd unsolicited response - DM (F=1)",
104                 "MDL_ERR_C: rx'd unsolicited response - UA (F=1)",
105                 "MDL_ERR_D: rx'd unsolicited response - UA (F=0)",
106                 "MDL_ERR_E: rx'd unsolicited response - DM (F=0)",
107                 "MDL_ERR_F: peer initiated re-establishment - SABME",
108                 "MDL_ERR_G: unsuccessful transmission N200times - SABME",
109                 "MDL_ERR_H: unsuccessful transmission N200times - DIS",
110                 "MDL_ERR_I: unsuccessful transmission N200times - Status ENQ",
111                 "MDL_ERR_J: other error - N(R) error",
112                 "MDL_ERR_K: other error - rx'd FRMR response",
113                 "MDL_ERR_L: other error - rx'd undefined frame",
114                 "MDL_ERR_M: other error - receipt of I field not permitted",
115                 "MDL_ERR_N: other error - rx'd frame with wrong size",
116                 "MDL_ERR_O: other error - N201 error",
117                 "MDL_ERR_MAX: i4b_mdl_error_ind called with wrong parameter!!!"
118         };
119
120         if(errorcode > MDL_ERR_MAX)
121                 errorcode = MDL_ERR_MAX;
122                 
123         DBGL2(L2_ERROR, "i4b_mdl_error_ind", ("unit = %d, location = %s\n", l2sc->unit, where));
124         DBGL2(L2_ERROR, "i4b_mdl_error_ind", ("error = %s\n", error_text[errorcode]));
125
126         switch(errorcode)
127         {       
128                 case MDL_ERR_A:
129                 case MDL_ERR_B:
130                         break;
131
132                 case MDL_ERR_C:
133                 case MDL_ERR_D:
134                         i4b_tei_verify(l2sc);
135                         break;
136
137                 case MDL_ERR_E:
138                 case MDL_ERR_F:
139                         break;
140
141                 case MDL_ERR_G:
142                 case MDL_ERR_H:
143                         i4b_tei_verify(l2sc);
144                         break;
145
146                 case MDL_ERR_I:
147                 case MDL_ERR_J:
148                 case MDL_ERR_K:
149                 case MDL_ERR_L:
150                 case MDL_ERR_M:
151                 case MDL_ERR_N:
152                 case MDL_ERR_O:
153                         break;
154
155                 default:
156                         break;
157         }
158 }
159  
160 #endif /* NI4BQ921 > 0 */