The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
in.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
stdint.h
>
4
#include <
sys/socket.h
>
5
6
/**
7
* @file netinet/in.h
8
* @brief IPv4 addresses and ports, and the IP protocols.
9
*
10
* the IPv6 types are here for programs that know both families. there is
11
* no IPv6 network: socket(AF_INET6, ...) gives EAFNOSUPPORT, and programs
12
* then use IPv4.
13
*
14
* addresses and ports in the structs are in network byte order (big
15
* endian); htons, htonl, ntohs and ntohl change between it and the CPU's.
16
*/
17
18
typedef
uint32_t
in_addr_t
;
19
typedef
uint16_t
in_port_t
;
20
21
struct
in_addr
22
{
23
in_addr_t
s_addr
;
24
};
25
26
struct
sockaddr_in
27
{
28
sa_family_t
sin_family
;
// AF_INET
29
in_port_t
sin_port
;
30
struct
in_addr
sin_addr
;
31
unsigned
char
sin_zero
[8];
32
};
33
34
struct
in6_addr
35
{
36
uint8_t
s6_addr
[16];
37
};
38
39
struct
sockaddr_in6
40
{
41
sa_family_t
sin6_family
;
// AF_INET6
42
in_port_t
sin6_port
;
43
uint32_t
sin6_flowinfo
;
44
struct
in6_addr
sin6_addr
;
45
uint32_t
sin6_scope_id
;
46
};
47
48
extern
const
struct
in6_addr
in6addr_any
;
// ::
49
extern
const
struct
in6_addr
in6addr_loopback
;
// ::1
50
51
#define IN6ADDR_ANY_INIT {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
52
#define IN6ADDR_LOOPBACK_INIT {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}
53
54
#define IPPROTO_IP 0
55
#define IPPROTO_ICMP 1
56
#define IPPROTO_TCP 6
57
#define IPPROTO_UDP 17
58
#define IPPROTO_IPV6 41
59
60
#define IPV6_V6ONLY 26
61
62
#define INADDR_ANY ((in_addr_t)0x00000000)
63
#define INADDR_BROADCAST ((in_addr_t)0xFFFFFFFF)
64
#define INADDR_NONE ((in_addr_t)0xFFFFFFFF)
65
#define INADDR_LOOPBACK ((in_addr_t)0x7F000001)
// 127.0.0.1, in host byte order
66
67
#define INET_ADDRSTRLEN 16
68
#define INET6_ADDRSTRLEN 46
69
70
static
inline
uint16_t
htons(
uint16_t
v)
71
{
72
return
__builtin_bswap16(v);
73
}
74
75
static
inline
uint16_t
ntohs(
uint16_t
v)
76
{
77
return
__builtin_bswap16(v);
78
}
79
80
static
inline
uint32_t
htonl(
uint32_t
v)
81
{
82
return
__builtin_bswap32(v);
83
}
84
85
static
inline
uint32_t
ntohl(
uint32_t
v)
86
{
87
return
__builtin_bswap32(v);
88
}
in6addr_loopback
const struct in6_addr in6addr_loopback
in_port_t
uint16_t in_port_t
Definition
in.h:19
in_addr_t
uint32_t in_addr_t
Definition
in.h:18
in6addr_any
const struct in6_addr in6addr_any
uint32_t
unsigned int uint32_t
Definition
fb.h:17
uint8_t
unsigned char uint8_t
Definition
fb.h:18
stdint.h
integer types of fixed width.
uint16_t
unsigned short uint16_t
Definition
stdint.h:13
socket.h
sockets: Unix domain stream sockets, with file descriptor passing, and IPv4 sockets (TCP; UDP,...
sa_family_t
unsigned short sa_family_t
Definition
socket.h:22
in6_addr
Definition
in.h:35
in6_addr::s6_addr
uint8_t s6_addr[16]
Definition
in.h:36
in_addr
Definition
in.h:22
in_addr::s_addr
in_addr_t s_addr
Definition
in.h:23
sockaddr_in6
Definition
in.h:40
sockaddr_in6::sin6_port
in_port_t sin6_port
Definition
in.h:42
sockaddr_in6::sin6_addr
struct in6_addr sin6_addr
Definition
in.h:44
sockaddr_in6::sin6_flowinfo
uint32_t sin6_flowinfo
Definition
in.h:43
sockaddr_in6::sin6_scope_id
uint32_t sin6_scope_id
Definition
in.h:45
sockaddr_in6::sin6_family
sa_family_t sin6_family
Definition
in.h:41
sockaddr_in
Definition
in.h:27
sockaddr_in::sin_zero
unsigned char sin_zero[8]
Definition
in.h:31
sockaddr_in::sin_addr
struct in_addr sin_addr
Definition
in.h:30
sockaddr_in::sin_family
sa_family_t sin_family
Definition
in.h:28
sockaddr_in::sin_port
in_port_t sin_port
Definition
in.h:29
src
libc
include
netinet
in.h
Generated by
1.18.0