$NetBSD: patch-ad,v 1.2 2000/04/10 01:24:39 jtk Exp $ Index: pptp_gre.c --- pptp_gre.c.orig Wed Feb 18 17:42:14 1998 +++ pptp_gre.c Sun Apr 9 21:21:00 2000 @@ -6,8 +6,8 @@ */ +#include #include #include #include -#include #include #include @@ -35,10 +35,10 @@ #if 1 #include -void print_packet(int fd, void *pack, unsigned len) { +void print_packet(int fd, void *pack, unsigned len, const char *msg) { unsigned char *b = (unsigned char *)pack; unsigned 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=end) { if ((status=read(fd,buffer,sizeof(buffer)))<0) return status; + if (status == 0) + return -1; /* FD is closed */ end = status; start = 0; } @@ -199,4 +201,5 @@ header = (struct pptp_gre_header *)(buffer+ip_len); +/* print_packet(2, buffer, status, "in");*/ /* verify packet (else discard) */ if (((ntoh8(header->ver)&0x7F)!=PPTP_GRE_VER) || /* version should be 1 */ @@ -259,5 +262,5 @@ /* special case ACK with no payload */ - if (pack==NULL) + if (pack==NULL) { if (ack_sent != seq_recv) { u.header.ver |= hton8(PPTP_GRE_FLAG_A); @@ -267,4 +270,5 @@ return write(fd, &u.header, sizeof(u.header)-sizeof(u.header.seq)); } else return 0; /* we don't need to send ACK */ + } /* send packet with payload */ u.header.flags |= hton8(PPTP_GRE_FLAG_S); @@ -284,5 +288,5 @@ 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");*/ return write(fd, u.buffer, header_len+len); }