Rawsock library  v0.3.4
Library to make the use of raw sockets easier, under Linux. Currently supporting IPv4, UDP and a custom latency measurement protocol (LaMP - supported both in raw and non-raw sockets).
ipcsum_alth.h File Reference
#include <linux/types.h>

Go to the source code of this file.

Functions

__sum16 ip_fast_csum (const void *iph, unsigned int ihl)
 Calculate the IPv4 checksum (optimized for IP headers, which always checksum on 4 octet boundaries) More...
 

Detailed Description

IP checksum calculation alternative header - from Linux kernel 4.19.1 (not an original work)

This header file gives access to a function (ip_fast_csum()) that can be used to compute, in an efficient and reliable way, the IPv4 checksum to be put inside the corresponding field of the IPv4 header.

It represents an alternative user-space header to access the Linux kernel ip_fast_csum() function.

This is not an original work: this function comes from the Linux kernel 4.19.1, released under GNU GPL version 2. There is no modification to its code.

The function, even though it is used internally in the main Rawsock module, is available through a separate header in order to enable any application to use it separately in user space, when needed.

Version
Rawsock library verion: 0.3.4; Linux kernel version: 4.19.1
Author
Jorge Cwik, jorge.nosp@m.@las.nosp@m.er.sa.nosp@m.tlin.nosp@m.k.net
Arnt Gulbrandsen, agulb.nosp@m.ra@n.nosp@m.vg.un.nosp@m.it.n.nosp@m.o
Tom May, ftom@.nosp@m.netc.nosp@m.om.co.nosp@m.m
Andreas Schwab, schwa.nosp@m.b@is.nosp@m.san.i.nosp@m.nfor.nosp@m.matik.nosp@m..uni.nosp@m.-dort.nosp@m.mund.nosp@m..de
Lots of code moved from tcp.c and ip.c; see those files, inside the Linux kernel code, for more names.

Definition in file ipcsum_alth.h.

Function Documentation

__sum16 ip_fast_csum ( const void *  iph,
unsigned int  ihl 
)

Calculate the IPv4 checksum (optimized for IP headers, which always checksum on 4 octet boundaries)

This function can be used to compute the IPv4 header checksum, given the whole header and the IHL field.

Example of use:

struct iphdr header;

header.check=ip_fast_csum((__u8 *)&header, 5); // IHL = 5 word -> no options
Parameters
[in]iphPointer to the IPv4 header.
[in]ihlValue of the IPv4 IHL (Internet Header Length).
Returns
The result of the checksum calculation, ready to be inserted inside the check field of the struct iphdr.

Definition at line 84 of file ipcsum_alth.c.