]> git.sesse.net Git - vlc/blobdiff - src/misc/httpd.c
- TLS API cleanup
[vlc] / src / misc / httpd.c
index 92f7ddd2c6feacc03886573e587a8f5b39ad402d..62d9a709786a0cc1274737b224916ec234060e55 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * httpd.c
  *****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004-2005 VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 #include <stdlib.h>
 #include <vlc/vlc.h>
 
+#ifdef ENABLE_HTTPD
+
 #include "vlc_httpd.h"
 #include "network.h"
+#include "vlc_tls.h"
 
 #include <string.h>
 #include <errno.h>
+
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
 #endif
-#include <fcntl.h>
+
+#ifdef HAVE_FCNTL_H
+#   include <fcntl.h>
+#endif
 
 #if defined( UNDER_CE )
 #   include <winsock.h>
 #   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 PF_INET AF_INET                                          /* BeOS */
 #endif
 
 #if 0
@@ -219,6 +232,9 @@ struct httpd_host_t
 
     int            i_client;
     httpd_client_t **client;
+    
+    /* TLS data */
+    tls_server_t *p_tls;
 };
 
 struct httpd_url_t
@@ -250,6 +266,9 @@ enum
     HTTPD_CLIENT_WAITING,
 
     HTTPD_CLIENT_DEAD,
+
+    HTTPD_CLIENT_TLS_HS_IN,
+    HTTPD_CLIENT_TLS_HS_OUT
 };
 /* mode */
 enum
@@ -284,6 +303,9 @@ struct httpd_client_t
     /* */
     httpd_message_t query;  /* client -> httpd */
     httpd_message_t answer; /* httpd -> client */
+    
+    /* TLS data */
+    tls_session_t *p_tls;
 };
 
 
@@ -367,6 +389,7 @@ static struct
     { ".jpg",   "image/jpeg" },
     { ".jpeg",  "image/jpeg" },
     { ".png",   "image/png" },
+    { ".mpjpeg","multipart/x-mixed-replace; boundary=This Random String" },
 
     /* media mime */
     { ".avi",   "video/avi" },
@@ -887,7 +910,14 @@ static int BuildAddr( struct sockaddr_in * p_socket,
 
 
 /* create a new host */
-httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
+httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host,
+                             int i_port )
+{
+    return httpd_TLSHostNew( p_this, psz_host, i_port, NULL );
+}
+
+httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, char *psz_host,
+                                int i_port, tls_server_t *p_tls )
 {
     httpd_t      *httpd;
     httpd_host_t *host = NULL;
@@ -902,28 +932,28 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
         char psz_port[6];
         struct addrinfo hints;
 
-#if 0
         memset( &hints, 0, sizeof( hints ) );
-        /* Check if we have force ipv4 or ipv6 */
-        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;
-#else
+
+#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 )
-            hints.ai_family = 0; // try IPv6, then IPv4
-#endif
+            hints.ai_family = PF_INET6;
 
         hints.ai_socktype = SOCK_STREAM;
         hints.ai_flags = AI_PASSIVE;
@@ -940,6 +970,7 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
             return NULL;
         }
     }
+
 #else
     struct sockaddr_in sock;
     struct httpd_addrinfo info;
@@ -997,7 +1028,11 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
         /* verify if it already exist */
         for( i = 0; i < httpd->i_host; i++ )
         {
-            if (GetAddrPort (&httpd->host[i]->sock) != i_port)
+            if( GetAddrPort (&httpd->host[i]->sock) != i_port )
+                continue;
+
+            /* Cannot re-use host if it uses TLS/SSL */
+            if( httpd->host[i]->p_tls != NULL )
                 continue;
 
 #ifdef AF_INET6
@@ -1006,7 +1041,7 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
                 const struct sockaddr_in6 *p_hsock, *p_sock;
 
                 p_hsock = (const struct sockaddr_in6 *)&httpd->host[i]->sock;
-                p_sock = (const struct sockaddr_in6 *)res->ai_addr;
+                p_sock = (const struct sockaddr_in6 *)ptr->ai_addr;
 
                 if( memcmp( &p_hsock->sin6_addr, &in6addr_any,
                             sizeof( struct in6_addr ) ) &&
@@ -1015,7 +1050,7 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
                                       sizeof( struct in6_addr ) ) ) )
                     continue; /* does not match */
             }
