UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
Web Server API
typedef void * UpnpWebFileHandle
 The type of handle returned by the web server for open requests.
 
typedef int(* VDCallback_GetInfo) (const char *filename, UpnpFileInfo *info, const void *cookie, const void **request_cookie)
 Get-info callback function prototype.
 
typedef UpnpWebFileHandle(* VDCallback_Open) (const char *filename, enum UpnpOpenFileMode Mode, const void *cookie, const void *request_cookie)
 Open callback function prototype.
 
typedef int(* VDCallback_Read) (UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie, const void *request_cookie)
 Read callback function prototype.
 
typedef int(* VDCallback_Write) (UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie, const void *request_cookie)
 Write callback function prototype.
 
typedef int(* VDCallback_Seek) (UpnpWebFileHandle fileHnd, off_t offset, int origin, const void *cookie, const void *request_cookie)
 Seek callback function prototype.
 
typedef int(* VDCallback_Close) (UpnpWebFileHandle fileHnd, const void *cookie, const void *request_cookie)
 Close callback function prototype.
 
typedef int(* WebCallback_HostValidate) (const char *hostname, void *cookie)
 Callback for validating HTTP requests HOST header values.
 
PUPNP_Api int UpnpSetWebServerRootDir (const char *rootDir)
 Sets the document root directory for the internal web server.
 
PUPNP_Api int UpnpVirtualDir_set_GetInfoCallback (VDCallback_GetInfo callback)
 Sets the get_info callback function to be used to access a web directory.
 
PUPNP_Api int UpnpVirtualDir_set_OpenCallback (VDCallback_Open callback)
 Sets the open callback function to be used to access a web directory.
 
PUPNP_Api int UpnpVirtualDir_set_ReadCallback (VDCallback_Read callback)
 Sets the read callback function to be used to access a web directory.
 
PUPNP_Api int UpnpVirtualDir_set_WriteCallback (VDCallback_Write callback)
 Sets the write callback function to be used to access a web directory.
 
PUPNP_Api int UpnpVirtualDir_set_SeekCallback (VDCallback_Seek callback)
 Sets the seek callback function to be used to access a web directory.
 
PUPNP_Api int UpnpVirtualDir_set_CloseCallback (VDCallback_Close callback)
 Sets the close callback function to be used to access a web directory.
 
PUPNP_Api int UpnpEnableWebserver (int enable)
 Enables or disables the webserver.
 
PUPNP_Api int UpnpIsWebserverEnabled (void)
 Returns the status of the webserver.
 
PUPNP_Api void UpnpSetHostValidateCallback (WebCallback_HostValidate callback, void *cookie)
 Set callback for validating HTTP requests HOST header values.
 
PUPNP_Api void UpnpSetAllowLiteralHostRedirection (int enable)
 Enable or disable literal IP redirection.
 
PUPNP_Api int UpnpSetWebServerCorsString (const char *corsString)
 Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameter to the global CORS string.
 
PUPNP_Api int UpnpAddVirtualDir (const char *newDirName, const void *cookie, const void **oldcookie)
 Adds a web directory mapping.
 
PUPNP_Api int UpnpRemoveVirtualDir (const char *dirName)
 Removes a web directory mapping made with UpnpAddVirtualDir().
 
PUPNP_Api void UpnpRemoveAllVirtualDirs (void)
 Removes all web directory mappings.
 

Detailed Description

Typedef Documentation

◆ UpnpWebFileHandle

typedef void* UpnpWebFileHandle

The type of handle returned by the web server for open requests.

Definition at line 2587 of file API.hpp.

◆ VDCallback_GetInfo

typedef int(* VDCallback_GetInfo) ( const char *filename, UpnpFileInfo *info, const void *cookie, const void **request_cookie)

Get-info callback function prototype.

Parameters
[in]filenameThe name of the file to query.
[out]infoPointer to a structure to store the information on the file.
[in]cookieThe cookie associated with this web directory
[out]request_cookieThe cookie associated with this request

Definition at line 2592 of file API.hpp.

◆ VDCallback_Open

typedef UpnpWebFileHandle(* VDCallback_Open) ( const char *filename, enum UpnpOpenFileMode Mode, const void *cookie, const void *request_cookie)

Open callback function prototype.

Parameters
[in]filenameThe name of the file to open.
[in]ModeThe mode in which to open the file. Valid values are UPNP_READ or UPNP_WRITE.
[in]cookieThe cookie associated with this web directory
[in]request_cookieThe cookie associated with this request

Definition at line 2638 of file API.hpp.

