From: Philipp Tölke Date: Mon, 28 Jun 2010 12:37:44 +0000 (+0000) Subject: vpn: cleanup of the code X-Git-Tag: initial-import-from-subversion-38251~21149 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9f90d6df221bdb91c8cd6c8ef6ecd54a6a3a086c;p=oweals%2Fgnunet.git vpn: cleanup of the code --- 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) {{{ free(buf); }}} -int recv_ipv6pkt(int fd, struct pkt_tun** pkt) {{{ -}}} - int recv_pkt(int fd, struct pkt_tun** pkt) {{{ - // TODO: länge lesen? - *pkt = (struct pkt_tun*)malloc(1504); - struct pkt_tun* _pkt = *pkt; - - unsigned char *data = (unsigned char*)_pkt; + int size = 1504; + unsigned char data[size]; debug(1, 0, "beginning to read...\n"); - int r = read(fd, data, 1504); + int r = read(fd, data, size); debug(1, 0, "read %d bytes\n", r); + *pkt = (struct pkt_tun*)malloc(r); + + memcpy(*pkt, data, r); + struct pkt_tun *_pkt = *pkt; + debug(1, 0, "read the flags: %04x\n", ntohs(_pkt->flags)); debug(1, 0, "read the type: %04x\n", ntohs(_pkt->type)); @@ -53,7 +52,7 @@ int recv_pkt(int fd, struct pkt_tun** pkt) {{{ case 0x86dd: debug(1, 0, "reading an ipv6-packet\n"); struct ip6_pkt * pkt6 = (struct ip6_pkt*) *pkt; - int size = payload(&(pkt6->hdr)); + size = payload(&(pkt6->hdr)); debug(1, 0, "read the size: %d\n", size); return size; 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) {{{ printf("ack: %u\n", ntohs(pkt->data.ack)); printf("off: %u\n", ntohs(pkt->data.off)); printf("wsz: %u\n", ntohs(pkt->data.wsz)); - printf("crc: %u\n", ntohs(pkt->data.crc)); + printf("crc: 0x%x\n", ntohs(pkt->data.crc)); printf("urg: %u\n", ntohs(pkt->data.urg)); printf("flags: %c%c%c%c%c%c%c%c\n", pkt->data.flg & 0x80 ? 'C' : '.',