diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2014-12-09 23:22:58 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-12-09 23:22:58 +0000 |
commit | b3d38d834365a913614b22eea653488a178b7659 (patch) | |
tree | aa3d0b82822c2fabef61de0b475a3c71932f117a | |
parent | 6057dd5fe66d53686990cf512f0c9fdbac0ca131 (diff) | |
parent | 400153fc8d1ae20a2fabec36e3144e7623f282d4 (diff) | |
download | platform_external_android-clat-b3d38d834365a913614b22eea653488a178b7659.tar.gz platform_external_android-clat-b3d38d834365a913614b22eea653488a178b7659.tar.bz2 platform_external_android-clat-b3d38d834365a913614b22eea653488a178b7659.zip |
am 400153fc: resolved conflicts for merge of 6b2007aa to lmp-mr1-dev-plus-aosp
* commit '400153fc8d1ae20a2fabec36e3144e7623f282d4':
Move send_tun into tun.c as well.
-rw-r--r-- | Android.mk | 2 | ||||
-rw-r--r-- | checksum.c | 1 | ||||
-rw-r--r-- | clatd.h | 13 | ||||
-rw-r--r-- | translate.c | 6 | ||||
-rw-r--r-- | translate.h | 11 | ||||
-rw-r--r-- | tun.c | 7 | ||||
-rw-r--r-- | tun.h | 5 |
7 files changed, 27 insertions, 18 deletions
@@ -30,7 +30,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := clatd_test LOCAL_CFLAGS := -Wall -Werror -Wunused-parameter -LOCAL_SRC_FILES := clatd_test.cpp checksum.c translate.c icmp.c ipv4.c ipv6.c logging.c config.c +LOCAL_SRC_FILES := clatd_test.cpp checksum.c translate.c icmp.c ipv4.c ipv6.c logging.c config.c tun.c LOCAL_MODULE_TAGS := eng tests LOCAL_SHARED_LIBRARIES := liblog @@ -22,7 +22,6 @@ #include <netinet/tcp.h> #include <netinet/ip6.h> #include <netinet/icmp6.h> -#include <linux/icmp.h> #include "checksum.h" @@ -18,6 +18,8 @@ #ifndef __CLATD_H__ #define __CLATD_H__ +#include <sys/uio.h> + #define MAXMTU 1500 #define PACKETLEN (MAXMTU+sizeof(struct tun_pi)) #define CLATD_VERSION "1.4" @@ -30,4 +32,15 @@ // how frequently (in seconds) to poll for an address change while there is no traffic #define NO_TRAFFIC_INTERFACE_POLL_FREQUENCY 90 +// A clat_packet is an array of iovec structures representing a packet that we are translating. +// The CLAT_POS_XXX constants represent the array indices within the clat_packet that contain +// specific parts of the packet. The packet_* functions operate on all the packet segments past a +// given position. +typedef enum { + CLAT_POS_TUNHDR, CLAT_POS_IPHDR, CLAT_POS_FRAGHDR, CLAT_POS_TRANSPORTHDR, + CLAT_POS_ICMPERR_IPHDR, CLAT_POS_ICMPERR_FRAGHDR, CLAT_POS_ICMPERR_TRANSPORTHDR, + CLAT_POS_PAYLOAD, CLAT_POS_MAX +} clat_packet_index; +typedef struct iovec clat_packet[CLAT_POS_MAX]; + #endif /* __CLATD_H__ */ diff --git a/translate.c b/translate.c index 487468b..ddc9bac 100644 --- a/translate.c +++ b/translate.c @@ -16,7 +16,6 @@ * translate.c - CLAT functions / partial implementation of rfc6145 */ #include <string.h> -#include <sys/uio.h> #include "icmp.h" #include "translate.h" @@ -25,6 +24,7 @@ #include "config.h" #include "logging.h" #include "debug.h" +#include "tun.h" /* function: packet_checksum * calculates the checksum over all the packet components starting from pos @@ -465,10 +465,6 @@ int tcp_translate(clat_packet out, clat_packet_index pos, const struct tcphdr *t return CLAT_POS_PAYLOAD + 1; } -void send_tun(int fd, clat_packet out, int iov_len) { - writev(fd, out, iov_len); -} - // Weak symbol so we can override it in the unit test. void send_rawv6(int fd, clat_packet out, int iov_len) __attribute__((weak)); diff --git a/translate.h b/translate.h index 46e178b..aa8b736 100644 --- a/translate.h +++ b/translate.h @@ -32,17 +32,6 @@ #define MAX_TCP_HDR (15 * 4) // Data offset field is 4 bits and counts in 32-bit words. -// A clat_packet is an array of iovec structures representing a packet that we are translating. -// The CLAT_POS_XXX constants represent the array indices within the clat_packet that contain -// specific parts of the packet. The packet_* functions operate on all the packet segments past a -// given position. -typedef enum { - CLAT_POS_TUNHDR, CLAT_POS_IPHDR, CLAT_POS_FRAGHDR, CLAT_POS_TRANSPORTHDR, - CLAT_POS_ICMPERR_IPHDR, CLAT_POS_ICMPERR_FRAGHDR, CLAT_POS_ICMPERR_TRANSPORTHDR, - CLAT_POS_PAYLOAD, CLAT_POS_MAX -} clat_packet_index; -typedef struct iovec clat_packet[CLAT_POS_MAX]; - // Calculates the checksum over all the packet components starting from pos. uint16_t packet_checksum(uint32_t checksum, clat_packet packet, clat_packet_index pos); @@ -22,6 +22,9 @@ #include <linux/if.h> #include <linux/if_tun.h> #include <sys/ioctl.h> +#include <sys/uio.h> + +#include "clatd.h" /* function: tun_open * tries to open the tunnel device @@ -60,3 +63,7 @@ int tun_alloc(char *dev, int fd) { strcpy(dev, ifr.ifr_name); return 0; } + +void send_tun(int fd, clat_packet out, int iov_len) { + writev(fd, out, iov_len); +} @@ -18,6 +18,10 @@ #ifndef __TUN_H__ #define __TUN_H__ +#include <linux/if.h> + +#include "clatd.h" + struct tun_data { char device4[IFNAMSIZ]; int read_fd6, write_fd6, fd4; @@ -26,5 +30,6 @@ struct tun_data { int set_nonblocking(int fd); int tun_open(); int tun_alloc(char *dev, int fd); +void send_tun(int fd, clat_packet out, int iov_len); #endif |