]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/i4b/layer2/i4b_lme.c
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / i4b / layer2 / i4b_lme.c
1 /*-
2  * Copyright (c) 1997, 2002 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  *
28  *      i4b_lme.c - layer management entity
29  *      -------------------------------------
30  *      last edit-date: [Sat Mar  9 17:49:42 2002]
31  *
32  *---------------------------------------------------------------------------*/
33
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/socket.h>
40 #include <net/if.h>
41
42 #include <i4b/include/i4b_debug.h>
43
44 #include <i4b/layer2/i4b_l2.h>
45
46 /*---------------------------------------------------------------------------*
47  *      mdl assign indication handler
48  *---------------------------------------------------------------------------*/
49 void
50 i4b_mdl_assign_ind(l2_softc_t *l2sc)
51 {
52         NDBGL2(L2_PRIM, "unit %d", l2sc->unit);
53         
54         i4b_l1_activate(l2sc);
55         
56         if(l2sc->tei_valid == TEI_VALID)
57         {
58                 l2sc->T202func = (void(*)(void*))i4b_tei_verify;
59                 l2sc->N202 = N202DEF;
60                 i4b_tei_verify(l2sc);
61         }
62         else
63         {
64                 l2sc->T202func = (void(*)(void*))i4b_tei_assign;
65                 l2sc->N202 = N202DEF;
66                 i4b_tei_assign(l2sc);
67         }               
68 }
69
70 /*---------------------------------------------------------------------------*
71  *      i4b_mdl_error_ind handler (Q.921 01/94 pp 156)
72  *---------------------------------------------------------------------------*/
73 void
74 i4b_mdl_error_ind(l2_softc_t *l2sc, char *where, int errorcode)
75 {
76 #if DO_I4B_DEBUG
77         static char *error_text[] = {
78                 "MDL_ERR_A: rx'd unsolicited response - supervisory (F=1)",
79                 "MDL_ERR_B: rx'd unsolicited response - DM (F=1)",
80                 "MDL_ERR_C: rx'd unsolicited response - UA (F=1)",
81                 "MDL_ERR_D: rx'd unsolicited response - UA (F=0)",
82                 "MDL_ERR_E: rx'd unsolicited response - DM (F=0)",
83                 "MDL_ERR_F: peer initiated re-establishment - SABME",
84                 "MDL_ERR_G: unsuccessful transmission N200times - SABME",
85                 "MDL_ERR_H: unsuccessful transmission N200times - DIS",
86                 "MDL_ERR_I: unsuccessful transmission N200times - Status ENQ",
87                 "MDL_ERR_J: other error - N(R) error",
88                 "MDL_ERR_K: other error - rx'd FRMR response",
89                 "MDL_ERR_L: other error - rx'd undefined frame",
90                 "MDL_ERR_M: other error - receipt of I field not permitted",
91                 "MDL_ERR_N: other error - rx'd frame with wrong size",
92                 "MDL_ERR_O: other error - N201 error",
93                 "MDL_ERR_MAX: i4b_mdl_error_ind called with wrong parameter!!!"
94         };
95 #endif
96
97         if(errorcode > MDL_ERR_MAX)
98                 errorcode = MDL_ERR_MAX;
99                 
100         NDBGL2(L2_ERROR, "unit = %d, location = %s", l2sc->unit, where);
101         NDBGL2(L2_ERROR, "error = %s", error_text[errorcode]);
102
103         switch(errorcode)
104         {       
105                 case MDL_ERR_A:
106                 case MDL_ERR_B:
107                         break;
108
109                 case MDL_ERR_C:
110                 case MDL_ERR_D:
111                         i4b_tei_verify(l2sc);
112                         break;
113
114                 case MDL_ERR_E:
115                 case MDL_ERR_F:
116                         break;
117
118                 case MDL_ERR_G:
119                 case MDL_ERR_H:
120                         i4b_tei_verify(l2sc);
121                         break;
122
123                 case MDL_ERR_I:
124                 case MDL_ERR_J:
125                 case MDL_ERR_K:
126                 case MDL_ERR_L:
127                 case MDL_ERR_M:
128                 case MDL_ERR_N:
129                 case MDL_ERR_O:
130                         break;
131
132                 default:
133                         break;
134         }
135 }