diff options
author | Philipp Tölke <toelke@in.tum.de> | 2010-08-03 18:59:06 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2010-08-03 18:59:06 +0000 |
commit | ae7b11f726ecce35865163d2b90209a9a98d25d5 (patch) | |
tree | 24d71c0430045096e86d0c53d85927d6317f033e /src | |
parent | 3ea1ee717f5bace1cc1f3ee250ab1348311e6be9 (diff) | |
download | gnunet-ae7b11f726ecce35865163d2b90209a9a98d25d5.tar.gz gnunet-ae7b11f726ecce35865163d2b90209a9a98d25d5.zip |
handle ipv4-packets
Diffstat (limited to 'src')
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.c | 49 | ||||
-rw-r--r-- | src/vpn/gnunet-vpn-packet.h | 18 | ||||
-rw-r--r-- | src/vpn/gnunet-vpn-pretty-print.c | 10 | ||||
-rw-r--r-- | src/vpn/gnunet-vpn-pretty-print.h | 1 |
4 files changed, 54 insertions, 24 deletions
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 24f141cfc..983335a10 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c | |||
@@ -66,7 +66,7 @@ static void start_helper_and_schedule(struct vpn_cls* mycls) { | |||
66 | mycls->helper_in = GNUNET_DISK_pipe(1); | 66 | mycls->helper_in = GNUNET_DISK_pipe(1); |
67 | mycls->helper_out = GNUNET_DISK_pipe(1); | 67 | mycls->helper_out = GNUNET_DISK_pipe(1); |
68 | 68 | ||
69 | mycls->helper_pid = GNUNET_OS_start_process(mycls->helper_in, mycls->helper_out, "gnunet-vpn-helper", "gnunet-vpn-helper", NULL); | 69 | mycls->helper_pid = GNUNET_OS_start_process(mycls->helper_in, mycls->helper_out, "gnunet-helper-vpn", "gnunet-helper-vpn", NULL); |
70 | 70 | ||
71 | mycls->fh_from_helper = GNUNET_DISK_pipe_handle (mycls->helper_out, GNUNET_DISK_PIPE_END_READ); | 71 | mycls->fh_from_helper = GNUNET_DISK_pipe_handle (mycls->helper_out, GNUNET_DISK_PIPE_END_READ); |
72 | 72 | ||
@@ -112,23 +112,36 @@ static void helper_read(void* cls, const struct GNUNET_SCHEDULER_TaskContext* ts | |||
112 | static void message_token(void *cls, void *client, const struct GNUNET_MessageHeader *message) { | 112 | static void message_token(void *cls, void *client, const struct GNUNET_MessageHeader *message) { |
113 | if (ntohs(message->type) != GNUNET_MESSAGE_TYPE_VPN_HELPER) return; | 113 | if (ntohs(message->type) != GNUNET_MESSAGE_TYPE_VPN_HELPER) return; |
114 | 114 | ||
115 | struct ip6_pkt *pkt6 = (struct ip6_pkt*) message; | 115 | struct tun_pkt *pkt_tun = (struct tun_pkt*) message; |
116 | struct ip6_tcp *pkt6_tcp; | 116 | |
117 | struct ip6_udp *pkt6_udp; | 117 | fprintf(stderr, "Packet, Type: %x\n", ntohs(pkt_tun->tun.type)); |
118 | 118 | ||
119 | pkt_printf(pkt6); | 119 | if (ntohs(pkt_tun->tun.type) == 0x86dd) { |
120 | switch(pkt6->ip6_hdr.nxthdr) { | 120 | struct ip6_pkt *pkt6 = (struct ip6_pkt*) message; |
121 | case 0x06: | 121 | struct ip6_tcp *pkt6_tcp; |
122 | pkt6_tcp = (struct ip6_tcp*)pkt6; | 122 | struct ip6_udp *pkt6_udp; |
123 | pkt_printf_ip6tcp(pkt6_tcp); | 123 | |
124 | break; | 124 | pkt_printf(pkt6); |
125 | case 0x11: | 125 | switch(pkt6->ip6_hdr.nxthdr) { |
126 | pkt6_udp = (struct ip6_udp*)pkt6; | 126 | case 0x06: |
127 | pkt_printf_ip6udp(pkt6_udp); | 127 | pkt6_tcp = (struct ip6_tcp*)pkt6; |
128 | if (ntohs(pkt6_udp->udp_hdr.dpt) == 53) { | 128 | pkt_printf_ip6tcp(pkt6_tcp); |
129 | pkt_printf_ip6dns((struct ip6_udp_dns*)pkt6_udp); | 129 | break; |
130 | } | 130 | case 0x11: |
131 | break; | 131 | pkt6_udp = (struct ip6_udp*)pkt6; |
132 | pkt_printf_ip6udp(pkt6_udp); | ||
133 | if (ntohs(pkt6_udp->udp_hdr.dpt) == 53) { | ||
134 | pkt_printf_ip6dns((struct ip6_udp_dns*)pkt6_udp); | ||
135 | } | ||
136 | break; | ||
137 | } | ||
138 | } else if (ntohs(pkt_tun->tun.type) == 0x0800) { | ||
139 | struct ip_pkt *pkt = (struct ip_pkt*) message; | ||
140 | struct ip_udp *udp = (struct ip_udp*) message; | ||
141 | fprintf(stderr, "IPv4\n"); | ||
142 | if (pkt->ip_hdr.proto == 0x11 && ntohl(udp->ip_hdr.dadr) == 0x0a0a0a02 && ntohs(udp->udp_hdr.dpt) == 53 ) { | ||
143 | pkt_printf_ipdns((struct ip_udp_dns*)udp); | ||
144 | } | ||
132 | } | 145 | } |
133 | 146 | ||
134 | } | 147 | } |
diff --git a/src/vpn/gnunet-vpn-packet.h b/src/vpn/gnunet-vpn-packet.h index 7bda6ab84..71908d10c 100644 --- a/src/vpn/gnunet-vpn-packet.h +++ b/src/vpn/gnunet-vpn-packet.h | |||
@@ -100,7 +100,17 @@ struct dns_record { | |||
100 | unsigned char* data; | 100 | unsigned char* data; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | struct udp_dns { | ||
104 | struct udp_pkt udp_hdr; | ||
105 | struct dns_pkt data; | ||
106 | }; | ||
107 | |||
103 | // Complete Packets | 108 | // Complete Packets |
109 | struct tun_pkt { | ||
110 | struct GNUNET_MessageHeader shdr; | ||
111 | struct pkt_tun tun; | ||
112 | }; | ||
113 | |||
104 | struct ip6_pkt { | 114 | struct ip6_pkt { |
105 | struct GNUNET_MessageHeader shdr; | 115 | struct GNUNET_MessageHeader shdr; |
106 | struct pkt_tun tun; | 116 | struct pkt_tun tun; |
@@ -128,8 +138,7 @@ struct ip6_udp_dns { | |||
128 | struct GNUNET_MessageHeader shdr; | 138 | struct GNUNET_MessageHeader shdr; |
129 | struct pkt_tun tun; | 139 | struct pkt_tun tun; |
130 | struct ip6_hdr ip6_hdr; | 140 | struct ip6_hdr ip6_hdr; |
131 | struct udp_pkt udp_hdr; | 141 | struct udp_dns udp_dns; |
132 | struct dns_pkt data; | ||
133 | }; | 142 | }; |
134 | 143 | ||
135 | struct ip_pkt { | 144 | struct ip_pkt { |
@@ -146,12 +155,11 @@ struct ip_udp { | |||
146 | struct udp_pkt udp_hdr; | 155 | struct udp_pkt udp_hdr; |
147 | unsigned char data[1]; | 156 | unsigned char data[1]; |
148 | }; | 157 | }; |
149 | |||
150 | struct ip_udp_dns { | 158 | struct ip_udp_dns { |
151 | struct GNUNET_MessageHeader shdr; | 159 | struct GNUNET_MessageHeader shdr; |
152 | struct pkt_tun tun; | 160 | struct pkt_tun tun; |
153 | struct ip_hdr ip_hdr; | 161 | struct ip_hdr ip_hdr; |
154 | struct udp_pkt udp_hdr; | 162 | struct udp_dns udp_dns; |
155 | struct dns_pkt data; | ||
156 | }; | 163 | }; |
164 | |||
157 | #endif | 165 | #endif |
diff --git a/src/vpn/gnunet-vpn-pretty-print.c b/src/vpn/gnunet-vpn-pretty-print.c index 81678d375..ea5936074 100644 --- a/src/vpn/gnunet-vpn-pretty-print.c +++ b/src/vpn/gnunet-vpn-pretty-print.c | |||
@@ -254,7 +254,7 @@ static char* dns_classes(short class) {{{ | |||
254 | return 0; | 254 | return 0; |
255 | }}} | 255 | }}} |
256 | 256 | ||
257 | void pkt_printf_ip6dns(struct ip6_udp_dns* pkt) {{{ | 257 | void pkt_printf_dns(struct udp_dns* pkt) {{{ |
258 | printf("DNS-Packet:\n"); | 258 | printf("DNS-Packet:\n"); |
259 | printf("\tid: %d\n", ntohs(pkt->data.id)); | 259 | printf("\tid: %d\n", ntohs(pkt->data.id)); |
260 | printf("\t%d: %s\n", pkt->data.qr, pkt->data.qr == 0 ? "query" : "response"); | 260 | printf("\t%d: %s\n", pkt->data.qr, pkt->data.qr == 0 ? "query" : "response"); |
@@ -292,3 +292,11 @@ void pkt_printf_ip6dns(struct ip6_udp_dns* pkt) {{{ | |||
292 | printf("query for %s type=%d (%s) class=%d (%s)\n", queries[i]->name, ntohs(queries[i]->qtype), dns_types(ntohs(queries[i]->qtype)), ntohs(queries[i]->qclass), dns_classes(ntohs(queries[i]->qclass))); | 292 | printf("query for %s type=%d (%s) class=%d (%s)\n", queries[i]->name, ntohs(queries[i]->qtype), dns_types(ntohs(queries[i]->qtype)), ntohs(queries[i]->qclass), dns_classes(ntohs(queries[i]->qclass))); |
293 | } | 293 | } |
294 | }}} | 294 | }}} |
295 | |||
296 | void pkt_printf_ip6dns(struct ip6_udp_dns* pkt) {{{ | ||
297 | pkt_printf_dns(&pkt->udp_dns); | ||
298 | }}} | ||
299 | |||
300 | void pkt_printf_ipdns(struct ip_udp_dns* pkt) {{{ | ||
301 | pkt_printf_dns(&pkt->udp_dns); | ||
302 | }}} | ||
diff --git a/src/vpn/gnunet-vpn-pretty-print.h b/src/vpn/gnunet-vpn-pretty-print.h index 57b1825b4..8e5ff66c2 100644 --- a/src/vpn/gnunet-vpn-pretty-print.h +++ b/src/vpn/gnunet-vpn-pretty-print.h | |||
@@ -11,4 +11,5 @@ void pkt_printf_ip6tcp(struct ip6_tcp* pkt); | |||
11 | void pkt_printf_ip6udp(struct ip6_udp* pkt); | 11 | void pkt_printf_ip6udp(struct ip6_udp* pkt); |
12 | void pkt_printf_ip6dns(struct ip6_udp_dns* pkt); | 12 | void pkt_printf_ip6dns(struct ip6_udp_dns* pkt); |
13 | 13 | ||
14 | void pkt_printf_ipdns(struct ip_udp_dns* pkt); | ||
14 | #endif | 15 | #endif |