/*****************************************************************************
* httpd.c
*****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004-2005 VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
- * Remi Denis-Courmont <courmisch@via.ecp.fr>
+ * Remi Denis-Courmont <rem # videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
# endif
#endif
-#if defined(WIN32)
+#if defined(WIN32) && !defined(UNDER_CE)
static const struct in6_addr in6addr_any = {{IN6ADDR_ANY_INIT}};
+#elif defined(UNDER_CE) && defined(AF_INET6)
+# undef AF_INET6
#endif
#ifndef PF_INET
*****************************************************************************/
#define LISTEN_BACKLOG 100
-#if defined(HAVE_GETNAMEINFO) && !defined(HAVE_GETADDRINFO)
-/*
- * For now, VLC's configure script does not check for getaddrinfo(),
- * but it should be present if getnameinfo() is (the opposite is untrue, with
- * Debian potato as an example)
- */
-# define HAVE_GETADDRINFO 1
-#endif
-
static void httpd_HostThread( httpd_host_t * );
static int GetAddrPort( const struct sockaddr_storage *p_ss );
vlc_value_t val;
char psz_port[6];
struct addrinfo hints;
+ int check;
memset( &hints, 0, sizeof( hints ) );
-#if 0
- /*
- * For now, keep IPv4 by default. That said, it should be safe to use
- * IPv6 by default *on the server side*, as, apart from NetBSD, most
- * systems accept IPv4 clients on IPv6 listening sockets.
- */
- hints.ai_family = PF_INET;
-#else
- hints.ai_family = 0;
-
/* Check if ipv4 or ipv6 were forced */
var_Create( p_this, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Get( p_this, "ipv4", &val );
if( val.b_bool )
hints.ai_family = PF_INET;
-#endif
+
var_Create( p_this, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Get( p_this, "ipv6", &val );
if( val.b_bool )
snprintf( psz_port, sizeof( psz_port ), "%d", i_port );
psz_port[sizeof( psz_port ) - 1] = '\0';
- if( getaddrinfo( psz_host, psz_port, &hints, &res ) )
+ check = getaddrinfo( psz_host, psz_port, &hints, &res );
+ if( check != 0 )
{
+#ifdef HAVE_GAI_STRERROR
+ msg_Err( p_this, "cannot resolve %s:%d : %s", psz_host, i_port,
+ gai_strerror( check ) );
+#else
msg_Err( p_this, "cannot resolve %s:%d", psz_host, i_port );
+#endif
return NULL;
}
}
if( cl->fd >= 0 )
{
if( cl->p_tls != NULL )
- tls_SessionClose( cl->p_tls );
+ tls_ServerSessionClose( cl->p_tls );
net_Close( cl->fd );
cl->fd = -1;
}
fcntl( fd, F_SETFL, O_NONBLOCK );
#endif
- /* FIXME: that MUST be non-blocking */
if( p_tls != NULL)
{
- switch ( tls_SessionHandshake( p_tls, fd ) )
+ switch ( tls_ServerSessionHandshake( p_tls, fd ) )
{
case -1:
msg_Err( host, "Rejecting TLS connection" );
net_Close( fd );
fd = -1;
+ p_tls = NULL;
break;
case 1: /* missing input - most likely */
}
vlc_mutex_unlock( &host->lock );
}
+
+ if( p_tls != NULL )
+ tls_ServerSessionClose( p_tls );
}
#ifndef HAVE_GETADDRINFO