61 lines
1.8 KiB
Text
61 lines
1.8 KiB
Text
$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 <sys/types.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/inet.h>
|
|
#include <sys/socket.h>
|
|
-#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/time.h>
|
|
@@ -35,10 +35,10 @@
|
|
#if 1
|
|
#include <stdio.h>
|
|
-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<len; i+=16) {
|
|
for (j=0; j<8; j++)
|
|
@@ -120,4 +120,6 @@
|
|
if (start>=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);
|
|
}
|