◆ VDCallback_Read

typedef int(* VDCallback_Read) ( UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie, const void *request_cookie)

Read callback function prototype.

Parameters
[in]fileHndThe handle of the file to read.
[out]bufThe buffer in which to place the data.
[in]buflenThe size of the buffer (i.e. the number of bytes to read).
[in]cookieThe cookie associated with this web directory
[in]request_cookieThe cookie associated with this request

Definition at line 2663 of file API.hpp.

◆ VDCallback_Write

typedef int(* VDCallback_Write) ( UpnpWebFileHandle fileHnd, char *buf, size_t buflen, const void *cookie, const void *request_cookie)

Write callback function prototype.

Parameters
[in]fileHndThe handle of the file to write.
[in]bufThe buffer with the bytes to write.
[in]buflenThe number of bytes to write.
[in]cookieThe cookie associated with this web directory
[in]request_cookieThe cookie associated with this request

Definition at line 2689 of file API.hpp.

◆ VDCallback_Seek

typedef int(* VDCallback_Seek) ( UpnpWebFileHandle fileHnd, off_t offset, int origin, const void *cookie, const void *request_cookie)

Seek callback function prototype.

Parameters
[in]fileHndThe handle of the file to move the file pointer.
[in]offsetThe number of bytes to move in the file. Positive values move foward and negative values move backward. Note that this must be positive if the origin is SEEK_SET.
[in]originThe position to move relative to. It can be SEEK_CUR to move relative to the current position, SEEK_END to move relative to the end of the file, or SEEK_SET to specify an absolute offset.
[in]cookieThe cookie associated with this web directory
[in]request_cookieThe cookie associated with this request

Definition at line 2715 of file API.hpp.

◆ VDCallback_Close

typedef int(* VDCallback_Close) ( UpnpWebFileHandle fileHnd, const void *cookie, const void *request_cookie)

Close callback function prototype.

Parameters
[in]fileHndThe handle of the file to close.
[in]cookieThe cookie associated with this web directory
[in]request_cookieThe cookie associated with this request

Definition at line 2746 of file API.hpp.

◆ WebCallback_HostValidate

typedef int(* WebCallback_HostValidate) (const char *hostname, void *cookie)

Callback for validating HTTP requests HOST header values.

Parameters
hostnamethe value in the request HOST header.
cookiePointer to user data to pass to the callback function when invoked.
Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: a request with the HOST header set to hostname should be processed.
  • UPNP_E_BAD_HTTPMSG the request should be rejected.

Definition at line 2800 of file API.hpp.

Function Documentation

◆ UpnpSetWebServerRootDir()

PUPNP_Api int UpnpSetWebServerRootDir ( const char *  rootDir)

Sets the document root directory for the internal web server.

This directory is considered the root directory (i.e. "/") of the web server.

The function is independent of whether the web server is enabled or disabled. To select the root directory '/' of the filesystem on the local storage to be also the websites virtual root directory then use UpnpSetWebServerRootDir("//").

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_FINISH: The library has not been initialized.
  • UPNP_E_INVALID_PARAM: rootDir argument is not valid.
  • UPNP_E_OUTOF_MEMORY: Resource for storing string not available.
Parameters
[in]rootDirPath on the filesystem of the local storage to be the root directory of the web server.

Definition at line 3398 of file upnpapi.cpp.

+ Here is the call graph for this function:

◆ UpnpVirtualDir_set_GetInfoCallback()

PUPNP_Api int UpnpVirtualDir_set_GetInfoCallback ( VDCallback_GetInfo  callback)

Sets the get_info callback function to be used to access a web directory.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: callback is not a valid pointer.
  • UPNP_E_INVALID_ARGUMENT: callback is not a valid pointer.

Definition at line 3599 of file upnpapi.cpp.

◆ UpnpVirtualDir_set_OpenCallback()

PUPNP_Api int UpnpVirtualDir_set_OpenCallback ( VDCallback_Open  callback)

Sets the open callback function to be used to access a web directory.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: callback is not a valid pointer.
  • UPNP_E_INVALID_ARGUMENT: callback is not a valid pointer.

Definition at line 3610 of file upnpapi.cpp.

◆ UpnpVirtualDir_set_ReadCallback()

PUPNP_Api int UpnpVirtualDir_set_ReadCallback ( VDCallback_Read  callback)

Sets the read callback function to be used to access a web directory.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: callback is not a valid pointer.
  • UPNP_E_INVALID_ARGUMENT: callback is not a valid pointer.

Definition at line 3621 of file upnpapi.cpp.

