summaryrefslogtreecommitdiffstats
path: root/ipv6.c
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-04-08 19:12:43 +0900
committerLorenzo Colitti <lorenzo@google.com>2013-04-12 09:59:11 +0900
commit5cc877d4fc20d66ca5a057a3dc445adb998409bd (patch)
tree04c07f58d75f425022269f6a441e59fa890f5729 /ipv6.c
parentf913fe49272286a7f1e58d94a208b6dc06a51fd2 (diff)
downloadandroid_external_android-clat-5cc877d4fc20d66ca5a057a3dc445adb998409bd.tar.gz
android_external_android-clat-5cc877d4fc20d66ca5a057a3dc445adb998409bd.tar.bz2
android_external_android-clat-5cc877d4fc20d66ca5a057a3dc445adb998409bd.zip
Treat the options as part of the TCP header.
This simplifies the code and makes UDP and TCP look the same. It will also make it easier to implement nested translation in the future because there will only be one iovec array entry for the transport layer header, regardless of whether we are translating UDP or TCP and regardless of the presence of options. Also get rid of a couple of memcpy statements by pointing to the original data instead. Bug: 8276725 Change-Id: I6a702aefdf3a070eedfc6f7d3ebec21880ecc22b
Diffstat (limited to 'ipv6.c')
-rw-r--r--ipv6.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/ipv6.c b/ipv6.c
index 8fc36a4..61013f2 100644
--- a/ipv6.c
+++ b/ipv6.c
@@ -66,40 +66,30 @@ void icmp6_packet(int fd, const char *packet, size_t len, struct ip6_hdr *ip6) {
* ip6 - ip6 header
*/
void tcp6_packet(int fd, const char *packet, size_t len, struct ip6_hdr *ip6) {
- struct tcphdr tcp;
+ const struct tcphdr *tcp = (const struct tcphdr *) packet;
const char *payload;
- const char *options;
- size_t payload_size, options_size;
+ size_t payload_size, header_size;
if(len < sizeof(tcp)) {
logmsg_dbg(ANDROID_LOG_ERROR,"tcp6_packet/(too small)");
return;
}
- memcpy(&tcp, packet, sizeof(tcp));
-
- if(tcp.doff < 5) {
- logmsg_dbg(ANDROID_LOG_ERROR,"tcp6_packet/tcp header length set to less than 5: %x",tcp.doff);
+ if(tcp->doff < 5) {
+ logmsg_dbg(ANDROID_LOG_ERROR,"tcp6_packet/tcp header length set to less than 5: %x", tcp->doff);
return;
}
- if((size_t)tcp.doff*4 > len) {
- logmsg_dbg(ANDROID_LOG_ERROR,"tcp6_packet/tcp header length set too large: %x",tcp.doff);
+ if((size_t) tcp->doff*4 > len) {
+ logmsg_dbg(ANDROID_LOG_ERROR,"tcp6_packet/tcp header length set too large: %x", tcp->doff);
return;
}
- if(tcp.doff > 5) {
- options = packet + sizeof(tcp);
- options_size = tcp.doff*4 - sizeof(tcp);
- } else {
- options = NULL;
- options_size = 0;
- }
-
- payload = packet + tcp.doff*4;
- payload_size = len - tcp.doff*4;
+ header_size = tcp->doff * 4;
+ payload = packet + header_size;
+ payload_size = len - header_size;
- tcp6_to_tcp(fd,ip6,&tcp,payload,payload_size,options,options_size);
+ tcp6_to_tcp(fd, ip6, tcp, header_size, payload, payload_size);
}
/* function: udp6_packet