From abbace3df4650d72bc1fb5b430cccd655826f888 Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Tue, 29 Apr 2025 01:42:49 -0400 Subject: [PATCH] Actually add ipv4 header for ipv4 support --- net/ipv4.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 net/ipv4.h diff --git a/net/ipv4.h b/net/ipv4.h new file mode 100644 index 0000000..d98fbc5 --- /dev/null +++ b/net/ipv4.h @@ -0,0 +1,53 @@ +#ifndef MINIMAL_IPV4_H +#define MINIMAL_IPV4_H +// From kernel header in.h +// location: uapi/linux/in.h or linux/in.h (older kerns) or /usr/include/netinet/in.h (installed path) + +#include "../sys.h" +#include "../int.h" + +struct in_addr { + uint32_t s_addr; +}; + +#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ +struct sockaddr_in { + unsigned short sin_family; // address family: AF_INET + uint16_t sin_port; // port in network byte order + struct in_addr sin_addr; // internet address + // Padding to match the size of struct sockaddr + unsigned char sin_zero[8]; +}; +/* Address to accept any incoming messages. */ +#define INADDR_ANY ((unsigned long int) 0x00000000) + +/* Standard well-defined IP protocols. */ +enum { + IPPROTO_IP = 0, /* Dummy protocol for TCP */ + IPPROTO_ICMP = 1, /* Internet Control Message Protocol */ + IPPROTO_IGMP = 2, /* Internet Group Management Protocol */ + IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */ + IPPROTO_TCP = 6, /* Transmission Control Protocol */ + IPPROTO_EGP = 8, /* Exterior Gateway Protocol */ + IPPROTO_PUP = 12, /* PUP protocol */ + IPPROTO_UDP = 17, /* User Datagram Protocol */ + IPPROTO_IDP = 22, /* XNS IDP protocol */ + IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol */ + IPPROTO_RSVP = 46, /* RSVP protocol */ + IPPROTO_GRE = 47, /* Cisco GRE tunnels (rfc 1701,1702) */ + + IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */ + + IPPROTO_ESP = 50, /* Encapsulation Security Payload protocol */ + IPPROTO_AH = 51, /* Authentication Header protocol */ + IPPROTO_BEETPH = 94, /* IP option pseudo header for BEET */ + IPPROTO_PIM = 103, /* Protocol Independent Multicast */ + + IPPROTO_COMP = 108, /* Compression Header protocol */ + IPPROTO_SCTP = 132, /* Stream Control Transport Protocol */ + + IPPROTO_RAW = 255, /* Raw IP packets */ + IPPROTO_MAX +}; + +#endif // MINIMAL_IPV4_H