-            else if( res->ai_family == PF_INET6 )
+            else if( ptr->ai_family == PF_INET6 )
                 continue;
             else
 #endif
@@ -1024,14 +1059,14 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
                 const struct sockaddr_in *p_hsock, *p_sock;
 
                 p_hsock = (const struct sockaddr_in *)&httpd->host[i]->sock;
-                p_sock = (const struct sockaddr_in *)res->ai_addr;
+                p_sock = (const struct sockaddr_in *)ptr->ai_addr;
 
                 if( p_hsock->sin_addr.s_addr != INADDR_ANY &&
                     ( p_sock->sin_family != AF_INET ||
                       p_hsock->sin_addr.s_addr != p_sock->sin_addr.s_addr ) )
                     continue; /* does not match */
             }
-            else if( res->ai_family == PF_INET )
+            else if( ptr->ai_family == PF_INET )
                 continue;
             else
             {
@@ -1052,7 +1087,7 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
         }
 
         /* create the listening socket */
-        fd = socket( res->ai_family, res->ai_socktype, res->ai_protocol );
+        fd = socket( ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol );
         if( fd == -1 )
             continue;
 
@@ -1067,7 +1102,7 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
         }
 
         /* bind it */
-        if( bind( fd, res->ai_addr, res->ai_addrlen ) )
+        if( bind( fd, ptr->ai_addr, ptr->ai_addrlen ) )
         {
             msg_Err( p_this, "cannot bind socket" );
             goto socket_error;
@@ -1101,21 +1136,22 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, char *psz_host, int i_port )
         if( listen( fd, LISTEN_BACKLOG ) < 0 )
         {
             msg_Err( p_this, "cannot listen socket" );
-            close( fd );
-            fd = -1;
+            goto socket_error;
         }
 
-        continue;
+        break; // success
 
 socket_error:
-        close( fd );
+        net_Close( fd );
         fd = -1;
     }
 
-    freeaddrinfo( res );
 
     if( fd == -1 )
+    {
+        freeaddrinfo( res );
         goto error;
+    }
 
     /* create the new host */
     host = vlc_object_create( p_this, sizeof( httpd_host_t ) );
@@ -1124,13 +1160,16 @@ socket_error:
     host->i_ref = 1;
     host->fd = fd;
 
-    memcpy( &host->sock, res->ai_addr, res->ai_addrlen );
-    host->i_sock_size = res->ai_addrlen;
+    memcpy( &host->sock, ptr->ai_addr, ptr->ai_addrlen );
+    host->i_sock_size = ptr->ai_addrlen;
     host->i_url     = 0;
     host->url       = NULL;
     host->i_client  = 0;
     host->client    = NULL;
-    
+
+    freeaddrinfo( res );
+    host->p_tls = p_tls;
+
     /* create the thread */
     if( vlc_thread_create( host, "httpd host thread", httpd_HostThread,
                            VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
@@ -1208,6 +1247,8 @@ void httpd_HostDelete( httpd_host_t *host )
         /* TODO */
     }
 
+    if( host->p_tls != NULL)
+        tls_ServerDelete( host->p_tls );
     net_Close( host->fd );
     vlc_mutex_destroy( &host->lock );
     vlc_object_destroy( host );
@@ -1424,7 +1465,7 @@ static void httpd_ClientInit( httpd_client_t *cl )
 {
     cl->i_state = HTTPD_CLIENT_RECEIVING;
     cl->i_activity_date = mdate();
-    cl->i_activity_timeout = 50000000;
+    cl->i_activity_timeout = I64C(10000000);
     cl->i_buffer_size = 10000;
     cl->i_buffer = 0;
     cl->p_buffer = malloc( cl->i_buffer_size );
@@ -1475,8 +1516,6 @@ char* httpd_ClientIP( httpd_client_t *cl )
         /* FIXME: msg_Err */
         return NULL;
         
-    fprintf( stderr, "ClientIP = %s\n", &sz_ip[1]);
-    
     if( strchr( &sz_ip[1], ':' ) != NULL )
     {
         *sz_ip = '[';
@@ -1484,7 +1523,6 @@ char* httpd_ClientIP( httpd_client_t *cl )
         sz_ip[i++] = ']';
         sz_ip[i] = '\0';
        
-        fprintf( stderr, "ClientIP (with []) = %s\n", sz_ip);
         return strdup( sz_ip );
     }
     
@@ -1498,8 +1536,10 @@ char* httpd_ClientIP( httpd_client_t *cl )
 
 static void httpd_ClientClean( httpd_client_t *cl )
 {
-    if( cl->fd > 0 )
+    if( cl->fd >= 0 )
     {
+        if( cl->p_tls != NULL )
+            tls_ServerSessionClose( cl->p_tls );
         net_Close( cl->fd );
         cl->fd = -1;
     }
@@ -1515,29 +1555,47 @@ static void httpd_ClientClean( httpd_client_t *cl )
 }
 
 static httpd_client_t *httpd_ClientNew( int fd, struct sockaddr_storage *sock,
-                                        int i_sock_size )
+                                        int i_sock_size,
+                                        tls_session_t *p_tls )
 {
     httpd_client_t *cl = malloc( sizeof( httpd_client_t ) );
-    /* set this new socket non-block */
-#if defined( WIN32 ) || defined( UNDER_CE )
-    {
-        unsigned long i_dummy = 1;
-        ioctlsocket( fd, FIONBIO, &i_dummy );
-    }
-#else
-    fcntl( fd, F_SETFL, O_NONBLOCK );
-#endif
     cl->i_ref   = 0;
     cl->fd      = fd;
     memcpy( &cl->sock, sock, sizeof( cl->sock ) );
     cl->i_sock_size = i_sock_size;
     cl->url     = NULL;
+    cl->p_tls = p_tls;
 
     httpd_ClientInit( cl );
 
     return cl;
 }
 
+
+static int httpd_NetRecv( httpd_client_t *cl, char *p, int i_len )
+{
+    tls_session_t *p_tls;
+    
+    p_tls = cl->p_tls;
+    if( p_tls != NULL)
+        return tls_Recv( p_tls, p, i_len );
+
+    return recv( cl->fd, p, i_len, 0 );
+}
+
+
+static int httpd_NetSend( httpd_client_t *cl, const char *p, int i_len )
+{
+    tls_session_t *p_tls;
+
+    p_tls = cl->p_tls;
+    if( p_tls != NULL)
+        return tls_Send( p_tls, p, i_len );
+
+    return send( cl->fd, p, i_len, 0 );
+}
+
+
 static void httpd_ClientRecv( httpd_client_t *cl )
 {
     int i_len;
@@ -1545,8 +1603,8 @@ static void httpd_ClientRecv( httpd_client_t *cl )
     if( cl->query.i_proto == HTTPD_PROTO_NONE )
     {
         /* enought to see if it's rtp over rtsp or RTSP/HTTP */
-        i_len = recv( cl->fd, &cl->p_buffer[cl->i_buffer], 4 - cl->i_buffer, 0 );
-
+        i_len = httpd_NetRecv( cl, &cl->p_buffer[cl->i_buffer],
+                               4 - cl->i_buffer );
         if( i_len > 0 )
         {
             cl->i_buffer += i_len;
@@ -1594,8 +1652,8 @@ static void httpd_ClientRecv( httpd_client_t *cl )
     else if( cl->query.i_body > 0 )
     {
         /* we are reading the body of a request or a channel */
-        i_len = recv( cl->fd, &cl->query.p_body[cl->i_buffer],
-                      cl->query.i_body - cl->i_buffer, 0 );
+        i_len = httpd_NetRecv( cl, &cl->query.p_body[cl->i_buffer],
+                               cl->query.i_body - cl->i_buffer );
         if( i_len > 0 )
         {
             cl->i_buffer += i_len;
@@ -1610,7 +1668,7 @@ static void httpd_ClientRecv( httpd_client_t *cl )
         /* we are reading a header -> char by char */
         for( ;; )
         {
-            i_len = recv( cl->fd, &cl->p_buffer[cl->i_buffer], 1, 0 );
+            i_len = httpd_NetRecv (cl, &cl->p_buffer[cl->i_buffer], 1 );
             if( i_len <= 0 )
             {
                 break;
@@ -1835,6 +1893,10 @@ static void httpd_ClientRecv( httpd_client_t *cl )
     }
     cl->i_activity_date = mdate();
 
+    /* XXX: for QT I have to disable timeout. Try to find why */
+    if( cl->query.i_proto == HTTPD_PROTO_RTSP )
+        cl->i_activity_timeout = 0;
+
     /* Debugging only */
     if( cl->i_state == HTTPD_CLIENT_RECEIVE_DONE )
     {
@@ -1862,6 +1924,7 @@ static void httpd_ClientRecv( httpd_client_t *cl )
     }
 }
 
+
 static void httpd_ClientSend( httpd_client_t *cl )
 {
     int i;
@@ -1907,8 +1970,8 @@ static void httpd_ClientSend( httpd_client_t *cl )
         fprintf( stderr, "%s",  cl->p_buffer );
     }
 
-    i_len = send( cl->fd, &cl->p_buffer[cl->i_buffer],
-                  cl->i_buffer_size - cl->i_buffer, 0 );
+    i_len = httpd_NetSend( cl, &cl->p_buffer[cl->i_buffer],
+                           cl->i_buffer_size - cl->i_buffer );
     if( i_len > 0 )
     {
         cl->i_activity_date = mdate();
@@ -1962,8 +2025,47 @@ static void httpd_ClientSend( httpd_client_t *cl )
     }
 }
 
+static void httpd_ClientTlsHsIn( httpd_client_t *cl )
+{
+    switch( tls_SessionContinueHandshake( cl->p_tls ) )
+    {
+        case 0:
+            cl->i_state = HTTPD_CLIENT_RECEIVING;
+            break;
+
+        case -1:
+            cl->i_state = HTTPD_CLIENT_DEAD;
+            cl->p_tls = NULL;
+            break;
+
+        case 2:
+            cl->i_state = HTTPD_CLIENT_TLS_HS_OUT;
+    }
+}
+
+static void httpd_ClientTlsHsOut( httpd_client_t *cl )
+{
+    switch( tls_SessionContinueHandshake( cl->p_tls ) )
+    {
+        case 0:
+            cl->i_state = HTTPD_CLIENT_RECEIVING;
+            break;
+
+        case -1:
+            cl->i_state = HTTPD_CLIENT_DEAD;
+            cl->p_tls = NULL;
+            break;
+
+        case 1:
+            cl->i_state = HTTPD_CLIENT_TLS_HS_IN;
+            break;
+    }
+}
+
 static void httpd_HostThread( httpd_host_t *host )
 {
+    tls_session_t *p_tls = NULL;
+
     while( !host->b_die )
     {
         struct timeval  timeout;
@@ -1988,6 +2090,10 @@ static void httpd_HostThread( httpd_host_t *host )
         FD_SET( host->fd, &fds_read );
         i_handle_max = host->fd;
 
+        /* prepare a new TLS session */
+        if( ( p_tls == NULL ) && ( host->p_tls != NULL ) )
+            p_tls = tls_ServerSessionPrepare( host->p_tls );
+
         /* add all socket that should be read/write and close dead connection */
         vlc_mutex_lock( &host->lock );
         for( i_client = 0; i_client < host->i_client; i_client++ )
@@ -1996,7 +2102,8 @@ static void httpd_HostThread( httpd_host_t *host )
 
             if( cl->i_ref < 0 || ( cl->i_ref == 0 &&
                 ( cl->i_state == HTTPD_CLIENT_DEAD ||
-                  cl->i_activity_date + cl->i_activity_timeout < mdate() ) ) )
+                  ( cl->i_activity_timeout > 0 &&
+                    cl->i_activity_date+cl->i_activity_timeout < mdate()) ) ) )
             {
                 char *ip;
 
@@ -2012,12 +2119,14 @@ static void httpd_HostThread( httpd_host_t *host )
                 i_client--;
                 continue;
             }
-            else if( cl->i_state == HTTPD_CLIENT_RECEIVING )
+            else if( ( cl->i_state == HTTPD_CLIENT_RECEIVING )
+                  || ( cl->i_state == HTTPD_CLIENT_TLS_HS_IN ) )
             {
                 FD_SET( cl->fd, &fds_read );
                 i_handle_max = __MAX( i_handle_max, cl->fd );
             }
-            else if( cl->i_state == HTTPD_CLIENT_SENDING )
+            else if( ( cl->i_state == HTTPD_CLIENT_SENDING )
+                  || ( cl->i_state == HTTPD_CLIENT_TLS_HS_OUT ) )
             {
                 FD_SET( cl->fd, &fds_write );
                 i_handle_max = __MAX( i_handle_max, cl->fd );
@@ -2224,7 +2333,7 @@ static void httpd_HostThread( httpd_host_t *host )
                             p += sprintf( p, "<title>Error 404</title>\n" );
                             p += sprintf( p, "</head>\n" );
                             p += sprintf( p, "<body>\n" );
-                            p += sprintf( p, "<h1><center> 404 Ressource not found(%s)</center></h1>\n", query->psz_url );
+                            p += sprintf( p, "<h1><center> 404 Resource not found(%s)</center></h1>\n", query->psz_url );
                             p += sprintf( p, "<hr />\n" );
                             p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" );
                             p += sprintf( p, "</body>\n" );
@@ -2355,21 +2464,62 @@ static void httpd_HostThread( httpd_host_t *host )
             int     fd;
 
             fd = accept( host->fd, (struct sockaddr *)&sock, &i_sock_size );
-            if( fd > 0 )
+            if( fd >= 0 )
             {
-                char *ip;
+                int i_state = 0;
 
-                httpd_client_t *cl = httpd_ClientNew( fd, &sock, i_sock_size );
+                /* set this new socket non-block */
+#if defined( WIN32 ) || defined( UNDER_CE )
+                {
+                    unsigned long i_dummy = 1;
+                    ioctlsocket( fd, FIONBIO, &i_dummy );
+                }
+#else
+                fcntl( fd, F_SETFL, O_NONBLOCK );
+#endif
 
-                vlc_mutex_lock( &host->lock );
-                TAB_APPEND( host->i_client, host->client, cl );
-                vlc_mutex_unlock( &host->lock );
+                if( p_tls != NULL)
+                {
+                    switch ( tls_ServerSessionHandshake( p_tls, fd ) )
+                    {
+                        case -1:
+                            msg_Err( host, "Rejecting TLS connection" );
+                            net_Close( fd );
+                            fd = -1;
+                            p_tls = NULL;
+                            break;
 
-                // FIXME: it sucks to allocate heap memory for a debug message
-                ip = httpd_ClientIP( cl );
-                msg_Dbg( host, "new connection (%s)",
-                         ip != NULL ? ip : "unknown" );
-                free( ip );
+                        case 1: /* missing input - most likely */
+                            i_state = HTTPD_CLIENT_TLS_HS_IN;
+                            break;
+
+                        case 2: /* missing output */
+                            i_state = HTTPD_CLIENT_TLS_HS_OUT;
+                            break;
+                    }
+                }
+                
+                if( fd >= 0 )
+                {
+                    char *ip;
+                    httpd_client_t *cl;
+
+                    cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls );
+                    p_tls = NULL;
+                    vlc_mutex_lock( &host->lock );
+                    TAB_APPEND( host->i_client, host->client, cl );
+                    vlc_mutex_unlock( &host->lock );
+
+                    if( i_state != 0 )
+                        cl->i_state = i_state; // override state for TLS
+
+                    // FIXME: it sucks to allocate memory for debug
+                    ip = httpd_ClientIP( cl );
+                    msg_Dbg( host, "new connection (%s)",
+                             ip != NULL ? ip : "unknown" );
+                    if( ip != NULL)
+                        free( ip );
+                }
             }
         }
         /* now try all others socket */
@@ -2385,6 +2535,14 @@ static void httpd_HostThread( httpd_host_t *host )
             {
                 httpd_ClientSend( cl );
             }
+            else if( cl->i_state == HTTPD_CLIENT_TLS_HS_IN )
+            {
+                httpd_ClientTlsHsIn( cl );
+            }
+            else if( cl->i_state == HTTPD_CLIENT_TLS_HS_OUT )
+            {
+                httpd_ClientTlsHsOut( cl );
+            }
 
             if( cl->i_mode == HTTPD_CLIENT_BIDIR &&
                 cl->i_state == HTTPD_CLIENT_SENDING &&
@@ -2395,6 +2553,9 @@ static void httpd_HostThread( httpd_host_t *host )
         }
         vlc_mutex_unlock( &host->lock );
     }
+
+    if( p_tls != NULL )
+        tls_ServerSessionClose( p_tls );
 }
 
 #ifndef HAVE_GETADDRINFO
@@ -2461,3 +2622,51 @@ static int GetAddrPort( const struct sockaddr_storage *p_ss )
     
     return ntohs( i_port );
 }
