## EXPORT_SPEC int UpnpRegisterRootDevice2

## ( IN Upnp_DescType descriptionType,
IN const char* description,
IN size_t bufferLen,
IN int config_baseURL,
IN Upnp_FunPtr Fun,
IN const void* Cookie,
OUT UpnpDevice_Handle* Hnd )

> UpnpRegisterRootDevice2 is similar to UpnpRegisterRootDevice, except that it also allows the description document to be specified as a file or a memory buffer.

## Documentation

> UpnpRegisterRootDevice2 is similar to UpnpRegisterRootDevice, except that it also allows the description document to be specified as a file or a memory buffer. The description can also be configured to have the correct IP and port address.

> NOTE: For the configuration to be functional, the internal web server MUST be present. In addition, the web server MUST be activated (using UpnpSetWebServerRootDir) before calling this function. The only condition where the web server can be absent is if the description document is specified as a URL and no configuration is required (i.e. `config_baseURL = 0`.)

> UpnpRegisterRootDevice2 is synchronous and does not generate any callbacks. Callbacks can occur as soon as this function returns.

> Examples of using different types of description documents:

>         1) Description specified as a URL:
>               descriptionType == UPNPREG_URL_DESC
>               description is the URL
>               bufferLen = 0 (ignored)
>         2) Description specified as a file:
>               descriptionType == UPNPREG_FILENAME_DESC
>               description is a filename
>               bufferLen = 0 (ignored)
>         3) Description specified as a memory buffer:
>               descriptionType == UPNPREG_BUF_DESC
>               description is pointer to a memory buffer
>               bufferLen == length of memory buffer

Parameters:
  descriptionType - The type of the description document.
  description - Treated as a URL, file name or memory buffer depending on description type.
  bufferLen - The length of memory buffer if passing a description in a buffer, otherwise it is ignored.
  config_baseURL - If nonzero, `URLBase` of description document is configured and the description is served using the internal web server.
  Fun - Pointer to the callback function for receiving asynchronous events.
  Cookie - Pointer to user data returned with the callback function when invoked.
  Hnd - Pointer to a variable to store the new device handle.
Returns:
  [int] An integer representing one of the following:
  - `UPNP_E_SUCCESS`: The operation completed successfully.
  - `UPNP_E_FINISH`: The SDK is already terminated or is not initialized.
  - `UPNP_E_INVALID_DESC`: The description document is not a valid device description.
  - `UPNP_E_INVALID_PARAM`: Either Callback or Hnd is not a valid pointer or DescURL is `NULL`.
  - `UPNP_E_NETWORK_ERROR`: A network error occurred.
  - `UPNP_E_SOCKET_WRITE`: An error or timeout occurred writing to a socket.
  - `UPNP_E_SOCKET_READ`: An error or timeout occurred reading from a socket.
  - `UPNP_E_SOCKET_BIND`: An error occurred binding a socket.
  - `UPNP_E_SOCKET_CONNECT`: An error occurred connecting the socket.
  - `UPNP_E_OUTOF_SOCKET`: Too many sockets are currently allocated.
  - `UPNP_E_OUTOF_MEMORY`: There are insufficient resources to register this root device.
  - `UPNP_E_URL_TOO_BIG`: Length of the URL is bigger than the internal buffer.
  - `UPNP_E_FILE_NOT_FOUND`: The description file could not be found.
  - `UPNP_E_FILE_READ_ERROR`: An error occurred reading the description file.
  - `UPNP_E_INVALID_URL`: The URL to the description document is invalid.
  - `UPNP_E_EXT_NOT_XML`: The URL to the description document or file should have a `.xml` extension.
  - `UPNP_E_NO_WEB_SERVER`: The internal web server has been compiled out; the SDK cannot configure itself from the description document.

Alphabetic index

This page was generated with the help of DOC++.