summaryrefslogtreecommitdiffstats
path: root/clatd_test.cpp
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-06-02 15:49:36 +0900
committerLorenzo Colitti <lorenzo@google.com>2014-06-13 11:47:42 +0900
commite24982ea3a4480d9d62c75b4d9a416b9479f7f0b (patch)
treec70f21345c22dcdb568249ffb47df91e7b8c687d /clatd_test.cpp
parent464fb26dd770b52b44721d46ef00985dc8fc88ee (diff)
downloadandroid_external_android-clat-e24982ea3a4480d9d62c75b4d9a416b9479f7f0b.tar.gz
android_external_android-clat-e24982ea3a4480d9d62c75b4d9a416b9479f7f0b.tar.bz2
android_external_android-clat-e24982ea3a4480d9d62c75b4d9a416b9479f7f0b.zip
Make translate_packet take a fd instead of a tun header.
This will make it easier to use separate fds for reading and writing in a future change. (cherry picked from commit 91d0f1bc6dd24e54ed3caef9b08525b332ab0adf) Bug: 15340961 Change-Id: I374b85f28ae570dc82d21e1ea82a2f072fd7fba3
Diffstat (limited to 'clatd_test.cpp')
-rw-r--r--clatd_test.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/clatd_test.cpp b/clatd_test.cpp
index 5172d3f..bc32a84 100644
--- a/clatd_test.cpp
+++ b/clatd_test.cpp
@@ -424,17 +424,13 @@ void do_translate_packet(const uint8_t *original, size_t original_len, uint8_t *
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0, fds)) {
abort();
}
- struct tun_data tunnel = {
- "clat", "clat4",
- fds[0], fds[1]
- };
struct tun_pi tun_header = { 0, 0 };
char foo[512];
snprintf(foo, sizeof(foo), "%s: Invalid original packet", msg);
check_packet(original, original_len, foo);
- int read_fd;
+ int read_fd, write_fd;
uint16_t expected_proto;
int version = ip_version(original);
switch (version) {
@@ -442,18 +438,20 @@ void do_translate_packet(const uint8_t *original, size_t original_len, uint8_t *
tun_header.proto = htons(ETH_P_IP);
expected_proto = htons(ETH_P_IPV6);
read_fd = fds[1];
+ write_fd = fds[0];
break;
case 6:
tun_header.proto = htons(ETH_P_IPV6);
expected_proto = htons(ETH_P_IP);
read_fd = fds[0];
+ write_fd = fds[1];
break;
default:
FAIL() << msg << ": Unsupported IP version " << version << "\n";
break;
}
- translate_packet(&tunnel, &tun_header, original, original_len);
+ translate_packet(write_fd, (version == 4), original, original_len);
struct tun_pi new_tun_header;
struct iovec iov[] = {