mirror of
https://github.com/irssi/irssi.git
synced 2026-08-20 09:02:13 +02:00
Network fixes. DCC fixes for IPv6 + BSDs.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3124 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
ae5b5f38bd
commit
a619fe9a2c
3 changed files with 17 additions and 4 deletions
|
|
@ -51,6 +51,11 @@ union sockaddr_union {
|
||||||
/* Cygwin need this, don't know others.. */
|
/* Cygwin need this, don't know others.. */
|
||||||
/*#define BLOCKING_SOCKETS 1*/
|
/*#define BLOCKING_SOCKETS 1*/
|
||||||
|
|
||||||
|
IPADDR ip4_any = {
|
||||||
|
AF_INET,
|
||||||
|
{ INADDR_ANY }
|
||||||
|
};
|
||||||
|
|
||||||
int net_ip_compare(IPADDR *ip1, IPADDR *ip2)
|
int net_ip_compare(IPADDR *ip1, IPADDR *ip2)
|
||||||
{
|
{
|
||||||
if (ip1->family != ip2->family)
|
if (ip1->family != ip2->family)
|
||||||
|
|
@ -114,7 +119,7 @@ void sin_set_port(union sockaddr_union *so, int port)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (so->sin.sin_family == AF_INET6)
|
if (so->sin.sin_family == AF_INET6)
|
||||||
so->sin6.sin6_port = htons(port);
|
so->sin6.sin6_port = htons((unsigned short)port);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
so->sin.sin_port = htons((unsigned short)port);
|
so->sin.sin_port = htons((unsigned short)port);
|
||||||
|
|
@ -283,8 +288,8 @@ GIOChannel *net_listen(IPADDR *my_ip, int *port)
|
||||||
g_return_val_if_fail(port != NULL, NULL);
|
g_return_val_if_fail(port != NULL, NULL);
|
||||||
|
|
||||||
memset(&so, 0, sizeof(so));
|
memset(&so, 0, sizeof(so));
|
||||||
sin_set_port(&so, *port);
|
|
||||||
sin_set_ip(&so, my_ip);
|
sin_set_ip(&so, my_ip);
|
||||||
|
sin_set_port(&so, *port);
|
||||||
|
|
||||||
/* create the socket */
|
/* create the socket */
|
||||||
handle = socket(so.sin.sin_family, SOCK_STREAM, 0);
|
handle = socket(so.sin.sin_family, SOCK_STREAM, 0);
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ struct _IPADDR {
|
||||||
|
|
||||||
#define IPADDR_IS_V6(ip) ((ip)->family != AF_INET)
|
#define IPADDR_IS_V6(ip) ((ip)->family != AF_INET)
|
||||||
|
|
||||||
|
extern IPADDR ip4_any;
|
||||||
|
|
||||||
/* returns 1 if IPADDRs are the same */
|
/* returns 1 if IPADDRs are the same */
|
||||||
int net_ip_compare(IPADDR *ip1, IPADDR *ip2);
|
int net_ip_compare(IPADDR *ip1, IPADDR *ip2);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,10 @@ GIOChannel *dcc_listen(GIOChannel *iface, IPADDR *ip, int *port)
|
||||||
if (first == 0) {
|
if (first == 0) {
|
||||||
/* random port */
|
/* random port */
|
||||||
*port = 0;
|
*port = 0;
|
||||||
return net_listen(NULL, port);
|
if (IPADDR_IS_V6(ip))
|
||||||
|
return net_listen(NULL, port);
|
||||||
|
else
|
||||||
|
return net_listen(&ip4_any, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get last port */
|
/* get last port */
|
||||||
|
|
@ -226,7 +229,10 @@ GIOChannel *dcc_listen(GIOChannel *iface, IPADDR *ip, int *port)
|
||||||
|
|
||||||
/* use the first available port */
|
/* use the first available port */
|
||||||
for (*port = first; *port <= last; (*port)++) {
|
for (*port = first; *port <= last; (*port)++) {
|
||||||
handle = net_listen(NULL, port);
|
if (IPADDR_IS_V6(ip))
|
||||||
|
handle = net_listen(NULL, port);
|
||||||
|
else
|
||||||
|
handle = net_listen(&ip4_any, port);
|
||||||
if (handle != NULL)
|
if (handle != NULL)
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue