/* Default client mode is FILE, use these to change it */
VLC_EXPORT( void, httpd_ClientModeStream, ( httpd_client_t *cl ) );
VLC_EXPORT( void, httpd_ClientModeBidir, ( httpd_client_t *cl ) );
-VLC_EXPORT( char*, httpd_ClientIP, ( httpd_client_t *cl, char *psz_ip ) );
-VLC_EXPORT( char*, httpd_ServerIP, ( httpd_client_t *cl, char *psz_ip ) );
+VLC_EXPORT( char*, httpd_ClientIP, ( const httpd_client_t *cl, char *psz_ip ) );
+VLC_EXPORT( char*, httpd_ServerIP, ( const httpd_client_t *cl, char *psz_ip ) );
/* High level */
void (*httpd_UrlDelete_inner) (httpd_url_t *);
void (*httpd_ClientModeStream_inner) (httpd_client_t *cl);
void (*httpd_ClientModeBidir_inner) (httpd_client_t *cl);
- char* (*httpd_ClientIP_inner) (httpd_client_t *cl, char *psz_ip);
+ char* (*httpd_ClientIP_inner) (const httpd_client_t *cl, char *psz_ip);
httpd_file_t * (*httpd_FileNew_inner) (httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill, httpd_file_sys_t *);
void (*httpd_FileDelete_inner) (httpd_file_t *);
httpd_redirect_t * (*httpd_RedirectNew_inner) (httpd_host_t *, const char *psz_url_dst, const char *psz_url_src);
int (*ACL_LoadFile_inner) (vlc_acl_t *p_acl, const char *path);
int (*ACL_AddNet_inner) (vlc_acl_t *p_acl, const char *psz_ip, int i_len, vlc_bool_t b_allow);
void (*ACL_Destroy_inner) (vlc_acl_t *p_acl);
- char* (*httpd_ServerIP_inner) (httpd_client_t *cl, char *psz_ip);
+ char* (*httpd_ServerIP_inner) (const httpd_client_t *cl, char *psz_ip);
char * (*FromLocale_inner) (const char *);
void (*LocaleFree_inner) (const char *);
char * (*ToLocale_inner) (const char *);
# include <winsock.h>
#elif defined( WIN32 )
# include <winsock2.h>
-# include <ws2tcpip.h>
#else
-# include <netdb.h> /* hostent ... */
# include <sys/socket.h>
-/* FIXME: should not be needed */
-# include <netinet/in.h>
-# ifdef HAVE_ARPA_INET_H
-# include <arpa/inet.h> /* inet_ntoa(), inet_aton() */
-# endif
#endif
#if defined( WIN32 )
{
httpd_handler_t *handler = (httpd_handler_t*)p_sys;
uint8_t *psz_args = query->psz_args;
- char psz_remote_addr[100];
+ char psz_remote_addr[NI_MAXNUMERICHOST];
if( answer == NULL || query == NULL )
{
answer->i_status = 0;
answer->psz_status = NULL;
- switch( cl->sock.ss_family )
- {
-#ifdef HAVE_INET_PTON
- case AF_INET:
- inet_ntop( cl->sock.ss_family,
- &((struct sockaddr_in *)&cl->sock)->sin_addr,
- psz_remote_addr, sizeof(psz_remote_addr) );
- break;
- case AF_INET6:
- inet_ntop( cl->sock.ss_family,
- &((struct sockaddr_in6 *)&cl->sock)->sin6_addr,
- psz_remote_addr, sizeof(psz_remote_addr) );
- break;
-#else
- case AF_INET:
- {
- char *psz_tmp = inet_ntoa( ((struct sockaddr_in *)&cl->sock)->sin_addr );
- strncpy( psz_remote_addr, psz_tmp, sizeof(psz_remote_addr) );
- break;
- }
-#endif
- default:
- psz_remote_addr[0] = '\0';
- }
+ if( httpd_ClientIP( cl, psz_remote_addr ) == NULL )
+ *psz_remote_addr = '\0';
handler->pf_fill( handler->p_sys, handler, query->psz_url, psz_args,
query->i_type, query->p_body, query->i_body,
cl->i_mode = HTTPD_CLIENT_BIDIR;
}
-char* httpd_ClientIP( httpd_client_t *cl, char *psz_ip )
+char* httpd_ClientIP( const httpd_client_t *cl, char *psz_ip )
{
return net_GetPeerAddress( cl->fd, psz_ip, NULL ) ? NULL : psz_ip;
}
-char* httpd_ServerIP( httpd_client_t *cl, char *psz_ip )
+char* httpd_ServerIP( const httpd_client_t *cl, char *psz_ip )
{
return net_GetSockAddress( cl->fd, psz_ip, NULL ) ? NULL : psz_ip;
}