<commit_before>/*
 * ip.h
 *
 * Internet Protocol (RFC 791).
 *
 * Copyright (c) 2000 <NAME> <<EMAIL>>
 *
 * $Id$
 */

#ifndef DNET_IP_H
#define DNET_IP_H

#define IP_ADDR_LEN	4
#define IP_ADDR_BITS	32

#define IP_HDR_LEN	20
#define IP_OPT_LEN	2
#define IP_OPT_LEN_MAX	40
#define IP_HDR_LEN_MAX	(IP_HDR_LEN + IP_OPT_LEN_MAX)

#define IP_LEN_MAX	65535
#define IP_LEN_MIN	IP_HDR_LEN

typedef uint32_t	ip_addr_t;

/*
 * IP header
 */
struct ip_hdr {
#if DNET_BYTESEX == DNET_LIL_ENDIAN
	uint8_t		ip_hl:4,	/* header length */
			ip_v:4;		/* version */
#elif DNET_BYTESEX == DNET_BIG_ENDIAN
	uint8_t		ip_v:4,		/* version */
			ip_hl:4;	/* header length */
#endif
	uint8_t		ip_tos;		/* type of service */
	uint16_t	ip_len;		/* total length (including header) */
	uint16_t	ip_id;		/* identification */
	uint16_t	ip_off;		/* fragment offset and flags */
	uint8_t		ip_ttl;		/* time to live */
	uint8_t		ip_p;		/* protocol */
	uint16_t	ip_sum;		/* checksum */
	ip_addr_t	ip_src;		/* source address */
	ip_addr_t	ip_dst;		/* destination address */
};

/*
 * Fragmentation flags
 */
#define IP_RF		0x8000		/* reserved fragment flag */
#define IP_DF		0x4000		/* dont fragment flag */
#define IP_MF		0x2000		/* more fragments flag */
#define IP_OFFMASK	0x1fff		/* mask for fragmenting bits */

/*
 * Type of service
 */
#define IP_TOS_LOWDELAY		0x10
#define IP_TOS_THROUGHPUT	0x08
#define IP_TOS_RELIABILITY	0x04
#define IP_TOS_ECT		0x02
#define IP_TOS_CE		0x01

/*
 * IP precedence
 */
#define IP_TOS_PREC_NETCONTROL		0xe0
#define IP_TOS_PREC_INTERNETCONTROL	0xc0
#define IP_TOS_PREC_CRITIC_ECP		0xa0
#define IP_TOS_PREC_FLASHOVERRIDE	0x80
#define IP_TOS_PREC_FLASH		0x60
#define IP_TOS_PREC_IMMEDIATE		0x40
#define IP_TOS_PREC_PRIORITY		0x20
#define IP_TOS_PREC_ROUTINE		0x00

#define IP_TTL_MAX		255

/*
 * Protocols
 */
#define	IP_PROTO_IP		0		/* Dummy for IP */
#define IP_PROTO_HOPOPTS	IP_PROTO_IP	/* IPv6 hop-by-hop options */
#define	IP_PROTO_ICMP		1		/* ICMP */
#define	IP_PROTO_IGMP		2		/* IGMP */
#define	IP_PROTO_IPIP		4		/* IP in IP */
#define	IP_PROTO_TCP		6		/* TCP */
#define	IP_PROTO_EGP		8		/* Exterior gateway protocol */
#define	IP_PROTO_PUP		12		/* PUP */
#define	IP_PROTO_UDP		17		/* UDP */
#define	IP_PROTO_IDP		22		/* XNS IDP */
#define	IP_PROTO_TP		29 		/* SO TP class 4 */
#define IP_PROTO_IPV6		41		/* IPv6 */
#define IP_PROTO_ROUTING	43		/* IPv6 routing header */
#define IP_PROTO_FRAGMENT	44		/* IPv6 fragmentation header */
#define IP_PROTO_RSVP		46		/* Reservation protocol */
#define	IP_PROTO_GRE		47		/* GRE encap, RFCs 1701/1702 */
#define	IP_PROTO_ESP		50		/* Encap. security payload */
#define	IP_PROTO_AH		51		/* Authentication header */
#define	IP_PROTO_MOBILE		55		/* IP Mobility, RFC 2004 */
#define IP_PROTO_ICMPV6		58		/* ICMP for IPv6 */
#define IP_PROTO_NONE		59		/* IPv6 no next header */
#define IP_PROTO_DSTOPTS	60		/* IPv6 destination options */
#define	IP_PROTO_EON		80		/* ISO CNLP */
#define IP_PROTO_ETHERIP	97		/* Ethernet in IPv4 */
#define	IP_PROTO_ENCAP		98		/* Encapsulation header */
#define IP_PROTO_PIM		103		/* Protocol indep. multicast */
#define IP_PROTO_IPCOMP		108		/* Compression header proto */
#define	IP_PROTO_RAW		255		/* Raw IP packets */
#define	IP_PROTO_MAX		256

