Add generic IP packet code and use it for GRE.
Bug: 11542311
Change-Id: I174e0b268869bc77927feeee57003580c47c30f2
diff --git a/translate.c b/translate.c
index 75ad08a..927b49c 100644
--- a/translate.c
+++ b/translate.c
@@ -279,6 +279,22 @@
return clat_packet_len;
}
+/* function: generic_packet
+ * takes a generic IP packet and sets it up for translation
+ * out - output packet
+ * pos - position in the output packet of the transport header
+ * payload - pointer to IP payload
+ * len - size of ip payload
+ * returns: the highest position in the output clat_packet that's filled in
+ */
+int generic_packet(clat_packet out, int pos, const char *payload, size_t len) {
+ out[pos].iov_len = 0;
+ out[CLAT_POS_PAYLOAD].iov_base = (char *) payload;
+ out[CLAT_POS_PAYLOAD].iov_len = len;
+
+ return CLAT_POS_PAYLOAD + 1;
+}
+
/* function: udp_packet
* takes a udp packet and sets it up for translation
* out - output packet