aboutsummaryrefslogtreecommitdiff
path: root/src/vpn/packet.c
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2010-07-20 08:17:12 +0000
committerPhilipp Tölke <toelke@in.tum.de>2010-07-20 08:17:12 +0000
commita6e1023d634f732e986176fcfa304c65239e0e50 (patch)
tree17aab068c73fa24aede63d39b4e26f2d24458368 /src/vpn/packet.c
parent003525498eea3350f03573eb0552de60f745e44f (diff)
downloadgnunet-a6e1023d634f732e986176fcfa304c65239e0e50.tar.gz
gnunet-a6e1023d634f732e986176fcfa304c65239e0e50.zip
Rename files to fit into the convention
Diffstat (limited to 'src/vpn/packet.c')
-rw-r--r--src/vpn/packet.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/src/vpn/packet.c b/src/vpn/packet.c
deleted file mode 100644
index deda87216..000000000
--- a/src/vpn/packet.c
+++ /dev/null
@@ -1,88 +0,0 @@
1#include <errno.h>
2#include <stdlib.h>
3#include <string.h>
4#include <unistd.h>
5#include <sys/uio.h>
6
7#include <linux/if_tun.h>
8
9#include "debug.h"
10#include "packet.h"
11#include "arpa/inet.h"
12
13short payload(struct ip6_hdr* hdr) {{{
14 return ntohs(hdr->paylgth);
15}}}
16
17void send_pkt(int fd, struct ip6_pkt* pkt) {{{
18 int sz = payload(&(pkt->hdr));
19 int w = 0;
20 char* buf = (char*)pkt;
21
22 w = 0;
23 while ( w > 0) {
24 int t = write(fd, buf+w, (sz + 40) - w);
25 if (t < 0)
26 debug(1, 0, "packet: write : %s\n", strerror(errno));
27 else
28 w+=t;
29 }
30
31 free(buf);
32}}}
33
34int recv_pkt(int fd, struct pkt_tun** pkt) {{{
35 int size = 1504;
36 unsigned char data[size];
37
38 debug(1, 0, "beginning to read...\n");
39
40 int r = read(fd, data, size);
41 debug(1, 0, "read %d bytes\n", r);
42
43 *pkt = (struct pkt_tun*)malloc(r);
44
45 memcpy(*pkt, data, r);
46 struct pkt_tun *_pkt = *pkt;
47
48 debug(1, 0, "read the flags: %04x\n", ntohs(_pkt->flags));
49 debug(1, 0, "read the type: %04x\n", ntohs(_pkt->type));
50
51 switch(ntohs(_pkt->type)) {
52 case 0x86dd:
53 debug(1, 0, "reading an ipv6-packet\n");
54 struct ip6_pkt * pkt6 = (struct ip6_pkt*) *pkt;
55 size = payload(&(pkt6->hdr));
56 // TODO: size might be greater than r!
57 debug(1, 0, "read the size: %d\n", size);
58 return size;
59 break;
60 case 0x0800:
61 debug(1, 0, "unknown pkt-type: IPv4\n");
62 //IPv4 TODO
63 break;
64 default:
65 debug(1, 0, "unknown pkt-type: 0x%02x\n", 0x800);
66 //Whatever TODO
67 break;
68 }
69 return -1;
70}}}
71
72struct ip6_pkt* parse_ip6(struct pkt_tun* pkt) {{{
73 struct ip6_pkt* pkt6 = (struct ip6_pkt*)pkt;
74
75 return pkt6;
76}}}
77
78struct ip6_tcp* parse_ip6_tcp(struct ip6_pkt* pkt) {{{
79 struct ip6_tcp* res = (struct ip6_tcp*) pkt;
80
81 return res;
82}}}
83
84struct ip6_udp* parse_ip6_udp(struct ip6_pkt* pkt) {{{
85 struct ip6_udp* res = (struct ip6_udp*) pkt;
86
87 return res;
88}}}