/*
 * Options
 */
#define IP_OPT_COPIED(o)	((o) & 0x80)
#define IP_OPT_CLASS(o)		((o) & 0x60)
#define IP_OPT_NUMBER(o)	((o) & 0x1f)

#define IP_OPT_CONTROL		0x00
#define IP_OPT_RESERVED1	0x20
#define IP_OPT_DEBMEAS		0x40
#define IP_OPT_RESERVED2	0x60

#define IP_OPT_EOL		0		/* end of options */
#define IP_OPT_NOP		1		/* no operation */
#define IP_OPT_RR		7		/* record route */
#define IP_OPT_TS		68		/* timestamp */
#define IP_OPT_SECURITY		130		/* provide s,c,h,tcc */
#define IP_OPT_LSRR		131		/* loose source route */
#define IP_OPT_SATID		136		/* satnet id */
#define IP_OPT_SSRR		137		/* strict source route */

#define IP_OPT_TYPEONLY(type)	((type) == IP_OPT_EOL || (type) == IP_OPT_NOP)

#ifndef __GNUC__
# define __attribute__(x)
# pragma pack(1)<commit_msg>define mask values in hex<commit_after>/*
 * ip.h
 *
 * Internet Protocol (RFC 791).
 *
 * Copyright (c) 2000 <NAME> <<EMAIL>>
 *
 * $Id$
 */

#ifndef DNET_IP_H
#define DNET_IP_H

#define IP_ADDR_LEN	4
#define IP_ADDR_BITS	32

#define IP_HDR_LEN	20
#define IP_OPT_LEN	2
#define IP_OPT_LEN_MAX	40
#define IP_HDR_LEN_MAX	(IP_HDR_LEN + IP_OPT_LEN_MAX)

#define IP_LEN_MAX	65535
#define IP_LEN_MIN	IP_HDR_LEN

typedef uint32_t	ip_addr_t;

/*
 * IP header
 */
struct ip_hdr {
#if DNET_BYTESEX == DNET_LIL_ENDIAN
	uint8_t		ip_hl:4,	/* header length */
			ip_v:4;		/* version */
#elif DNET_BYTESEX == DNET_BIG_ENDIAN
	uint8_t		ip_v:4,		/* version */
			ip_hl:4;	/* header length */
#endif
	uint8_t		ip_tos;		/* type of service */
	uint16_t	ip_len;		/* total length (including header) */
	uint16_t	ip_id;		/* identification */
	uint16_t	ip_off;		/* fragment offset and flags */
	uint8_t		ip_ttl;		/* time to live */
	uint8_t		ip_p;		/* protocol */
	uint16_t	ip_sum;		/* checksum */
	ip_addr_t	ip_src;		/* source address */
	ip_addr_t	ip_dst;		/* destination address */
};

/*
 * Fragmentation flags
 */
#define IP_RF		0x8000		/* reserved fragment flag */
#define IP_DF		0x4000		/* dont fragment flag */
#define IP_MF		0x2000		/* more fragments flag */
#define IP_OFFMASK	0x1fff		/* mask for fragmenting bits */

/*
 * Type of service
 */
#define IP_TOS_LOWDELAY		0x10
#define IP_TOS_THROUGHPUT	0x08
#define IP_TOS_RELIABILITY	0x04
#define IP_TOS_ECT		0x02
#define IP_TOS_CE		0x01

/*
 * IP precedence
 */
