打开ppp packet打印

diff --git a/pppd/utils.c b/pppd/utils.c
index 6f668b8..6f1db8f 100644
--- a/pppd/utils.c
+++ b/pppd/utils.c
@@ -670,9 +670,10 @@ log_write(level, buf)
     int level;
     char *buf;
 {
+    dbglog("%s",buf);
     syslog(level, "%s", buf);
 
-    fprintf(stderr, buf);
+    fprintf(stderr,"%s", buf);
     
     if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) {
        int n = strlen(buf);


@@ -861,8 +862,20 @@ dump_packet(const char *tag, unsigned char *p, int len)
            && l >= HEADERLEN && l <= len - PPP_HDRLEN)
            return;
     }
+    {
+       char bufout[100] = {0};
+       int i = 0;
+       int level;
 
-    dbglog("%s %P", tag, p, len);
+       for(i = 0; i < len; i++)
+           sprintf(&(bufout[2*i]), "%.2x", p[i]);
+        dbglog("%s [%s], len %d", tag, bufout, len);
+
+       level = ANDROID_LOG_DEBUG;
+       init_pr_log(tag, level);
+       format_packet(p, len, pr_log, &level);
+       end_pr_log();
+    }
 }


修改后的函数如下
static void
log_write(level, buf)
    int level;
    char *buf;
{
    dbglog("%s",buf);
    syslog(level, "%s", buf);

    fprintf(stderr,"%s", buf);
    
    if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) {
	int n = strlen(buf);

	if (n > 0 && buf[n-1] == '\n')
	    --n;
	if (write(log_to_fd, buf, n) != n
	    || write(log_to_fd, "\n", 1) != 1)
	    log_to_fd = -1;
    }
}

void
dump_packet(const char *tag, unsigned char *p, int len)
{
    int proto;

    if (!debug)
	return;

    /*
     * don't print LCP echo request/reply packets if debug <= 1
     * and the link is up.
     */
    proto = (p[2] << 8) + p[3];
    if (debug <= 1 && unsuccess == 0 && proto == PPP_LCP
	&& len >= PPP_HDRLEN + HEADERLEN) {
	unsigned char *lcp = p + PPP_HDRLEN;
	int l = (lcp[2] << 8) + lcp[3];

	if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP)
	    && l >= HEADERLEN && l <= len - PPP_HDRLEN)
	    return;
    }
    {
	char bufout[100] = {0};
	int i = 0;
	int level;

	for(i = 0; i < len; i++)
	    sprintf(&(bufout[2*i]), "%.2x", p[i]);
        dbglog("%s [%s], len %d", tag, bufout, len);

	level = ANDROID_LOG_DEBUG;
	init_pr_log(tag, level);
	format_packet(p, len, pr_log, &level);
	end_pr_log();
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值