<commit_before>/*
* Copyright (c) 2016, 2017 <NAME>
* This file is part of Onyx, and is released under the terms of the MIT License
* check LICENSE at the root directory for more information
*/
#ifndef _ONYX_NET_IP_H
#define _ONYX_NET_IP_H

#include <stdint.h>

#include <onyx/net/netif.h>
#include <onyx/packetbuf.h>
#include <onyx/net/socket.h>
#include <onyx/net/proto_family.h>

#include <sys/socket.h>

#define IPV4_ICMP 1
#define IPV4_IGMP 2
#define IPV4_TCP 6
#define IPV4_UDP 17
#define IPV4_ENCAP 41
#define IPV4_OSPF 89
#define IPV4_SCTP 132

struct ip_header
{
	/* TODO: These bitfields are screwing up the structure's size, I think */
	unsigned int ihl : 4;
	unsigned int version : 4;
	unsigned int dscp : 6;
	unsigned int ecn : 2;
	uint16_t total_len;
	uint16_t identification;
	uint16_t frag_info;
	uint8_t ttl;
	uint8_t proto;
	uint16_t header_checksum;
	uint32_t source_ip;
	uint32_t dest_ip;
} __attribute__((packed));

union sockaddr_in_both
{
	sockaddr_in in4;
	sockaddr_in6 in6;
};

class inet_proto_family;

/* Forward declaration of ip::v4::proto_family for inet_socket friendship */
namespace ip
{

namespace v4
{
	class proto_family;
}

};
<commit_msg>net/inet: Add ifdef to correct bitfield for big endian targets.<commit_after>/*
* Copyright (c) 2016, 2017 <NAME>
* This file is part of Onyx, and is released under the terms of the MIT License
* check LICENSE at the root directory for more information
*/
#ifndef _ONYX_NET_IP_H
#define _ONYX_NET_IP_H

#include <stdint.h>

#include <onyx/net/netif.h>
#include <onyx/packetbuf.h>
#include <onyx/net/socket.h>
#include <onyx/net/proto_family.h>

#include <sys/socket.h>

#define IPV4_ICMP 1
#define IPV4_IGMP 2
#define IPV4_TCP 6
#define IPV4_UDP 17
#define IPV4_ENCAP 41
#define IPV4_OSPF 89
#define IPV4_SCTP 132

struct ip_header
{
	/* TODO: These bitfields are screwing up the structure's size, I think */
#if __BYTE_ORDER == __LITTLE_ENDIAN
	unsigned int ihl : 4;
	unsigned int version : 4;
#else
	unsigned int version : 4;
	unsigned int ihl : 4;
#endif
	uint8_t tos;
	uint16_t total_len;
	uint16_t identification;
	uint16_t frag_info;
	uint8_t ttl;
	uint8_t proto;
	uint16_t header_checksum;
	uint32_t source_ip;
	uint32_t dest_ip;
} __attribute__((packed));

union sockaddr_in_both
{
	sockaddr_in in4;
	sockaddr_in6 in6;
};

class inet_proto_family;

/* Forward declaration of ip::v4::proto_family for inet_socket friendship */
namespace ip
{

namespace v4
{
	class proto_family;
}

};

{'fraction_non_alphanumeric': 0.09035656401944894, 'fraction_numerical': 0.04092382495948136, 'mean_word_length': 4.836879432624113, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5602115', 'n_tokens_mistral': 1040, 'n_tokens_neox': 969, 'n_words': 286}