UPNP API
卫嘉佑
2023-12-01
/*
if '0' is used as the port number in UpnpInit, then this function can be used to retrieve the actual port allocated to the SDK.
*/
unsigned short UpnpGetServerPort(void);
char * UpnpGetServerIpAddress(void);
int UpnpRegisterClient(
Upnp_FunPtr Callback,
const void *Cookie,
UpnpClient_Handle *Hnd
);
int UpnpRegisterRootDevice(
const char *DescUrl,
Upnp_FunPtr Callback,
const void *Cookie,
UpnpDevice_Handle *Hnd
);
int UpnpRegisterRootDevice2(
Upnp_DescType descriptionType,
const char* description,
size_t bufferLen,
int config_baseURL,
Upnp_FunPtr Fun,
const void * Cookie,
UpnpDevice_Handle* Hnd
);
int UpnpUnRegisterClient(
UpnpClient_Handle Hnd
);
int UpnpUnRegisterRootDevice(
UpnpDevice_Handle
);
int UpnpSetContentLength(
UpnpClient_Handle Hnd,
int contentLength
);
int UpnpSetMaxContentLength(
size_t contentLength
);
=====================
= =
= Discover =
= =
=====================
int UpnpSearchAsync(
UpnpClient_Handle Hnd,
int Mx,
const char *Target,
const void Cookie
);
int UpnpSendAdvertisement(
UpnpDevice_Handle Hnd,
int Exp
);
=============================
= =
= Control =
= =
=============================
int UpnpGetServiceVarStatus(
UpnpClient_Handle Hnd,
cont char *ActionURL,
cont char *VarName,
DOMString *StVarVal
);
int UpnpGetServiceVarStatusAsync(
UpnpClient_Handle Hnd,
cont char* ActionURL,
const VarName,
Upnp_FunPtr Fun,
const void *Cookie
);
int UpnpSendAction(
UpnpClient_Handle Hnd,
const char *ActionURL,
const char *ServiceType,
const char *DevUDN,
IXML_Document *Action,
IXML_Document **RespNode
);
int UpnpSendActionEx(
UpnpClent_Handle Hnd,
const char *ActionURL,
const char *ServiceType,
const char *DevUDN,
IXML_Document *Header,
IXML_Document *Action,
IXML_Document **RespNode
);
int UpnpSendActionAsync(
UpnpClient_Handle Hnd,
const char *ActionURL,
const char *ServiceType,
const char *DevUDN,
IXML_Document *Action,
Upnp_FunPtr Fun,
const void *Cookie
);
int UpnpSendActionExAsync(
UpnpClient_Handle Hnd,
const char* ActionURL,
const char* ServiceType,
const char* DevUDN,
IXML_Document *Header,
IXML_Document *Action,
Upnp_FunPtr Fun,
const void* Cookie
);
=================================
= =
= EVENTING =
= =
=================================
int UpnpAcceptSubscription(
UpnpDevice_Handle Hnd,
const char *DevID,
const char *ServID,
const char **VarName,
const char **NewVal,
int cVariables,
Upnp_SID SubsId
);
int UpnpAcceptSubscriptionExt(
UpnpDevice_Handle Hnd,
const char *DevID,
const char *SerID,
IXML_Document *PropSet,
Upnp_SID SubsId
);
int UpnpNotify(
UpnpDevice_Handle,
const char* DevID,
const char* SerID,
const char** VarName,
const char** NewVal,
int cVariables
);
int UpnpNotifyExt(
UpnpDevice_Handle,
const char* DevID,
const char* ServID,
IXML_Document *PropSet
);
int UpnpRenewSubscription(
UpnpClient_Handle Hnd,
int *TimeOut,
Upnp_SID SubsId
);
int UpnpRenewSubscriptionAsync(
UpnpClient_Handle Hnd,
int TimeOut,
Upnp_SID SubsId,
Upnp_FunPtr Fun,
const void *Cookie
);
int UpnpSetMaxSubscriptions(
UpnpDevice_Handle Hnd,
int MaxSubscriptions
);
int UpnpSetMaxSubscriptionTimeOut(
UpnpDevice_Handle Hnd,
int MaxSubscriptionTimeOut
);
int UpnpSubscribe(
UpnpClient_Handle Hnd,
const char* PublisherUrl,
int *TimeOut,
Upnp_SID SubsId
);
int UpnpSubscribeAsync(
UpnpClient_Handle Hnd,
const char* PublisherUrl,
int TimeOut,
Upnp_FunPtr Fun,
const void *Cookie
);
int UpnpUnSubscribe(
UpnpClient_Handle Hnd,
Upnp_SID SubsId
);
int UpnpUnSubscribeAsync(
UpnpClient_Handle Hnd,
Upnp_SID SubsId,
Upnp_FunPtr Fun,
const void *Cookie
);
=================================
= =
= Client =
= =
=================================
int UpnpDownloadUrlItem(
const char* url,
char **outBuf,
char *contentType
);
int UpnpOpenHttpGet(
const char* url,
void **handle,
char **contentType,
int *contentLength,
int *httpStatus,
int *timeout
);
int UpnpOpenHttpGetEx(
const char* url,
void **handle,
char **contentType,
int *contentLength,
int *lowRange,
int *highRange,
int *timeout
);
int UpnpReadHttpGet(
void *handle,
char *buf,
unsigned int *size,
int timeout
);
int UpnpCloseHttpGet(void *handle);
int UpnpOpenHttpPost(
const char *url,
void **handle,
const char* contentType,
int contentLength,
int timeout
);
int UpnpWriteHttpPost(
void *handle,
char *buf,
unsigned int *size,
int timeout
);
int UpnpCloseHttpPost(
void *handle,
int *httpStatus,
int timeout
);
int UpnpDownloadXmlDoc(
const char *url,
IXML_Document **xmlDoc
);
=================================
= =
= Web Server api =
= =
=================================
int UpnpSetWebServerRootDir(
const char* rootDir
);
int UpnpSetVirtualDirCallbacks(
struct UpnpVirtualDirCallback* callbacks
);
int UpnpEnableWebserver(int enable);
int UpnpIsWebserverEnabled();
int UpnpAddVirtualDir(const char* dirname);
int UpnpRemoveVirtualDir(const char* dirName);
void UpnpRemoveAllVirtualDirs();
void UpnpFree(void *item);
=================================
= =
= UPNP TOOL =
= =
=================================
int UpnpResolveURL(
const char* BaseURL,
const char* RelURL,
char *AbsURL
);
IXML_Document* UpnpMakeAction(
const char* ActionName,
const char* ServType,
int NumArg,
const char* Arg,
...
);
int UpnpAddToAction(
IXML_Document **ActionDoc,
const char * ActionName,
const char *ServType,
const char *ArgName,
const char *ArgVal
);
IXML_Document *UpnpMakeActionResponse(
const char* ActionName,
const char* ServType,
int NumArg,
const
);
int UpnpAddToActionResponse(
IXML_Document **ActonResponse,
const char *ActionName,
const char *ServType,
const char *ArgName,
cosnt char *ArgVal
);
int UpnpAddToPropertySet(
IXML_Document **PropSet,
const char *ArgName,
const char *ArgVal
);
IXML_Document *UpnpCreatePropertySet(
int NumArg,
const char* Arg,
...
);
const char* UpnpGetErrorMessage(int errorcodes);