◆ UpnpVirtualDir_set_WriteCallback()

PUPNP_Api int UpnpVirtualDir_set_WriteCallback ( VDCallback_Write  callback)

Sets the write callback function to be used to access a web directory.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: callback is not a valid pointer.
  • UPNP_E_INVALID_ARGUMENT: callback is not a valid pointer.

Definition at line 3632 of file upnpapi.cpp.

◆ UpnpVirtualDir_set_SeekCallback()

PUPNP_Api int UpnpVirtualDir_set_SeekCallback ( VDCallback_Seek  callback)

Sets the seek callback function to be used to access a web directory.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: callback is not a valid pointer.
  • UPNP_E_INVALID_ARGUMENT: callback is not a valid pointer.

Definition at line 3643 of file upnpapi.cpp.

◆ UpnpVirtualDir_set_CloseCallback()

PUPNP_Api int UpnpVirtualDir_set_CloseCallback ( VDCallback_Close  callback)

Sets the close callback function to be used to access a web directory.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: callback is not a valid pointer.
  • UPNP_E_INVALID_ARGUMENT: callback is not a valid pointer.

Definition at line 3654 of file upnpapi.cpp.

◆ UpnpEnableWebserver()

PUPNP_Api int UpnpEnableWebserver ( int  enable)

Enables or disables the webserver.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_FINISH: The library has not been initialized.
  • UPNP_E_OUTOF_MEMORY: The web server could not be started due to an out-of-memory condition.
  • UPNP_E_NO_WEB_SERVER: The internal web server has been compiled out so it can't be enabled or disabled.
Parameters
[in]enable1 to enable, 0 to disable.

Definition at line 3565 of file upnpapi.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpnpIsWebserverEnabled()

PUPNP_Api int UpnpIsWebserverEnabled ( void  )

Returns the status of the webserver.

Returns
An integer representing one of the following:
  • 1: The webserver is enabled.
  • 0: The webserver is not enabled.

Definition at line 3581 of file upnpapi.cpp.

◆ UpnpSetHostValidateCallback()

PUPNP_Api void UpnpSetHostValidateCallback ( WebCallback_HostValidate  callback,
void *  cookie 
)

Set callback for validating HTTP requests HOST header values.

Parameters
callbackthe host validating callback function or NULL.
cookiethe chocolate you like.

Definition at line 3589 of file upnpapi.cpp.

◆ UpnpSetAllowLiteralHostRedirection()

PUPNP_Api void UpnpSetAllowLiteralHostRedirection ( int  enable)

Enable or disable literal IP redirection.

Parameters
enableZero to disable (default) non-zero to enable.

Definition at line 3595 of file upnpapi.cpp.

◆ UpnpSetWebServerCorsString()

PUPNP_Api int UpnpSetWebServerCorsString ( const char *  corsString)

Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameter to the global CORS string.

Note
This function is not available when the web server is not compiled into the UPnP Library.
Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_ARGUMENT: rootDir is an invalid directory.
Parameters
[in]corsStringString having the Access-Control-Allow-Origin string.

Definition at line 3411 of file upnpapi.cpp.

+ Here is the call graph for this function:

◆ UpnpAddVirtualDir()

PUPNP_Api int UpnpAddVirtualDir ( const char *  newDirName,
const void *  cookie,
const void **  oldcookie 
)

Adds a web directory mapping.

All webserver requests containing the given directory are read using functions contained in a VirtualDirCallbacks structure registered via UpnpSetVirtualDirCallbacks().

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_FINISH: The library has not been initialized.
  • UPNP_E_INVALID_ARGUMENT: dirName is not valid.
Parameters
[in]newDirNameThe name of the new directory mapping to add.
[in]cookieThe cookie to associated with this web directory
[out]oldcookieThe cookie previously associated, if mapping is already present

Definition at line 3424 of file upnpapi.cpp.

◆ UpnpRemoveVirtualDir()

PUPNP_Api int UpnpRemoveVirtualDir ( const char *  dirName)

Removes a web directory mapping made with UpnpAddVirtualDir().

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_FINISH: The library has not been initialized.
  • UPNP_E_INVALID_ARGUMENT: dirName is not valid.
Parameters
[in]dirNameThe name of the web directory mapping to remove.

Definition at line 3499 of file upnpapi.cpp.

◆ UpnpRemoveAllVirtualDirs()

PUPNP_Api void UpnpRemoveAllVirtualDirs ( void  )

Removes all web directory mappings.

Definition at line 3545 of file upnpapi.cpp.

+ Here is the caller graph for this function: