Example #1
0
/*
 * Debug and Log 
 */
void
eicon_log(eicon_card * card, int level, const char *fmt, ...)
{
	va_list args;
	char Line[160];
	u_char *p;


	if ((DebugVar & level) || (DebugVar & 256)) {
		va_start(args, fmt);

		if (DebugVar & level) {
			if (DebugVar & 256) {
				/* log-buffer */
				p = Line;
				p += jiftime(p, jiffies);
				*p++ = 32;
				p += vsprintf(p, fmt, args);
				*p = 0;	
				eicon_putstatus(card, Line);
			} else {
				/* printk, syslogd */
				vsprintf(Line, fmt, args);
				printk(KERN_DEBUG "%s", Line);
			}
		}

		va_end(args);
	}
}
Example #2
0
void VHiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt,
		      va_list args)
{
	/* if head == NULL the fmt contains the full info */

	u_long		flags;
	int		count, i;
	u_char		*p;
	isdn_ctrl	ic;
	int		len;
	const u_char	*data;

	if (!cs) {
		printk(KERN_WARNING "HiSax: No CardStatus for message");
		return;
	}
	spin_lock_irqsave(&cs->statlock, flags);
	if (head) {
		p = tmpbuf;
		p += jiftime(p, jiffies);
		p += sprintf(p, " %s", head);
		p += vsprintf(p, fmt, args);
		*p++ = '\n';
		*p = 0;
		len = p - tmpbuf;
		data = tmpbuf;
	} else {
		data = fmt;
		len = strlen(fmt);
	}
	if (len > HISAX_STATUS_BUFSIZE) {
		spin_unlock_irqrestore(&cs->statlock, flags);
		printk(KERN_WARNING "HiSax: status overflow %d/%d\n",
		       len, HISAX_STATUS_BUFSIZE);
		return;
	}
	count = len;
	i = cs->status_end - cs->status_write + 1;
	if (i >= len)
		i = len;
	len -= i;
	memcpy(cs->status_write, data, i);
	cs->status_write += i;
	if (cs->status_write > cs->status_end)
		cs->status_write = cs->status_buf;
	if (len) {
		memcpy(cs->status_write, data + i, len);
		cs->status_write += len;
	}
#ifdef KERNELSTACK_DEBUG
	i = (ulong) & len - current->kernel_stack_page;
	sprintf(tmpbuf, "kstack %s %lx use %ld\n", current->comm,
		current->kernel_stack_page, i);
	len = strlen(tmpbuf);
	for (p = tmpbuf, i = len; i > 0; i--, p++) {
		*cs->status_write++ = *p;
		if (cs->status_write > cs->status_end)
			cs->status_write = cs->status_buf;
		count++;
	}
#endif
	spin_unlock_irqrestore(&cs->statlock, flags);
	if (count) {
		ic.command = ISDN_STAT_STAVAIL;
		ic.driver = cs->myid;
		ic.arg = count;
		cs->iif.statcallb(&ic);
	}
}
Example #3
0
void
dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
{
	u_char *bend, *buf;
	char *dp;
	unsigned char pd, cr_l, cr, mt;
	unsigned char sapi, tei, ftyp;
	int i, cset = 0, cs_old = 0, cs_fest = 0;
	int size, finish = 0;

	if (skb->len < 3)
		return;
	/* display header */
	dp = cs->dlog;
	dp += jiftime(dp, jiffies);
	*dp++ = ' ';
	sapi = skb->data[0] >> 2;
	tei  = skb->data[1] >> 1;
	ftyp = skb->data[2];
	buf = skb->data;
	dp += sprintf(dp, "frame %s ", dir ? "network->user" : "user->network");
	size = skb->len;
	
	if (tei == GROUP_TEI) {
		if (sapi == CTRL_SAPI) { /* sapi 0 */
			if (ftyp == 3) {
				dp += sprintf(dp, "broadcast\n");
				buf += 3;
				size -= 3;
			} else {
				dp += sprintf(dp, "no UI broadcast\n");
				finish = 1;
			}
		} else if (sapi == TEI_SAPI) {
			dp += sprintf(dp, "tei management\n");
			finish = 1;
		} else {
			dp += sprintf(dp, "unknown sapi %d broadcast\n", sapi);
			finish = 1;
		}
	} else {
		if (sapi == CTRL_SAPI) {
			if (!(ftyp & 1)) { /* IFrame */
				dp += sprintf(dp, "with tei %d\n", tei);
				buf += 4;
				size -= 4;
			} else {
				dp += sprintf(dp, "SFrame with tei %d\n", tei);
				finish = 1;
			}
		} else {
			dp += sprintf(dp, "unknown sapi %d tei %d\n", sapi, tei);
			finish = 1;
		}
	}
	bend = skb->data + skb->len;
	if (buf >= bend) {
		dp += sprintf(dp, "frame too short\n");
		finish = 1;
	}
	if (finish) {
		*dp = 0;
		HiSax_putstatus(cs, NULL, cs->dlog);
		return;
	}
	if ((0xfe & buf[0]) == PROTO_DIS_N0) {	/* 1TR6 */
		/* locate message type */
		pd = *buf++;
		cr_l = *buf++;
		if (cr_l)
			cr = *buf++;
		else
			cr = 0;
		mt = *buf++;
		if (pd == PROTO_DIS_N0) {	/* N0 */
			for (i = 0; i < MT_N0_LEN; i++)
				if (mt_n0[i].nr == mt)
					break;
			/* display message type if it exists */
			if (i == MT_N0_LEN)
				dp += sprintf(dp, "callref %d %s size %d unknown message type N0 %x!\n",
					      cr & 0x7f, (cr & 0x80) ? "called" : "caller",
					      size, mt);
			else
				dp += sprintf(dp, "callref %d %s size %d message type %s\n",
					      cr & 0x7f, (cr & 0x80) ? "called" : "caller",
					      size, mt_n0[i].descr);
		} else {	/* N1 */
			for (i = 0; i < MT_N1_LEN; i++)
				if (mt_n1[i].nr == mt)
					break;
			/* display message type if it exists */
			if (i == MT_N1_LEN)
				dp += sprintf(dp, "callref %d %s size %d unknown message type N1 %x!\n",
					      cr & 0x7f, (cr & 0x80) ? "called" : "caller",
					      size, mt);
			else
				dp += sprintf(dp, "callref %d %s size %d message type %s\n",
					      cr & 0x7f, (cr & 0x80) ? "called" : "caller",
					      size, mt_n1[i].descr);
		}

		/* display each information element */
		while (buf < bend) {
			/* Is it a single octet information element? */
			if (*buf & 0x80) {
				switch ((*buf >> 4) & 7) {
					case 1:
						dp += sprintf(dp, "  Shift %x\n", *buf & 0xf);
						cs_old = cset;
						cset = *buf & 7;
						cs_fest = *buf & 8;
						break;
					case 3:
						dp += sprintf(dp, "  Congestion level %x\n", *buf & 0xf);
						break;
					case 2:
						if (*buf == 0xa0) {
							dp += sprintf(dp, "  More data\n");
							break;
						}
						if (*buf == 0xa1) {
							dp += sprintf(dp, "  Sending complete\n");
						}
						break;
						/* fall through */
					default:
						dp += sprintf(dp, "  Reserved %x\n", *buf);
						break;
				}
				buf++;
				continue;
			}
			/* No, locate it in the table */
			if (cset == 0) {
				for (i = 0; i < WE_0_LEN; i++)
					if (*buf == we_0[i].nr)
						break;

				/* When found, give appropriate msg */
				if (i != WE_0_LEN) {
					dp += sprintf(dp, "  %s\n", we_0[i].descr);
					dp += we_0[i].f(dp, buf);
				} else
					dp += sprintf(dp, "  Codeset %d attribute %x attribute size %d\n", cset, *buf, buf[1]);
			} else if (cset == 6) {
				for (i = 0; i < WE_6_LEN; i++)
					if (*buf == we_6[i].nr)
						break;

				/* When found, give appropriate msg */
				if (i != WE_6_LEN) {
					dp += sprintf(dp, "  %s\n", we_6[i].descr);
					dp += we_6[i].f(dp, buf);
				} else
					dp += sprintf(dp, "  Codeset %d attribute %x attribute size %d\n", cset, *buf, buf[1]);
			} else
				dp += sprintf(dp, "  Unknown Codeset %d attribute %x attribute size %d\n", cset, *buf, buf[1]);
			/* Skip to next element */
			if (cs_fest == 8) {
				cset = cs_old;
				cs_old = 0;
				cs_fest = 0;
			}
			buf += buf[1] + 2;
		}
	} else if ((buf[0] == 8) && (cs->protocol == ISDN_PTYPE_NI1)) {	/* NI-1 */