VLC  3.0.0-git
Data Structures | Macros | Enumerations | Functions | Variables
httpd.c File Reference
Include dependency graph for httpd.c:

Data Structures

struct  httpd_host_t
 
struct  httpd_url_t
 
struct  httpd_client_t
 
struct  httpd_file_t
 
struct  httpd_handler_t
 
struct  httpd_redirect_t
 
struct  httpd_stream_t
 
struct  httpd
 

Macros

#define HTTPD_CL_BUFSIZE   10000
 

Enumerations

enum  {
  HTTPD_CLIENT_RECEIVING, HTTPD_CLIENT_RECEIVE_DONE, HTTPD_CLIENT_SENDING, HTTPD_CLIENT_SEND_DONE,
  HTTPD_CLIENT_WAITING, HTTPD_CLIENT_DEAD, HTTPD_CLIENT_TLS_HS_IN, HTTPD_CLIENT_TLS_HS_OUT
}
 
enum  { HTTPD_CLIENT_FILE, HTTPD_CLIENT_STREAM }
 

Functions

static void httpd_ClientDestroy (httpd_client_t *cl)
 
static void httpd_AppendData (httpd_stream_t *stream, uint8_t *p_data, int i_data)
 
static const char * httpd_ReasonFromCode (unsigned i_code)
 
static size_t httpd_HtmlError (char **body, int code, const char *url)
 
static int httpd_FileCallBack (httpd_callback_sys_t *p_sys, httpd_client_t *cl, httpd_message_t *answer, const httpd_message_t *query)
 
httpd_file_thttpd_FileNew (httpd_host_t *host, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, httpd_file_callback_t pf_fill, httpd_file_sys_t *p_sys)
 
httpd_file_sys_thttpd_FileDelete (httpd_file_t *file)
 
static int httpd_HandlerCallBack (httpd_callback_sys_t *p_sys, httpd_client_t *cl, httpd_message_t *answer, const httpd_message_t *query)
 
httpd_handler_thttpd_HandlerNew (httpd_host_t *host, const char *psz_url, const char *psz_user, const char *psz_password, httpd_handler_callback_t pf_fill, void *p_sys)
 
void * httpd_HandlerDelete (httpd_handler_t *handler)
 
static int httpd_RedirectCallBack (httpd_callback_sys_t *p_sys, httpd_client_t *cl, httpd_message_t *answer, const httpd_message_t *query)
 
httpd_redirect_thttpd_RedirectNew (httpd_host_t *host, const char *psz_url_dst, const char *psz_url_src)
 
void httpd_RedirectDelete (httpd_redirect_t *rdir)
 
static int httpd_StreamCallBack (httpd_callback_sys_t *p_sys, httpd_client_t *cl, httpd_message_t *answer, const httpd_message_t *query)
 
httpd_stream_thttpd_StreamNew (httpd_host_t *host, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password)
 
int httpd_StreamHeader (httpd_stream_t *stream, uint8_t *p_data, int i_data)
 
int httpd_StreamSend (httpd_stream_t *stream, const block_t *p_block)
 
void httpd_StreamDelete (httpd_stream_t *stream)
 
static void * httpd_HostThread (void *)
 
static httpd_host_thttpd_HostCreate (vlc_object_t *, const char *, const char *, vlc_tls_creds_t *)
 
httpd_host_tvlc_http_HostNew (vlc_object_t *p_this)
 
httpd_host_tvlc_https_HostNew (vlc_object_t *obj)
 
httpd_host_tvlc_rtsp_HostNew (vlc_object_t *p_this)
 
void httpd_HostDelete (httpd_host_t *host)
 
httpd_url_thttpd_UrlNew (httpd_host_t *host, const char *psz_url, const char *psz_user, const char *psz_password)
 
int httpd_UrlCatch (httpd_url_t *url, int i_msg, httpd_callback_t cb, httpd_callback_sys_t *p_sys)
 
void httpd_UrlDelete (httpd_url_t *url)
 
static void httpd_MsgInit (httpd_message_t *msg)
 
static void httpd_MsgClean (httpd_message_t *msg)
 
const char * httpd_MsgGet (const httpd_message_t *msg, const char *name)
 
void httpd_MsgAdd (httpd_message_t *msg, const char *name, const char *psz_value,...)
 
static void httpd_ClientInit (httpd_client_t *cl, mtime_t now)
 
