====== لیست structهای مورد نیاز ======
در لیست زیر structها و manual هایی که در باره آنها توضیح داده اند مشخص شده اند:
// man 3 getaddrinfo
// Header: /usr/include/netdb.h
// Source: glibc-2.39/resolv/netdb.h
// Debian package: libc6-dev
struct addrinfo {
int ai_flags; // AI_PASSIVE, AI_CANONNAME, etc.
int ai_family; // AF_INET, AF_INET6, AF_UNSPEC
int ai_socktype; // SOCK_STREAM, SOCK_DGRAM, 0
int ai_protocol; // use 0 for "any"
socklen_t ai_addrlen; // size of ai_addr in bytes
struct sockaddr *ai_addr; // struct sockaddr_in or sockaddr_in6
char *ai_canonname; // full canonical hostname
struct addrinfo *ai_next; // linked list, next node
};
// man 2 bind
// man 3 sockaddr
// Header: /usr/include/bits/socket.h (/usr/include/x86_64-linux-gnu/bits/socket.h)
// Source: glibc-2.39/bits/socket.h (glibc-2.39/bits/sockaddr.h)
// Debian package: libc6-dev
struct sockaddr {
sa_family_t sa_family; // address family, AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};
// man 7 ip
// man 3 sockaddr
// Header: /usr/include/netinet/in.h
// Source: glibc-2.39/inet/netinet/in.h
// Debian package: libc6-dev
typedef uint16_t in_port_t;
struct sockaddr_in {
sa_family_t sin_family; // Address family, AF_INET
in_port_t sin_port; // Port number, Network Byte Order with htons()
struct in_addr sin_addr; // Internet address
unsigned char sin_zero[8]; // Same size as struct sockaddr, set to zero with memset()
};
// man 7 ipv6
// man 3 sockaddr
// Header: /usr/include/netinet/in.h
// Source: glibc-2.39/inet/netinet/in.h
// Debian package: libc6-dev
typedef uint16_t in_port_t;
struct sockaddr_in6 {
sa_family_t sin6_family; // Address family, AF_INET6
in_port_t sin6_port; // Port number, Network Byte Order
u_int32_t sin6_flowinfo; // IPv6 flow info
struct in6_addr sin6_addr; // IPv6 address
u_int32_t sin6_scope_id; // Set of interfaces for a scope (Scope ID)
};
// man 7 ip
// man 3 inet
// man 3 sockaddr
// Header: /usr/include/netinet/in.h
// Source: glibc-2.39/inet/netinet/in.h
// Debian package: libc6-dev
// Internet address (a structure for historical reasons)
typedef uint32_t in_addr_t;
struct in_addr {
in_addr_t s_addr; // that's a 32-bit int (4 bytes)
};
// man 7 ipv6
// man 3 sockaddr
// Header: /usr/include/netinet/in.h
// Source: glibc-2.39/inet/netinet/in.h
// Debian package: libc6-dev
struct in6_addr {
uint8_t s6_addr[16]; // IPv6 address
};
// man 7 socket
// man 3 sockaddr
// Header: /usr/include/bits/socket.h (/usr/include/x86_64-linux-gnu/bits/socket.h)
// Source: glibc-2.39/bits/socket.h (glibc-2.39/bits/sockaddr.h)
// Debian package: libc6-dev
// both IPv4 and IPv6
struct sockaddr_storage {
sa_family_t ss_family; // address family
// all this is padding, implementation specific, ignore it:
char __ss_padding[_SS_PADSIZE];
__ss_aligntype __ss_align; // Force desired alignment.
};