projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9523702
)
When trying to bind default broadcast (ipv6) fails, retry with broadcast ipv4.
author
Wilfried Goesgens
<dothebart@citadel.org>
Sat, 16 Feb 2013 13:05:30 +0000
(14:05 +0100)
committer
Wilfried Goesgens
<dothebart@citadel.org>
Sat, 16 Feb 2013 13:05:30 +0000
(14:05 +0100)
webcit/tcp_sockets.c
patch
|
blob
|
history
diff --git
a/webcit/tcp_sockets.c
b/webcit/tcp_sockets.c
index 2835344f47eef51393adcfdc1ef66714ec07cc42..cb0ad320e393606f9877dce03b2810281582d53e 100644
(file)
--- a/
webcit/tcp_sockets.c
+++ b/
webcit/tcp_sockets.c
@@
-512,14
+512,17
@@
int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target)
* port_number port number to bind
* queue_len number of incoming connections to allow in the queue
*/
* port_number port number to bind
* queue_len number of incoming connections to allow in the queue
*/
-int webcit_tcp_server(char *ip_addr, int port_number, int queue_len)
+int webcit_tcp_server(c
onst c
har *ip_addr, int port_number, int queue_len)
{
{
+ const char *ipv4broadcast = "0.0.0.0";
+ int IsDefault = 0;
struct protoent *p;
struct sockaddr_in6 sin6;
struct sockaddr_in sin4;
int s, i, b;
int ip_version = 6;
struct protoent *p;
struct sockaddr_in6 sin6;
struct sockaddr_in sin4;
int s, i, b;
int ip_version = 6;
+retry:
memset(&sin6, 0, sizeof(sin6));
memset(&sin4, 0, sizeof(sin4));
sin6.sin6_family = AF_INET6;
memset(&sin6, 0, sizeof(sin6));
memset(&sin4, 0, sizeof(sin4));
sin6.sin6_family = AF_INET6;
@@
-565,6
+568,12
@@
int webcit_tcp_server(char *ip_addr, int port_number, int queue_len)
s = socket( ((ip_version == 6) ? PF_INET6 : PF_INET), SOCK_STREAM, (p->p_proto));
if (s < 0) {
s = socket( ((ip_version == 6) ? PF_INET6 : PF_INET), SOCK_STREAM, (p->p_proto));
if (s < 0) {
+ if (IsDefault && (errno == EAFNOSUPPORT))
+ {
+ s = 0;
+ ip_addr = ipv4broadcast;
+ goto retry;
+ }
syslog(LOG_WARNING, "Can't create a listening socket: %s\n", strerror(errno));
return (-WC_EXIT_BIND);
}
syslog(LOG_WARNING, "Can't create a listening socket: %s\n", strerror(errno));
return (-WC_EXIT_BIND);
}