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

📄 capi.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 3 页
字号:
				} else {					ctmp = (act2000_chan *)tmp;					ctmp->plci = msg->msg.disconnect_ind.plci;					actcapi_disconnect_resp(card, ctmp);				}				break;			case 0x4001:				/* SELECT_B2_PROTOCOL_CONF */				chan = find_plci(card, msg->msg.select_b2_protocol_conf.plci);				if (chan >= 0)					switch (card->bch[chan].fsm_state) {						case ACT2000_STATE_ICALL:						case ACT2000_STATE_OWAIT:							ctmp = &card->bch[chan];							if (msg->msg.select_b2_protocol_conf.info == 0)								actcapi_select_b3_protocol_req(card, ctmp);							else {								ctmp->fsm_state = ACT2000_STATE_NULL;								cmd.driver = card->myid;								cmd.command = ISDN_STAT_DHUP;								cmd.arg = chan;								card->interface.statcallb(&cmd);							}							break;					}				break;			case 0x8001:				/* SELECT_B3_PROTOCOL_CONF */				chan = find_plci(card, msg->msg.select_b3_protocol_conf.plci);				if (chan >= 0)					switch (card->bch[chan].fsm_state) {						case ACT2000_STATE_ICALL:						case ACT2000_STATE_OWAIT:							ctmp = &card->bch[chan];							if (msg->msg.select_b3_protocol_conf.info == 0)								actcapi_listen_b3_req(card, ctmp);							else {								ctmp->fsm_state = ACT2000_STATE_NULL;								cmd.driver = card->myid;								cmd.command = ISDN_STAT_DHUP;								cmd.arg = chan;								card->interface.statcallb(&cmd);							}					}				break;			case 0x8101:				/* LISTEN_B3_CONF */				chan = find_plci(card, msg->msg.listen_b3_conf.plci);				if (chan >= 0)					switch (card->bch[chan].fsm_state) {						case ACT2000_STATE_ICALL:							ctmp = &card->bch[chan];							if (msg->msg.listen_b3_conf.info == 0)								actcapi_connect_resp(card, ctmp, 0);							else {								ctmp->fsm_state = ACT2000_STATE_NULL;								cmd.driver = card->myid;								cmd.command = ISDN_STAT_DHUP;								cmd.arg = chan;								card->interface.statcallb(&cmd);							}							break;						case ACT2000_STATE_OWAIT:							ctmp = &card->bch[chan];							if (msg->msg.listen_b3_conf.info == 0) {								actcapi_connect_b3_req(card, ctmp);								ctmp->fsm_state = ACT2000_STATE_OBWAIT;								cmd.driver = card->myid;								cmd.command = ISDN_STAT_DCONN;								cmd.arg = chan;								card->interface.statcallb(&cmd);							} else {								ctmp->fsm_state = ACT2000_STATE_NULL;								cmd.driver = card->myid;								cmd.command = ISDN_STAT_DHUP;								cmd.arg = chan;								card->interface.statcallb(&cmd);							}							break;					}				break;			case 0x8201:				/* CONNECT_B3_CONF */				chan = find_plci(card, msg->msg.connect_b3_conf.plci);				if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_OBWAIT)) {					ctmp = &card->bch[chan];					if (msg->msg.connect_b3_conf.info) {						ctmp->fsm_state = ACT2000_STATE_NULL;						cmd.driver = card->myid;						cmd.command = ISDN_STAT_DHUP;						cmd.arg = chan;						card->interface.statcallb(&cmd);					} else {						ctmp->ncci = msg->msg.connect_b3_conf.ncci;						ctmp->fsm_state = ACT2000_STATE_BWAIT;					}				}				break;			case 0x8401:				/* DISCONNECT_B3_CONF */				chan = find_ncci(card, msg->msg.disconnect_b3_conf.ncci);				if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BHWAIT))					card->bch[chan].fsm_state = ACT2000_STATE_BHWAIT2;				break;			case 0x0702:				/* INFO_IND */				chan = find_plci(card, msg->msg.info_ind.plci);				if (chan >= 0)					/* TODO: Eval Charging info / cause */					actcapi_info_resp(card, &card->bch[chan]);				break;			case 0x0401:				/* LISTEN_CONF */			case 0x0501:				/* LISTEN_CONF */			case 0xff01:				/* MANUFACTURER_CONF */				break;			case 0xff02:				/* MANUFACTURER_IND */				if (msg->msg.manuf_msg == 3) {					memset(tmp, 0, sizeof(tmp));					strncpy(tmp,						&msg->msg.manufacturer_ind_err.errstring,						msg->hdr.len - 16);					if (msg->msg.manufacturer_ind_err.errcode)						printk(KERN_WARNING "act2000: %s\n", tmp);					else {						printk(KERN_DEBUG "act2000: %s\n", tmp);						if ((!strncmp(tmp, "INFO: Trace buffer con", 22)) ||						    (!strncmp(tmp, "INFO: Compile Date/Tim", 22))) {							card->flags |= ACT2000_FLAGS_RUNNING;							cmd.command = ISDN_STAT_RUN;							cmd.driver = card->myid;							cmd.arg = 0;							actcapi_manufacturer_req_net(card);							actcapi_manufacturer_req_msn(card);							actcapi_listen_req(card);							card->interface.statcallb(&cmd);						}					}				}				break;			default:				printk(KERN_WARNING "act2000: UNHANDLED Message %04x\n", ccmd);				break;		}		dev_kfree_skb(skb);	}}#ifdef DEBUG_MSGstatic voidactcapi_debug_caddr(actcapi_addr *addr){	char tmp[30];	printk(KERN_DEBUG " Alen  = %d\n", addr->len);	if (addr->len > 0)		printk(KERN_DEBUG " Atnp  = 0x%02x\n", addr->tnp);	if (addr->len > 1) {		memset(tmp, 0, 30);		memcpy(tmp, addr->num, addr->len - 1);		printk(KERN_DEBUG " Anum  = '%s'\n", tmp);	}}static voidactcapi_debug_ncpi(actcapi_ncpi *ncpi){	printk(KERN_DEBUG " ncpi.len = %d\n", ncpi->len);	if (ncpi->len >= 2)		printk(KERN_DEBUG " ncpi.lic = 0x%04x\n", ncpi->lic);	if (ncpi->len >= 4)		printk(KERN_DEBUG " ncpi.hic = 0x%04x\n", ncpi->hic);	if (ncpi->len >= 6)		printk(KERN_DEBUG " ncpi.ltc = 0x%04x\n", ncpi->ltc);	if (ncpi->len >= 8)		printk(KERN_DEBUG " ncpi.htc = 0x%04x\n", ncpi->htc);	if (ncpi->len >= 10)		printk(KERN_DEBUG " ncpi.loc = 0x%04x\n", ncpi->loc);	if (ncpi->len >= 12)		printk(KERN_DEBUG " ncpi.hoc = 0x%04x\n", ncpi->hoc);	if (ncpi->len >= 13)		printk(KERN_DEBUG " ncpi.mod = %d\n", ncpi->modulo);}static voidactcapi_debug_dlpd(actcapi_dlpd *dlpd){	printk(KERN_DEBUG " dlpd.len = %d\n", dlpd->len);	if (dlpd->len >= 2)		printk(KERN_DEBUG " dlpd.dlen   = 0x%04x\n", dlpd->dlen);	if (dlpd->len >= 3)		printk(KERN_DEBUG " dlpd.laa    = 0x%02x\n", dlpd->laa);	if (dlpd->len >= 4)		printk(KERN_DEBUG " dlpd.lab    = 0x%02x\n", dlpd->lab);	if (dlpd->len >= 5)		printk(KERN_DEBUG " dlpd.modulo = %d\n", dlpd->modulo);	if (dlpd->len >= 6)		printk(KERN_DEBUG " dlpd.win    = %d\n", dlpd->win);}#ifdef DEBUG_DUMP_SKBstatic void dump_skb(struct sk_buff *skb) {	char tmp[80];	char *p = skb->data;	char *t = tmp;	int i;	for (i = 0; i < skb->len; i++) {		t += sprintf(t, "%02x ", *p++ & 0xff);		if ((i & 0x0f) == 8) {			printk(KERN_DEBUG "dump: %s\n", tmp);			t = tmp;		}	}	if (i & 0x07)		printk(KERN_DEBUG "dump: %s\n", tmp);}#endifvoidactcapi_debug_msg(struct sk_buff *skb, int direction){	actcapi_msg *msg = (actcapi_msg *)skb->data;	char *descr;	int i;	char tmp[170];	#ifndef DEBUG_DATA_MSG	if (msg->hdr.cmd.cmd == 0x86)		return;#endif	descr = "INVALID";#ifdef DEBUG_DUMP_SKB	dump_skb(skb);#endif	for (i = 0; i < num_valid_msg; i++)		if ((msg->hdr.cmd.cmd == valid_msg[i].cmd.cmd) &&		    (msg->hdr.cmd.subcmd == valid_msg[i].cmd.subcmd)) {			descr = valid_msg[i].description;			break;		}	printk(KERN_DEBUG "%s %s msg\n", direction?"Outgoing":"Incoming", descr);	printk(KERN_DEBUG " ApplID = %d\n", msg->hdr.applicationID);	printk(KERN_DEBUG " Len    = %d\n", msg->hdr.len);	printk(KERN_DEBUG " MsgNum = 0x%04x\n", msg->hdr.msgnum);	printk(KERN_DEBUG " Cmd    = 0x%02x\n", msg->hdr.cmd.cmd);	printk(KERN_DEBUG " SubCmd = 0x%02x\n", msg->hdr.cmd.subcmd);	switch (i) {		case 0:			/* DATA B3 IND */			printk(KERN_DEBUG " BLOCK = 0x%02x\n",			       msg->msg.data_b3_ind.blocknr);			break;		case 2:			/* CONNECT CONF */			printk(KERN_DEBUG " PLCI = 0x%04x\n",			       msg->msg.connect_conf.plci);			printk(KERN_DEBUG " Info = 0x%04x\n",			       msg->msg.connect_conf.info);			break;		case 3:			/* CONNECT IND */			printk(KERN_DEBUG " PLCI = 0x%04x\n",			       msg->msg.connect_ind.plci);			printk(KERN_DEBUG " Contr = %d\n",			       msg->msg.connect_ind.controller);			printk(KERN_DEBUG " SI1   = %d\n",			       msg->msg.connect_ind.si1);			printk(KERN_DEBUG " SI2   = %d\n",			       msg->msg.connect_ind.si2);			printk(KERN_DEBUG " EAZ   = '%c'\n",			       msg->msg.connect_ind.eaz);			actcapi_debug_caddr(&msg->msg.connect_ind.addr);			break;		case 5:			/* CONNECT ACTIVE IND */			printk(KERN_DEBUG " PLCI = 0x%04x\n",			       msg->msg.connect_active_ind.plci);			actcapi_debug_caddr(&msg->msg.connect_active_ind.addr);			break;		case 8:			/* LISTEN CONF */			printk(KERN_DEBUG " Contr = %d\n",			       msg->msg.listen_conf.controller);			printk(KERN_DEBUG " Info = 0x%04x\n",			       msg->msg.listen_conf.info);			break;		case 11:			/* INFO IND */			printk(KERN_DEBUG " PLCI = 0x%04x\n",			       msg->msg.info_ind.plci);			printk(KERN_DEBUG " Imsk = 0x%04x\n",			       msg->msg.info_ind.nr.mask);			if (msg->hdr.len > 12) {				int l = msg->hdr.len - 12;				int j;				char *p = tmp;				for (j = 0; j < l ; j++)					p += sprintf(p, "%02x ", msg->msg.info_ind.el.display[j]);				printk(KERN_DEBUG " D = '%s'\n", tmp);			}			break;		case 14:			/* SELECT B2 PROTOCOL CONF */			printk(KERN_DEBUG " PLCI = 0x%04x\n",			       msg->msg.select_b2_protocol_conf.plci);			printk(KERN_DEBUG " Info = 0x%04x\n",			       msg->msg.select_b2_protocol_conf.info);			break;		case 15:			/* SELECT B3 PROTOCOL CONF */			printk(KERN_DEBUG " PLCI = 0x%04x\n",			       msg->msg.select_b3_protocol_conf.plci);			printk(KERN_DEBUG " Info = 0x%04x\n",			       msg->msg.select_b3_protocol_conf.info);			break;		case 16:			/* LISTEN B3 CONF */			printk(KERN_DEBUG " PLCI = 0x%04x\n",			       msg->msg.listen_b3_conf.plci);			printk(KERN_DEBUG " Info = 0x%04x\n",			       msg->msg.listen_b3_conf.info);			break;		case 18:			/* CONNECT B3 IND */			printk(KERN_DEBUG " NCCI = 0x%04x\n",			       msg->msg.connect_b3_ind.ncci);			printk(KERN_DEBUG " PLCI = 0x%04x\n",			       msg->msg.connect_b3_ind.plci);			actcapi_debug_ncpi(&msg->msg.connect_b3_ind.ncpi);			break;		case 19:			/* CONNECT B3 ACTIVE IND */			printk(KERN_DEBUG " NCCI = 0x%04x\n",			       msg->msg.connect_b3_active_ind.ncci);			actcapi_debug_ncpi(&msg->msg.connect_b3_active_ind.ncpi);			break;		case 26:			/* MANUFACTURER IND */			printk(KERN_DEBUG " Mmsg = 0x%02x\n",			       msg->msg.manufacturer_ind_err.manuf_msg);			switch (msg->msg.manufacturer_ind_err.manuf_msg) {				case 3:					printk(KERN_DEBUG " Contr = %d\n",					       msg->msg.manufacturer_ind_err.controller);					printk(KERN_DEBUG " Code = 0x%08x\n",					       msg->msg.manufacturer_ind_err.errcode);					memset(tmp, 0, sizeof(tmp));					strncpy(tmp, &msg->msg.manufacturer_ind_err.errstring,						msg->hdr.len - 16);					printk(KERN_DEBUG " Emsg = '%s'\n", tmp);					break;			}			break;		case 30:			/* LISTEN REQ */			printk(KERN_DEBUG " Imsk = 0x%08x\n",			       msg->msg.listen_req.infomask);			printk(KERN_DEBUG " Emsk = 0x%04x\n",			       msg->msg.listen_req.eazmask);			printk(KERN_DEBUG " Smsk = 0x%04x\n",			       msg->msg.listen_req.simask);			break;		case 35:			/* SELECT_B2_PROTOCOL_REQ */			printk(KERN_DEBUG " PLCI  = 0x%04x\n",			       msg->msg.select_b2_protocol_req.plci);			printk(KERN_DEBUG " prot  = 0x%02x\n",			       msg->msg.select_b2_protocol_req.protocol);			if (msg->hdr.len >= 11)				printk(KERN_DEBUG "No dlpd\n");			else				actcapi_debug_dlpd(&msg->msg.select_b2_protocol_req.dlpd);			break;		case 44:			/* CONNECT RESP */			printk(KERN_DEBUG " PLCI  = 0x%04x\n",			       msg->msg.connect_resp.plci);			printk(KERN_DEBUG " CAUSE = 0x%02x\n",			       msg->msg.connect_resp.rejectcause);			break;		case 45:			/* CONNECT ACTIVE RESP */			printk(KERN_DEBUG " PLCI  = 0x%04x\n",			       msg->msg.connect_active_resp.plci);			break;	}}#endif

⌨️ 快捷键说明

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