summaryrefslogtreecommitdiffstats
path: root/translate.h
Commit message (Collapse)AuthorAgeFilesLines
* clatd: Relay checksum information from packet socket to TUN interfaceSubash Abhinov Kasiviswanathan2015-11-151-2/+2
| | | | | | | | | | | | | | | | | | With this change, we can notify network stack to disable checksum validation for GRO packets as well as other packets which have checksum validation completed earlier in a driver. GRO packets have the ip_summed field set to CHECKSUM_PARTIAL while checksum offloaded packets have the ip_summed field as CHECKSUM_UNNECESSARY. Kernel copies this ip_summed field to the status field in the tpacket filter. The information from the status field is then passed as part of the TUN header to the TUN interface. Any other packet will have the complete checksum validation done in the network stack. Note that this only applies to packets which are captured in packet sockets and passed onto the TUN interface. Change-Id: I536c0356cbbf30fed7ecda5fdd0d38fa0dfd7bf3
* Move send_tun into tun.c as well.Lorenzo Colitti2014-12-081-11/+0
| | | | | | Also remove a redundant include in checksum.c. Change-Id: I0b8858343b1496f22904d3b316b6c435be0f648a
* Make translate_packet take a fd instead of a tun header.Lorenzo Colitti2014-06-101-2/+1
| | | | | | | | This will make it easier to use separate fds for reading and writing in a future change. Bug: 15340961 Change-Id: I5b081b05765cae0488ac599be5738ce9737cae41
* resolved conflicts for merge of e22ed104 to klp-modular-dev-plus-aospLorenzo Colitti2014-03-131-0/+5
|\ | | | | | | Change-Id: I6d77583042b4707e4e9dda7c4641019c5c5a7248
| * DO NOT MERGE: Support translating fragmented packets.Lorenzo Colitti2014-03-101-3/+10
| | | | | | | | | | Bug: 11542311 Change-Id: I5dd29805e12b919ae3105b6128aaedefd7e78b48
| * DO NOT MERGE: Move translation entry point into translate.c.Lorenzo Colitti2014-03-101-0/+14
| | | | | | | | | | | | | | | | | | | | | | The entry point to the translation code is currently called packet_handler and lives in clatd.c. Move it into translate.c and rename it to translate_packet, since that's what it does. Also get rid of some redundant includes. Bug: 11542311 Change-Id: I821bb9590b9105ea1d425c3bbe0e634c4ce667b5
| * DO NOT MERGE: Fix up checksums instead of recalculating them.Lorenzo Colitti2014-03-101-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | Currently the checksums of translated packets are calculated from scratch by checksumming the translated packet. This is slow and does not work in the case of fragments, because the whole packet is not available. Instead, calculate the checksum by adjusting the checksum of the original packet. Bug: 11542311 Bug: 12116252 Change-Id: I457347753d1bb5b23e3ae759bf2e4388102772d7
| * DO NOT MERGE: Add generic IP packet code and use it for GRE.Lorenzo Colitti2014-03-101-0/+3
| | | | | | | | | | Bug: 11542311 Change-Id: I91040f35814bd7b23288228a7fdf80f1be2f5a04
| * DO NOT MERGE: Fix compiler warnings and enable -Wall -WerrorLorenzo Colitti2014-03-101-1/+1
| | | | | | | | Change-Id: I4eb9eb407500893a27745ed2df6da9a378ddb159
| * DO NOT MERGE: Remove two almost-unused include files.Lorenzo Colitti2014-03-101-0/+4
| | | | | | | | | | | | This fixes a compiler warning. Change-Id: I7f4a866fd5a65a64861fe22e9d32a1a8b8e9758d
| * Revert "DO NOT MERGE: Remove two almost-unused include files."Lorenzo Colitti2014-03-081-4/+0
| | | | | | | | | | | | This reverts commit 86cb1ac3d69805bebcac7a18b408d656603028f4. Change-Id: If592b80e8107f468c2fe1caf00fcff49f25a9441
| * DO NOT MERGE: Remove two almost-unused include files.Lorenzo Colitti2014-03-091-0/+4
| | | | | | | | | | | | This fixes a compiler warning. Change-Id: I14b5d3c871e9b2fdc8400d999e76e494ad510328
* | Declare pos as clat_packet_index instead of intLorenzo Colitti2014-02-251-16/+15
| | | | | | | | | | Bug: 11542311 Change-Id: Id5771c9685286b70a8ad283c259c7f83662e8b76
* | Use uint8_t not char for binary data to avoid -Wall -Werror issues on x86 buildsBrian Carlstrom2014-02-241-9/+12
| | | | | | | | Change-Id: Ib61e67f15360c27c3ebf61f870a9482217c52357
* | Support translating fragmented packets.Lorenzo Colitti2014-02-221-3/+10
| | | | | | | | | | Bug: 11542311 Change-Id: I14a20b9ac669cdb5927f6ac26147bb0109099497
* | Move translation entry point into translate.c.Lorenzo Colitti2014-02-141-0/+14
| | | | | | | | | | | | | | | | | | | | | | The entry point to the translation code is currently called packet_handler and lives in clatd.c. Move it into translate.c and rename it to translate_packet, since that's what it does. Also get rid of some redundant includes. Bug: 11542311 Change-Id: I8529fb87f3a86ee6724fad54787c33a5e86c56ab
* | Fix up checksums instead of recalculating them.Lorenzo Colitti2014-02-141-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | Currently the checksums of translated packets are calculated from scratch by checksumming the translated packet. This is slow and does not work in the case of fragments, because the whole packet is not available. Instead, calculate the checksum by adjusting the checksum of the original packet. Bug: 11542311 Bug: 12116252 Change-Id: I6b78a94ca5bd96b13ee2653b6200551193b3dcc1
* | Add generic IP packet code and use it for GRE.Lorenzo Colitti2013-11-251-0/+3
| | | | | | | | | | Bug: 11542311 Change-Id: I174e0b268869bc77927feeee57003580c47c30f2
* | Fix compiler warnings and enable -Wall -WerrorLorenzo Colitti2013-11-181-1/+1
| | | | | | | | Change-Id: I24847fa35644d92bff0fe31ccfc5c4b3e8705779
* | Remove two almost-unused include files.Lorenzo Colitti2013-11-181-0/+4
|/ | | | | | This fixes a compiler warning. Change-Id: I14b5d3c871e9b2fdc8400d999e76e494ad510328
* Support translating ICMP errors.Lorenzo Colitti2013-04-121-0/+1
| | | | | | | | | When receiving ICMPv6 messages from IPv6-only nodes, use 255.0.0.<ttl> as a fake IPv4 source address. It's better than nothing. Bug: 8276725 Change-Id: Iae93f75764cb9cd875af9bb5f1862a0dce2c2fa7
* Improve checksum calculation and address checkingLorenzo Colitti2013-04-121-8/+15
| | | | | | | | | | | | | 1. Add a function that calculates the checksum of all the packet components starting from the specified position. This simplifies the code a bit and makes it easier to translate nested packets like ICMP error messages. 2. Don't hardcode IP source and destination addresses. This is required to translate ICMP error messages. Bug: 8276725 Change-Id: I2cae45683ae3943e508608fd0a140180dbc60823
* Pass around packet data instead of fdsLorenzo Colitti2013-04-121-8/+33
| | | | | | | | | | | | | | | | | The current code calls all the translation functions one after another, accumulating the translated packet into local variables on the stack and calling writev() at the end. This does not allow calling the translation functions re-entrantly, which is needed, for example, to translate ICMP errors (which contain the packet that caused them). Define a clat_packet type to wrap the array of iovecs and an enum of packet positions. Also clean up the code a bit: get rid of a fair bit of duplicated code (though there is still some left), get rid of some redundant memcpy statements, fix style issues, etc. Bug: 8276725 Change-Id: Ib58d2348894e82275234fc67dbdb1f82753f204f
* Treat the options as part of the TCP header.Lorenzo Colitti2013-04-121-2/+4
| | | | | | | | | | | | | | 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
* android clat serviceDaniel Drown2012-11-121-0/+30
This software provides the nat 4->6 translation needed for the "clat" part of the 464xlat standard. It is needed for better IPv4 application support while on an IPv6-only mobile network connection using 464xlat's nat64 (such as T-Mobile's IPv6 trial). A general diagram of how 464xlat works: http://dan.drown.org/android/clat/Clat-Plat.png Depends-on: I2392f8127dcd90d16b0f20ff31bcc5aa096db464 Change-Id: If2bc6916fc66fd4bca7cc241c83cfae839b82e15 Signed-off-by: Daniel Drown <dan-android@drown.org>