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

📄 tpam_nco.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 2 页
字号:
	return skb;}/* * Extract a parameter from a TLV block. * * 	skb: sk_buff containing the PCI message * 	type: parameter to search for (PARAM_*) * 	value: to be filled with the value of the parameter * 	len: maximum length of the parameter value * * Return: 0 if OK, <0 if error. */static int extract_NCOParameter(struct sk_buff *skb, u8 type, 				void *value, u16 len) {	void *buffer = (void *)skb->data;	pci_mpb *p;	void * bufferend;	u8 valtype;	u16 vallen;	/* calculate the start and end of the TLV block */	buffer += sizeof(skb_header);	p = (pci_mpb *)buffer;	buffer += sizeof(pci_mpb);	bufferend = buffer + p->actualBlockTLVSize;	/* walk through the parameters */	while (buffer < bufferend) {		/* parameter type */		valtype = *((u8 *)buffer++);		/* parameter length */		vallen = *((u8 *)buffer++);		if (vallen == 0xff) {			/* parameter length is on 2 bytes */			vallen = *((u8 *)buffer++);			vallen <<= 8;			vallen |= *((u8 *)buffer++);		}		/* got the right parameter */		if (valtype == type) {			/* not enough space for returning the value */			if (vallen > len)				return -1;			/* OK, return it */			memcpy(value, buffer, vallen);			return 0;		}		buffer += vallen;	}	return -1;}/* * Parse a ACreateNCOCnf message. * * 	skb: the sk_buff containing the message * 	status: to be filled with the status field value * 	ncoid: to be filled with the ncoid field value * * Return: 0 if OK, <0 if error. */int parse_ACreateNCOCnf(struct sk_buff *skb, u8 *status, u32 *ncoid) {	/* extract the status */	if (extract_NCOParameter(skb, PAR_CompletionStatus, status, 1)) {		printk(KERN_ERR "TurboPAM(parse_ACreateNCOCnf): "		       "CompletionStatus not found\n");		return -1;	}	if (*status) {		dprintk("TurboPAM(parse_ACreateNCOCnf): status=%d\n", *status);		return 0;	}	/* extract the ncoid */	if (extract_NCOParameter(skb, PAR_NCOID, ncoid, 4)) {		printk(KERN_ERR "TurboPAM(parse_ACreateNCOCnf): "		       "NCOID not found\n");		return -1;	}	dprintk("TurboPAM(parse_ACreateNCOCnf): ncoid=%lu, status=%d\n",		(unsigned long)*ncoid, *status);	return 0;}/* * Parse a ADestroyNCOCnf message. Not used in the driver. * * 	skb: the sk_buff containing the message * 	status: to be filled with the status field value * 	ncoid: to be filled with the ncoid field value * * Return: 0 if OK, <0 if error. */int parse_ADestroyNCOCnf(struct sk_buff *skb, u8 *status, u32 *ncoid) {	/* extract the status */	if (extract_NCOParameter(skb, PAR_CompletionStatus, status, 1)) {		printk(KERN_ERR "TurboPAM(parse_ADestroyNCOCnf): "		       "CompletionStatus not found\n");		return -1;	}	if (*status) {		dprintk("TurboPAM(parse_ADestroyNCOCnf): status=%d\n", *status);		return 0;	}	/* extract the ncoid */	if (extract_NCOParameter(skb, PAR_NCOID, ncoid, 4)) {		printk(KERN_ERR "TurboPAM(parse_ADestroyNCOCnf): "		       "NCOID not found\n");		return -1;	}	dprintk("TurboPAM(parse_ADestroyNCOCnf): ncoid=%lu, status=%d\n", 		(unsigned long)*ncoid, *status);	return 0;}/* * Parse a CConnectCnf message. * * 	skb: the sk_buff containing the message * 	ncoid: to be filled with the ncoid field value * * Return: 0 if OK, <0 if error. */int parse_CConnectCnf(struct sk_buff *skb, u32 *ncoid) {	/* extract the ncoid */	if (extract_NCOParameter(skb, PAR_NCOID, ncoid, 4)) {		printk(KERN_ERR "TurboPAM(parse_CConnectCnf): "		       "NCOID not found\n");		return -1;	}	dprintk("TurboPAM(parse_CConnectCnf): ncoid=%lu\n", 		(unsigned long)*ncoid);	return 0;}/* * Parse a CConnectInd message. * * 	skb: the sk_buff containing the message * 	ncoid: to be filled with the ncoid field value * 	hdlc: to be filled with 1 if the incoming connection is a HDLC one, * 		with 0 if the incoming connection is a modem one * 	calling: to be filled with the calling phone number value * 	called: to be filled with the called phone number value * 	plan: to be filled with the plan value * 	screen: to be filled with the screen value * * Return: 0 if OK, <0 if error. */int parse_CConnectInd(struct sk_buff *skb, u32 *ncoid, u8 *hdlc, 		      u8 *calling, u8 *called, u8 *plan, u8 *screen) {	u8 phone[PHONE_MAXIMUMSIZE + 4];	/* extract the ncoid */	if (extract_NCOParameter(skb, PAR_NCOID, ncoid, 4)) {		printk(KERN_ERR "TurboPAM(parse_CConnectInd): "		       "NCOID not found\n");		return -1;	}	/* extract the bearer capability field */	if (extract_NCOParameter(skb, PAR_BearerCap, hdlc, 1)) {		printk(KERN_ERR "TurboPAM(parse_CConnectInd): "		       "BearerCap not found\n");		return -1;	}	*hdlc = (*hdlc == 0x88) ? 1 : 0;	/* extract the calling number / plan / screen */	if (extract_NCOParameter(skb, PAR_CallingNumber, phone, 				 PHONE_MAXIMUMSIZE + 4)) {		printk(KERN_ERR "TurboPAM(parse_CConnectInd): "		       "CallingNumber not found\n");		return -1;	}	memcpy(calling, phone + 4, PHONE_MAXIMUMSIZE);	*plan = phone[1];	*screen = phone[3];	/* extract the called number */	if (extract_NCOParameter(skb, PAR_CalledNumber, phone, 				 PHONE_MAXIMUMSIZE + 2)) {		printk(KERN_ERR "TurboPAM(parse_CConnectInd): "		       "CalledNumber not found\n");		return -1;	}	memcpy(called, phone + 2, PHONE_MAXIMUMSIZE);	dprintk("TurboPAM(parse_CConnectInd): "		"ncoid=%lu, hdlc=%d, plan=%d, scr=%d, calling=%s, called=%s\n",		(unsigned long)*ncoid, *hdlc, *plan, *screen, calling, called);	return 0;}/* * Parse a CDisconnectCnf message. * * 	skb: the sk_buff containing the message * 	ncoid: to be filled with the ncoid field value * 	causetopuf: to be filled with the cause field value * * Return: 0 if OK, <0 if error. */int parse_CDisconnectCnf(struct sk_buff *skb, u32 *ncoid, u32 *causetopuf) {	/* extract the ncoid */	if (extract_NCOParameter(skb, PAR_NCOID, ncoid, 4)) {		printk(KERN_ERR "TurboPAM(parse_CDisconnectCnf): "		       "NCOID not found\n");		return -1;	}	/* extract the cause of disconnection */	if (extract_NCOParameter(skb, PAR_CauseToPUF, causetopuf, 4)) {		printk(KERN_ERR "TurboPAM(parse_CDisconnectCnf): "		       "CauseToPUF not found\n");		return -1;	}	dprintk("TurboPAM(parse_CDisconnectCnf): ncoid=%lu, causetopuf=%lu\n", 		(unsigned long)*ncoid, (unsigned long)*causetopuf);	return 0;}/* * Parse a CDisconnectInd message. * * 	skb: the sk_buff containing the message * 	ncoid: to be filled with the ncoid field value * 	causetopuf: to be filled with the cause field value * * Return: 0 if OK, <0 if error. */int parse_CDisconnectInd(struct sk_buff *skb, u32 *ncoid, u32 *causetopuf) {	/* extract the ncoid */	if (extract_NCOParameter(skb, PAR_NCOID, ncoid, 4)) {		printk(KERN_ERR "TurboPAM(parse_CDisconnectInd): "		       "NCOID not found\n");		return -1;	}	/* extract the cause of disconnection */	if (extract_NCOParameter(skb, PAR_CauseToPUF, causetopuf, 4)) {		printk(KERN_ERR "TurboPAM(parse_CDisconnectInd): "		       "CauseToPUF not found\n");		return -1;	}	dprintk("TurboPAM(parse_CDisconnectInd): ncoid=%lu, causetopuf=%lu\n", 		(unsigned long)*ncoid, (unsigned long)*causetopuf);	return 0;}/* * Parse a U3ReadyToReceiveInd message. * * 	skb: the sk_buff containing the message * 	ncoid: to be filled with the ncoid field value * 	ready: to be filled with the ready field value * * Return: 0 if OK, <0 if error. */int parse_U3ReadyToReceiveInd(struct sk_buff *skb, u32 *ncoid, u8 *ready) {	/* extract the ncoid */	if (extract_NCOParameter(skb, PAR_NCOID, ncoid, 4)) {		printk(KERN_ERR "TurboPAM(parse_U3ReadyToReceiveInd): "		       "NCOID not found\n");		return -1;	}	/* extract the ready flag */	if (extract_NCOParameter(skb, PAR_ReadyFlag, ready, 1)) {		printk(KERN_ERR "TurboPAM(parse_U3ReadyToReceiveInd): "		       "ReadyFlag not found\n");		return -1;	}	dprintk("TurboPAM(parse_U3ReadyToReceiveInd): ncoid=%lu, ready=%d\n", 		(unsigned long)*ncoid, *ready);	return 0;}/* * Parse a U3DataInd message. * * 	skb: the sk_buff containing the message + data * 	ncoid: to be filled with the ncoid field value * 	data: to be filled with the data  * 	ready: to be filled with the data length * * Return: 0 if OK, <0 if error. */int parse_U3DataInd(struct sk_buff *skb, u32 *ncoid, u8 **data, u16 *len) {	pci_mpb *p;	/* extract the ncoid */	if (extract_NCOParameter(skb, PAR_NCOID, ncoid, 4) == -1) {		printk(KERN_ERR "TurboPAM(parse_U3DataInd): NCOID not found\n");		return -1;	}	/* get a pointer to the beginning of the data block and its length */	p = (pci_mpb *)(skb->data + sizeof(skb_header));	*len = p->actualDataSize;	skb_pull(skb, 		 sizeof(skb_header) + sizeof(pci_mpb) + p->actualBlockTLVSize);	*data = skb->data;	dprintk("TurboPAM(parse_U3DataInd): ncoid=%lu, datalen=%d\n", 		(unsigned long)*ncoid, *len);	return 0;}

⌨️ 快捷键说明

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