⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdt2.c

📁 No7信令,我需要交换类似的代码, 请店长审核,谢谢了,急着交换,谢谢
💻 C
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** @(#) sdt2.c,v SS7AlphaRelease(0.7) 2001/12/11 07:51:42 ----------------------------------------------------------------------------- Copyright (C) 2001  OpenSS7 Corporation <http://www.openss7.com> All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ----------------------------------------------------------------------------- U.S. GOVERNMENT RESTRICTED RIGHTS.  If you are licensing this Software on behalf of the U.S. Government ("Government"), the following provisions apply to you.  If the Software is supplied by the Department of Defense ("DoD"), it is classified as "Commercial Computer Software" under paragraph 252.227-7014 of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any successor regulations) and the Government is acquiring only the license rights granted herein (the license rights customarily provided to non-Government users).  If the Software is supplied to any unit or agency of the Government other than DoD, it is classified as "Restricted Computer Software" and the Government's rights in the Software are defined in paragraph 52.227-19 of the Federal Acquisition Regulations ("FAR") (or any success regulations) or, in the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR (or any successor regulations). ----------------------------------------------------------------------------- Last Modified 2001/12/11 07:51:42 by brian *****************************************************************************/#ident "@(#) sdt2.c,v SS7AlphaRelease(0.7) 2001/12/11 07:51:42"static char const ident[] = "sdt2.c,v SS7AlphaRelease(0.7) 2001/12/11 07:51:42";#include <linux/config.h>#include <linux/version.h>#include <linux/modversion.h>#include <linux/module.h>#include <sys/stream.h>#include <sys/stropts.h>#include <sys/cmn_err.h>#include <sys/dki.h>#include <ss7/lmi.h>#include <ss7/lmi_ioctl.h>#include <ss7/devi.h>#include <ss7/devi_ioctl.h>#include <ss7/sdli.h>#include <ss7/sdli_ioctl.h>#include <ss7/sdti.h>#include <ss7/sdti_ioctl.h>#include "../debug.h"#include "../bufq.h"#define SDT_DESCRIP	"SIGNALLING DATA TERMINAL (SDT) STREAMS MODULE"#define SDT_COPYRIGHT	"Copyright (c) 2001 Openss7 Corp.  All Rights Reserved."#define SDT_DEVICE	"Part of the OpenSS7 Stack for LiS STREAMS"#define SDT_CONTACT	"Brian Bidulock <bidulock@openss7.org>"#define SDT_BANNER	SDT_DESCRIP	"\n" \			SDT_COPYRIGHT	"\n" \			SDT_DEVICE	"\n" \			SDT_CONTACT	"\n"MODULE_AUTHOR(SDT_CONTACT);MODULE_DESCRIPTION(SDT_DESCRIP);MODULE_SUPPORTED_DEVICE(SDT_DEVICE);#ifndef INT#define INT void#endiftypedef void (*bufcall_fnc_t)(long);/* *  ========================================================================= * *  STREAMS Definitions * *  ========================================================================= */static struct module_info sdt_minfo ={	0,		/* Module ID number		*/	"sdt",		/* Module name			*/	0,		/* Min packet size		*/	INFPSZ,		/* Max packet size		*/	0,		/* Hi water mark		*/	0		/* Lo water mark		*/};static int sdt_open (queue_t *, dev_t *, int, int, cred_t *);static int sdt_close(queue_t *, int, cred_t *);static INT sdt_rput (queue_t *, mblk_t *);static INT sdt_wput (queue_t *, mblk_t *);static struct qinit sdt_rinit ={	sdt_rput,	/* Read put (msg from below)	*/	NULL,		/* Read queue service		*/	sdt_open,	/* Each oepn			*/	sdt_close,	/* Lase close			*/	NULL,		/* Admin (not used)		*/	&sdt_minfo,	/* Information			*/	NULL		/* Statistics			*/};static struct qinit sdt_winit ={	sdt_wput,	/* Write put (msg from below)	*/	NULL,		/* Write queues service		*/	NULL,		/* Each open			*/	NULL,		/* Last close			*/	&sdt_minfo,	/* Information			*/	NULL		/* Statistics			*/};static struct streamtab sdt_info ={	&sdt_rinit,	/* Upper read  queue		*/	&sdt_winit,	/* Upper write queue		*/	NULL,		/* Lower read  queue		*/	NULL		/* Lower write queue		*/};/* *  ========================================================================= * *  SDT Private Structure * *  ========================================================================= */typedef struct sdt{	queue_t		*rq;		/* read  queue			*/	queue_t		*wq;		/* write queue			*/	uint		i_state;	/* interface state		*/	lmi_option_t	option;		/* protocol options		*/	sdt_statem_t	statem;		/* state variables		*/	sdt_config_t	config;		/* configuration		*/	sdt_stats_t	stats;		/* statistics			*/	sdt_stats_t	stamp;		/* timestamps			*/}sdt_t;/*   *  ========================================================================= * *  OUTPUT Events * *  ========================================================================= *//* *  ------------------------------------------------------------------------- * *  SDT Provider -> SDT User Primitives * *  ------------------------------------------------------------------------- *//* *  SDT_RC_SIGNAL_UNIT_IND *  ----------------------------------- */static intsdt_rc_signal_unit_ind(sdt_t *s, mblk_t *dp){	mblk_t *mp;	sdt_rc_signal_unit_ind_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdt_primitive    = SDT_RC_SIGNAL_UNIT_IND;		mp->b_cont = dp;		putnext(s->rq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDT_RC_CONGESTION_ACCEPT_IND *  ----------------------------------- */static intsdt_rc_congestion_accept_ind(sdt_t *s){	mblk_t *mp;	sdt_rc_congestion_accept_ind_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdt_primitive    = SDT_RC_CONGESTION_ACCEPT_IND;		putnext(s->rq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDT_RC_CONGESTION_DISCARD_IND *  ----------------------------------- */static intsdt_rc_congestion_discard_ind(sdt_t *s){	mblk_t *mp;	sdt_rc_congestion_discard_ind_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdt_primitive    = SDT_RC_CONGESTION_DISCARD_IND;		putnext(s->rq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDT_RC_NO_CONGESTION_IND *  ----------------------------------- */static intsdt_rc_no_congestion_ind(sdt_t *s){	mblk_t *mp;	sdt_rc_no_congestion_ind_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdt_primitive    = SDT_RC_NO_CONGESTION_IND;		putnext(s->rq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDT_IAC_CORRECT_SU_IND *  ----------------------------------- */static intsdt_iac_correct_su_ind(sdt_t *s){	mblk_t *mp;	sdt_iac_correct_su_ind_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdt_primitive    = SDT_IAC_CORRECT_SU_IND;		putnext(s->rq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDT_IAC_ABORT_PROVING_IND *  ----------------------------------- */static intsdt_iac_abort_proving_ind(sdt_t *s){	mblk_t *mp;	sdt_iac_abort_proving_ind_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdt_primitive    = SDT_IAC_ABORT_PROVING_IND;		putnext(s->rq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDT_LSC_LINK_FAILURE_IND *  ----------------------------------- */static intsdt_lsc_link_failure_ind(sdt_t *s){	mblk_t *mp;	sdt_lsc_link_failure_ind_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdt_primitive    = SDT_LSC_LINK_FAILURE_IND;		putnext(s->rq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDT_TXC_TRANSMISSION_REQUEST_IND *  ----------------------------------- */static intsdt_txc_transmission_request_ind(sdt_t *s){	mblk_t *mp;	sdt_txc_transmission_request_ind_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdt_primitive    = SDT_TXC_TRANSMISSION_REQUEST_IND;		putnext(s->rq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  ------------------------------------------------------------------------- * *  SDL User --> SDL Provider Primitives * *  ------------------------------------------------------------------------- *//* *  SDL_DAEDT_TRANSMISSION_REQ *  ----------------------------------- */static intsdl_daedt_transmission_req(sdt_t *s, mblk_t *dp){	mblk_t *mp;	sdl_daedt_transmission_req_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdl_primitive    = SDL_DAEDT_TRANSMISSION_REQ;		mp->b_cont = dp;		putnext(s->wq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDL_DAEDT_START_REQ *  ----------------------------------- */static intsdl_daedt_start_req(sdt_t *s){	mblk_t *mp;	sdl_daedt_start_req_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdl_primitive    = SDL_DAEDT_START_REQ;		putnext(s->wq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  SDL_DAEDR_START_REQ *  ----------------------------------- */static intsdl_daedr_start_req(sdt_t *s){	mblk_t *mp;	sdl_daedr_start_req_t *p;	if ( (mp = allocb(sizeof(*p), BPRI_MED)) )	{		mp->b_datap->db_type = M_PCPROTO;		p = ((typeof(p))mp->b_wptr)++;		p->sdl_primitive    = SDL_DAEDR_START_REQ;		putnext(s->wq, mp);		return(0);	} rare(); return(-ENOBUFS);}/* *  ========================================================================= * *  SDT State Machine * *  ========================================================================= */static voidsdt_aerm_su_in_error(sdt_t *s){	if ( s->statem.aerm_state == SDT_STATE_MONITORING )	{		s->statem.Ca++;		if ( s->statem.Ca == s->statem.Ti )		{			s->statem.aborted_proving = 1;			sdt_iac_abort_proving_ind(s);			s->statem.aerm_state = SDT_STATE_IDLE;		}	}}static voidsdt_aerm_correct_su(sdt_t *s){	if ( s->statem.aerm_state == SDT_STATE_IDLE )	{		if ( s->statem.aborted_proving )		{			sdt_iac_correct_su_ind(s);			s->statem.aborted_proving = 0;		}	}}static voidsdt_suerm_start(sdt_t *s){	s->statem.Cs = 0;	s->statem.Ns = 0;	s->statem.suerm_state = SDT_STATE_IN_SERVICE;}static voidsdt_suerm_stop(sdt_t *s){	s->statem.suerm_state = SDT_STATE_IDLE;}static voidsdt_suerm_su_in_error(sdt_t *s) /* RxISR */{	if ( s->statem.suerm_state == SDT_STATE_IN_SERVICE )	{		s->statem.Cs++;		if ( s->statem.Cs >= s->config.T )		{			sdt_lsc_link_failure_ind(s);			s->statem.suerm_state = SDT_STATE_IDLE;			return;		}		s->statem.Ns++;		if ( s->statem.Ns >= s->config.D )		{			s->statem.Ns = 0;			if ( s->statem.Cs )				s->statem.Cs--;		}	}}static voidsdt_eim_su_in_error(sdt_t *s) /* RxISR */{	if ( s->statem.eim_state == SDT_STATE_MONITORING )		s->statem.interval_error = 1;}static voidsdt_suerm_correct_su(sdt_t *s) /* RxISR */{	if ( s->statem.suerm_state == SDT_STATE_IN_SERVICE )	{		s->statem.Ns++;		if ( s->statem.Ns >= s->config.D )		{			s->statem.Ns = 0;			if ( s->statem.Cs )				s->statem.Cs--;		}	}}static voidsdt_eim_correct_su(sdt_t *s) /* RxISR */{	if ( s->statem.eim_state == SDT_STATE_MONITORING )		s->statem.su_received = 1;}static void sdt_t8_timeout(sdt_t *s);static void

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -