packet: move some common code out of wrapper.c and util.c
This commit is contained in:
40
pass-1/packet.h
Normal file
40
pass-1/packet.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef _PACKET_H_
|
||||
#define _PACKET_H_
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip6.h>
|
||||
|
||||
struct packet {
|
||||
union {
|
||||
#ifdef __USE_BSD
|
||||
struct ip ip;
|
||||
#else
|
||||
struct iphdr ip;
|
||||
#endif
|
||||
struct ip6_hdr ip6;
|
||||
} hdr;
|
||||
char payload[IP_MAXPACKET]; /* payload is this - header size, but OK */
|
||||
};
|
||||
|
||||
// wrapper.c expects this name
|
||||
#define recv_pkt packet
|
||||
|
||||
|
||||
// It's all our code that uses this. 12 is much more than we need to
|
||||
// construct a wrapped packet at the moment.
|
||||
//
|
||||
// initial usage:
|
||||
// 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
|
||||
struct rsp_data {
|
||||
int count;
|
||||
struct iovec iovs[MAX_IOVS];
|
||||
unsigned char scratch[IP_MAXPACKET]; // somewhere easy to put results
|
||||
};
|
||||
|
||||
void compute_ip_checksum( struct iphdr* pkt );
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user