aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2010-06-28 12:37:44 +0000
committerPhilipp Tölke <toelke@in.tum.de>2010-06-28 12:37:44 +0000
commit9f90d6df221bdb91c8cd6c8ef6ecd54a6a3a086c (patch)
tree92bbfcd762408b8b1c11f44cc022856c8a1ed3c8 /src
parenta5cff0a0a73df5c9155e90c93dd59a92da705c95 (diff)
downloadgnunet-9f90d6df221bdb91c8cd6c8ef6ecd54a6a3a086c.tar.gz
gnunet-9f90d6df221bdb91c8cd6c8ef6ecd54a6a3a086c.zip
vpn: cleanup of the code
Diffstat (limited to 'src')
-rw-r--r--src/vpn/packet.c19
-rw-r--r--src/vpn/pretty-print.c2
2 files changed, 10 insertions, 11 deletions
diff --git a/src/vpn/packet.c b/src/vpn/packet.c
index 4e96fb5f1..963c6948f 100644
--- a/src/vpn/packet.c
+++ b/src/vpn/packet.c
@@ -31,21 +31,20 @@ void send_pkt(int fd, struct ip6_pkt* pkt) {{{
31 free(buf); 31 free(buf);
32}}} 32}}}
33 33
34int recv_ipv6pkt(int fd, struct pkt_tun** pkt) {{{
35}}}
36
37int recv_pkt(int fd, struct pkt_tun** pkt) {{{ 34int recv_pkt(int fd, struct pkt_tun** pkt) {{{
38 // TODO: länge lesen? 35 int size = 1504;
39 *pkt = (struct pkt_tun*)malloc(1504); 36 unsigned char data[size];
40 struct pkt_tun* _pkt = *pkt;
41
42 unsigned char *data = (unsigned char*)_pkt;
43 37
44 debug(1, 0, "beginning to read...\n"); 38 debug(1, 0, "beginning to read...\n");
45 39
46 int r = read(fd, data, 1504); 40 int r = read(fd, data, size);
47 debug(1, 0, "read %d bytes\n", r); 41 debug(1, 0, "read %d bytes\n", r);
48 42
43 *pkt = (struct pkt_tun*)malloc(r);
44
45 memcpy(*pkt, data, r);
46 struct pkt_tun *_pkt = *pkt;
47
49 debug(1, 0, "read the flags: %04x\n", ntohs(_pkt->flags)); 48 debug(1, 0, "read the flags: %04x\n", ntohs(_pkt->flags));
50 debug(1, 0, "read the type: %04x\n", ntohs(_pkt->type)); 49 debug(1, 0, "read the type: %04x\n", ntohs(_pkt->type));
51 50
@@ -53,7 +52,7 @@ int recv_pkt(int fd, struct pkt_tun** pkt) {{{
53 case 0x86dd: 52 case 0x86dd:
54 debug(1, 0, "reading an ipv6-packet\n"); 53 debug(1, 0, "reading an ipv6-packet\n");
55 struct ip6_pkt * pkt6 = (struct ip6_pkt*) *pkt; 54 struct ip6_pkt * pkt6 = (struct ip6_pkt*) *pkt;
56 int size = payload(&(pkt6->hdr)); 55 size = payload(&(pkt6->hdr));
57 debug(1, 0, "read the size: %d\n", size); 56 debug(1, 0, "read the size: %d\n", size);
58 return size; 57 return size;
59 break; 58 break;
diff --git a/src/vpn/pretty-print.c b/src/vpn/pretty-print.c
index 96e435d2d..22a642728 100644
--- a/src/vpn/pretty-print.c
+++ b/src/vpn/pretty-print.c
@@ -151,7 +151,7 @@ void pkt_printf_ip6tcp(struct ip6_tcp* pkt) {{{
151 printf("ack: %u\n", ntohs(pkt->data.ack)); 151 printf("ack: %u\n", ntohs(pkt->data.ack));
152 printf("off: %u\n", ntohs(pkt->data.off)); 152 printf("off: %u\n", ntohs(pkt->data.off));
153 printf("wsz: %u\n", ntohs(pkt->data.wsz)); 153 printf("wsz: %u\n", ntohs(pkt->data.wsz));
154 printf("crc: %u\n", ntohs(pkt->data.crc)); 154 printf("crc: 0x%x\n", ntohs(pkt->data.crc));
155 printf("urg: %u\n", ntohs(pkt->data.urg)); 155 printf("urg: %u\n", ntohs(pkt->data.urg));
156 printf("flags: %c%c%c%c%c%c%c%c\n", 156 printf("flags: %c%c%c%c%c%c%c%c\n",
157 pkt->data.flg & 0x80 ? 'C' : '.', 157 pkt->data.flg & 0x80 ? 'C' : '.',