char * httpd_ClientIP (const httpd_client_t *cl, char *ip, int *port)
 
char * httpd_ServerIP (const httpd_client_t *cl, char *ip, int *port)
 
static httpd_client_thttpd_ClientNew (vlc_tls_t *sock, mtime_t now)
 
static ssize_t httpd_NetRecv (httpd_client_t *cl, uint8_t *p, size_t i_len)
 
static ssize_t httpd_NetSend (httpd_client_t *cl, const uint8_t *p, size_t i_len)
 
static void httpd_ClientRecv (httpd_client_t *cl)
 
static void httpd_ClientSend (httpd_client_t *cl)
 
static void httpd_ClientTlsHandshake (httpd_host_t *host, httpd_client_t *cl)
 
static bool httpdAuthOk (const char *user, const char *pass, const char *b64)
 
static void httpdLoop (httpd_host_t *host)
 
int httpd_StreamSetHTTPHeaders (httpd_stream_t *p_stream, const httpd_header *p_headers, size_t i_headers)
 

Variables

static struct httpd httpd = { PTHREAD_MUTEX_INITIALIZER , NULL, 0 }
 
struct {
   const char   name [16]
 
   int   i_type
 
   int   i_proto
 
msg_type []
 

Macro Definition Documentation

◆ HTTPD_CL_BUFSIZE

#define HTTPD_CL_BUFSIZE   10000

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HTTPD_CLIENT_RECEIVING 
HTTPD_CLIENT_RECEIVE_DONE 
HTTPD_CLIENT_SENDING 
HTTPD_CLIENT_SEND_DONE 
HTTPD_CLIENT_WAITING 
HTTPD_CLIENT_DEAD 
HTTPD_CLIENT_TLS_HS_IN 
HTTPD_CLIENT_TLS_HS_OUT 

◆ anonymous enum

anonymous enum
Enumerator
HTTPD_CLIENT_FILE 
HTTPD_CLIENT_STREAM 

Function Documentation

◆ httpd_AppendData()

static void httpd_AppendData ( httpd_stream_t stream,
uint8_t *  p_data,
int  i_data 
)
static

◆ httpd_ClientDestroy()

static void httpd_ClientDestroy ( httpd_client_t cl)
static

◆ httpd_ClientInit()

static void httpd_ClientInit ( httpd_client_t cl,
mtime_t  now 
)
static

◆ httpd_ClientIP()

char* httpd_ClientIP ( const httpd_client_t cl,
char *  ip,
int *  port 
)

◆ httpd_ClientNew()

static httpd_client_t* httpd_ClientNew ( vlc_tls_t sock,
mtime_t  now 
)
static

◆ httpd_ClientRecv()

static void httpd_ClientRecv ( httpd_client_t cl)
static

◆ httpd_ClientSend()

static void httpd_ClientSend ( httpd_client_t cl)
static

◆ httpd_ClientTlsHandshake()

static void httpd_ClientTlsHandshake ( httpd_host_t host,
httpd_client_t cl 
)
static

◆ httpd_FileCallBack()

static int httpd_FileCallBack ( httpd_callback_sys_t p_sys,
httpd_client_t cl,
httpd_message_t answer,
const httpd_message_t query 
)
static

◆ httpd_FileDelete()

httpd_file_sys_t* httpd_FileDelete ( httpd_file_t file)

◆ httpd_FileNew()

httpd_file_t* httpd_FileNew ( httpd_host_t host,
const char *  psz_url,
const char *  psz_mime,
const char *  psz_user,
const char *  psz_password,
httpd_file_callback_t  pf_fill,
httpd_file_sys_t p_sys 
)

◆ httpd_HandlerCallBack()

static int httpd_HandlerCallBack ( httpd_callback_sys_t p_sys,
httpd_client_t cl,
httpd_message_t answer,
const httpd_message_t query 
)
static

◆ httpd_HandlerDelete()

void* httpd_HandlerDelete ( httpd_handler_t handler)

◆ httpd_HandlerNew()

httpd_handler_t* httpd_HandlerNew ( httpd_host_t host,
const char *  psz_url,
const char *  psz_user,
const char *  psz_password,
httpd_handler_callback_t  pf_fill,
void *  p_sys 
)

◆ httpd_HostCreate()

static httpd_host_t * httpd_HostCreate ( vlc_object_t p_this,
const char *  hostvar,
const char *  portvar,
vlc_tls_creds_t p_tls 
)
static

◆ httpd_HostDelete()

void httpd_HostDelete ( httpd_host_t host)

◆ httpd_HostThread()

static void * httpd_HostThread ( void *  data)
static

◆ httpd_HtmlError()

static size_t httpd_HtmlError ( char **  body,
int  code,
const char *  url 
)
static

◆ httpd_MsgAdd()

void httpd_MsgAdd ( httpd_message_t msg,
const char *  name,
const char *  psz_value,
  ... 
)

◆ httpd_MsgClean()

static void httpd_MsgClean ( httpd_message_t msg)
static

◆ httpd_MsgGet()

const char* httpd_MsgGet ( const httpd_message_t msg,
const char *  name 
)

◆ httpd_MsgInit()

static void httpd_MsgInit ( httpd_message_t msg)
static

◆ httpd_NetRecv()

static ssize_t httpd_NetRecv ( httpd_client_t cl,
uint8_t *  p,
size_t  i_len 
)
static

References p, vlc_tls::readv, and httpd_client_t::sock.

Referenced by httpd_ClientRecv().

◆ httpd_NetSend()

static ssize_t httpd_NetSend ( httpd_client_t cl,
const uint8_t *  p,
size_t  i_len 
)
static

◆ httpd_ReasonFromCode()

static const char* httpd_ReasonFromCode ( unsigned  i_code)
static

◆ httpd_RedirectCallBack()

static int httpd_RedirectCallBack ( httpd_callback_sys_t p_sys,
httpd_client_t cl,
httpd_message_t answer,
const httpd_message_t query 
)
static

◆ httpd_RedirectDelete()

void httpd_RedirectDelete ( httpd_redirect_t rdir)

◆ httpd_RedirectNew()

httpd_redirect_t* httpd_RedirectNew ( httpd_host_t host,
const char *  psz_url_dst,
const char *  psz_url_src 
)

◆ httpd_ServerIP()

char* httpd_ServerIP ( const httpd_client_t cl,
char *  ip,
int *  port 
)

◆ httpd_StreamCallBack()

static int httpd_StreamCallBack ( httpd_callback_sys_t p_sys,
httpd_client_t cl,
httpd_message_t answer,
const httpd_message_t query 
)
static

◆ httpd_StreamDelete()

void httpd_StreamDelete ( httpd_stream_t stream)

◆ httpd_StreamHeader()

int httpd_StreamHeader ( httpd_stream_t stream,
uint8_t *  p_data,
int  i_data 
)

◆ httpd_StreamNew()

httpd_stream_t* httpd_StreamNew ( httpd_host_t host,
const char *  psz_url,
const char *  psz_mime,
const char *  psz_user,
const char *  psz_password 
)

◆ httpd_StreamSend()

int httpd_StreamSend ( httpd_stream_t stream,
const block_t p_block 
)

◆ httpd_StreamSetHTTPHeaders()

int httpd_StreamSetHTTPHeaders ( httpd_stream_t p_stream,
const httpd_header p_headers,
size_t  i_headers 
)

◆ httpd_UrlCatch()

int httpd_UrlCatch ( httpd_url_t url,
int  i_msg,
httpd_callback_t  cb,
httpd_callback_sys_t p_sys 
)

◆ httpd_UrlDelete()

void httpd_UrlDelete ( httpd_url_t url)

◆ httpd_UrlNew()

httpd_url_t* httpd_UrlNew ( httpd_host_t host,
const char *  psz_url,
const char *  psz_user,
const char *  psz_password 
)

◆ httpdAuthOk()

static bool httpdAuthOk ( const char *  user,
const char *  pass,
const char *  b64 
)
static

References vlc_b64_decode().

Referenced by httpdLoop().

◆ httpdLoop()

static void httpdLoop ( httpd_host_t host)
static

References httpd_client_t::answer, httpd_client_t::b_stream_mode, httpd_url_t::catch, httpd_url_t::cb, pollfd::events, pollfd::fd, HTTPD_CLIENT_DEAD, HTTPD_CLIENT_RECEIVE_DONE, HTTPD_CLIENT_RECEIVING, HTTPD_CLIENT_SEND_DONE, HTTPD_CLIENT_SENDING, HTTPD_CLIENT_TLS_HS_IN, HTTPD_CLIENT_TLS_HS_OUT, HTTPD_CLIENT_WAITING, httpd_ClientDestroy(), httpd_ClientNew(), httpd_ClientRecv(), httpd_ClientSend(), httpd_ClientTlsHandshake(), httpd_HtmlError(), HTTPD_MSG_ANSWER, HTTPD_MSG_NONE, HTTPD_MSG_OPTIONS, httpd_MsgAdd(), httpd_MsgClean(), httpd_MsgGet(), httpd_MsgInit(), HTTPD_PROTO_HTTP, HTTPD_PROTO_NONE, HTTPD_PROTO_RTSP, httpdAuthOk(), httpd_client_t::i_activity_date, httpd_client_t::i_activity_timeout, httpd_message_t::i_body, httpd_message_t::i_body_offset, httpd_client_t::i_buffer, httpd_client_t::i_buffer_size, httpd_host_t::i_client, httpd_message_t::i_proto, httpd_client_t::i_ref, httpd_client_t::i_state, httpd_message_t::i_status, httpd_message_t::i_type, httpd_message_t::i_version, mdate(), msg_Err, mutex_cleanup_push, httpd_host_t::nfd, p, httpd_message_t::p_body, httpd_client_t::p_buffer, httpd_url_t::p_sys, poll(), POLLIN, POLLOUT, httpd_url_t::psz_password, httpd_message_t::psz_url, httpd_url_t::psz_url, httpd_url_t::psz_user, httpd_client_t::query, pollfd::revents, httpd_client_t::sock, strcasecmp(), TAB_APPEND, TAB_REMOVE, unlikely, httpd_host_t::url, httpd_client_t::url, vlc_accept(), vlc_cleanup_pop, vlc_close(), vlc_cond_wait(), vlc_mutex_lock(), vlc_mutex_unlock(), vlc_restorecancel(), vlc_savecancel(), vlc_strerror_c(), vlc_tls_GetFD(), vlc_tls_ServerSessionCreate(), vlc_tls_SessionDelete(), vlc_tls_SocketOpen(), and xmalloc().

Referenced by httpd_HostThread().

◆ vlc_http_HostNew()

httpd_host_t* vlc_http_HostNew ( vlc_object_t p_this)

References httpd_HostCreate().

◆ vlc_https_HostNew()

httpd_host_t* vlc_https_HostNew ( vlc_object_t obj)

◆ vlc_rtsp_HostNew()

httpd_host_t* vlc_rtsp_HostNew ( vlc_object_t p_this)

References httpd_HostCreate().

Variable Documentation

◆ httpd

struct httpd httpd = { PTHREAD_MUTEX_INITIALIZER , NULL, 0 }
static

◆ i_proto

int i_proto

◆ i_type

int i_type

◆ msg_type

const { ... } msg_type[]
Initial value:
=
{
{ "DESCRIBE", HTTPD_MSG_DESCRIBE, HTTPD_PROTO_RTSP },
{ "SETUP", HTTPD_MSG_SETUP, HTTPD_PROTO_RTSP },
{ "PLAY", HTTPD_MSG_PLAY, HTTPD_PROTO_RTSP },
{ "PAUSE", HTTPD_MSG_PAUSE, HTTPD_PROTO_RTSP },
{ "GET_PARAMETER", HTTPD_MSG_GETPARAMETER, HTTPD_PROTO_RTSP },
{ "TEARDOWN", HTTPD_MSG_TEARDOWN, HTTPD_PROTO_RTSP },
{ "HEAD", HTTPD_MSG_HEAD, HTTPD_PROTO_HTTP },
{ "POST", HTTPD_MSG_POST, HTTPD_PROTO_HTTP },
}
Definition: vlc_httpd.h:49
Definition: vlc_httpd.h:43
Definition: vlc_httpd.h:46
Definition: vlc_httpd.h:50
Definition: vlc_httpd.h:48
Definition: vlc_httpd.h:42
Definition: vlc_httpd.h:60
Definition: vlc_httpd.h:35
Definition: vlc_httpd.h:62
Definition: vlc_httpd.h:41
Definition: vlc_httpd.h:51
Definition: vlc_httpd.h:47
Definition: vlc_httpd.h:52
Definition: vlc_httpd.h:61

Referenced by httpd_ClientRecv(), and vlc_Log().

◆ name

const char name[16]