mirror of
https://github.com/qemu/qemu.git
synced 2025-01-19 12:03:51 +08:00
MinGW: Replace setsockopt by qemu_setsocketopt
Instead of adding missing type casts which are needed by MinGW for the 4th argument, the patch uses qemu_setsockopt which was invented for this purpose. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
afed260822
commit
9957fc7f1e
@ -171,7 +171,7 @@ struct HCIInfo *bt_host_hci(const char *id)
|
||||
hci_filter_all_ptypes(&flt);
|
||||
hci_filter_all_events(&flt);
|
||||
|
||||
if (setsockopt(fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
|
||||
if (qemu_setsockopt(fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
|
||||
fprintf(stderr, "qemu: Can't set HCI filter on socket (%i)\n", errno);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2887,7 +2887,7 @@ static int gdbserver_open(int port)
|
||||
|
||||
/* allow fast reuse */
|
||||
val = 1;
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
|
||||
qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
||||
|
||||
sockaddr.sin_family = AF_INET;
|
||||
sockaddr.sin_port = htons(port);
|
||||
|
21
net/socket.c
21
net/socket.c
@ -262,8 +262,7 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
|
||||
}
|
||||
|
||||
val = 1;
|
||||
ret=setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
(const char *)&val, sizeof(val));
|
||||
ret = qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
||||
if (ret < 0) {
|
||||
perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)");
|
||||
goto fail;
|
||||
@ -283,8 +282,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
|
||||
imr.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||
}
|
||||
|
||||
ret = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||
(const char *)&imr, sizeof(struct ip_mreq));
|
||||
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||
&imr, sizeof(struct ip_mreq));
|
||||
if (ret < 0) {
|
||||
perror("setsockopt(IP_ADD_MEMBERSHIP)");
|
||||
goto fail;
|
||||
@ -292,8 +291,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
|
||||
|
||||
/* Force mcast msgs to loopback (eg. several QEMUs in same host */
|
||||
loop = 1;
|
||||
ret=setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
|
||||
(const char *)&loop, sizeof(loop));
|
||||
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
|
||||
&loop, sizeof(loop));
|
||||
if (ret < 0) {
|
||||
perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)");
|
||||
goto fail;
|
||||
@ -301,8 +300,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
|
||||
|
||||
/* If a bind address is given, only send packets from that address */
|
||||
if (localaddr != NULL) {
|
||||
ret = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
(const char *)localaddr, sizeof(*localaddr));
|
||||
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
localaddr, sizeof(*localaddr));
|
||||
if (ret < 0) {
|
||||
perror("setsockopt(IP_MULTICAST_IF)");
|
||||
goto fail;
|
||||
@ -521,7 +520,7 @@ static int net_socket_listen_init(NetClientState *peer,
|
||||
|
||||
/* allow fast reuse */
|
||||
val = 1;
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
|
||||
qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
||||
|
||||
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
|
||||
if (ret < 0) {
|
||||
@ -659,8 +658,8 @@ static int net_socket_udp_init(NetClientState *peer,
|
||||
return -1;
|
||||
}
|
||||
val = 1;
|
||||
ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
(const char *)&val, sizeof(val));
|
||||
ret = qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
&val, sizeof(val));
|
||||
if (ret < 0) {
|
||||
perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)");
|
||||
closesocket(fd);
|
||||
|
@ -212,9 +212,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
|
||||
} while (so->s < 0 && errno == EINTR);
|
||||
closesocket(s);
|
||||
opt = 1;
|
||||
setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
|
||||
qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
|
||||
opt = 1;
|
||||
setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
|
||||
qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
|
||||
socket_set_nonblock(so->s);
|
||||
|
||||
/* Append the telnet options now */
|
||||
|
@ -627,7 +627,7 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
|
||||
addr.sin_port = hport;
|
||||
|
||||
if (((s = qemu_socket(AF_INET,SOCK_STREAM,0)) < 0) ||
|
||||
(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
|
||||
(qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)) < 0) ||
|
||||
(bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
|
||||
(listen(s,1) < 0)) {
|
||||
int tmperrno = errno; /* Don't clobber the real reason we failed */
|
||||
@ -642,7 +642,7 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
|
||||
qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
|
||||
|
||||
getsockname(s,(struct sockaddr *)&addr,&addrlen);
|
||||
so->so_fport = addr.sin_port;
|
||||
|
@ -338,9 +338,9 @@ int tcp_fconnect(struct socket *so)
|
||||
|
||||
socket_set_nonblock(s);
|
||||
opt = 1;
|
||||
setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(opt ));
|
||||
qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
|
||||
opt = 1;
|
||||
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(opt ));
|
||||
qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==
|
||||
@ -427,9 +427,9 @@ void tcp_connect(struct socket *inso)
|
||||
}
|
||||
socket_set_nonblock(s);
|
||||
opt = 1;
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
|
||||
qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
|
||||
opt = 1;
|
||||
setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
|
||||
qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
|
||||
socket_set_nodelay(s);
|
||||
|
||||
so->so_fport = addr.sin_port;
|
||||
|
@ -372,7 +372,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
|
||||
udp_detach(so);
|
||||
return NULL;
|
||||
}
|
||||
setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
|
||||
qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
|
||||
|
||||
getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
|
||||
so->so_fport = addr.sin_port;
|
||||
|
@ -156,12 +156,12 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
|
||||
continue;
|
||||
}
|
||||
|
||||
setsockopt(slisten,SOL_SOCKET,SO_REUSEADDR,(void*)&on,sizeof(on));
|
||||
qemu_setsockopt(slisten, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
||||
#ifdef IPV6_V6ONLY
|
||||
if (e->ai_family == PF_INET6) {
|
||||
/* listen on both ipv4 and ipv6 */
|
||||
setsockopt(slisten,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&off,
|
||||
sizeof(off));
|
||||
qemu_setsockopt(slisten, IPPROTO_IPV6, IPV6_V6ONLY, &off,
|
||||
sizeof(off));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -229,7 +229,7 @@ static void wait_for_connect(void *opaque)
|
||||
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
|
||||
|
||||
do {
|
||||
rc = getsockopt(s->fd, SOL_SOCKET, SO_ERROR, (void *) &val, &valsize);
|
||||
rc = qemu_getsockopt(s->fd, SOL_SOCKET, SO_ERROR, &val, &valsize);
|
||||
} while (rc == -1 && socket_error() == EINTR);
|
||||
|
||||
/* update rc to contain error */
|
||||
@ -456,7 +456,7 @@ int inet_dgram_opts(QemuOpts *opts, Error **errp)
|
||||
error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED);
|
||||
goto err;
|
||||
}
|
||||
setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(void*)&on,sizeof(on));
|
||||
qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
||||
|
||||
/* bind socket */
|
||||
if (bind(sock, local->ai_addr, local->ai_addrlen) < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user