Prep for 6-in-6, 4-in-6, 6-in-4

This commit is contained in:
Nick Thomas
2013-08-15 00:09:23 +01:00
parent 2ffff92d36
commit 1cdf838ac9
5 changed files with 212 additions and 113 deletions

View File

@@ -34,7 +34,7 @@ struct packet {
// 0 - wrapping ip header, including enc_size
// 1 - encrypted portion of payload, in scratch.
// 2 - unencrypted portion of payload, in recv_pkt
#define MAX_IOVS 12
#define MAX_IOVS 3
struct rsp_data {
int count;
struct iovec iovs[MAX_IOVS];
@@ -42,19 +42,25 @@ struct rsp_data {
};
static inline int packet_find_protocol( struct packet *pkt )
{
if ( pkt->hdr.ip.version == 0x04 ) {
return pkt->hdr.ip.protocol;
}
if ( pkt->hdr.ip.version == 0x06 ) {
return pkt->hdr.ip6.ip6_nxt;
}
// If we need more fragments than this, I am a sad person
#define MAX_PACKET_FRAGMENTS 4
return -1;
}
void compute_ip_checksum( struct iphdr* pkt );
int wrap_ipv4_packet( struct rlocs *reg, struct packet *pkt, struct rsp_data *frag1, struct rsp_data *frag2 );
int wrap_ipv6_packet(struct rlocs* reg, struct packet *pkt, struct rsp_data *out);
int unwrap_ipv4_packet(struct rlocs* reg, struct packet *pkt, struct rsp_data *out);
int unwrap_ipv6_packet(struct rlocs* reg, struct packet *pkt, struct rsp_data *out);
int wrap_packet( struct rlocs *reg, struct packet *pkt, struct rsp_data *frag1, struct rsp_data *frag2 );
int unwrap_packet( struct rlocs *reg, struct packet *pkt, struct rsp_data *out );
struct peer_context *packet_peer_context( struct rlocs *reg, struct packet *pkt, int direction );
#endif