summaryrefslogtreecommitdiffstats
path: root/translate.h
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-02-25 09:27:31 +0900
committerLorenzo Colitti <lorenzo@google.com>2014-02-25 14:42:22 +0900
commita4454bfda99803c287b78f8d1cd7bdc1b56065db (patch)
treecfd53ea75be3ab1de009c549e703319a4ad2473a /translate.h
parentfcac410fa15613873a07143ccd46470b869346a3 (diff)
downloadandroid_external_android-clat-a4454bfda99803c287b78f8d1cd7bdc1b56065db.tar.gz
android_external_android-clat-a4454bfda99803c287b78f8d1cd7bdc1b56065db.tar.bz2
android_external_android-clat-a4454bfda99803c287b78f8d1cd7bdc1b56065db.zip
Declare pos as clat_packet_index instead of int
Bug: 11542311 Change-Id: Id5771c9685286b70a8ad283c259c7f83662e8b76
Diffstat (limited to 'translate.h')
-rw-r--r--translate.h31
1 files changed, 15 insertions, 16 deletions
diff --git a/translate.h b/translate.h
index ab20a55..421d2a5 100644
--- a/translate.h
+++ b/translate.h
@@ -36,18 +36,18 @@
// 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.
-enum clat_packet_index {
+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, int pos);
+uint16_t packet_checksum(uint32_t checksum, clat_packet packet, clat_packet_index pos);
// Returns the total length of the packet components after pos.
-uint16_t packet_length(clat_packet packet, int pos);
+uint16_t packet_length(clat_packet packet, clat_packet_index pos);
// Returns true iff the given IPv6 address is in the plat subnet.
int is_in_plat_subnet(const struct in6_addr *addr6);
@@ -64,8 +64,8 @@ void translate_packet(const struct tun_data *tunnel, struct tun_pi *tun_header,
const uint8_t *packet, size_t packetsize);
// Translate IPv4 and IPv6 packets.
-int ipv4_packet(clat_packet out, int pos, const uint8_t *packet, size_t len);
-int ipv6_packet(clat_packet out, int pos, const uint8_t *packet, size_t len);
+int ipv4_packet(clat_packet out, clat_packet_index pos, const uint8_t *packet, size_t len);
+int ipv6_packet(clat_packet out, clat_packet_index pos, const uint8_t *packet, size_t len);
// Deal with fragmented packets.
size_t maybe_fill_frag_header(struct ip6_frag *frag_hdr, struct ip6_hdr *ip6_targ,
@@ -73,25 +73,24 @@ size_t maybe_fill_frag_header(struct ip6_frag *frag_hdr, struct ip6_hdr *ip6_tar
uint8_t parse_frag_header(const struct ip6_frag *frag_hdr, struct iphdr *ip_targ);
// Translate ICMP packets.
-int icmp_to_icmp6(clat_packet out, int pos, const struct icmphdr *icmp, uint32_t checksum,
- const uint8_t *payload, size_t payload_size);
-int icmp6_to_icmp(clat_packet out, int pos, const struct icmp6_hdr *icmp6,
+int icmp_to_icmp6(clat_packet out, clat_packet_index pos, const struct icmphdr *icmp,
+ uint32_t checksum, const uint8_t *payload, size_t payload_size);
+int icmp6_to_icmp(clat_packet out, clat_packet_index pos, const struct icmp6_hdr *icmp6,
const uint8_t *payload, size_t payload_size);
// Translate generic IP packets.
-int generic_packet(clat_packet out, int pos,
- const uint8_t *payload, size_t len);
+int generic_packet(clat_packet out, clat_packet_index pos, const uint8_t *payload, size_t len);
// Translate TCP and UDP packets.
-int tcp_packet(clat_packet out, int pos, const struct tcphdr *tcp,
+int tcp_packet(clat_packet out, clat_packet_index pos, const struct tcphdr *tcp,
uint32_t old_sum, uint32_t new_sum, size_t len);
-int udp_packet(clat_packet out, int pos, const struct udphdr *udp,
+int udp_packet(clat_packet out, clat_packet_index pos, const struct udphdr *udp,
uint32_t old_sum, uint32_t new_sum, size_t len);
-int tcp_translate(clat_packet out, int pos, const struct tcphdr *tcp, size_t header_size,
- uint32_t old_sum, uint32_t new_sum,
+int tcp_translate(clat_packet out, clat_packet_index pos, const struct tcphdr *tcp,
+ size_t header_size, uint32_t old_sum, uint32_t new_sum,
const uint8_t *payload, size_t payload_size);
-int udp_translate(clat_packet out, int pos, const struct udphdr *udp,
+int udp_translate(clat_packet out, clat_packet_index pos, const struct udphdr *udp,
uint32_t old_sum, uint32_t new_sum,
const uint8_t *payload, size_t payload_size);