#define IP_TOS_PREC_NETCONTROL		0xe0
#define IP_TOS_PREC_INTERNETCONTROL	0xc0
#define IP_TOS_PREC_CRITIC_ECP		0xa0
#define IP_TOS_PREC_FLASHOVERRIDE	0x80
#define IP_TOS_PREC_FLASH		0x60
#define IP_TOS_PREC_IMMEDIATE		0x40
#define IP_TOS_PREC_PRIORITY		0x20
#define IP_TOS_PREC_ROUTINE		0x00

#define IP_TTL_MAX		255

/*
 * Protocols
 */
#define	IP_PROTO_IP		0		/* Dummy for IP */
#define IP_PROTO_HOPOPTS	IP_PROTO_IP	/* IPv6 hop-by-hop options */
#define	IP_PROTO_ICMP		1		/* ICMP */
#define	IP_PROTO_IGMP		2		/* IGMP */
#define	IP_PROTO_IPIP		4		/* IP in IP */
#define	IP_PROTO_TCP		6		/* TCP */
#define	IP_PROTO_EGP		8		/* Exterior gateway protocol */
#define	IP_PROTO_PUP		12		/* PUP */
#define	IP_PROTO_UDP		17		/* UDP */
#define	IP_PROTO_IDP		22		/* XNS IDP */
#define	IP_PROTO_TP		29 		/* SO TP class 4 */
#define IP_PROTO_IPV6		41		/* IPv6 */
#define IP_PROTO_ROUTING	43		/* IPv6 routing header */
#define IP_PROTO_FRAGMENT	44		/* IPv6 fragmentation header */
#define IP_PROTO_RSVP		46		/* Reservation protocol */
#define	IP_PROTO_GRE		47		/* GRE encap, RFCs 1701/1702 */
#define	IP_PROTO_ESP		50		/* Encap. security payload */
#define	IP_PROTO_AH		51		/* Authentication header */
#define	IP_PROTO_MOBILE		55		/* IP Mobility, RFC 2004 */
#define IP_PROTO_ICMPV6		58		/* ICMP for IPv6 */
#define IP_PROTO_NONE		59		/* IPv6 no next header */
#define IP_PROTO_DSTOPTS	60		/* IPv6 destination options */
#define	IP_PROTO_EON		80		/* ISO CNLP */
#define IP_PROTO_ETHERIP	97		/* Ethernet in IPv4 */
#define	IP_PROTO_ENCAP		98		/* Encapsulation header */
#define IP_PROTO_PIM		103		/* Protocol indep. multicast */
#define IP_PROTO_IPCOMP		108		/* Compression header proto */
#define	IP_PROTO_RAW		255		/* Raw IP packets */
#define	IP_PROTO_MAX		256

/*
 * Options
 */
#define IP_OPT_COPIED(o)	((o) & 0x80)
#define IP_OPT_CLASS(o)		((o) & 0x60)
#define IP_OPT_NUMBER(o)	((o) & 0x1f)

#define IP_OPT_CONTROL		0x00
#define IP_OPT_RESERVED1	0x20
#define IP_OPT_DEBMEAS		0x40
#define IP_OPT_RESERVED2	0x60

#define IP_OPT_EOL		0x0		/* end of options */
#define IP_OPT_NOP		0x1		/* no operation */
#define IP_OPT_RR		0x7		/* record route */
#define IP_OPT_TS		0x44		/* timestamp */
#define IP_OPT_SECURITY		0x82		/* provide s,c,h,tcc */
#define IP_OPT_LSRR		0x83		/* loose source route */
#define IP_OPT_SATID		0x88		/* satnet id */
#define IP_OPT_SSRR		0x89		/* strict source route */

#define IP_OPT_TYPEONLY(type)	((type) == IP_OPT_EOL || (type) == IP_OPT_NOP)

#ifndef __GNUC__
# define __attribute__(x)
# pragma pack(1)
{'fraction_non_alphanumeric': 0.1069198101423932, 'fraction_numerical': 0.0534599050711966, 'mean_word_length': 3.718326458456099, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1827649', 'n_tokens_mistral': 3813, 'n_tokens_neox': 3557, 'n_words': 839}