diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2014-12-08 12:53:05 +0900 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2015-03-03 16:50:25 +0900 |
commit | 8dcc99dbbb7a49370dfb30ab73ded5234385cfe9 (patch) | |
tree | ec5546f71db73f5f02d1991106717d6782aa03bf | |
parent | 4b3c23768cb81ac16838834d3ef3c26984137066 (diff) | |
download | android_external_android-clat-8dcc99dbbb7a49370dfb30ab73ded5234385cfe9.tar.gz android_external_android-clat-8dcc99dbbb7a49370dfb30ab73ded5234385cfe9.tar.bz2 android_external_android-clat-8dcc99dbbb7a49370dfb30ab73ded5234385cfe9.zip |
Move send_tun into tun.c as well.
Also remove a redundant include in checksum.c.
(cherry picked from commit 6b2007aacd13344c9bc73d5d858bd903b432c228)
Change-Id: I8fd33ff52375b51e5d2f15b0a206d0a2dd3ba461
-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 |