Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / sys / net / i4b / layer2 / i4b_lme.c
1 /*
2  * Copyright (c) 1997, 2000 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  *      $Id: i4b_lme.c,v 1.15 2000/08/24 11:48:58 hm Exp $ 
31  *
32  * $FreeBSD: src/sys/i4b/layer2/i4b_lme.c,v 1.6.2.1 2001/08/10 14:08:41 obrien Exp $
33  * $DragonFly: src/sys/net/i4b/layer2/i4b_lme.c,v 1.5 2005/06/14 21:19:19 joerg Exp $
34  *
35  *      last edit-date: [Mon May 29 16:55:12 2000]
36  *
37  *---------------------------------------------------------------------------*/
38
39 #include "use_i4bq921.h"
40 #if NI4BQ921 > 0
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/socket.h>
45 #include <net/if.h>
46
47 #include <net/i4b/include/machine/i4b_debug.h>
48
49 #include "i4b_l2.h"
50
51 /*---------------------------------------------------------------------------*
52  *      mdl assign indication handler
53  *---------------------------------------------------------------------------*/
54 void
55 i4b_mdl_assign_ind(l2_softc_t *l2sc)
56 {
57         NDBGL2(L2_PRIM, "unit %d", l2sc->unit);
58         
59         i4b_l1_activate(l2sc);
60         
61         if(l2sc->tei_valid == TEI_VALID)
62         {
63                 l2sc->T202func = (void(*)(void*))i4b_tei_verify;
64                 l2sc->N202 = N202DEF;
65                 i4b_tei_verify(l2sc);
66         }
67         else
68         {
69                 l2sc->T202func = (void(*)(void*))i4b_tei_assign;
70                 l2sc->N202 = N202DEF;
71                 i4b_tei_assign(l2sc);
72         }               
73 }
74
75 /*---------------------------------------------------------------------------*
76  *      i4b_mdl_error_ind handler (Q.921 01/94 pp 156)
77  *---------------------------------------------------------------------------*/
78 void
79 i4b_mdl_error_ind(l2_softc_t *l2sc, char *where, int errorcode)
80 {
81 #if DO_I4B_DEBUG
82         static char *error_text[] = {
83                 "MDL_ERR_A: rx'd unsolicited response - supervisory (F=1)",
84                 "MDL_ERR_B: rx'd unsolicited response - DM (F=1)",
85                 "MDL_ERR_C: rx'd unsolicited response - UA (F=1)",
86                 "MDL_ERR_D: rx'd unsolicited response - UA (F=0)",
87                 "MDL_ERR_E: rx'd unsolicited response - DM (F=0)",
88                 "MDL_ERR_F: peer initiated re-establishment - SABME",
89                 "MDL_ERR_G: unsuccessful transmission N200times - SABME",
90                 "MDL_ERR_H: unsuccessful transmission N200times - DIS",
91                 "MDL_ERR_I: unsuccessful transmission N200times - Status ENQ",
92                 "MDL_ERR_J: other error - N(R) error",
93                 "MDL_ERR_K: other error - rx'd FRMR response",
94                 "MDL_ERR_L: other error - rx'd undefined frame",
95                 "MDL_ERR_M: other error - receipt of I field not permitted",
96                 "MDL_ERR_N: other error - rx'd frame with wrong size",
97                 "MDL_ERR_O: other error - N201 error",
98                 "MDL_ERR_MAX: i4b_mdl_error_ind called with wrong parameter!!!"
99         };
100 #endif
101
102         if(errorcode > MDL_ERR_MAX)
103                 errorcode = MDL_ERR_MAX;
104                 
105         NDBGL2(L2_ERROR, "unit = %d, location = %s", l2sc->unit, where);
106         NDBGL2(L2_ERROR, "error = %s", error_text[errorcode]);
107
108         switch(errorcode)
109         {       
110                 case MDL_ERR_A:
111                 case MDL_ERR_B:
112                         break;
113
114                 case MDL_ERR_C:
115                 case MDL_ERR_D:
116                         i4b_tei_verify(l2sc);
117                         break;
118
119                 case MDL_ERR_E:
120                 case MDL_ERR_F:
121                         break;
122
123                 case MDL_ERR_G:
124                 case MDL_ERR_H:
125                         i4b_tei_verify(l2sc);
126                         break;
127
128                 case MDL_ERR_I:
129                 case MDL_ERR_J:
130                 case MDL_ERR_K:
131                 case MDL_ERR_L:
132                 case MDL_ERR_M:
133                 case MDL_ERR_N:
134                 case MDL_ERR_O:
135                         break;
136
137                 default:
138                         break;
139         }
140 }
141  
142 #endif /* NI4BQ921 > 0 */