+
+#else /* ENABLE_HTTPD */
+
+/* We just define an empty wrapper */
+httpd_host_t *httpd_TLSHostNew( vlc_object_t *a, char *b, int c,
+                                tls_server_t *d )
+{
+    msg_Err( a, "HTTP daemon support is disabled" );
+    return 0;
+}
+httpd_host_t *httpd_HostNew( vlc_object_t *a, char *b, int c )
+{
+    msg_Err( a, "HTTP daemon support is disabled" );
+    return 0;
+}
+void httpd_HostDelete( httpd_host_t *a ){}
+httpd_url_t *httpd_UrlNew( httpd_host_t *a, char *b ){ return 0; }
+httpd_url_t *httpd_UrlNewUnique( httpd_host_t *a, char *b, char *c,
+                                 char *d ){ return 0; }
+int httpd_UrlCatch( httpd_url_t *a, int b, httpd_callback_t c,
+                    httpd_callback_sys_t *d ){ return 0; }
+void httpd_UrlDelete( httpd_url_t *a ){}
+
+char *httpd_ClientIP( httpd_client_t *a ){ return 0; }
+void httpd_ClientModeStream( httpd_client_t *a ){}
+void httpd_ClientModeBidir( httpd_client_t *a ){}
+
+void httpd_FileDelete( httpd_file_t *a ){}
+httpd_file_t *httpd_FileNew( httpd_host_t *a, char *b, char *c, char *d,
+                             char *e, httpd_file_callback_t f,
+                             httpd_file_sys_t *g ){ return 0; }
+
+void httpd_RedirectDelete( httpd_redirect_t *a ){}
+httpd_redirect_t *httpd_RedirectNew( httpd_host_t *a,
+                                     char *b, char *c ){ return 0; }
+
+void httpd_StreamDelete( httpd_stream_t *a ){}
+int  httpd_StreamHeader( httpd_stream_t *a, uint8_t *b, int c ){ return 0; }
+int  httpd_StreamSend  ( httpd_stream_t *a, uint8_t *b, int c ){ return 0; }
+httpd_stream_t *httpd_StreamNew( httpd_host_t *a, char *b, char *c,
+                                 char *d, char *e ){ return 0; }
+
+void httpd_MsgInit ( httpd_message_t *a ){}
+void httpd_MsgAdd  ( httpd_message_t *a, char *b, char *c, ... ){}
+char *httpd_MsgGet ( httpd_message_t *a, char *b ){ return 0; }
+void httpd_MsgClean( httpd_message_t *a ){}
+
+#endif /* ENABLE_HTTPD */