2013-09-26 17:14:40 +02:00

48 lines
1.8 KiB
Plaintext

$NetBSD: patch-ad,v 1.3 2006/03/14 13:53:57 rillig Exp $
Added more logging.
--- pptp_gre.c.orig 2005-07-28 03:15:11.000000000 +0200
+++ pptp_gre.c 2006-03-14 14:15:51.000000000 +0100
@@ -44,12 +44,12 @@ int dequeue_gre(callback_t callback, int
#if 1
#include <stdio.h>
-void print_packet(int fd, void *pack, unsigned int len)
+void print_packet(int fd, void *pack, unsigned int len, const char *msg)
{
unsigned char *b = (unsigned char *)pack;
unsigned int i,j;
FILE *out = fdopen(fd, "w");
- fprintf(out,"-- begin packet (%u) --\n", len);
+ fprintf(out,"-- begin %s packet (%u) --\n", msg, len);
for (i = 0; i < len; i += 16) {
for (j = 0; j < 8; j++)
if (i + 2 * j + 1 < len)
@@ -234,6 +234,8 @@ int decaps_hdlc(int fd, int (*cb)(int cl
if ( start + len <= end)
if ((status = cb (cl, buffer + start, len)) < 0)
return status; /* error-check */
+ if (status == 0)
+ return -1; /* avoid an endless loop */
start += len;
}
return 0;
@@ -329,6 +331,7 @@ int decaps_gre (int fd, callback_t callb
if ((buffer[0] & 0xF0) == 0x40)
ip_len = (buffer[0] & 0xF) * 4;
header = (struct pptp_gre_header *)(buffer + ip_len);
+ /* print_packet(2, buffer, status, "in"); */
/* verify packet (else discard) */
if ( /* version should be 1 */
((ntoh8(header->ver) & 0x7F) != PPTP_GRE_VER) ||
@@ -508,7 +511,7 @@ int encaps_gre (int fd, void *pack, unsi
/* record and increment sequence numbers */
seq_sent = seq; seq++;
/* write this baby out to the net */
- /* print_packet(2, u.buffer, header_len + len); */
+ /* print_packet(2, u.buffer, header_len + len, "out"); */
rc = write(fd, u.buffer, header_len + len);
if (rc < 0) {
stats.tx_failed++;