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.9 2005/12/11 12:25:06 christos Exp $ 31 * 32 * $FreeBSD$ 33 * 34 * last edit-date: [Fri Jan 5 11:33:47 2001] 35 * 36 *---------------------------------------------------------------------------*/ 37 38#include <sys/cdefs.h> 39__KERNEL_RCSID(0, "$NetBSD: i4b_lme.c,v 1.5.8.5 2005/11/10 14:11:36 skrll Exp $"); 40 41#ifdef __FreeBSD__ 42#include "i4bq921.h" 43#else 44#define NI4BQ921 1 45#endif 46#if NI4BQ921 > 0 47 48#include <sys/param.h> 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#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000 56#include <sys/callout.h> 57#endif 58 59#ifdef __FreeBSD__ 60#include <machine/i4b_debug.h> 61#include <machine/i4b_ioctl.h> 62#else 63#include <netisdn/i4b_debug.h> 64#include <netisdn/i4b_ioctl.h> 65#endif 66 67#include <netisdn/i4b_l2.h> 68#include <netisdn/i4b_l1l2.h> 69#include <netisdn/i4b_isdnq931.h> 70#include <netisdn/i4b_mbuf.h> 71#include <netisdn/i4b_l2fsm.h> 72#include <netisdn/i4b_l3l4.h> 73 74/*---------------------------------------------------------------------------* 75 * mdl assign indication handler 76 *---------------------------------------------------------------------------*/ 77void 78i4b_mdl_assign_ind(l2_softc_t *l2sc) 79{ 80 NDBGL2(L2_PRIM, "isdnif %d", l2sc->drv->isdnif); 81 82 i4b_l1_activate(l2sc); 83 84 if(l2sc->tei_valid == TEI_VALID) 85 { 86 l2sc->T202func = (void(*)(void*))i4b_tei_verify; 87 l2sc->N202 = N202DEF; 88 i4b_tei_verify(l2sc); 89 } 90 else 91 { 92 l2sc->T202func = (void(*)(void*))i4b_tei_assign; 93 l2sc->N202 = N202DEF; 94 i4b_tei_assign(l2sc); 95 } 96} 97 98/*---------------------------------------------------------------------------* 99 * i4b_mdl_error_ind handler (Q.921 01/94 pp 156) 100 *---------------------------------------------------------------------------*/ 101void 102i4b_mdl_error_ind(l2_softc_t *l2sc, const char *where, int errorcode) 103{ 104#if DO_I4B_DEBUG 105 static const char *error_text[] = { 106 "MDL_ERR_A: rx'd unsolicited response - supervisory (F=1)", 107 "MDL_ERR_B: rx'd unsolicited response - DM (F=1)", 108 "MDL_ERR_C: rx'd unsolicited response - UA (F=1)", 109 "MDL_ERR_D: rx'd unsolicited response - UA (F=0)", 110 "MDL_ERR_E: rx'd unsolicited response - DM (F=0)", 111 "MDL_ERR_F: peer initiated re-establishment - SABME", 112 "MDL_ERR_G: unsuccessful transmission N200times - SABME", 113 "MDL_ERR_H: unsuccessful transmission N200times - DIS", 114 "MDL_ERR_I: unsuccessful transmission N200times - Status ENQ", 115 "MDL_ERR_J: other error - N(R) error", 116 "MDL_ERR_K: other error - rx'd FRMR response", 117 "MDL_ERR_L: other error - rx'd undefined frame", 118 "MDL_ERR_M: other error - receipt of I field not permitted", 119 "MDL_ERR_N: other error - rx'd frame with wrong size", 120 "MDL_ERR_O: other error - N201 error", 121 "MDL_ERR_MAX: i4b_mdl_error_ind called with wrong parameter!!!" 122 }; 123#endif 124 125 if(errorcode > MDL_ERR_MAX) 126 errorcode = MDL_ERR_MAX; 127 128 NDBGL2(L2_ERROR, "isdnif = %d, location = %s", 129 l2sc->drv->isdnif, where); 130 NDBGL2(L2_ERROR, "error = %s", error_text[errorcode]); 131 132 switch(errorcode) 133 { 134 case MDL_ERR_A: 135 case MDL_ERR_B: 136 break; 137 138 case MDL_ERR_C: 139 case MDL_ERR_D: 140 i4b_tei_verify(l2sc); 141 break; 142 143 case MDL_ERR_E: 144 case MDL_ERR_F: 145 break; 146 147 case MDL_ERR_G: 148 case MDL_ERR_H: 149 i4b_tei_verify(l2sc); 150 break; 151 152 case MDL_ERR_I: 153 case MDL_ERR_J: 154 case MDL_ERR_K: 155 case MDL_ERR_L: 156 case MDL_ERR_M: 157 case MDL_ERR_N: 158 case MDL_ERR_O: 159 break; 160 161 default: 162 break; 163 } 164} 165 166#endif /* NI4BQ921 > 0 */ 167