📄 upnp.h
字号:
UPNPREG_FILENAME_DESC,
/** The description is a pointer to a character array containing
the XML description document. */
UPNPREG_BUF_DESC
};
typedef enum Upnp_DescType_e Upnp_DescType;
/** Returned as part of a {\bf UPNP_CONTROL_ACTION_COMPLETE} callback. */
struct Upnp_Action_Request
{
/** The result of the operation. */
int ErrCode;
/** The socket number of the connection to the requestor. */
int Socket;
/** The error string in case of error. */
char ErrStr[LINE_SIZE];
/** The Action Name. */
char ActionName[UPNP_NAME_SIZE];
/** The unique device ID. */
char DevUDN[UPNP_NAME_SIZE];
/** The service ID. */
char ServiceID[UPNP_NAME_SIZE];
/** The DOM document describing the action. */
IXML_Document *ActionRequest;
/** The DOM document describing the result of the action. */
IXML_Document *ActionResult;
/** IP address of the control point requesting this action. */
struct in_addr CtrlPtIPAddr;
/** The DOM document containing the information from the
the SOAP header. */
IXML_Document *SoapHeader;
};
struct Upnp_Action_Complete
{
/** The result of the operation. */
int ErrCode;
/** The control URL for service. */
char CtrlUrl[UPNP_NAME_SIZE];
/** The DOM document describing the action. */
IXML_Document *ActionRequest;
/** The DOM document describing the result of the action. */
IXML_Document *ActionResult;
};
/** Represents the request for current value of a state variable in a service
* state table. */
struct Upnp_State_Var_Request
{
/** The result of the operation. */
int ErrCode;
/** The socket number of the connection to the requestor. */
int Socket;
/** The error string in case of error. */
char ErrStr[LINE_SIZE];
/** The unique device ID. */
char DevUDN[UPNP_NAME_SIZE];
/** The service ID. */
char ServiceID[UPNP_NAME_SIZE];
/** The name of the variable. */
char StateVarName[UPNP_NAME_SIZE];
/** IP address of sender requesting the state variable. */
struct in_addr CtrlPtIPAddr;
/** The current value of the variable. This needs to be allocated by
* the caller. When finished with it, the SDK frees this {\bf DOMString}. */
DOMString CurrentVal;
};
/** Represents the reply for the current value of a state variable in an
asynchronous call. */
struct Upnp_State_Var_Complete
{
/** The result of the operation. */
int ErrCode;
/** The control URL for the service. */
char CtrlUrl[UPNP_NAME_SIZE];
/** The name of the variable. */
char StateVarName[UPNP_NAME_SIZE];
/** The current value of the variable or error string in case of error. */
DOMString CurrentVal;
};
/** Returned along with a {\bf UPNP_EVENT_RECEIVED} callback. */
struct Upnp_Event
{
/** The subscription ID for this subscription. */
Upnp_SID Sid;
/** The event sequence number. */
int EventKey;
/** The DOM tree representing the changes generating the event. */
IXML_Document *ChangedVariables;
};
// MULTICAST!!!
struct Upnp_BroadcastEvent
{
// notification type (deviceID)
Upnp_NotId NotificationType;
// notification subtype (serviceID)
Upnp_NotId NotificationSubtype;
/** The DOM tree representing the changes generating the event. */
IXML_Document *ChangedVariables;
};
//
// This typedef is required by Doc++ to parse the last entry of the
// Upnp_Discovery structure correctly.
//
typedef struct sockaddr_in SOCKADDRIN;
/** Returned in a {\bf UPNP_DISCOVERY_RESULT} callback. */
struct Upnp_Discovery
{
/** The result code of the {\bf UpnpSearchAsync} call. */
int ErrCode;
/** The expiration time of the advertisement. */
int Expires;
/** The unique device identifier. */
char DeviceId[LINE_SIZE];
/** The device type. */
char DeviceType[LINE_SIZE];
/** The service type. */
char ServiceType[LINE_SIZE];
/** The service version. */
char ServiceVer[LINE_SIZE];
/** The URL to the UPnP description document for the device. */
char Location[LINE_SIZE];
/** The operating system the device is running. */
char Os[LINE_SIZE];
/** Date when the response was generated. */
char Date[LINE_SIZE];
/** Confirmation that the MAN header was understood by the device. */
char Ext[LINE_SIZE];
/** The host address of the device responding to the search. */
SOCKADDRIN * DestAddr;
};
/** Returned along with a {\bf UPNP_EVENT_SUBSCRIBE_COMPLETE} or {\bf
* UPNP_EVENT_UNSUBSCRIBE_COMPLETE} callback. */
struct Upnp_Event_Subscribe {
/** The SID for this subscription. For subscriptions, this only
* contains a valid SID if the {\bf Upnp_EventSubscribe.result} field
* contains a {\tt UPNP_E_SUCCESS} result code. For unsubscriptions,
* this contains the SID from which the subscription is being
* unsubscribed. */
Upnp_SID Sid;
/** The result of the operation. */
int ErrCode;
/** The event URL being subscribed to or removed from. */
char PublisherUrl[UPNP_NAME_SIZE];
/** The actual subscription time (for subscriptions only). */
int TimeOut;
};
/** Returned along with a {\bf UPNP_EVENT_SUBSCRIPTION_REQUEST}
* callback. */
struct Upnp_Subscription_Request
{
/** The identifier for the service being subscribed to. */
char *ServiceId;
/** Universal device name. */
char *UDN;
/** The assigned subscription ID for this subscription. */
Upnp_SID Sid;
};
struct File_Info
{
/** The length of the file. A length less than 0 indicates the size
* is unknown, and data will be sent until 0 bytes are returned from
* a read call. */
int file_length;
/** The time at which the contents of the file was modified;
* The time system is always local (not GMT). */
time_t last_modified;
/** If the file is a directory, {\bf is_directory} contains
* a non-zero value. For a regular file, it should be 0. */
int is_directory;
/** If the file or directory is readable, this contains
* a non-zero value. If unreadable, it should be set to 0. */
int is_readable;
/** The content type of the file. This string needs to be allocated
* by the caller using {\bf ixmlCloneDOMString}. When finished
* with it, the SDK frees the {\bf DOMString}. */
DOMString content_type;
};
/* The type of handle returned by the web server for open requests. */
typedef void *UpnpWebFileHandle;
/** The {\bf UpnpVirtualDirCallbacks} structure contains the pointers to
* file-related callback functions a device application can register to
* virtualize URLs.
*/
struct UpnpVirtualDirCallbacks
{
/** Called by the web server to query information on a file. The callback
* should return 0 on success or -1 on an error. */
int (*get_info) (
IN const char *filename, /** The name of the file to query. */
OUT struct File_Info *info /** Pointer to a structure to store the
information on the file. */
);
/** Called by the web server to open a file. The callback should return
* a valid handle if the file can be opened. Otherwise, it should return
* {\tt NULL} to signify an error. */
UpnpWebFileHandle (*open)(
IN const char *filename, /** The name of the file to open. */
IN enum UpnpOpenFileMode Mode /** The mode in which to open the file.
Valid values are {\tt UPNP_READ} or
{\tt UPNP_WRITE}. */
);
/** Called by the web server to perform a sequential read from an open
* file. The callback should copy {\bf buflen} bytes from the file into
* the buffer.
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt 0}: The file contains no more data (EOF).
* \item {\tt >0}: A successful read of the number of bytes in the
* return code.
* \item {\tt <0}: An error occurred reading the file.
* \end{itemzie}
*/
int (*read) (
IN UpnpWebFileHandle fileHnd, /** The handle of the file to read. */
OUT char *buf, /** The buffer in which to place the
data. */
IN size_t buflen /** The size of the buffer (i.e. the
number of bytes to read). */
);
/** Called by the web server to perform a sequential write to an open
* file. The callback should write {\bf buflen} bytes into the file from
* the buffer. It should return the actual number of bytes written,
* which might be less than {\bf buflen} in the case of a write error.
*/
int (*write) (
IN UpnpWebFileHandle fileHnd, /** The handle of the file to write. */
IN char *buf, /** The buffer with the bytes to write. */
IN size_t buflen /** The number of bytes to write. */
);
/** Called by the web server to move the file pointer, or offset, into
* an open file. The {\bf origin} parameter determines where to start
* moving the file pointer. A value of {\tt SEEK_CUR} moves the
* file pointer relative to where it is. The {\bf offset} parameter can
* be either positive (move forward) or negative (move backward).
* {\tt SEEK_END} moves relative to the end of the file. A positive
* {\bf offset} extends the file. A negative {\bf offset} moves backward
* in the file. Finally, {\tt SEEK_SET} moves to an absolute position in
* the file. In this case, {\bf offset} must be positive. The callback
* should return 0 on a successful seek or a non-zero value on an error.
*/
int (*seek) (
IN UpnpWebFileHandle fileHnd, /** The handle of the file to move the
file pointer. */
IN long offset, /** The number of bytes to move in the
file. Positive values move foward and
negative values move backward. Note
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -