Added module which arbitrarily increases the size of the packet we received. Needs some tweaking to allow for modification of the header and payload fields yet, but the space allocation is already there. Also, multiple improvements overall

This commit is contained in:
h3xduck
2021-11-24 20:41:07 -05:00
parent 74cc7ff9e5
commit 442f955cf5
8 changed files with 592 additions and 269 deletions

View File

@@ -0,0 +1,31 @@
#ifndef __IP_HELPER_H__
#define __IP_HELPER_H__
#include <linux/ip.h>
/**
* IP checksum calculation.
* Following RFC 1071.
* In essence 1's complement of 16-bit groups.
* Taken from my own library https://github.com/h3xduck/RawTCP_Lib/blob/master/src/packet.c
*/
static __always_inline unsigned short checksum(unsigned short *addr, int nbytes){
long sum = 0;
unsigned short checksum;
while(nbytes>1){
sum += (unsigned short) *addr++;
nbytes -= 2;
}
if(nbytes>0){
sum +=htons((unsigned char)*addr);
}
while (sum>>16){
sum = (sum & 0xffff) + (sum >> 16);
}
checksum = ~sum;
return checksum;
}
#endif