mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
Use PF_* instead of AF_* as first parameter of socket(2).
This commit is contained in:
parent
4035b6ba66
commit
d9b56bad7d
@ -267,7 +267,7 @@ get_address(struct socket_info *info, enum addr_type type)
|
||||
info->addr = (struct sockaddr *) sin;
|
||||
info->size = sizeof(*sin);
|
||||
|
||||
return AF_INET;
|
||||
return PF_INET;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -373,12 +373,12 @@ bind_to_af_unix(void)
|
||||
{
|
||||
mode_t saved_mask = umask(0177);
|
||||
int attempts = 0;
|
||||
int af = get_address(&s_info_listen, ADDR_IP_SERVER);
|
||||
int pf = get_address(&s_info_listen, ADDR_IP_SERVER);
|
||||
|
||||
if (af == -1) goto free_and_error;
|
||||
if (pf == -1) goto free_and_error;
|
||||
|
||||
while (1) {
|
||||
s_info_listen.fd = socket(af, SOCK_STREAM, 0);
|
||||
s_info_listen.fd = socket(pf, SOCK_STREAM, 0);
|
||||
if (s_info_listen.fd == -1) {
|
||||
report_af_unix_error("socket()", errno);
|
||||
goto free_and_error;
|
||||
@ -435,12 +435,12 @@ static int
|
||||
connect_to_af_unix(void)
|
||||
{
|
||||
int attempts = 0;
|
||||
int af = get_address(&s_info_connect, ADDR_IP_CLIENT);
|
||||
int pf = get_address(&s_info_connect, ADDR_IP_CLIENT);
|
||||
|
||||
while (af != -1 && attempts++ < MAX_CONNECT_TRIES) {
|
||||
while (pf != -1 && attempts++ < MAX_CONNECT_TRIES) {
|
||||
int saved_errno;
|
||||
|
||||
s_info_connect.fd = socket(af, SOCK_STREAM, 0);
|
||||
s_info_connect.fd = socket(pf, SOCK_STREAM, 0);
|
||||
if (s_info_connect.fd == -1) {
|
||||
report_af_unix_error("socket()", errno);
|
||||
break;
|
||||
|
@ -303,7 +303,7 @@ sock_error:
|
||||
|
||||
/* Get a passive socket */
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (sock < 0)
|
||||
goto sock_error;
|
||||
|
||||
@ -504,6 +504,7 @@ connect_socket(struct socket *csocket, enum connection_state state)
|
||||
#else
|
||||
struct sockaddr_in addr = *((struct sockaddr_in *) &connect_info->addr[i]);
|
||||
#endif
|
||||
int pf;
|
||||
int family;
|
||||
int force_family = connect_info->ip_family;
|
||||
|
||||
@ -532,18 +533,30 @@ connect_socket(struct socket *csocket, enum connection_state state)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IPV6
|
||||
if (family == AF_INET6 && (!get_opt_bool("connection.try_ipv6") || (force_family && force_family != 6))) {
|
||||
silent_fail = 1;
|
||||
continue;
|
||||
if (family == AF_INET6) {
|
||||
pf = PF_INET6;
|
||||
if (!get_opt_bool("connection.try_ipv6")
|
||||
|| (force_family && force_family != 6)) {
|
||||
silent_fail = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
} else
|
||||
#endif
|
||||
if (family == AF_INET && (!get_opt_bool("connection.try_ipv4") || (force_family && force_family != 4))) {
|
||||
silent_fail = 1;
|
||||
if (family == AF_INET) {
|
||||
pf = PF_INET;
|
||||
if (!get_opt_bool("connection.try_ipv4")
|
||||
|| (force_family && force_family != 4)) {
|
||||
silent_fail = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
silent_fail = 0;
|
||||
|
||||
sock = socket(family, SOCK_STREAM, IPPROTO_TCP);
|
||||
sock = socket(pf, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (sock == -1) {
|
||||
if (errno && !saved_errno) saved_errno = errno;
|
||||
continue;
|
||||
|
@ -51,9 +51,9 @@ be_close(int s)
|
||||
}
|
||||
|
||||
int
|
||||
be_socket(int af, int sock, int prot)
|
||||
be_socket(int pf, int sock, int prot)
|
||||
{
|
||||
int h = socket(af, sock, prot);
|
||||
int h = socket(pf, sock, prot);
|
||||
|
||||
if (h < 0) return h;
|
||||
return h + SHS;
|
||||
@ -122,13 +122,13 @@ be_pipe(int *fd)
|
||||
int retry_count = 0;
|
||||
|
||||
again:
|
||||
s1 = be_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
s1 = be_socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (s1 < 0) {
|
||||
/*perror("socket1");*/
|
||||
goto fatal_retry;
|
||||
}
|
||||
|
||||
s2 = be_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
s2 = be_socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (s2 < 0) {
|
||||
/*perror("socket2");*/
|
||||
be_close(s1);
|
||||
|
@ -82,13 +82,13 @@
|
||||
#include "osdep/getifaddrs.h"
|
||||
|
||||
|
||||
#if (defined(AF_INET6) && defined(SIOCGIF6CONF) && defined(SIOCGIF6FLAGS)) \
|
||||
|| (defined(AF_INET) && defined(SIOCGIFCONF) && defined(SIOCGIFFLAGS)) \
|
||||
#if (defined(PF_INET6) && defined(SIOCGIF6CONF) && defined(SIOCGIF6FLAGS)) \
|
||||
|| (defined(PF_INET) && defined(SIOCGIFCONF) && defined(SIOCGIFFLAGS)) \
|
||||
|| (defined(CONFIG_IPV6) && defined(SIOCGIFCONF))
|
||||
|
||||
static int
|
||||
getifaddrs2(struct ifaddrs **ifap,
|
||||
int af, int siocgifconf, int siocgifflags, size_t ifreq_sz)
|
||||
int pf, int siocgifconf, int siocgifflags, size_t ifreq_sz)
|
||||
{
|
||||
struct sockaddr sa_zero;
|
||||
struct ifreq *ifr;
|
||||
@ -104,7 +104,7 @@ getifaddrs2(struct ifaddrs **ifap,
|
||||
int num, j = 0;
|
||||
|
||||
memset(&sa_zero, 0, sizeof(sa_zero));
|
||||
fd = socket(af, SOCK_DGRAM, 0);
|
||||
fd = socket(pf, SOCK_DGRAM, 0);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
@ -240,19 +240,19 @@ getifaddrs(struct ifaddrs **ifap)
|
||||
|
||||
errno = ENXIO;
|
||||
|
||||
#if defined(AF_INET6) && defined(SIOCGIF6CONF) && defined(SIOCGIF6FLAGS)
|
||||
#if defined(PF_INET6) && defined(SIOCGIF6CONF) && defined(SIOCGIF6FLAGS)
|
||||
if (ret)
|
||||
ret = getifaddrs2(ifap, AF_INET6, SIOCGIF6CONF, SIOCGIF6FLAGS,
|
||||
ret = getifaddrs2(ifap, PF_INET6, SIOCGIF6CONF, SIOCGIF6FLAGS,
|
||||
sizeof(struct in6_ifreq));
|
||||
#endif
|
||||
#if defined(CONFIG_IPV6) && defined(SIOCGIFCONF)
|
||||
if (ret)
|
||||
ret = getifaddrs2(ifap, AF_INET6, SIOCGIFCONF, SIOCGIFFLAGS,
|
||||
ret = getifaddrs2(ifap, PF_INET6, SIOCGIFCONF, SIOCGIFFLAGS,
|
||||
sizeof(struct ifreq));
|
||||
#endif
|
||||
#if defined(AF_INET) && defined(SIOCGIFCONF) && defined(SIOCGIFFLAGS)
|
||||
#if defined(PF_INET) && defined(SIOCGIFCONF) && defined(SIOCGIFFLAGS)
|
||||
if (ret)
|
||||
ret = getifaddrs2(ifap, AF_INET, SIOCGIFCONF, SIOCGIFFLAGS,
|
||||
ret = getifaddrs2(ifap, PF_INET, SIOCGIFCONF, SIOCGIFFLAGS,
|
||||
sizeof(struct ifreq));
|
||||
#endif
|
||||
|
||||
@ -322,7 +322,7 @@ main()
|
||||
{
|
||||
struct ifaddrs *a = NULL, *b;
|
||||
|
||||
getifaddrs2(&a, AF_INET, SIOCGIFCONF, SIOCGIFFLAGS,
|
||||
getifaddrs2(&a, PF_INET, SIOCGIFCONF, SIOCGIFFLAGS,
|
||||
sizeof(struct ifreq));
|
||||
print_ifaddrs(a);
|
||||
printf("---\n");
|
||||
|
@ -347,9 +347,9 @@ win32_ioctl(int fd, long option, int *flag)
|
||||
}
|
||||
|
||||
int
|
||||
win32_socket(int family, int type, int protocol)
|
||||
win32_socket(int pf, int type, int protocol)
|
||||
{
|
||||
SOCKET s = socket(family, type, protocol);
|
||||
SOCKET s = socket(pf, type, protocol);
|
||||
int rc;
|
||||
|
||||
if (s == INVALID_SOCKET) {
|
||||
@ -359,7 +359,7 @@ win32_socket(int family, int type, int protocol)
|
||||
rc = s + SOCK_SHIFT;
|
||||
}
|
||||
|
||||
TRACE("family %d, type %d, proto %d -> rc %d", family, type, protocol, rc);
|
||||
TRACE("family %d, type %d, proto %d -> rc %d", pf, type, protocol, rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
int win32_write(int fd, const void *buf, unsigned len);
|
||||
int win32_read(int fd, void *buf, unsigned len);
|
||||
int win32_pipe(int *fds);
|
||||
int win32_socket(int af, int type, int proto);
|
||||
int win32_socket(int pf, int type, int proto);
|
||||
int win32_connect(int fd, struct sockaddr *addr, int addr_len);
|
||||
int win32_getpeername(int fd, struct sockaddr *addr, int *addr_len);
|
||||
int win32_getsockname(int fd, struct sockaddr *addr, int *addr_len);
|
||||
@ -33,7 +33,7 @@ char *win32_strerror(int err);
|
||||
#define write win32_write
|
||||
#define close win32_close
|
||||
#define pipe win32_pipe
|
||||
#define socket(af, type, prot) win32_socket(af, type, prot)
|
||||
#define socket(pf, type, prot) win32_socket(pf, type, prot)
|
||||
#define connect(fd, a, al) win32_connect(fd, a, al)
|
||||
#define getpeername(fd, a, al) win32_getpeername(fd, a, al)
|
||||
#define getsockname(fd, a, al) win32_getsockname(fd, a, al)
|
||||
|
@ -369,7 +369,7 @@ init_bittorrent_listening_socket(struct connection *conn)
|
||||
if (bittorrent_socket != -1)
|
||||
close(bittorrent_socket);
|
||||
|
||||
bittorrent_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
bittorrent_socket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (bittorrent_socket < 0)
|
||||
return -errno;
|
||||
|
||||
|
@ -836,10 +836,10 @@ next:
|
||||
}
|
||||
|
||||
static int
|
||||
ftp_data_connect(struct connection *conn, int family, struct sockaddr_storage *sa,
|
||||
ftp_data_connect(struct connection *conn, int pf, struct sockaddr_storage *sa,
|
||||
int size_of_sockaddr)
|
||||
{
|
||||
int fd = socket(family, SOCK_STREAM, 0);
|
||||
int fd = socket(pf, SOCK_STREAM, 0);
|
||||
|
||||
if (fd < 0 || set_nonblocking_fd(fd) < 0) {
|
||||
abort_connection(conn, S_FTP_ERROR);
|
||||
|
Loading…
x
Reference in New Issue
Block a user