Linux Kernel Network Programming - struct iphdr data-structure - ip_send_check() API Example and Sample Demo
Linux Kernel Network Programming - struct iphdr data-structure - ip_send_check() API Example and Sample Demo

Here is my sample source-code discussed in the video:

/* ip_send_check.c
 * Author: Kiran Kankipati
 * Updated: 15-feb-2017
 */
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/module.h> 
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/skbuff.h>  
#include <linux/udp.h>
#include <linux/ip.h>
#include <linux/in.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/net.h>
#include <linux/netdevice.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/inet.h>
#include <linux/inetdevice.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/if_arp.h>
#include <linux/icmp.h>
#include <linux/netlink.h>
#include <linux/mroute.h>
#include <net/checksum.h>
#include <net/inet_ecn.h>
#include <net/xfrm.h>
#include <net/route.h>
#include <net/sock.h>
#include <net/ip.h>
#include <net/tcp.h>
#include <net/arp.h>
#include <net/udp.h>
#include <net/icmp.h>
#include <net/inetpeer.h>
#include <net/protocol.h>
#include <net/flow.h>
#include <asm/types.h>

static struct nf_hook_ops nfho_post_routing;

unsigned int post_routing_hook_func(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
{
	struct iphdr *iph = ip_hdr(skb);

	/*------ test ip checksum --------*/
	//iph->check = 0;
	//ip_send_check(iph);
	/*--------------------------------*/
	
	return NF_ACCEPT; //this will accept the packet
}


static int hello_init(void)
{
	//Packet TX
	nfho_post_routing.hook = post_routing_hook_func;
	nfho_post_routing.hooknum = NF_INET_POST_ROUTING;
	nfho_post_routing.pf = PF_INET;
	nfho_post_routing.priority = NF_IP_PRI_FIRST;
	nf_register_hook(&nfho_post_routing);

	return 0;
}

static void hello_exit(void) { nf_unregister_hook(&nfho_post_routing); }

module_init(hello_init);
module_exit(hello_exit);

Its makefile:

obj-m += ip_send_check.o
all: 
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules