upnp.h 112 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947
  1. #ifndef UPNP_H
  2. #define UPNP_H
  3. /*******************************************************************************
  4. *
  5. * Copyright (c) 2000-2003 Intel Corporation
  6. * All rights reserved.
  7. * Copyright (C) 2011-2012 France Telecom All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. *
  12. * * Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. * * Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * * Neither name of Intel Corporation nor the names of its contributors
  18. * may be used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  29. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************/
  34. /*!
  35. * \defgroup UPnPAPI UPnP API
  36. *
  37. * @{
  38. *
  39. * \file
  40. */
  41. #include "ixml.h"
  42. #include "upnpconfig.h"
  43. #include "UpnpGlobal.h"
  44. #include "UpnpInet.h"
  45. /*
  46. * \todo Document the exact reason of these include files and solve this
  47. * include mess in an include file like UpnpTime.h
  48. */
  49. #ifdef WIN32
  50. #include <time.h>
  51. #ifdef UPNP_USE_MSVCPP
  52. #include <sys/types.h> /* needed for off_t */
  53. #endif
  54. #elif (defined(BSD) && BSD >= 199306)
  55. #include <time.h>
  56. #else
  57. /* Other systems ??? */
  58. #endif
  59. #define LINE_SIZE (size_t)180
  60. #define NAME_SIZE (size_t)256
  61. #define MNFT_NAME_SIZE 64
  62. #define MODL_NAME_SIZE 32
  63. #define SERL_NUMR_SIZE 64
  64. #define MODL_DESC_SIZE 64
  65. #define UPNP_INFINITE -1
  66. #define UPNP_USING_CHUNKED -3
  67. #define UPNP_UNTIL_CLOSE -4
  68. /*!
  69. * \name Error codes
  70. *
  71. * The functions in the SDK API can return a variety of error
  72. * codes to describe problems encountered during execution. This section
  73. * lists the error codes and provides a brief description of what each error
  74. * code means. Refer to the documentation for each function for a
  75. * description of what an error code means in that context.
  76. *
  77. * @{
  78. */
  79. /*!
  80. * \brief The operation completed successfully.
  81. *
  82. * For asynchronous functions, this only means that the packet generated by
  83. * the operation was successfully transmitted on the network. The result of
  84. * the entire operation comes as part of the callback for that operation.
  85. */
  86. #define UPNP_E_SUCCESS 0
  87. /*!
  88. * \brief The handle passed to a function is not a recognized as a valid handle.
  89. */
  90. #define UPNP_E_INVALID_HANDLE -100
  91. /*!
  92. * \brief One or more of the parameters passed to the function is not valid.
  93. *
  94. * Refer to the documentation for each function for more information on the
  95. * valid ranges of the parameters.
  96. */
  97. #define UPNP_E_INVALID_PARAM -101
  98. /*!
  99. * \brief The SDK does not have any more space for additional handles.
  100. *
  101. * The SDK allocates space for only a few handles in order to conserve memory.
  102. */
  103. #define UPNP_E_OUTOF_HANDLE -102
  104. #define UPNP_E_OUTOF_CONTEXT -103
  105. /*!
  106. * \brief Not enough resources are currently available to complete the operation.
  107. *
  108. * Most operations require some free memory in order to complete their work.
  109. */
  110. #define UPNP_E_OUTOF_MEMORY -104
  111. /*!
  112. * \brief The SDK has already been initialized.
  113. *
  114. * The SDK needs to be initialied only once per process. Any additional
  115. * initialization attempts simply return this error with no other ill effects.
  116. */
  117. #define UPNP_E_INIT -105
  118. #define UPNP_E_BUFFER_TOO_SMALL -106
  119. /*!
  120. * \brief The description document passed to \b UpnpRegisterRootDevice,
  121. * \b UpnpRegisterRootDevice2 \b UpnpRegisterRootDevice3 or
  122. * \b UpnpRegisterRootDevice4 is invalid.
  123. */
  124. #define UPNP_E_INVALID_DESC -107
  125. /*!
  126. * \brief An URL passed into the function is invalid.
  127. *
  128. * The actual cause is function specific, but in general, the URL itself
  129. * might be malformed (e.g. have invalid characters in it) or the host might
  130. * be unreachable.
  131. */
  132. #define UPNP_E_INVALID_URL -108
  133. #define UPNP_E_INVALID_SID -109
  134. #define UPNP_E_INVALID_DEVICE -110
  135. /*!
  136. * \brief The device ID/service ID pair does not refer to a valid service.
  137. *
  138. * Returned only by \b UpnpNotify, \b UpnpNotifyExt, \b UpnpAcceptSubscription,
  139. * and \b UpnpAcceptSubscriptionExt.
  140. */
  141. #define UPNP_E_INVALID_SERVICE -111
  142. /*!
  143. * \brief The response received from the remote side of a connection is not correct
  144. * for the protocol.
  145. *
  146. * This applies to the GENA, SOAP, and HTTP protocols.
  147. */
  148. #define UPNP_E_BAD_RESPONSE -113
  149. #define UPNP_E_BAD_REQUEST -114
  150. /*!
  151. * \brief The SOAP action message is invalid.
  152. *
  153. * This can be because the DOM document passed to the function was malformed or
  154. * the action message is not correct for the given action.
  155. */
  156. #define UPNP_E_INVALID_ACTION -115
  157. /*!
  158. * \brief \b UpnpInit has not been called, or \b UpnpFinish has already been called.
  159. *
  160. * None of the API functions operate until \b UpnpInit successfully completes.
  161. */
  162. #define UPNP_E_FINISH -116
  163. /*!
  164. * \brief \b UpnpInit cannot complete.
  165. *
  166. * The typical reason is failure to allocate sufficient resources.
  167. */
  168. #define UPNP_E_INIT_FAILED -117
  169. /*!
  170. * \brief The URL passed into a function is too long.
  171. *
  172. * The SDK limits URLs to 180 characters in length.
  173. */
  174. #define UPNP_E_URL_TOO_BIG -118
  175. /*!
  176. * \brief The HTTP message contains invalid message headers.
  177. *
  178. * The error always refers to the HTTP message header received from the remote
  179. * host. The main areas where this occurs are in SOAP control messages (e.g.
  180. * \b UpnpSendAction), GENA subscription message (e.g. \b UpnpSubscribe),
  181. * GENA event notifications (e.g. \b UpnpNotify), and HTTP transfers (e.g.
  182. * \b UpnpDownloadXmlDoc).
  183. */
  184. #define UPNP_E_BAD_HTTPMSG -119
  185. /*!
  186. * \brief A client or a device is already registered.
  187. *
  188. * The SDK currently has a limit of one registered client and one registered
  189. * device per process.
  190. */
  191. #define UPNP_E_ALREADY_REGISTERED -120
  192. /*!
  193. * \brief The interface provided to \b UpnpInit2 is unknown or does not have a valid
  194. * IPv4 or IPv6 address configured.
  195. */
  196. #define UPNP_E_INVALID_INTERFACE -121
  197. /*!
  198. * \brief A network error occurred.
  199. *
  200. * It is the generic error code for network problems that are not covered under
  201. * one of the more specific error codes. The typical meaning is the SDK failed
  202. * to read the local IP address or had problems configuring one of the sockets.
  203. */
  204. #define UPNP_E_NETWORK_ERROR -200
  205. /*!
  206. * \brief An error happened while writing to a socket.
  207. *
  208. * This occurs in any function that makes network connections, such as discovery
  209. * (e.g. \b UpnpSearchAsync or \b UpnpSendAdvertisement), control (e.g.
  210. * \b UpnpSendAction), eventing (e.g. \b UpnpNotify), and HTTP functions (e.g.
  211. * \b UpnpDownloadXmlDoc).
  212. */
  213. #define UPNP_E_SOCKET_WRITE -201
  214. /*!
  215. * \brief An error happened while reading from a socket.
  216. *
  217. * This occurs in any function that makes network connections, such as discovery
  218. * (e.g. \b UpnpSearchAsync or \b UpnpSendAdvertisement), control (e.g.
  219. * \b UpnpSendAction), eventing (e.g. \b UpnpNotify), and HTTP functions (e.g.
  220. * \b UpnpDownloadXmlDoc).
  221. */
  222. #define UPNP_E_SOCKET_READ -202
  223. /*!
  224. * \brief The SDK had a problem binding a socket to a network interface.
  225. *
  226. * This occurs in any function that makes network connections, such as discovery
  227. * (e.g. \b UpnpSearchAsync or \b UpnpSendAdvertisement), control (e.g.
  228. * \b UpnpSendAction), eventing (e.g. \b UpnpNotify), and HTTP functions (e.g.
  229. * \b UpnpDownloadXmlDoc).
  230. */
  231. #define UPNP_E_SOCKET_BIND -203
  232. /*!
  233. * \brief The SDK had a problem connecting to a remote host.
  234. *
  235. * This occurs in any function that makes network connections, such as discovery
  236. * (e.g. \b UpnpSearchAsync or \b UpnpSendAdvertisement), control (e.g.
  237. * \b UpnpSendAction), eventing (e.g. \b UpnpNotify), and HTTP functions (e.g.
  238. * \b UpnpDownloadXmlDoc).
  239. */
  240. #define UPNP_E_SOCKET_CONNECT -204
  241. /*!
  242. * \brief The SDK cannot create any more sockets.
  243. *
  244. * This occurs in any function that makes network connections, such as discovery
  245. * (e.g. \b UpnpSearchAsync or \b UpnpSendAdvertisement), control (e.g.
  246. * \b UpnpSendAction), eventing (e.g. \b UpnpNotify), and HTTP functions (e.g.
  247. * \b UpnpDownloadXmlDoc).
  248. */
  249. #define UPNP_E_OUTOF_SOCKET -205
  250. /*!
  251. * \brief The SDK had a problem setting the socket to listen for incoming
  252. * connections.
  253. *
  254. * This error only happens during initialization (i.e. \b UpnpInit).
  255. */
  256. #define UPNP_E_LISTEN -206
  257. /*!
  258. * \brief Too much time elapsed before the required number of bytes were sent
  259. * or received over a socket.
  260. *
  261. * This error can be returned by any function that performs network operations.
  262. */
  263. #define UPNP_E_TIMEDOUT -207
  264. /*!
  265. * \brief Generic socket error code for conditions not covered by other error
  266. * codes.
  267. *
  268. * This error can be returned by any function that performs network operations.
  269. */
  270. #define UPNP_E_SOCKET_ERROR -208
  271. #define UPNP_E_FILE_WRITE_ERROR -209
  272. /*! \brief The operation was canceled.
  273. *
  274. * This error can be returned by any function that allows for external cancelation.
  275. */
  276. #define UPNP_E_CANCELED -210
  277. #define UPNP_E_EVENT_PROTOCOL -300
  278. /*!
  279. * \brief A subscription request was rejected from the remote side.
  280. */
  281. #define UPNP_E_SUBSCRIBE_UNACCEPTED -301
  282. /*!
  283. * \brief An unsubscribe request was rejected from the remote side.
  284. */
  285. #define UPNP_E_UNSUBSCRIBE_UNACCEPTED -302
  286. /*!
  287. * \brief The remote host did not accept the notify sent from the local device.
  288. */
  289. #define UPNP_E_NOTIFY_UNACCEPTED -303
  290. /*!
  291. * \brief One or more of the parameters passed to a function is invalid.
  292. *
  293. * Refer to the individual function descriptions for the acceptable ranges for
  294. * parameters.
  295. */
  296. #define UPNP_E_INVALID_ARGUMENT -501
  297. /*!
  298. * \brief The filename passed to one of the device registration functions was
  299. * not found or was not accessible.
  300. */
  301. #define UPNP_E_FILE_NOT_FOUND -502
  302. /*!
  303. * \brief An error happened while reading a file.
  304. */
  305. #define UPNP_E_FILE_READ_ERROR -503
  306. /*!
  307. * \brief The file name of the description document passed to
  308. * \b UpnpRegisterRootDevice2 does not end in ".xml".
  309. */
  310. #define UPNP_E_EXT_NOT_XML -504
  311. #define UPNP_E_NO_WEB_SERVER -505
  312. #define UPNP_E_OUTOF_BOUNDS -506
  313. /*!
  314. * \brief The response to a SOAP request did not contain the required XML
  315. * constructs.
  316. */
  317. #define UPNP_E_NOT_FOUND -507
  318. /*!
  319. * \brief Generic error code for internal conditions not covered by other
  320. * error codes.
  321. */
  322. #define UPNP_E_INTERNAL_ERROR -911
  323. /* SOAP-related error codes */
  324. #define UPNP_SOAP_E_INVALID_ACTION 401
  325. #define UPNP_SOAP_E_INVALID_ARGS 402
  326. #define UPNP_SOAP_E_OUT_OF_SYNC 403
  327. #define UPNP_SOAP_E_INVALID_VAR 404
  328. #define UPNP_SOAP_E_ACTION_FAILED 501
  329. /* @} ErrorCodes */
  330. /*!
  331. * \name Constants and Types
  332. *
  333. * @{
  334. */
  335. enum UpnpOpenFileMode
  336. {
  337. UPNP_READ,
  338. UPNP_WRITE
  339. };
  340. /*!
  341. * \brief Returned when a control point application registers with
  342. * \b UpnpRegisterClient.
  343. *
  344. * Client handles can only be used with functions that operate with a client
  345. * handle.
  346. */
  347. typedef int UpnpClient_Handle;
  348. /*!
  349. * \brief Returned when a device application registers with
  350. * \b UpnpRegisterRootDevice, \b UpnpRegisterRootDevice2,
  351. * \b UpnpRegisterRootDevice3 or \b UpnpRegisterRootDevice4.
  352. *
  353. * Device handles can only be used with functions that operate with a device
  354. * handle.
  355. */
  356. typedef int UpnpDevice_Handle;
  357. /*!
  358. * \brief The reason code for an event callback.
  359. *
  360. * The \b Event parameter will be different depending on the reason for the
  361. * callback. The descriptions for each event type describe the contents of the
  362. * \b Event parameter.
  363. */
  364. enum Upnp_EventType_e {
  365. /*
  366. * Control callbacks
  367. */
  368. /*! Received by a device when a control point issues a control
  369. * request. The \b Event parameter contains a pointer to a \b
  370. * UpnpActionRequest structure containing the action. The application
  371. * stores the results of the action in this structure. */
  372. UPNP_CONTROL_ACTION_REQUEST,
  373. /*! A \b UpnpSendActionAsync call completed. The \b Event
  374. * parameter contains a pointer to a \b UpnpActionComplete structure
  375. * with the results of the action. */
  376. UPNP_CONTROL_ACTION_COMPLETE,
  377. /*! Received by a device when a query for a single service variable
  378. * arrives. The \b Event parameter contains a pointer to a \b
  379. * UpnpStateVarRequest structure containing the name of the variable
  380. * and value. */
  381. UPNP_CONTROL_GET_VAR_REQUEST,
  382. /*! A \b UpnpGetServiceVarStatus call completed. The \b Event
  383. * parameter contains a pointer to a \b UpnpStateVarComplete structure
  384. * containing the value for the variable. */
  385. UPNP_CONTROL_GET_VAR_COMPLETE,
  386. /*
  387. * Discovery callbacks
  388. */
  389. /*! Received by a control point when a new device or service is available.
  390. * The \b Event parameter contains a pointer to a \b
  391. * UpnpDiscovery structure with the information about the device
  392. * or service. */
  393. UPNP_DISCOVERY_ADVERTISEMENT_ALIVE,
  394. /*! Received by a control point when a device or service shuts down. The \b
  395. * Event parameter contains a pointer to a \b UpnpDiscovery
  396. * structure containing the information about the device or
  397. * service. */
  398. UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE,
  399. /*! Received by a control point when a matching device or service responds.
  400. * The \b Event parameter contains a pointer to a \b
  401. * UpnpDiscovery structure containing the information about
  402. * the reply to the search request. */
  403. UPNP_DISCOVERY_SEARCH_RESULT,
  404. /*! Received by a control point when the search timeout expires. The
  405. * SDK generates no more callbacks for this search after this
  406. * event. The \b Event parameter is \c NULL. */
  407. UPNP_DISCOVERY_SEARCH_TIMEOUT,
  408. /*
  409. * Eventing callbacks
  410. */
  411. /*! Received by a device when a subscription arrives.
  412. * The \b Event parameter contains a pointer to a \b
  413. * UpnpSubscriptionRequest structure. At this point, the
  414. * subscription has already been accepted. \b UpnpAcceptSubscription
  415. * needs to be called to confirm the subscription and transmit the
  416. * initial state table. This can be done during this callback. The SDK
  417. * generates no events for a subscription unless the device
  418. * application calls \b UpnpAcceptSubscription.
  419. */
  420. UPNP_EVENT_SUBSCRIPTION_REQUEST,
  421. /*! Received by a control point when an event arrives. The \b
  422. * Event parameter contains a \b UpnpEvent structure
  423. * with the information about the event. */
  424. UPNP_EVENT_RECEIVED,
  425. /*! A \b UpnpRenewSubscriptionAsync call completed. The status of
  426. * the renewal is in the \b Event parameter as a \b
  427. * Upnp_Event_Subscription structure. */
  428. UPNP_EVENT_RENEWAL_COMPLETE,
  429. /*! A \b UpnpSubscribeAsync call completed. The status of the
  430. * subscription is in the \b Event parameter as a \b
  431. * Upnp_Event_Subscription structure. */
  432. UPNP_EVENT_SUBSCRIBE_COMPLETE,
  433. /*! A \b UpnpUnSubscribeAsync call completed. The status of the
  434. * subscription is in the \b Event parameter as a \b
  435. * UpnpEventSubscribe structure. */
  436. UPNP_EVENT_UNSUBSCRIBE_COMPLETE,
  437. /*! The auto-renewal of a client subscription failed.
  438. * The \b Event parameter is a \b UpnpEventSubscribe structure
  439. * with the error code set appropriately. The subscription is no longer
  440. * valid. */
  441. UPNP_EVENT_AUTORENEWAL_FAILED,
  442. /*! A client subscription has expired. This will only occur
  443. * if auto-renewal of subscriptions is disabled.
  444. * The \b Event parameter is a \b UpnpEventSubscribe
  445. * structure. The subscription is no longer valid. */
  446. UPNP_EVENT_SUBSCRIPTION_EXPIRED
  447. };
  448. typedef enum Upnp_EventType_e Upnp_EventType;
  449. /*!
  450. * \brief Holds the subscription identifier for a subscription between a
  451. * client and a device.
  452. *
  453. * The SID is a string representation of a globally unique id (GUID) and should
  454. * not be modified.
  455. */
  456. typedef char Upnp_SID[44];
  457. /*!
  458. * \brief Represents the different types of searches that can be performed
  459. * using the SDK for UPnP Devices API.
  460. *
  461. * By specifying these different values to \b UpnpSearchAsync, the control
  462. * point application can control the scope of the search from all devices
  463. * to specific devices or services.
  464. */
  465. enum Upnp_SType_e {
  466. /*! Search for all devices and services on the network. */
  467. UPNP_S_ALL,
  468. /*! Search for all root devices on the network. */
  469. UPNP_S_ROOT,
  470. /*! Search for a particular device type or a particular device instance. */
  471. UPNP_S_DEVICE,
  472. /*! Search for a particular service type, possibly on a particular
  473. * device type or device instance. */
  474. UPNP_S_SERVICE
  475. };
  476. typedef enum Upnp_SType_e Upnp_SType;
  477. /*!
  478. * \brief Specifies the type of description in \b UpnpRegisterRootDevice2.
  479. *
  480. * These values control how \b UpnpRegisterRootDevice2 interprets the
  481. * \b description parameter.
  482. */
  483. enum Upnp_DescType_e {
  484. /*! The description is the URL to the description document. */
  485. UPNPREG_URL_DESC,
  486. /*! The description is a file name on the local file system
  487. containing the description of the device. */
  488. UPNPREG_FILENAME_DESC,
  489. /*! The description is a pointer to a character array containing
  490. the XML description document. */
  491. UPNPREG_BUF_DESC
  492. };
  493. typedef enum Upnp_DescType_e Upnp_DescType;
  494. /** Returned as part of a {\bf UPNP_CONTROL_ACTION_COMPLETE} callback. */
  495. struct Upnp_Action_Request
  496. {
  497. /** The result of the operation. */
  498. int ErrCode;
  499. /** The socket number of the connection to the requestor. */
  500. int Socket;
  501. /** The error string in case of error. */
  502. char ErrStr[LINE_SIZE];
  503. /** The Action Name. */
  504. char ActionName[NAME_SIZE];
  505. /** The unique device ID. */
  506. char DevUDN[NAME_SIZE];
  507. /** The service ID. */
  508. char ServiceID[NAME_SIZE];
  509. /** The DOM document describing the action. */
  510. IXML_Document *ActionRequest;
  511. /** The DOM document describing the result of the action. */
  512. IXML_Document *ActionResult;
  513. /** IP address of the control point requesting this action. */
  514. struct sockaddr_storage CtrlPtIPAddr;
  515. /** The DOM document containing the information from the
  516. the SOAP header. */
  517. IXML_Document *SoapHeader;
  518. };
  519. /* compat code for libupnp-1.8 */
  520. typedef struct Upnp_Action_Request UpnpActionRequest;
  521. #define UpnpActionRequest_get_ErrCode(x) ((x)->ErrCode)
  522. #define UpnpActionRequest_get_Socket(x) ((x)->Socket)
  523. #define UpnpActionRequest_get_ErrStr_cstr(x) ((x)->ErrStr)
  524. #define UpnpActionRequest_get_ActionName_cstr(x) ((x)->ActionName)
  525. #define UpnpActionRequest_get_DevUDN_cstr(x) ((x)->DevUDN)
  526. #define UpnpActionRequest_get_ServiceID_cstr(x) ((x)->ServiceID)
  527. #define UpnpActionRequest_get_ActionRequest(x) ((x)->ActionRequest)
  528. #define UpnpActionRequest_get_ActionResult(x) ((x)->ActionResult)
  529. struct Upnp_Action_Complete
  530. {
  531. /** The result of the operation. */
  532. int ErrCode;
  533. /** The control URL for service. */
  534. char CtrlUrl[NAME_SIZE];
  535. /** The DOM document describing the action. */
  536. IXML_Document *ActionRequest;
  537. /** The DOM document describing the result of the action. */
  538. IXML_Document *ActionResult;
  539. };
  540. /* compat code for libupnp-1.8 */
  541. typedef struct Upnp_Action_Complete UpnpActionComplete;
  542. #define UpnpActionComplete_get_ErrCode(x) ((x)->ErrCode)
  543. #define UpnpActionComplete_get_CtrlUrl_cstr(x) ((x)->CtrlUrl)
  544. #define UpnpActionComplete_get_ActionRequest(x) ((x)->ActionRequest)
  545. #define UpnpActionComplete_get_ActionResult(x) ((x)->ActionResult)
  546. /** Represents the request for current value of a state variable in a service
  547. * state table. */
  548. struct Upnp_State_Var_Request
  549. {
  550. /** The result of the operation. */
  551. int ErrCode;
  552. /** The socket number of the connection to the requestor. */
  553. int Socket;
  554. /** The error string in case of error. */
  555. char ErrStr[LINE_SIZE];
  556. /** The unique device ID. */
  557. char DevUDN[NAME_SIZE];
  558. /** The service ID. */
  559. char ServiceID[NAME_SIZE];
  560. /** The name of the variable. */
  561. char StateVarName[NAME_SIZE];
  562. /** IP address of sender requesting the state variable. */
  563. struct sockaddr_storage CtrlPtIPAddr;
  564. /** The current value of the variable. This needs to be allocated by
  565. * the caller. When finished with it, the SDK frees this {\bf DOMString}. */
  566. DOMString CurrentVal;
  567. };
  568. /* compat code for libupnp-1.8 */
  569. typedef struct Upnp_State_Var_Request UpnpStateVarRequest;
  570. #define UpnpStateVarRequest_get_ErrCode(x) ((x)->ErrCode)
  571. #define UpnpStateVarRequest_get_Socket(x) ((x)->Socket)
  572. #define UpnpStateVarRequest_get_ErrStr_cstr(x) ((x)->ErrStr)
  573. #define UpnpStateVarRequest_get_DevUDN_cstr(x) ((x)->DevUDN)
  574. #define UpnpStateVarRequest_get_ServiceID_cstr(x) ((x)->ServiceID)
  575. #define UpnpStateVarRequest_get_StateVarName_cstr(x) ((x)->StateVarName)
  576. /** Represents the reply for the current value of a state variable in an
  577. asynchronous call. */
  578. struct Upnp_State_Var_Complete
  579. {
  580. /** The result of the operation. */
  581. int ErrCode;
  582. /** The control URL for the service. */
  583. char CtrlUrl[NAME_SIZE];
  584. /** The name of the variable. */
  585. char StateVarName[NAME_SIZE];
  586. /** The current value of the variable or error string in case of error. */
  587. DOMString CurrentVal;
  588. };
  589. /* compat code for libupnp-1.8 */
  590. typedef struct Upnp_State_Var_Complete UpnpStateVarComplete;
  591. #define UpnpStateVarComplete_get_ErrCode(x) ((x)->ErrCode)
  592. #define UpnpStateVarComplete_get_CtrlUrl_cstr(x) ((x)->CtrlUrl)
  593. #define UpnpStateVarComplete_get_StateVarName_cstr(x) ((x)->StateVarName)
  594. /** Returned along with a {\bf UPNP_EVENT_RECEIVED} callback. */
  595. struct Upnp_Event
  596. {
  597. /** The subscription ID for this subscription. */
  598. Upnp_SID Sid;
  599. /** The event sequence number. */
  600. int EventKey;
  601. /** The DOM tree representing the changes generating the event. */
  602. IXML_Document *ChangedVariables;
  603. };
  604. /* compat code for libupnp-1.8 */
  605. typedef struct Upnp_Event UpnpEvent;
  606. #define UpnpEvent_get_SID_cstr(x) ((x)->Sid)
  607. #define UpnpEvent_get_EventKey(x) ((x)->EventKey)
  608. #define UpnpEvent_get_ChangedVariables(x) ((x)->ChangedVariables)
  609. /*
  610. * This typedef is required by Doc++ to parse the last entry of the
  611. * Upnp_Discovery structure correctly.
  612. */
  613. /** Returned in a {\bf UPNP_DISCOVERY_RESULT} callback. */
  614. struct Upnp_Discovery
  615. {
  616. /** The result code of the {\bf UpnpSearchAsync} call. */
  617. int ErrCode;
  618. /** The expiration time of the advertisement. */
  619. int Expires;
  620. /** The unique device identifier. */
  621. char DeviceId[LINE_SIZE];
  622. /** The device type. */
  623. char DeviceType[LINE_SIZE];
  624. /** The service type. */
  625. char ServiceType[LINE_SIZE];
  626. /** The service version. */
  627. char ServiceVer[LINE_SIZE];
  628. /** The URL to the UPnP description document for the device. */
  629. char Location[LINE_SIZE];
  630. /** The operating system the device is running. */
  631. char Os[LINE_SIZE];
  632. /** Date when the response was generated. */
  633. char Date[LINE_SIZE];
  634. /** Confirmation that the MAN header was understood by the device. */
  635. char Ext[LINE_SIZE];
  636. /** The host address of the device responding to the search. */
  637. struct sockaddr_storage DestAddr;
  638. };
  639. /* compat code for libupnp-1.8 */
  640. typedef struct Upnp_Discovery UpnpDiscovery;
  641. #define UpnpDiscovery_get_ErrCode(x) ((x)->ErrCode)
  642. #define UpnpDiscovery_get_Expires(x) ((x)->Expires)
  643. #define UpnpDiscovery_get_DeviceID_cstr(x) ((x)->DeviceId)
  644. #define UpnpDiscovery_get_DeviceType_cstr(x) ((x)->DeviceType)
  645. #define UpnpDiscovery_get_ServiceType_cstr(x) ((x)->ServiceType)
  646. #define UpnpDiscovery_get_ServiceVer_cstr(x) ((x)->ServiceVer)
  647. #define UpnpDiscovery_get_Location_cstr(x) ((x)->Location)
  648. #define UpnpDiscovery_get_Os_cstr(x) ((x)->Os)
  649. #define UpnpDiscovery_get_Date_cstr(x) ((x)->Date)
  650. #define UpnpDiscovery_get_Ext_cstr(x) ((x)->Ext)
  651. /** Returned along with a {\bf UPNP_EVENT_SUBSCRIBE_COMPLETE} or {\bf
  652. * UPNP_EVENT_UNSUBSCRIBE_COMPLETE} callback. */
  653. struct Upnp_Event_Subscribe {
  654. /** The SID for this subscription. For subscriptions, this only
  655. * contains a valid SID if the {\bf Upnp_EventSubscribe.result} field
  656. * contains a {\tt UPNP_E_SUCCESS} result code. For unsubscriptions,
  657. * this contains the SID from which the subscription is being
  658. * unsubscribed. */
  659. Upnp_SID Sid;
  660. /** The result of the operation. */
  661. int ErrCode;
  662. /** The event URL being subscribed to or removed from. */
  663. char PublisherUrl[NAME_SIZE];
  664. /** The actual subscription time (for subscriptions only). */
  665. int TimeOut;
  666. };
  667. /* compat code for libupnp-1.8 */
  668. typedef struct Upnp_Event_Subscribe UpnpEventSubscribe;
  669. #define UpnpEventSubscribe_get_SID_cstr(x) ((x)->Sid)
  670. #define UpnpEventSubscribe_get_ErrCode(x) ((x)->ErrCode)
  671. #define UpnpEventSubscribe_get_PublisherUrl_cstr(x) ((x)->PublisherUrl)
  672. #define UpnpEventSubscribe_get_TimeOut(x) ((x)->TimeOut)
  673. /** Returned along with a {\bf UPNP_EVENT_SUBSCRIPTION_REQUEST}
  674. * callback. */
  675. struct Upnp_Subscription_Request
  676. {
  677. /** The identifier for the service being subscribed to. */
  678. char *ServiceId;
  679. /** Universal device name. */
  680. char *UDN;
  681. /** The assigned subscription ID for this subscription. */
  682. Upnp_SID Sid;
  683. };
  684. /* compat code for libupnp-1.8 */
  685. typedef struct Upnp_Subscription_Request UpnpSubscriptionRequest;
  686. #define UpnpSubscriptionRequest_get_ServiceId_cstr(x) ((x)->ServiceId)
  687. #define UpnpSubscriptionRequest_get_UDN_cstr(x) ((x)->UDN)
  688. #define UpnpSubscriptionRequest_get_SID_cstr(x) ((x)->Sid)
  689. struct Extra_Headers
  690. {
  691. /** The length of the file. A length less than 0 indicates the size
  692. * is unknown, and data will be sent until 0 bytes are returned from
  693. * a read call. */
  694. char *name;
  695. char *value;
  696. DOMString resp;
  697. };
  698. struct File_Info
  699. {
  700. /** The length of the file. A length less than 0 indicates the size
  701. * is unknown, and data will be sent until 0 bytes are returned from
  702. * a read call. */
  703. off_t file_length;
  704. /** The time at which the contents of the file was modified;
  705. * The time system is always local (not GMT). */
  706. time_t last_modified;
  707. /** If the file is a directory, {\bf is_directory} contains
  708. * a non-zero value. For a regular file, it should be 0. */
  709. int is_directory;
  710. /** If the file or directory is readable, this contains
  711. * a non-zero value. If unreadable, it should be set to 0. */
  712. int is_readable;
  713. /** The content type of the file. This string needs to be allocated
  714. * by the caller using {\bf ixmlCloneDOMString}. When finished
  715. * with it, the SDK frees the {\bf DOMString}. */
  716. DOMString content_type;
  717. /** Headers to be modified / added. A modified response must be allocated
  718. * by the caller using {\bf ixmlCloneDOMString}. When finished with it,
  719. * the SDK frees all of them. */
  720. struct Extra_Headers *extra_headers;
  721. };
  722. /* compat code for libupnp-1.8 */
  723. typedef struct File_Info UpnpFileInfo;
  724. #define UpnpFileInfo_get_FileLength(x) ((x)->file_length)
  725. #define UpnpFileInfo_get_LastModified(x) ((x)->last_modified)
  726. #define UpnpFileInfo_get_IsDirectory(x) ((x)->is_directory)
  727. #define UpnpFileInfo_get_IsReadable(x) ((x)->is_readable)
  728. /*!
  729. * All callback functions share the same prototype, documented below.
  730. * Note that any memory passed to the callback function
  731. * is valid only during the callback and should be copied if it
  732. * needs to persist. This callback function needs to be thread
  733. * safe. The context of the callback is always on a valid thread
  734. * context and standard synchronization methods can be used. Note,
  735. * however, because of this the callback cannot call SDK functions
  736. * unless explicitly noted.
  737. *
  738. * \verbatim
  739. int CallbackFxn(Upnp_EventType EventType, void *Event, void *Cookie);
  740. \endverbatim
  741. *
  742. * where \b EventType is the event that triggered the callback,
  743. * \b Event is a structure that denotes event-specific information for that
  744. * event, and \b Cookie is the user data passed when the callback was
  745. * registered.
  746. *
  747. * See \b Upnp_EventType for more information on the callback values and
  748. * the associated \b Event parameter.
  749. *
  750. * The return value of the callback is currently ignored. It may be used
  751. * in the future to communicate results back to the SDK.
  752. */
  753. typedef int (*Upnp_FunPtr)(
  754. /*! [in] .*/
  755. Upnp_EventType EventType,
  756. /*! [in] .*/
  757. void *Event,
  758. /*! [in] .*/
  759. void *Cookie);
  760. /* @} Constants and Types */
  761. #ifdef __cplusplus
  762. extern "C" {
  763. #endif /* __cplusplus */
  764. /*!
  765. * \name Initialization and Registration
  766. *
  767. * @{
  768. */
  769. /*!
  770. * \brief Initializes the Linux SDK for UPnP Devices (IPv4 only).
  771. *
  772. * \deprecated Kept for backwards compatibility. Use UpnpInit2 for new
  773. * implementations or where IPv6 is required.
  774. *
  775. * This function must be called before any other API function can be called.
  776. * It should be called only once. Subsequent calls to this API return a
  777. * \c UPNP_E_INIT error code.
  778. *
  779. * Optionally, the application can specify a host IPv4 address (in the
  780. * case of a multi-homed configuration) and a port number to use for
  781. * all UPnP operations. Since a port number can be used only by one
  782. * process, multiple processes using the SDK must specify
  783. * different port numbers.
  784. *
  785. * If unspecified, the SDK will use the first IPv4-capable adapter's IP address
  786. * and an arbitrary port.
  787. *
  788. * This call is synchronous.
  789. *
  790. * \return An integer representing one of the following:
  791. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  792. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist
  793. * to initialize the SDK.
  794. * \li \c UPNP_E_INIT: The SDK is already initialized.
  795. * \li \c UPNP_E_INIT_FAILED: The SDK initialization
  796. * failed for an unknown reason.
  797. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  798. * \li \c UPNP_E_LISTEN: An error occurred listening to a socket.
  799. * \li \c UPNP_E_OUTOF_SOCKET: An error ocurred creating a socket.
  800. * \li \c UPNP_E_INTERNAL_ERROR: An internal error ocurred.
  801. */
  802. EXPORT_SPEC int UpnpInit(
  803. /*! The host local IPv4 address to use, in string format, for example
  804. * "192.168.0.1", or \c NULL to use the first IPv4 adapter's IP address. */
  805. const char *HostIP,
  806. /*! Local Port to listen for incoming connections
  807. * \c NULL will pick an arbitrary free port. */
  808. unsigned short DestPort);
  809. /*!
  810. * \brief Initializes the Linux SDK for UPnP Devices (IPv4 or IPv6).
  811. *
  812. * This function must be called before any other API function can be called.
  813. * It should be called only once. Subsequent calls to this API return a
  814. * \c UPNP_E_INIT error code.
  815. *
  816. * Optionally, the application can specify an interface name (in the
  817. * case of a multi-homed configuration) and a port number to use for
  818. * all UPnP operations. Since a port number can be used only by one
  819. * process, multiple processes using the SDK must specify
  820. * different port numbers.
  821. *
  822. * If unspecified, the SDK will use the first suitable interface and an
  823. * arbitrary port.
  824. *
  825. * This call is synchronous.
  826. *
  827. * \return An integer representing one of the following:
  828. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  829. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist
  830. * to initialize the SDK.
  831. * \li \c UPNP_E_INIT: The SDK is already initialized.
  832. * \li \c UPNP_E_INIT_FAILED: The SDK initialization
  833. * failed for an unknown reason.
  834. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  835. * \li \c UPNP_E_LISTEN: An error occurred listening to a socket.
  836. * \li \c UPNP_E_OUTOF_SOCKET: An error ocurred creating a socket.
  837. * \li \c UPNP_E_INTERNAL_ERROR: An internal error ocurred.
  838. * \li \c UPNP_E_INVALID_INTERFACE: IfName is invalid or does not
  839. * have a valid IPv4 or IPv6 addresss configured.
  840. */
  841. #ifdef UPNP_ENABLE_IPV6
  842. EXPORT_SPEC int UpnpInit2(
  843. /*! The interface name to use by the UPnP SDK operations.
  844. * Examples: "eth0", "xl0", "Local Area Connection", \c NULL to
  845. * use the first suitable interface. */
  846. const char *IfName,
  847. /*! Local Port to listen for incoming connections.
  848. * \c NULL will pick an arbitrary free port. */
  849. unsigned short DestPort);
  850. #endif
  851. /*!
  852. * \brief Terminates the Linux SDK for UPnP Devices.
  853. *
  854. * \li Checks for pending jobs and threads
  855. * \li Unregisters either the client or device
  856. * \li Shuts down the Timer Thread
  857. * \li Stops the Mini Server
  858. * \li Uninitializes the Thread Pool
  859. * \li For Win32 cleans up Winsock Interface
  860. * \li Cleans up mutex objects
  861. *
  862. * This function must be the last API function called. It should be called only
  863. * once. Subsequent calls to this API return a \c UPNP_E_FINISH error code.
  864. *
  865. * \return An integer representing one of the following:
  866. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  867. * \li \c UPNP_E_FINISH: The SDK is already terminated or
  868. * it is not initialized.
  869. */
  870. EXPORT_SPEC int UpnpFinish(void);
  871. /*!
  872. * \brief Returns the internal server IPv4 UPnP listening port.
  873. *
  874. * If '0' is used as the port number in \b UpnpInit, then this function can be
  875. * used to retrieve the actual port allocated to the SDK.
  876. *
  877. * \return
  878. * \li On success: The port on which an internal server is listening for IPv4 UPnP
  879. * related requests.
  880. * \li On error: 0 is returned if \b UpnpInit has not succeeded.
  881. */
  882. EXPORT_SPEC unsigned short UpnpGetServerPort(void);
  883. /*!
  884. * \brief Returns the internal server IPv6 UPnP listening port.
  885. *
  886. * If '0' is used as the port number in \b UpnpInit, then this function can be
  887. * used to retrieve the actual port allocated to the SDK.
  888. *
  889. * \return
  890. * \li On success: The port on which an internal server is listening for IPv6 UPnP
  891. * related requests.
  892. * \li On error: 0 is returned if \b UpnpInit has not succeeded.
  893. */
  894. #ifdef UPNP_ENABLE_IPV6
  895. EXPORT_SPEC unsigned short UpnpGetServerPort6(void);
  896. #endif
  897. /*!
  898. * \brief Returns the local IPv4 listening ip address.
  899. *
  900. * If \c NULL is used as the IPv4 address in \b UpnpInit, then this function can
  901. * be used to retrieve the actual interface address on which device is running.
  902. *
  903. * \return
  904. * \li On success: The IPv4 address on which an internal server is
  905. * listening for UPnP related requests.
  906. * \li On error: \c NULL is returned if \b UpnpInit has not succeeded.
  907. */
  908. EXPORT_SPEC char *UpnpGetServerIpAddress(void);
  909. /*!
  910. * \brief Returns the local IPv6 listening ip address.
  911. *
  912. * If \c NULL is used as the IPv6 address in \b UpnpInit, then this function can
  913. * be used to retrieve the actual interface address on which device is running.
  914. *
  915. * \return
  916. * \li On success: The IPv6 address on which an internal server is
  917. * listening for UPnP related requests.
  918. * \li On error: \c NULL is returned if \b UpnpInit has not succeeded.
  919. */
  920. #ifdef UPNP_ENABLE_IPV6
  921. EXPORT_SPEC char *UpnpGetServerIp6Address(void);
  922. EXPORT_SPEC char *UpnpGetServerUlaGuaIp6Address(void);
  923. #endif
  924. /*!
  925. * \brief Registers a device application with the UPnP Library.
  926. *
  927. * A device application cannot make any other API calls until it registers
  928. * using this function.
  929. *
  930. * Device applications can also register as control points (see
  931. * \b UpnpRegisterClient to get a control point handle to perform control
  932. * point functionality).
  933. *
  934. * This is a synchronous call and does not generate any callbacks. Callbacks
  935. * can occur as soon as this function returns.
  936. *
  937. * \return An integer representing one of the following:
  938. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  939. * \li \c UPNP_E_FINISH: The SDK is already terminated or is not
  940. * initialized.
  941. * \li \c UPNP_E_INVALID_DESC: The description document was not
  942. * a valid device description.
  943. * \li \c UPNP_E_INVALID_URL: The URL for the description document
  944. * is not valid.
  945. * \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
  946. * is not a valid pointer or \b DescURL is \c NULL.
  947. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  948. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  949. * to a socket.
  950. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  951. * from a socket.
  952. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  953. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
  954. * socket.
  955. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  956. * allocated.
  957. * \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
  958. * register this root device.
  959. */
  960. EXPORT_SPEC int UpnpRegisterRootDevice(
  961. /*! [in] Pointer to a string containing the description URL for this root device
  962. * instance. */
  963. const char *DescUrl,
  964. /*! [in] Pointer to the callback function for receiving asynchronous events. */
  965. Upnp_FunPtr Callback,
  966. /*! [in] Pointer to user data returned with the callback function when invoked. */
  967. const void *Cookie,
  968. /*! [out] Pointer to a variable to store the new device handle. */
  969. UpnpDevice_Handle *Hnd);
  970. /*!
  971. * \brief Registers a device application with the UPnP Library. Similar to
  972. * \b UpnpRegisterRootDevice, except that it also allows the description
  973. * document to be specified as a file or a memory buffer.
  974. *
  975. * The description can also be configured to have the correct IP and port
  976. * address.
  977. *
  978. * NOTE: For the configuration to be functional, the internal web server
  979. * MUST be present. In addition, the web server MUST be activated
  980. * (using \b UpnpSetWebServerRootDir) before calling this function.
  981. * The only condition where the web server can be absent is if the
  982. * description document is specified as a URL and no configuration is
  983. * required (i.e. <tt>config_baseURL = 0</tt>.)
  984. *
  985. * This is a synchronous call and does not generate any callbacks. Callbacks
  986. * can occur as soon as this function returns.
  987. *
  988. * Examples of using different types of description documents:
  989. * \verbatim
  990. 1) Description specified as a URL:
  991. descriptionType == UPNPREG_URL_DESC
  992. description is the URL
  993. bufferLen = 0 (ignored)
  994. 2) Description specified as a file:
  995. descriptionType == UPNPREG_FILENAME_DESC
  996. description is a filename
  997. bufferLen = 0 (ignored)
  998. 3) Description specified as a memory buffer:
  999. descriptionType == UPNPREG_BUF_DESC
  1000. description is pointer to a memory buffer
  1001. bufferLen == length of memory buffer
  1002. \endverbatim
  1003. *
  1004. * \return An integer representing one of the following:
  1005. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1006. * \li \c UPNP_E_FINISH: The SDK is already terminated or
  1007. * is not initialized.
  1008. * \li \c UPNP_E_INVALID_DESC: The description document is not
  1009. * a valid device description.
  1010. * \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
  1011. * is not a valid pointer or \b DescURL is \c NULL.
  1012. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  1013. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  1014. * to a socket.
  1015. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  1016. * from a socket.
  1017. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  1018. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
  1019. * socket.
  1020. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  1021. * allocated.
  1022. * \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
  1023. * register this root device.
  1024. * \li \c UPNP_E_URL_TOO_BIG: Length of the URL is bigger than the
  1025. * internal buffer.
  1026. * \li \c UPNP_E_FILE_NOT_FOUND: The description file could not
  1027. * be found.
  1028. * \li \c UPNP_E_FILE_READ_ERROR: An error occurred reading the
  1029. * description file.
  1030. * \li \c UPNP_E_INVALID_URL: The URL to the description document
  1031. * is invalid.
  1032. * \li \c UPNP_E_EXT_NOT_XML: The URL to the description document
  1033. * or file should have a <tt>.xml</tt> extension.
  1034. * \li \c UPNP_E_NO_WEB_SERVER: The internal web server has been
  1035. * compiled out; the SDK cannot configure itself from the
  1036. * description document.
  1037. */
  1038. EXPORT_SPEC int UpnpRegisterRootDevice2(
  1039. /*! [in] The type of the description document. */
  1040. Upnp_DescType descriptionType,
  1041. /*! [in] Treated as a URL, file name or memory buffer depending on
  1042. * description type. */
  1043. const char* description,
  1044. /*! [in] The length of memory buffer if passing a description in a buffer,
  1045. * otherwise it is ignored. */
  1046. size_t bufferLen,
  1047. /*! [in] If nonzero, \c URLBase of description document is configured and
  1048. * the description is served using the internal web server. */
  1049. int config_baseURL,
  1050. /*! [in] Pointer to the callback function for receiving asynchronous events. */
  1051. Upnp_FunPtr Fun,
  1052. /*! [in] Pointer to user data returned with the callback function when
  1053. * invoked. */
  1054. const void* Cookie,
  1055. /*! [out] Pointer to a variable to store the new device handle. */
  1056. UpnpDevice_Handle* Hnd);
  1057. /*!
  1058. * \brief Registers a device application for a specific address family with
  1059. * the UPnP library.
  1060. *
  1061. * A device application cannot make any other API calls until it registers
  1062. * using this function. Device applications can also register as control
  1063. * points (see \b UpnpRegisterClient to get a control point handle to perform
  1064. * control point functionality).
  1065. *
  1066. * This is synchronous and does not generate any callbacks. Callbacks can occur
  1067. * as soon as this function returns.
  1068. *
  1069. * \return An integer representing one of the following:
  1070. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1071. * \li \c UPNP_E_FINISH: The SDK is already terminated or
  1072. * is not initialized.
  1073. * \li \c UPNP_E_INVALID_DESC: The description document was not
  1074. * a valid device description.
  1075. * \li \c UPNP_E_INVALID_URL: The URL for the description document
  1076. * is not valid.
  1077. * \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
  1078. * is not a valid pointer or \b DescURL is \c NULL.
  1079. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  1080. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  1081. * to a socket.
  1082. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  1083. * from a socket.
  1084. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  1085. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
  1086. * socket.
  1087. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  1088. * allocated.
  1089. * \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
  1090. * register this root device.
  1091. */
  1092. EXPORT_SPEC int UpnpRegisterRootDevice3(
  1093. /*! [in] Pointer to a string containing the description URL for this root
  1094. * device instance. */
  1095. const char *DescUrl,
  1096. /*! [in] Pointer to the callback function for receiving asynchronous events. */
  1097. Upnp_FunPtr Callback,
  1098. /*! [in] Pointer to user data returned with the callback function when invoked. */
  1099. const void *Cookie,
  1100. /*! [out] Pointer to a variable to store the new device handle. */
  1101. UpnpDevice_Handle *Hnd,
  1102. /*! [in] Address family of this device. Can be AF_INET for an IPv4 device, or
  1103. * AF_INET6 for an IPv6 device. Defaults to AF_INET. */
  1104. int AddressFamily);
  1105. /*!
  1106. * \brief Registers a device application for a specific address family with
  1107. * the UPnP library. This function can also be used to specify a dedicated
  1108. * description URL to be returned for legacy CPs.
  1109. *
  1110. * A device application cannot make any other API calls until it registers
  1111. * using this function. Device applications can also register as control
  1112. * points (see \b UpnpRegisterClient to get a control point handle to perform
  1113. * control point functionality).
  1114. *
  1115. * This is synchronous and does not generate any callbacks. Callbacks can occur
  1116. * as soon as this function returns.
  1117. *
  1118. * \return An integer representing one of the following:
  1119. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1120. * \li \c UPNP_E_FINISH: The SDK is already terminated or
  1121. * is not initialized.
  1122. * \li \c UPNP_E_INVALID_DESC: The description document was not
  1123. * a valid device description.
  1124. * \li \c UPNP_E_INVALID_URL: The URL for the description document
  1125. * is not valid.
  1126. * \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
  1127. * is not a valid pointer or \b DescURL is \c NULL.
  1128. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  1129. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  1130. * to a socket.
  1131. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  1132. * from a socket.
  1133. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  1134. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
  1135. * socket.
  1136. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  1137. * allocated.
  1138. * \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
  1139. * register this root device.
  1140. */
  1141. EXPORT_SPEC int UpnpRegisterRootDevice4(
  1142. /*! [in] Pointer to a string containing the description URL for this root
  1143. * device instance. */
  1144. const char *DescUrl,
  1145. /*! [in] Pointer to the callback function for receiving asynchronous events. */
  1146. Upnp_FunPtr Callback,
  1147. /*! [in] Pointer to user data returned with the callback function when invoked. */
  1148. const void *Cookie,
  1149. /*! [out] Pointer to a variable to store the new device handle. */
  1150. UpnpDevice_Handle *Hnd,
  1151. /*! [in] Address family of this device. Can be AF_INET for an IPv4 device, or
  1152. * AF_INET6 for an IPv6 device. Defaults to AF_INET. */
  1153. int AddressFamily,
  1154. /*! [in] Pointer to a string containing the description URL to be returned for
  1155. * legacy CPs for this root device instance. */
  1156. const char *LowerDescUrl);
  1157. /*!
  1158. * \brief Unregisters a root device registered with \b UpnpRegisterRootDevice,
  1159. * \b UpnpRegisterRootDevice2, \b UpnpRegisterRootDevice3 or
  1160. * \b UpnpRegisterRootDevice4.
  1161. *
  1162. * After this call, the \b UpnpDevice_Handle is no longer valid. For all
  1163. * advertisements that have not yet expired, the SDK sends a device unavailable
  1164. * message automatically.
  1165. *
  1166. * This is a synchronous call and generates no callbacks. Once this call
  1167. * returns, the SDK will no longer generate callbacks to the application.
  1168. *
  1169. * \return An integer representing one of the following:
  1170. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1171. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device handle.
  1172. */
  1173. EXPORT_SPEC int UpnpUnRegisterRootDevice(
  1174. /*! [in] The handle of the root device instance to unregister. */
  1175. UpnpDevice_Handle Hnd);
  1176. /*!
  1177. * \brief Unregisters a root device registered with \b UpnpRegisterRootDevice,
  1178. * \b UpnpRegisterRootDevice2, \b UpnpRegisterRootDevice3 or
  1179. * \b UpnpRegisterRootDevice4.
  1180. *
  1181. * After this call, the \b UpnpDevice_Handle is no longer valid. For all
  1182. * advertisements that have not yet expired, the SDK sends a device unavailable
  1183. * message automatically.
  1184. *
  1185. * This is a synchronous call and generates no callbacks. Once this call
  1186. * returns, the SDK will no longer generate callbacks to the application.
  1187. *
  1188. * This function allow a device to specify the SSDP extensions defined by UPnP
  1189. * Low Power.
  1190. *
  1191. * \return An integer representing one of the following:
  1192. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1193. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device handle.
  1194. */
  1195. EXPORT_SPEC int UpnpUnRegisterRootDeviceLowPower(
  1196. /*! [in] The handle of the root device instance to unregister. */
  1197. UpnpDevice_Handle Hnd,
  1198. /*! PowerState as defined by UPnP Low Power. */
  1199. int PowerState,
  1200. /*! SleepPeriod as defined by UPnP Low Power. */
  1201. int SleepPeriod,
  1202. /*! RegistrationState as defined by UPnP Low Power. */
  1203. int RegistrationState);
  1204. /*!
  1205. * \brief Registers a control point application with the UPnP Library.
  1206. *
  1207. * A control point application cannot make any other API calls until it
  1208. * registers using this function.
  1209. *
  1210. * \b UpnpRegisterClient is a synchronous call and generates no callbacks.
  1211. * Callbacks can occur as soon as this function returns.
  1212. *
  1213. * \return An integer representing one of the following:
  1214. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1215. * \li \c UPNP_E_FINISH: The SDK is already terminated or
  1216. * is not initialized.
  1217. * \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
  1218. * is not a valid pointer.
  1219. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1220. * register this control point.
  1221. */
  1222. EXPORT_SPEC int UpnpRegisterClient(
  1223. /*! [in] Pointer to a function for receiving asynchronous events. */
  1224. Upnp_FunPtr Callback,
  1225. /*! [in] Pointer to user data returned with the callback function when invoked. */
  1226. const void *Cookie,
  1227. /*! [out] Pointer to a variable to store the new control point handle. */
  1228. UpnpClient_Handle *Hnd);
  1229. /*!
  1230. * \brief Unregisters a control point application, unsubscribing all active
  1231. * subscriptions.
  1232. *
  1233. * This function unregisters a client registered with UpnpRegisterclient or
  1234. * UpnpRegisterclient2. After this call, the \b UpnpClient_Handle is no longer
  1235. * valid. The UPnP Library generates no more callbacks after this function
  1236. * returns.
  1237. *
  1238. * \b UpnpUnRegisterClient is a synchronous call and generates no
  1239. * callbacks.
  1240. *
  1241. * \return An integer representing one of the following:
  1242. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1243. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control point handle.
  1244. */
  1245. EXPORT_SPEC int UpnpUnRegisterClient(
  1246. /*! [in] The handle of the control point instance to unregister. */
  1247. UpnpClient_Handle Hnd);
  1248. /*!
  1249. * \deprecated Use \b UpnpSetMaxContentLength instead.
  1250. *
  1251. * Warning: the Handle argument provided here is not used, so the effect
  1252. * of this function is global to the SDK (= same as \b UpnpSetMaxContentLength).
  1253. */
  1254. EXPORT_SPEC int UpnpSetContentLength(
  1255. /*! [in] The handle of the device instance for which the coincoming content
  1256. * length needs to be set. */
  1257. UpnpClient_Handle Hnd,
  1258. /*! [in] Permissible content length */
  1259. size_t contentLength);
  1260. /*!
  1261. * \brief Sets the maximum content-length that the SDK will process on an
  1262. * incoming SOAP requests or responses.
  1263. *
  1264. * This API allows devices that have memory constraints to exhibit consistent
  1265. * behaviour if the size of the incoming SOAP message exceeds the memory that
  1266. * device can allocate.
  1267. *
  1268. * If set to 0 then checking will be disabled.
  1269. *
  1270. * The default maximum content-length is \c DEFAULT_SOAP_CONTENT_LENGTH
  1271. * = 16K bytes.
  1272. *
  1273. * \return An integer representing one of the following:
  1274. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1275. */
  1276. EXPORT_SPEC int UpnpSetMaxContentLength(
  1277. /*! [in] The maximum permissible content length for incoming SOAP actions,
  1278. * in bytes. */
  1279. size_t contentLength);
  1280. /* @} Initialization and Registration */
  1281. /******************************************************************************
  1282. ******************************************************************************
  1283. * *
  1284. * D I S C O V E R Y *
  1285. * *
  1286. ******************************************************************************
  1287. ******************************************************************************/
  1288. /*!
  1289. * \name Discovery
  1290. *
  1291. * @{
  1292. */
  1293. /*!
  1294. * \brief Searches for devices matching the given search target.
  1295. *
  1296. * The function returns immediately and the SDK calls the default callback
  1297. * function, registered during the \b UpnpRegisterClient call, for each
  1298. * matching root device, device, or service. The application specifies the
  1299. * search type by the \b Target parameter.
  1300. *
  1301. * This function searches for the devices for the provided maximum time.
  1302. * It is an asynchronous function. It schedules a search job and returns.
  1303. * The client is notified about the search results after search timer.
  1304. *
  1305. * Note that there is no way for the SDK to distinguish which client
  1306. * instance issued a particular search. Therefore, the client can get
  1307. * search callbacks that do not match the original criteria of the search.
  1308. * Also, the application will receive multiple callbacks for each search.
  1309. *
  1310. * \return An integer representing one of the following:
  1311. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1312. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1313. * point handle.
  1314. * \li \c UPNP_E_INVALID_PARAM: \b Target is \c NULL.
  1315. */
  1316. EXPORT_SPEC int UpnpSearchAsync(
  1317. /*! The handle of the client performing the search. */
  1318. UpnpClient_Handle Hnd,
  1319. /*! The time, in seconds, to wait for responses. If the time is greater
  1320. * than \c MAX_SEARCH_TIME then the time is set to \c MAX_SEARCH_TIME.
  1321. * If the time is less than \c MIN_SEARCH_TIME then the time is set to
  1322. * \c MIN_SEARCH_TIME. */
  1323. int Mx,
  1324. /*! The search target as defined in the UPnP Device Architecture v1.0
  1325. * specification. */
  1326. const char *TTarget_constarget_const,
  1327. /*! The user data to pass when the callback function is invoked. */
  1328. const void *Cookie_const);
  1329. /*!
  1330. * \brief Sends out the discovery announcements for all devices and services
  1331. * for a device.
  1332. *
  1333. * Each announcement is made with the same expiration time.
  1334. *
  1335. * This is a synchronous call.
  1336. *
  1337. * \return An integer representing one of the following:
  1338. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1339. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid
  1340. * device handle.
  1341. * \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
  1342. * send future advertisements.
  1343. */
  1344. EXPORT_SPEC int UpnpSendAdvertisement(
  1345. /*! The device handle for which to send out the announcements. */
  1346. UpnpDevice_Handle Hnd,
  1347. /*! The expiration age, in seconds, of the announcements. If the
  1348. * expiration age is less than 1 then the expiration age is set to
  1349. * \c DEFAULT_MAXAGE. If the expiration age is less than or equal to
  1350. * \c AUTO_ADVERTISEMENT_TIME * 2 then the expiration age is set to
  1351. * ( \c AUTO_ADVERTISEMENT_TIME + 1 ) * 2. */
  1352. int Exp);
  1353. /*!
  1354. * \brief Sends out the discovery announcements for all devices and services
  1355. * for a device.
  1356. *
  1357. * Each announcement is made with the same expiration time.
  1358. *
  1359. * This is a synchronous call.
  1360. *
  1361. * This function allow a device to specify the SSDP extensions defined by UPnP
  1362. * Low Power.
  1363. *
  1364. * \return An integer representing one of the following:
  1365. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1366. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid
  1367. * device handle.
  1368. * \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
  1369. * send future advertisements.
  1370. */
  1371. EXPORT_SPEC int UpnpSendAdvertisementLowPower(
  1372. /*! The device handle for which to send out the announcements. */
  1373. UpnpDevice_Handle Hnd,
  1374. /*! The expiration age, in seconds, of the announcements. If the
  1375. * expiration age is less than 1 then the expiration age is set to
  1376. * \c DEFAULT_MAXAGE. If the expiration age is less than or equal to
  1377. * \c AUTO_ADVERTISEMENT_TIME * 2 then the expiration age is set to
  1378. * ( \c AUTO_ADVERTISEMENT_TIME + 1 ) * 2. */
  1379. int Exp,
  1380. /*! PowerState as defined by UPnP Low Power. */
  1381. int PowerState,
  1382. /*! SleepPeriod as defined by UPnP Low Power. */
  1383. int SleepPeriod,
  1384. /*! RegistrationState as defined by UPnP Low Power. */
  1385. int RegistrationState);
  1386. /* @} Discovery */
  1387. /******************************************************************************
  1388. ******************************************************************************
  1389. * *
  1390. * C O N T R O L *
  1391. * *
  1392. ******************************************************************************
  1393. ******************************************************************************/
  1394. /*!
  1395. * \name Control
  1396. *
  1397. * @{
  1398. */
  1399. /*!
  1400. * \brief Queries the state of a state variable of a service on another device.
  1401. *
  1402. * \deprecated
  1403. * <b>The use of this function is deprecated by the UPnP Forum</b>.
  1404. *
  1405. * This is a synchronous call.
  1406. *
  1407. * A positive return value indicates a SOAP error code, whereas a negative
  1408. * return code indicates an SDK error code.
  1409. *
  1410. * \return An integer representing one of the following:
  1411. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1412. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1413. * point handle.
  1414. * \li \c UPNP_E_INVALID_URL: \b ActionUrl is not a valid URL.
  1415. * \li \c UPNP_E_INVALID_DESC: The XML document was not
  1416. * found or it does not contain a valid XML description.
  1417. * \li \c UPNP_E_INVALID_PARAM: \b StVarVal is not a valid
  1418. * pointer or \b VarName or \b ActionUrl is \c NULL.
  1419. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1420. * complete this operation.
  1421. * \li \c UPNP_SOAP_E_INVALID_VAR: The given variable is invalid
  1422. * according to the device.
  1423. */
  1424. EXPORT_SPEC int UpnpGetServiceVarStatus(
  1425. /*! [in] The handle of the control point. */
  1426. UpnpClient_Handle Hnd,
  1427. /*! [in] The URL of the service. */
  1428. const char *ActionURL,
  1429. /*! [in] The name of the variable to query. */
  1430. const char *VarName,
  1431. /*! [out] The pointer to store the value for \b VarName. The SDK allocates
  1432. * this string and the caller needs to free it using
  1433. * \b ixmlFreeDOMString. */
  1434. DOMString *StVarVal);
  1435. /*!
  1436. * \brief Queries the state of a variable of a service, generating a callback
  1437. * when the operation is complete.
  1438. *
  1439. * \deprecated
  1440. * <b>The use of this function is deprecated by the UPnP Forum</b>.
  1441. *
  1442. * \return An integer representing one of the following:
  1443. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1444. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1445. * point handle.
  1446. * \li \c UPNP_E_INVALID_URL: The \b ActionUrl is not a valid URL.
  1447. * \li \c UPNP_E_INVALID_PARAM: \b VarName, \b Fun or
  1448. * \b ActionUrl is not a valid pointer.
  1449. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1450. * complete this operation.
  1451. */
  1452. EXPORT_SPEC int UpnpGetServiceVarStatusAsync(
  1453. /*! [in] The handle of the control point. */
  1454. UpnpClient_Handle Hnd,
  1455. /*! [in] The URL of the service. */
  1456. const char *ActionURL,
  1457. /*! [in] The name of the variable to query. */
  1458. const char *VarName,
  1459. /*! [in] Pointer to a callback function to be invoked when the operation
  1460. * is complete. */
  1461. Upnp_FunPtr Fun,
  1462. /*! [in] Pointer to user data to pass to the callback function when invoked. */
  1463. const void *Cookie);
  1464. /*!
  1465. * \brief Sends a message to change a state variable in a service.
  1466. *
  1467. * This is a synchronous call that does not return until the action is complete.
  1468. *
  1469. * Note that a positive return value indicates a SOAP-protocol error code.
  1470. * In this case, the error description can be retrieved from \b RespNode.
  1471. * A negative return value indicates an SDK error.
  1472. *
  1473. * \return An integer representing one of the following:
  1474. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1475. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1476. * point handle.
  1477. * \li \c UPNP_E_INVALID_URL: \b ActionUrl is not a valid URL.
  1478. * \li \c UPNP_E_INVALID_ACTION: This action is not valid.
  1479. * \li \c UPNP_E_INVALID_DEVICE: \b DevUDN is not a
  1480. * valid device.
  1481. * \li \c UPNP_E_INVALID_PARAM: \b ServiceType, \b Action,
  1482. * \b ActionUrl, or
  1483. * \b RespNode is not a valid pointer.
  1484. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1485. * complete this operation.
  1486. */
  1487. EXPORT_SPEC int UpnpSendAction(
  1488. /*! [in] The handle of the control point sending the action. */
  1489. UpnpClient_Handle Hnd,
  1490. /*! [in] The action URL of the service. */
  1491. const char *ActionURL,
  1492. /*! [in] The type of the service. */
  1493. const char *ServiceType,
  1494. /*! [in] This parameter is ignored and must be \c NULL. */
  1495. const char *DevUDN,
  1496. /*! [in] The DOM document for the action. */
  1497. IXML_Document *Action,
  1498. /*! [out] The DOM document for the response to the action. The SDK allocates
  1499. * this document and the caller needs to free it. */
  1500. IXML_Document **RespNode);
  1501. /*!
  1502. * \brief Sends a message to change a state variable in a service.
  1503. *
  1504. * This is a synchronous call that does not return until the action is complete.
  1505. *
  1506. * Note that a positive return value indicates a SOAP-protocol error code.
  1507. * In this case, the error description can be retrieved from \b RespNode.
  1508. * A negative return value indicates an SDK error.
  1509. *
  1510. * \return An integer representing one of the following:
  1511. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1512. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1513. * point handle.
  1514. * \li \c UPNP_E_INVALID_URL: \b ActionUrl is not a valid URL.
  1515. * \li \c UPNP_E_INVALID_ACTION: This action is not valid.
  1516. * \li \c UPNP_E_INVALID_DEVICE: \b DevUDN is not a
  1517. * valid device.
  1518. * \li \c UPNP_E_INVALID_PARAM: \b ServiceType, \b Action,
  1519. * \b ActionUrl, or
  1520. * \b RespNode is not a valid pointer.
  1521. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1522. * complete this operation.
  1523. */
  1524. EXPORT_SPEC int UpnpSendActionEx(
  1525. /*! [in] The handle of the control point sending the action. */
  1526. UpnpClient_Handle Hnd,
  1527. /*! [in] The action URL of the service. */
  1528. const char *ActionURL,
  1529. /*! [in] The type of the service. */
  1530. const char *ServiceType,
  1531. /*! [in] This parameter is ignored and must be \c NULL. */
  1532. const char *DevUDN,
  1533. /*! [in] The DOM document for the SOAP header. This may be \c NULL if the
  1534. * header is not required. */
  1535. IXML_Document *Header,
  1536. /*! [in] The DOM document for the action. */
  1537. IXML_Document *Action,
  1538. /*! [out] The DOM document for the response to the action. The SDK allocates
  1539. * this document and the caller needs to free it. */
  1540. IXML_Document **RespNode);
  1541. /*!
  1542. * \brief Sends a message to change a state variable in a service, generating a
  1543. * callback when the operation is complete.
  1544. *
  1545. * See \b UpnpSendAction for comments on positive return values. These
  1546. * positive return values are sent in the event struct associated with the
  1547. * \c UPNP_CONTROL_ACTION_COMPLETE event.
  1548. *
  1549. * \return An integer representing one of the following:
  1550. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1551. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1552. * point handle.
  1553. * \li \c UPNP_E_INVALID_URL: \b ActionUrl is an invalid URL.
  1554. * \li \c UPNP_E_INVALID_DEVICE: \b DevUDN is an invalid device.
  1555. * \li \c UPNP_E_INVALID_PARAM: Either \b Fun is not a valid
  1556. * callback function or \b ServiceType, \b Act, or
  1557. * \b ActionUrl is \c NULL.
  1558. * \li \c UPNP_E_INVALID_ACTION: This action is not valid.
  1559. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1560. * complete this operation.
  1561. */
  1562. EXPORT_SPEC int UpnpSendActionAsync(
  1563. /*! [in] The handle of the control point sending the action. */
  1564. UpnpClient_Handle Hnd,
  1565. /*! [in] The action URL of the service. */
  1566. const char *ActionURL,
  1567. /*! [in] The type of the service. */
  1568. const char *ServiceType,
  1569. /*! [in] This parameter is ignored and must be \c NULL. */
  1570. const char *DevUDN,
  1571. /*! [in] The DOM document for the action to perform on this device. */
  1572. IXML_Document *Action,
  1573. /*! [in] Pointer to a callback function to be invoked when the operation
  1574. * completes. */
  1575. Upnp_FunPtr Fun,
  1576. /*! [in] Pointer to user data that to be passed to the callback when
  1577. * invoked. */
  1578. const void *Cookie);
  1579. /*!
  1580. * \brief Sends a message to change a state variable in a service, generating a
  1581. * callback when the operation is complete.
  1582. *
  1583. * See \b UpnpSendAction for comments on positive return values. These
  1584. * positive return values are sent in the event struct associated with the
  1585. * \c UPNP_CONTROL_ACTION_COMPLETE event.
  1586. *
  1587. * \return An integer representing one of the following:
  1588. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1589. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1590. * point handle.
  1591. * \li \c UPNP_E_INVALID_URL: \b ActionUrl is an invalid URL.
  1592. * \li \c UPNP_E_INVALID_DEVICE: \b DevUDN is an invalid device.
  1593. * \li \c UPNP_E_INVALID_PARAM: Either \b Fun is not a valid
  1594. * callback function or \b ServiceType, \b Act, or
  1595. * \b ActionUrl is \c NULL.
  1596. * \li \c UPNP_E_INVALID_ACTION: This action is not valid.
  1597. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1598. * complete this operation.
  1599. */
  1600. EXPORT_SPEC int UpnpSendActionExAsync(
  1601. /*! [in] The handle of the control point sending the action. */
  1602. UpnpClient_Handle Hnd,
  1603. /*! [in] The action URL of the service. */
  1604. const char *ActionURL,
  1605. /*! [in] The type of the service. */
  1606. const char *ServiceType,
  1607. /*! [in] This parameter is ignored and must be \c NULL. */
  1608. const char *DevUDN,
  1609. /*! [in] The DOM document for the SOAP header. This may be \c NULL if the
  1610. * header is not required. */
  1611. IXML_Document *Header,
  1612. /*! [in] The DOM document for the action to perform on this device. */
  1613. IXML_Document *Action,
  1614. /*! [in] Pointer to a callback function to be invoked when the operation
  1615. * completes. */
  1616. Upnp_FunPtr Fun,
  1617. /*! [in] Pointer to user data that to be passed to the callback when
  1618. * invoked. */
  1619. const void *Cookie);
  1620. /*! @} Control */
  1621. /******************************************************************************
  1622. ******************************************************************************
  1623. * *
  1624. * E V E N T I N G *
  1625. * *
  1626. ******************************************************************************
  1627. ******************************************************************************/
  1628. /*!
  1629. * \name Eventing
  1630. *
  1631. * @{
  1632. */
  1633. /*!
  1634. * \brief Accepts a subscription request and sends out the current state of the
  1635. * eventable variables for a service.
  1636. *
  1637. * The device application should call this function when it receives a
  1638. * \c UPNP_EVENT_SUBSCRIPTION_REQUEST callback.
  1639. *
  1640. * This function is synchronous and generates no callbacks.
  1641. *
  1642. * This function can be called during the execution of a callback function.
  1643. *
  1644. * \return An integer representing one of the following:
  1645. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1646. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device
  1647. * handle.
  1648. * \li \c UPNP_E_INVALID_SERVICE: The \b DevId/\b ServId
  1649. * pair refers to an invalid service.
  1650. * \li \c UPNP_E_INVALID_SID: The specified subscription ID is not
  1651. * valid.
  1652. * \li \c UPNP_E_INVALID_PARAM: Either \b VarName,
  1653. * \b NewVal, \b DevID, or \b ServID is not a valid
  1654. * pointer or \b cVariables is less than zero.
  1655. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1656. * complete this operation.
  1657. */
  1658. EXPORT_SPEC int UpnpAcceptSubscription(
  1659. /*! [in] The handle of the device. */
  1660. UpnpDevice_Handle Hnd,
  1661. /*! [in] The device ID of the subdevice of the service generating the event. */
  1662. const char *DevID,
  1663. /*! [in] The unique service identifier of the service generating the event. */
  1664. const char *ServID,
  1665. /*! [in] Pointer to an array of event variables. */
  1666. const char **VarName,
  1667. /*! [in] Pointer to an array of values for the event variables. */
  1668. const char **NewVal,
  1669. /*! [in] The number of event variables in \b VarName. */
  1670. int cVariables,
  1671. /*! [in] The subscription ID of the newly registered control point. */
  1672. const Upnp_SID SubsId);
  1673. /*!
  1674. * \brief Similar to \b UpnpAcceptSubscription() except that it takes a DOM
  1675. * document for the variables to event rather than an array of strings.
  1676. *
  1677. * This function is sychronous and generates no callbacks.
  1678. *
  1679. * This function can be called during the execution of a callback function.
  1680. *
  1681. * \return An integer representing one of the following:
  1682. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1683. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device
  1684. * handle.
  1685. * \li \c UPNP_E_INVALID_SERVICE: The \b DevId/\b ServId
  1686. * pair refers to an invalid service.
  1687. * \li \c UPNP_E_INVALID_SID: The specified subscription ID is not
  1688. * valid.
  1689. * \li \c UPNP_E_INVALID_PARAM: Either \b VarName,
  1690. * \b NewVal, \b DevID, \b ServID, or \b PropSet
  1691. * is not a valid pointer.
  1692. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1693. * complete this operation.
  1694. */
  1695. EXPORT_SPEC int UpnpAcceptSubscriptionExt(
  1696. /*! [in] The handle of the device. */
  1697. UpnpDevice_Handle Hnd,
  1698. /*! [in] The device ID of the subdevice of the service generating the event. */
  1699. const char *DevID,
  1700. /*! [in] The unique service identifier of the service generating the event. */
  1701. const char *ServID,
  1702. /*! [in] The DOM document for the property set. Property set documents must
  1703. * conform to the XML schema defined in section 4.3 of the Universal
  1704. * Plug and Play Device Architecture specification. */
  1705. IXML_Document *PropSet,
  1706. /*! [in] The subscription ID of the newly registered control point. */
  1707. Upnp_SID SubsId);
  1708. /*!
  1709. * \brief Sends out an event change notification to all control points
  1710. * subscribed to a particular service.
  1711. *
  1712. * This function is synchronous and generates no callbacks.
  1713. *
  1714. * This function may be called during a callback function to send out a
  1715. * notification.
  1716. *
  1717. * \return An integer representing one of the following:
  1718. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1719. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device
  1720. * handle.
  1721. * \li \c UPNP_E_INVALID_SERVICE: The \b DevId/\b ServId
  1722. * pair refers to an invalid service.
  1723. * \li \c UPNP_E_INVALID_PARAM: Either \b VarName, \b NewVal,
  1724. * \b DevID, or \b ServID is not a valid pointer or
  1725. * \b cVariables is less than zero.
  1726. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1727. * complete this operation.
  1728. */
  1729. EXPORT_SPEC int UpnpNotify(
  1730. /*! [in] The handle to the device sending the event. */
  1731. UpnpDevice_Handle,
  1732. /*! [in] The device ID of the subdevice of the service generating the event. */
  1733. const char *DevID,
  1734. /*! [in] The unique identifier of the service generating the event. */
  1735. const char *ServID,
  1736. /*! [in] Pointer to an array of variables that have changed. */
  1737. const char **VarName,
  1738. /*! [in] Pointer to an array of new values for those variables. */
  1739. const char **NewVal,
  1740. /*! [in] The count of variables included in this notification. */
  1741. int cVariables);
  1742. /*!
  1743. * \brief Similar to \b UpnpNotify except that it takes a DOM document for the
  1744. * event rather than an array of strings.
  1745. *
  1746. * This function is synchronous and generates no callbacks.
  1747. *
  1748. * This function may be called during a callback function to send out a
  1749. * notification.
  1750. *
  1751. * \return An integer representing one of the following:
  1752. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1753. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device
  1754. * handle.
  1755. * \li \c UPNP_E_INVALID_SERVICE: The \b DevId/\b ServId
  1756. * pair refers to an invalid service.
  1757. * \li \c UPNP_E_INVALID_PARAM: Either \b VarName, \b NewVal,
  1758. * \b DevID, \b ServID, or \b PropSet
  1759. * is not a valid pointer or \b cVariables is less than zero.
  1760. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1761. * complete this operation.
  1762. */
  1763. EXPORT_SPEC int UpnpNotifyExt(
  1764. /*! [in] The handle to the device sending the event. */
  1765. UpnpDevice_Handle,
  1766. /*! [in] The device ID of the subdevice of the service generating the event. */
  1767. const char *DevID,
  1768. /*! [in] The unique identifier of the service generating the event. */
  1769. const char *ServID,
  1770. /*! [in] The DOM document for the property set. Property set documents must
  1771. * conform to the XML schema defined in section 4.3 of the Universal
  1772. * Plug and Play Device Architecture specification. */
  1773. IXML_Document *PropSet);
  1774. /*!
  1775. * \brief Renews a subscription that is about to expire.
  1776. *
  1777. * This function is synchronous.
  1778. *
  1779. * \return An integer representing one of the following:
  1780. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1781. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1782. * point handle.
  1783. * \li \c UPNP_E_INVALID_PARAM: \b Timeout is not a valid pointer.
  1784. * \li \c UPNP_E_INVALID_SID: The SID being passed to this function
  1785. * is not a valid subscription ID.
  1786. * \li \c UPNP_E_NETWORK_ERROR: A network error occured.
  1787. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  1788. * to a socket.
  1789. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  1790. * from a socket.
  1791. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  1792. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting to
  1793. * \b PublisherUrl.
  1794. * \li \c UPNP_E_OUTOF_SOCKET: An error occurred creating a socket.
  1795. * \li \c UPNP_E_BAD_RESPONSE: An error occurred in response from
  1796. * the publisher.
  1797. * \li \c UPNP_E_SUBSCRIBE_UNACCEPTED: The publisher refused
  1798. * the subscription renew.
  1799. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1800. * complete this operation.
  1801. */
  1802. EXPORT_SPEC int UpnpRenewSubscription(
  1803. /*! [in] The handle of the control point that is renewing the subscription. */
  1804. UpnpClient_Handle Hnd,
  1805. /*! [in,out] Pointer to a variable containing the requested subscription time.
  1806. * Upon return, it contains the actual renewal time. */
  1807. int *TimeOut,
  1808. /*! [in] The ID for the subscription to renew. */
  1809. const Upnp_SID SubsId);
  1810. /*!
  1811. * \brief Renews a subscription that is about to expire, generating a callback
  1812. * when the operation is complete.
  1813. *
  1814. * Note that many of the error codes for this function are returned in
  1815. * the \b UpnpEventSubscribe structure. In those cases, the function
  1816. * returns \c UPNP_E_SUCCESS and the appropriate error code will
  1817. * be in the <b>UpnpEventSubscribe.ErrCode</b> field in the \b Event
  1818. * structure passed to the callback.
  1819. *
  1820. * \return An integer representing one of the following:
  1821. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1822. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1823. * point handle.
  1824. * \li \c UPNP_E_INVALID_SID: The \b SubsId is not a valid
  1825. * subscription ID.
  1826. * \li \c UPNP_E_INVALID_PARAM: Either \b Fun is not a valid
  1827. * callback function pointer or \b Timeout is less than zero
  1828. * but is not \c UPNP_INFINITE.
  1829. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1830. * complete this operation.
  1831. * \li \c UPNP_E_NETWORK_ERROR: A network error occured (returned in
  1832. * the <b>UpnpEventSubscribe.ErrCode</b> field as part of the
  1833. * callback).
  1834. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  1835. * to a socket (returned in the <b>UpnpEventSubscribe.ErrCode</b>
  1836. * field as part of the callback).
  1837. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  1838. * from a socket (returned in the
  1839. * <b>UpnpEventSubscribe.ErrCode</b> field as part of the
  1840. * callback).
  1841. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding the socket
  1842. * (returned in the <b>UpnpEventSubscribe.ErrCode</b> field as
  1843. * part of the callback).
  1844. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting to
  1845. * \b PublisherUrl (returned in the \b
  1846. * UpnpEventSubscribe.ErrCode field as part of the callback).
  1847. * \li \c UPNP_E_OUTOF_SOCKET: An error occurred creating socket (
  1848. * returned in the <b>UpnpEventSubscribe.ErrCode</b> field as
  1849. * part of the callback).
  1850. * \li \c UPNP_E_BAD_RESPONSE: An error occurred in response from
  1851. * the publisher (returned in the \b
  1852. * UpnpEventSubscribe.ErrCode field as part of the callback).
  1853. * \li \c UPNP_E_SUBSCRIBE_UNACCEPTED: The publisher refused
  1854. * the subscription request (returned in the \b
  1855. * UpnpEventSubscribe.ErrCode field as part of the callback).
  1856. */
  1857. EXPORT_SPEC int UpnpRenewSubscriptionAsync(
  1858. /*! [in] The handle of the control point that is renewing the subscription. */
  1859. UpnpClient_Handle Hnd,
  1860. /*! [in] The requested subscription time. The actual timeout value is
  1861. * returned when the callback function is called. */
  1862. int TimeOut,
  1863. /*! [in] The ID for the subscription to renew. */
  1864. Upnp_SID SubsId,
  1865. /*! [in] Pointer to a callback function to be invoked when the renewal is
  1866. * complete. */
  1867. Upnp_FunPtr Fun,
  1868. /*! [in] Pointer to user data passed to the callback function when invoked. */
  1869. const void *Cookie);
  1870. /*!
  1871. * \brief Sets the maximum number of subscriptions accepted per service.
  1872. *
  1873. * The default value accepts as many as system resources allow. If the number
  1874. * of current subscriptions for a service is greater than the requested value,
  1875. * the SDK accepts no new subscriptions or renewals, however, the SDK does not
  1876. * remove any current subscriptions.
  1877. *
  1878. * \return An integer representing one of the following:
  1879. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1880. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device
  1881. * handle.
  1882. */
  1883. EXPORT_SPEC int UpnpSetMaxSubscriptions(
  1884. /*! The handle of the device for which the maximum number of
  1885. * subscriptions is being set. */
  1886. UpnpDevice_Handle Hnd,
  1887. /*! The maximum number of subscriptions to be allowed per service. */
  1888. int MaxSubscriptions);
  1889. /*!
  1890. * \brief Sets the maximum time-out accepted for a subscription request or
  1891. * renewal.
  1892. *
  1893. * The default value accepts the time-out set by the control point.
  1894. * If a control point requests a subscription time-out less than or equal to
  1895. * the maximum, the SDK grants the value requested by the control point. If the
  1896. * time-out is greater, the SDK returns the maximum value.
  1897. *
  1898. * \return An integer representing one of the following:
  1899. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1900. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device
  1901. * handle.
  1902. */
  1903. EXPORT_SPEC int UpnpSetMaxSubscriptionTimeOut(
  1904. /*! The handle of the device for which the maximum subscription
  1905. * time-out is being set. */
  1906. UpnpDevice_Handle Hnd,
  1907. /*! The maximum subscription time-out to be accepted. */
  1908. int MaxSubscriptionTimeOut);
  1909. /*!
  1910. * \brief Registers a control point to receive event notifications from another
  1911. * device.
  1912. *
  1913. * This operation is synchronous.
  1914. *
  1915. * \return An integer representing one of the following:
  1916. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1917. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1918. * point handle.
  1919. * \li \c UPNP_E_INVALID_URL: \b PublisherUrl is not a valid URL.
  1920. * \li \c UPNP_E_INVALID_PARAM: \b Timeout is not a valid pointer
  1921. * or \b SubsId or \b PublisherUrl is \c NULL.
  1922. * \li \c UPNP_E_NETWORK_ERROR: A network error occured.
  1923. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  1924. * to a socket.
  1925. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  1926. * from a socket.
  1927. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  1928. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting to
  1929. * \b PublisherUrl.
  1930. * \li \c UPNP_E_OUTOF_SOCKET: An error occurred creating a socket.
  1931. * \li \c UPNP_E_BAD_RESPONSE: An error occurred in response from
  1932. * the publisher.
  1933. * \li \c UPNP_E_SUBSCRIBE_UNACCEPTED: The publisher refused
  1934. * the subscription request.
  1935. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1936. * complete this operation.
  1937. */
  1938. EXPORT_SPEC int UpnpSubscribe(
  1939. /*! [in] The handle of the control point. */
  1940. UpnpClient_Handle Hnd,
  1941. /*! [in] The URL of the service to subscribe to. */
  1942. const char *PublisherUrl,
  1943. /*! [in,out]Pointer to a variable containing the requested subscription time.
  1944. * Upon return, it contains the actual subscription time returned from
  1945. * the service. */
  1946. int *TimeOut,
  1947. /*! [out] Pointer to a variable to receive the subscription ID (SID). */
  1948. Upnp_SID SubsId);
  1949. /*!
  1950. * \brief Performs the same operation as \b UpnpSubscribe, but returns
  1951. * immediately and calls the registered callback function when the operation
  1952. * is complete.
  1953. *
  1954. * Note that many of the error codes for this function are returned in
  1955. * the \b UpnpEventSubscribe structure. In those cases, the function
  1956. * returns \c UPNP_E_SUCCESS and the appropriate error code will
  1957. * be in the <b>UpnpEventSubscribe.ErrCode</b> field in the \b Event
  1958. * structure passed to the callback.
  1959. *
  1960. * \return An integer representing one of the following:
  1961. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  1962. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  1963. * point handle.
  1964. * \li \c UPNP_E_INVALID_URL: The \b PublisherUrl is not a valid
  1965. * URL.
  1966. * \li \c UPNP_E_INVALID_PARAM: Either \b TimeOut or \b Fun or
  1967. * \b PublisherUrl is not a valid pointer.
  1968. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  1969. * complete this operation.
  1970. * \li \c UPNP_E_NETWORK_ERROR: A network error occured (returned in
  1971. * the <b>UpnpEventSubscribe.ErrCode</b> field as part of the
  1972. * callback).
  1973. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  1974. * to a socket (returned in the
  1975. * <b>UpnpEventSubscribe.ErrCode</b> field as part of the
  1976. * callback).
  1977. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  1978. * from a socket (returned in the
  1979. * <b>UpnpEventSubscribe.ErrCode</b> field as part of the
  1980. * callback).
  1981. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding the socket
  1982. * (returned in the <b>UpnpEventSubscribe.ErrCode</b> field as
  1983. * part of the callback).
  1984. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting to
  1985. * \b PublisherUrl (returned in the \b
  1986. * UpnpEventSubscribe.ErrCode field as part of the callback).
  1987. * \li \c UPNP_E_OUTOF_SOCKET: An error occurred creating the
  1988. * socket (returned in the <b>UpnpEventSubscribe.ErrCode</b>
  1989. * field as part of the callback).
  1990. * \li \c UPNP_E_BAD_RESPONSE: An error occurred in response from
  1991. * the publisher (returned in the \b
  1992. * UpnpEventSubscribe.ErrCode field as part of the callback).
  1993. * \li \c UPNP_E_SUBSCRIBE_UNACCEPTED: The publisher refused
  1994. * the subscription request (returned in the \b
  1995. * UpnpEventSubscribe.ErrCode field as part of the callback).
  1996. */
  1997. EXPORT_SPEC int UpnpSubscribeAsync(
  1998. /*! The handle of the control point that is subscribing. */
  1999. UpnpClient_Handle Hnd,
  2000. /*! The URL of the service to subscribe to. */
  2001. const char *PublisherUrl,
  2002. /*! The requested subscription time. Upon return, it contains the actual
  2003. * subscription time returned from the service. */
  2004. int TimeOut,
  2005. /*! Pointer to the callback function for this subscribe request. */
  2006. Upnp_FunPtr Fun,
  2007. /*! A user data value passed to the callback function when invoked. */
  2008. const void *Cookie);
  2009. /*!
  2010. * \brief Removes the subscription of a control point from a service previously
  2011. * subscribed to using \b UpnpSubscribe or \b UpnpSubscribeAsync.
  2012. *
  2013. * This is a synchronous call.
  2014. *
  2015. * \return An integer representing one of the following:
  2016. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2017. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  2018. * point handle.
  2019. * \li \c UPNP_E_INVALID_SID: The \b SubsId is not a valid
  2020. * subscription ID.
  2021. * \li \c UPNP_E_NETWORK_ERROR: A network error occured.
  2022. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2023. * to a socket.
  2024. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  2025. * from a socket.
  2026. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  2027. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting to
  2028. * \b PublisherUrl.
  2029. * \li \c UPNP_E_OUTOF_SOCKET: An error ocurred creating a socket.
  2030. * \li \c UPNP_E_BAD_RESPONSE: An error occurred in response from
  2031. * the publisher.
  2032. * \li \c UPNP_E_UNSUBSCRIBE_UNACCEPTED: The publisher refused
  2033. * the unsubscribe request (the client is still unsubscribed and
  2034. * no longer receives events).
  2035. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  2036. * complete this operation.
  2037. */
  2038. EXPORT_SPEC int UpnpUnSubscribe(
  2039. /*! [in] The handle of the subscribed control point. */
  2040. UpnpClient_Handle Hnd,
  2041. /*! [in] The ID returned when the control point subscribed to the service. */
  2042. const Upnp_SID SubsId);
  2043. /*!
  2044. * \brief Removes a subscription of a control point from a service previously
  2045. * subscribed to using \b UpnpSubscribe or \b UpnpSubscribeAsync, generating
  2046. * a callback when the operation is complete.
  2047. *
  2048. * Note that many of the error codes for this function are returned in
  2049. * the \b UpnpEventSubscribe structure. In those cases, the function
  2050. * returns \c UPNP_E_SUCCESS and the appropriate error code will
  2051. * be in the <b>UpnpEventSubscribe.ErrCode</b> field in the \b Event
  2052. * structure passed to the callback.
  2053. *
  2054. * \return An integer representing one of the following:
  2055. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2056. * \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control
  2057. * point handle.
  2058. * \li \c UPNP_E_INVALID_SID: The \b SubsId is not a valid SID.
  2059. * \li \c UPNP_E_INVALID_PARAM: \b Fun is not a valid callback
  2060. * function pointer.
  2061. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  2062. * complete this operation.
  2063. * \li \c UPNP_E_NETWORK_ERROR: A network error occured (returned in
  2064. * the <b>UpnpEventSubscribe.ErrCode</b> field as part of the
  2065. * callback).
  2066. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2067. * to a socket (returned in the <b>UpnpEventSubscribe.ErrCode</b>
  2068. * field as part of the callback).
  2069. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  2070. * from a socket (returned in the
  2071. * <b>UpnpEventSubscribe.ErrCode</b> field as part of the
  2072. * callback).
  2073. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding the socket
  2074. * (returned in the <b>UpnpEventSubscribe.ErrCode</b> field as
  2075. * part of the callback).
  2076. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting to
  2077. * \b PublisherUrl (returned in the <b>UpnpEventSubscribe.ErrCode</b>
  2078. * field as part of the callback).
  2079. * \li \c UPNP_E_OUTOF_SOCKET: An error occurred creating a socket (
  2080. * returned in the <b>UpnpEventSubscribe.ErrCode</b> field as
  2081. * part of the callback).
  2082. * \li \c UPNP_E_BAD_RESPONSE: An error occurred in response from
  2083. * the publisher (returned in the <b>UpnpEventSubscribe.ErrCode</b>
  2084. * field as part of the callback).
  2085. * \li \c UPNP_E_UNSUBSCRIBE_UNACCEPTED: The publisher refused
  2086. * the subscription request (returned in the
  2087. * <b>UpnpEventSubscribe.ErrCode</b> field as part of the callback).
  2088. */
  2089. EXPORT_SPEC int UpnpUnSubscribeAsync(
  2090. /*! [in] The handle of the subscribed control point. */
  2091. UpnpClient_Handle Hnd,
  2092. /*! [in] The ID returned when the control point subscribed to the service. */
  2093. Upnp_SID SubsId,
  2094. /*! [in] Pointer to a callback function to be called when the operation is
  2095. * complete. */
  2096. Upnp_FunPtr Fun,
  2097. /*! [in] Pointer to user data to pass to the callback function when invoked. */
  2098. const void *Cookie);
  2099. /*! @} Eventing */
  2100. /******************************************************************************
  2101. ******************************************************************************
  2102. * *
  2103. * C L I E N T - A P I *
  2104. * *
  2105. ******************************************************************************
  2106. ******************************************************************************/
  2107. /*!
  2108. * \name Control Point HTTP API
  2109. *
  2110. * @{
  2111. */
  2112. /*!
  2113. * \brief Downloads a file specified in a URL.
  2114. *
  2115. * The SDK allocates the memory for \b outBuf and the application is
  2116. * responsible for freeing this memory. Note that the item is passed as a
  2117. * single buffer. Large items should not be transferred using this function.
  2118. *
  2119. * \return An integer representing one of the following:
  2120. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2121. * \li \c UPNP_E_INVALID_PARAM: Either \b url, \b outBuf
  2122. * or \b contentType is not a valid pointer.
  2123. * \li \c UPNP_E_INVALID_URL: The \b url is not a valid
  2124. * URL.
  2125. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  2126. * download this file.
  2127. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  2128. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2129. * to a socket.
  2130. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  2131. * from a socket.
  2132. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  2133. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting a
  2134. * socket.
  2135. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  2136. * allocated.
  2137. */
  2138. EXPORT_SPEC int UpnpDownloadUrlItem(
  2139. /*! [in] URL of an item to download. */
  2140. const char *url,
  2141. /*! [out] Buffer to store the downloaded item. */
  2142. char **outBuf,
  2143. /*! [out] HTTP header value content type if present. It should be at least
  2144. * \c LINE_SIZE bytes in size. */
  2145. char *contentType);
  2146. /*!
  2147. * \brief Gets a file specified in a URL.
  2148. *
  2149. * The SDK allocates the memory for \b handle and \b contentType, the
  2150. * application is responsible for freeing this memory.
  2151. *
  2152. * \return An integer representing one of the following:
  2153. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2154. * \li \c UPNP_E_INVALID_PARAM: Either \b url, \b handle,
  2155. * \b contentType, \b contentLength or \b httpStatus
  2156. * is not a valid pointer.
  2157. * \li \c UPNP_E_INVALID_URL: The \b url is not a valid
  2158. * URL.
  2159. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  2160. * download this file.
  2161. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  2162. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2163. * to a socket.
  2164. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  2165. * from a socket.
  2166. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  2167. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting a
  2168. * socket.
  2169. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  2170. * allocated.
  2171. * \li \c UPNP_E_BAD_RESPONSE: A bad response was received from the
  2172. * remote server.
  2173. */
  2174. EXPORT_SPEC int UpnpOpenHttpGet(
  2175. /*! [in] The URL of an item to get. */
  2176. const char *url,
  2177. /*! [in,out] A pointer to store the handle for this connection. */
  2178. void **handle,
  2179. /*! [in,out] A buffer to store the media type of the item. */
  2180. char **contentType,
  2181. /*! [in,out] A pointer to store the length of the item. */
  2182. int *contentLength,
  2183. /*! [in,out] The status returned on receiving a response message. */
  2184. int *httpStatus,
  2185. /*! [in] The time out value sent with the request during which a response
  2186. * is expected from the server, failing which, an error is reported
  2187. * back to the user. */
  2188. int timeout);
  2189. /*!
  2190. * \brief Gets a file specified in a URL through the specified proxy.
  2191. *
  2192. * The SDK allocates the memory for \b handle and \b contentType, the
  2193. * application is responsible for freeing this memory.
  2194. *
  2195. * \return An integer representing one of the following:
  2196. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2197. * \li \c UPNP_E_INVALID_PARAM: Either \b url, \b handle,
  2198. * \b contentType, \b contentLength or \b httpStatus
  2199. * is not a valid pointer.
  2200. * \li \c UPNP_E_INVALID_URL: The \b url is not a valid
  2201. * URL.
  2202. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  2203. * download this file.
  2204. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  2205. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2206. * to a socket.
  2207. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  2208. * from a socket.
  2209. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  2210. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting a
  2211. * socket.
  2212. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  2213. * allocated.
  2214. * \li \c UPNP_E_BAD_RESPONSE: A bad response was received from the
  2215. * remote server.
  2216. */
  2217. EXPORT_SPEC int UpnpOpenHttpGetProxy(
  2218. /*! [in] The URL of an item to get. */
  2219. const char *url,
  2220. /*! [in] The URL of the proxy. */
  2221. const char *proxy_str,
  2222. /*! [in,out] A pointer to store the handle for this connection. */
  2223. void **handle,
  2224. /*! [in,out] A buffer to store the media type of the item. */
  2225. char **contentType,
  2226. /*! [in,out] A pointer to store the length of the item. */
  2227. int *contentLength,
  2228. /*! [in,out] The status returned on receiving a response message. */
  2229. int *httpStatus,
  2230. /*! [in] The time out value sent with the request during which a response
  2231. * is expected from the server, failing which, an error is reported
  2232. * back to the user. */
  2233. int timeout);
  2234. /*!
  2235. * \brief Gets specified number of bytes from a file specified in the URL.
  2236. *
  2237. * The number of bytes is specified through a low count and a high count which
  2238. * are passed as a range of bytes for the request. The SDK allocates the memory
  2239. * for \b handle and \b contentType, the application is responsible for freeing
  2240. * this memory.
  2241. *
  2242. * \return An integer representing one of the following:
  2243. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2244. * \li \c UPNP_E_INVALID_PARAM: Either \b url, \b handle,
  2245. * \b contentType, \b contentLength or \b httpStatus
  2246. * is not a valid pointer.
  2247. * \li \c UPNP_E_INVALID_URL: The \b url is not a valid
  2248. * URL.
  2249. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  2250. * download this file.
  2251. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  2252. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2253. * to a socket.
  2254. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  2255. * from a socket.
  2256. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  2257. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting a
  2258. * socket.
  2259. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  2260. * allocated.
  2261. * \li \c UPNP_E_BAD_RESPONSE: A bad response was received from the
  2262. * remote server.
  2263. */
  2264. EXPORT_SPEC int UpnpOpenHttpGetEx(
  2265. /*! [in] The URL of the item to get. */
  2266. const char *url,
  2267. /*! [in,out] A pointer to store the handle for this connection. */
  2268. void **handle,
  2269. /*! [in,out] A buffer to store the media type of the item. */
  2270. char **contentType,
  2271. /*! [in,out] A buffer to store the length of the item. */
  2272. int *contentLength,
  2273. /*! [in,out] The status returned on receiving a response message from the remote server. */
  2274. int *httpStatus,
  2275. /*! [in] An integer value representing the low end of a range to retrieve. */
  2276. int lowRange,
  2277. /*! [in] An integer value representing the high end of a range to retrieve. */
  2278. int highRange,
  2279. /*! [in] A time out value sent with the request during which a response is
  2280. * expected from the server, failing which, an error is reported back
  2281. * to the user. */
  2282. int timeout);
  2283. /*!
  2284. * \brief Gets specified number of bytes from a file specified in a URL.
  2285. *
  2286. * \return An integer representing one of the following:
  2287. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2288. * \li \c UPNP_E_INVALID_PARAM: Either \b handle, \b buf
  2289. * or \b size is not a valid pointer.
  2290. * \li \c UPNP_E_BAD_RESPONSE: A bad response was received from the
  2291. * remote server.
  2292. * \li \c UPNP_E_BAD_HTTPMSG: Either the request or response was in
  2293. * the incorrect format.
  2294. * \li \c UPNP_E_CANCELED: another thread called UpnpCancelHttpGet.
  2295. *
  2296. * Note: In case of return values, the status code parameter of the passed
  2297. * in handle value may provide additional information on the return
  2298. * value.
  2299. */
  2300. EXPORT_SPEC int UpnpReadHttpGet(
  2301. /*! [in] The token created by the call to \b UpnpOpenHttpGet. */
  2302. void *handle,
  2303. /*! [in,out] The buffer to store the read item. */
  2304. char *buf,
  2305. /*! [in,out] The size of the buffer to be read. */
  2306. size_t *size,
  2307. /*! [in] The time out value sent with the request during which a response is
  2308. * expected from the server, failing which, an error is reported back to
  2309. * the user. */
  2310. int timeout);
  2311. /*!
  2312. * \brief Retrieve progress information of a http-get transfer.
  2313. *
  2314. * \return An integer representing one of the following:
  2315. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2316. * \li \c UPNP_E_INVALID_PARAM: Either \b handle, \b length
  2317. * or \b total is not a valid pointer.
  2318. */
  2319. EXPORT_SPEC int UpnpHttpGetProgress(
  2320. /*! [in] The token created by the call to \b UpnpOpenHttpGet. */
  2321. void *handle,
  2322. /*! [out] The number of bytes received. */
  2323. size_t *length,
  2324. /*! [out] The content length. */
  2325. size_t *total);
  2326. /*!
  2327. * \brief Set the cancel flag of the \b handle parameter.
  2328. *
  2329. * \return An integer representing one of the following:
  2330. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2331. * \li \c UPNP_E_INVALID_PARAM: \b handle is not a valid pointer.
  2332. */
  2333. EXPORT_SPEC int UpnpCancelHttpGet(
  2334. /*! [in] The handle of the connection created by the call to
  2335. * \b UpnpOpenHttpGet. */
  2336. void *handle);
  2337. /*!
  2338. * \brief Closes the connection and frees memory that was allocated for the
  2339. * \b handle parameter.
  2340. *
  2341. * \return An integer representing one of the following:
  2342. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2343. * \li \c UPNP_E_INVALID_PARAM: \b handle is not a valid pointer.
  2344. */
  2345. EXPORT_SPEC int UpnpCloseHttpGet(
  2346. /*! [in] The handle of the connection created by the call to
  2347. * \b UpnpOpenHttpGet. */
  2348. void *handle);
  2349. /*!
  2350. * \brief Makes an HTTP POST request message, opens a connection to the server
  2351. * and sends the POST request to the server if the connection to the server
  2352. * succeeds.
  2353. *
  2354. * The SDK allocates the memory for \b handle and \b contentType, the
  2355. * application is responsible for freeing this memory.
  2356. *
  2357. * \return An integer representing one of the following:
  2358. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2359. * \li \c UPNP_E_INVALID_PARAM: Either \b url, \b handle
  2360. * or \b contentType is not a valid pointer.
  2361. * \li \c UPNP_E_INVALID_URL: The \b url is not a valid
  2362. * URL.
  2363. * \li \c UPNP_E_OUTOF_MEMORY: Insufficient resources exist to
  2364. * download this file.
  2365. * \li \c UPNP_E_SOCKET_ERROR: Error occured allocating a socket and
  2366. * resources or an error occurred binding a socket.
  2367. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2368. * to a socket.
  2369. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting a
  2370. * socket.
  2371. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  2372. * allocated.
  2373. */
  2374. EXPORT_SPEC int UpnpOpenHttpPost(
  2375. /*! [in] The URL in which to send the POST request. */
  2376. const char *url,
  2377. /*! [in,out] A pointer in which to store the handle for this connection. This
  2378. * handle is required for futher operations over this connection. */
  2379. void **handle,
  2380. /*! [in] A buffer to store the media type of content being sent. */
  2381. const char *contentType,
  2382. /*! [in] The length of the content, in bytes, being posted. */
  2383. int contentLength,
  2384. /*! [in] The time out value sent with the request during which a response
  2385. * is expected from the receiver, failing which, an error is reported. */
  2386. int timeout);
  2387. /*!
  2388. * \brief Sends a request to a server to copy the contents of a buffer to the
  2389. * URI specified in the \b UpnpOpenHttpPost call.
  2390. *
  2391. * \return An integer representing one of the following:
  2392. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2393. * \li \c UPNP_E_INVALID_PARAM: Either \b handle, \b buf
  2394. * or \b size is not a valid pointer.
  2395. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2396. * to a socket.
  2397. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  2398. * allocated.
  2399. */
  2400. EXPORT_SPEC int UpnpWriteHttpPost(
  2401. /*! [in] The handle of the connection created by the call to
  2402. * \b UpnpOpenHttpPost. */
  2403. void *handle,
  2404. /*! [in] The buffer to be posted. */
  2405. char *buf,
  2406. /*! [in] The size, in bytes of \b buf. */
  2407. size_t *size,
  2408. /*! [in] A timeout value sent with the request during which a response is
  2409. * expected from the server, failing which, an error is reported. */
  2410. int timeout);
  2411. /*!
  2412. * \brief Sends and receives any pending data, closes the connection with the
  2413. * server, and frees memory allocated during the \b UpnpOpenHttpPost call.
  2414. *
  2415. * \return An integer representing one of the following:
  2416. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2417. * \li \c UPNP_E_INVALID_PARAM: Either \b handle, or
  2418. * \b httpStatus is not a valid pointer.
  2419. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  2420. * from a socket.
  2421. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  2422. * allocated.
  2423. */
  2424. EXPORT_SPEC int UpnpCloseHttpPost(
  2425. /*! [in] The handle of the connection to close, created by the call to
  2426. * \b UpnpOpenHttpPost. */
  2427. void *handle,
  2428. /*! [in,out] A pointer to a buffer to store the final status of the connection. */
  2429. int *httpStatus,
  2430. /*! [in] A time out value sent with the request during which a response is
  2431. * expected from the server, failing which, an error is reported. */
  2432. int timeout);
  2433. /*!
  2434. * \brief Downloads an XML document specified in a URL.
  2435. *
  2436. * The SDK parses the document and returns it in the form of a
  2437. * DOM document. The application is responsible for freeing the DOM document.
  2438. *
  2439. * \return An integer representing one of the following:
  2440. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2441. * \li \c UPNP_E_INVALID_PARAM: Either \b url or \b xmlDoc
  2442. * is not a valid pointer.
  2443. * \li \c UPNP_E_INVALID_DESC: The XML document was not
  2444. * found or it does not contain a valid XML description.
  2445. * \li \c UPNP_E_INVALID_URL: The \b url is not a valid
  2446. * URL.
  2447. * \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
  2448. * download the XML document.
  2449. * \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
  2450. * \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
  2451. * to a socket.
  2452. * \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
  2453. * from a socket.
  2454. * \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
  2455. * \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
  2456. * socket.
  2457. * \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
  2458. * allocated.
  2459. */
  2460. EXPORT_SPEC int UpnpDownloadXmlDoc(
  2461. /*! [in] URL of the XML document. */
  2462. const char *url,
  2463. /*! [out] A pointer in which to store the XML document. */
  2464. IXML_Document **xmlDoc);
  2465. /*! @} Control Point HTTP API */
  2466. /******************************************************************************
  2467. ******************************************************************************
  2468. * *
  2469. * W E B S E R V E R A P I *
  2470. * *
  2471. ******************************************************************************
  2472. ******************************************************************************/
  2473. /*!
  2474. * \name Web Server API
  2475. *
  2476. * @{
  2477. */
  2478. /*!
  2479. * \brief Sets the document root directory for the internal web server.
  2480. *
  2481. * This directory is considered the root directory (i.e. "/") of the web server.
  2482. *
  2483. * This function also activates or deactivates the web server. To disable the
  2484. * web server, pass \c NULL for \b rootDir; to activate, pass a valid directory
  2485. * string.
  2486. *
  2487. * \note This function is not available when the web server is not compiled
  2488. * into the UPnP Library.
  2489. *
  2490. * \return An integer representing one of the following:
  2491. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2492. * \li \c UPNP_E_INVALID_ARGUMENT: \b rootDir is an invalid directory.
  2493. */
  2494. EXPORT_SPEC int UpnpSetWebServerRootDir(
  2495. /*! [in] Path of the root directory of the web server. */
  2496. const char *rootDir);
  2497. /*!
  2498. * \brief The type of handle returned by the web server for open requests.
  2499. */
  2500. typedef void *UpnpWebFileHandle;
  2501. /*!
  2502. * \brief Get-info callback function prototype.
  2503. */
  2504. typedef int (*VDCallback_GetInfo)(
  2505. /*! [in] The name of the file to query. */
  2506. const char *filename,
  2507. /*! [out] Pointer to a structure to store the information on the file. */
  2508. struct File_Info *info);
  2509. /*!
  2510. * \brief Sets the get_info callback function to be used to access a virtual
  2511. * directory.
  2512. *
  2513. * \return An integer representing one of the following:
  2514. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2515. * \li \c UPNP_E_INVALID_ARGUMENT: \b callback is not a valid pointer.
  2516. */
  2517. EXPORT_SPEC int UpnpVirtualDir_set_GetInfoCallback(VDCallback_GetInfo callback);
  2518. /*!
  2519. * \brief Open callback function prototype.
  2520. */
  2521. typedef UpnpWebFileHandle (*VDCallback_Open)(
  2522. /*! [in] The name of the file to open. */
  2523. const char *filename,
  2524. /*! [in] The mode in which to open the file.
  2525. * Valid values are \c UPNP_READ or \c UPNP_WRITE. */
  2526. enum UpnpOpenFileMode Mode);
  2527. /*!
  2528. * \brief Sets the open callback function to be used to access a virtual
  2529. * directory.
  2530. *
  2531. * \return An integer representing one of the following:
  2532. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2533. * \li \c UPNP_E_INVALID_ARGUMENT: \b callback is not a valid pointer.
  2534. */
  2535. EXPORT_SPEC int UpnpVirtualDir_set_OpenCallback(VDCallback_Open callback);
  2536. /*!
  2537. * \brief Read callback function prototype.
  2538. */
  2539. typedef int (*VDCallback_Read)(
  2540. /*! [in] The handle of the file to read. */
  2541. UpnpWebFileHandle fileHnd,
  2542. /*! [out] The buffer in which to place the data. */
  2543. char *buf,
  2544. /*! [in] The size of the buffer (i.e. the number of bytes to read). */
  2545. size_t buflen);
  2546. /*!
  2547. * \brief Sets the read callback function to be used to access a virtual
  2548. * directory.
  2549. *
  2550. * \return An integer representing one of the following:
  2551. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2552. * \li \c UPNP_E_INVALID_ARGUMENT: \b callback is not a valid pointer.
  2553. */
  2554. EXPORT_SPEC int UpnpVirtualDir_set_ReadCallback(VDCallback_Read callback);
  2555. /*!
  2556. * \brief Write callback function prototype.
  2557. */
  2558. typedef int (*VDCallback_Write)(
  2559. /*! [in] The handle of the file to write. */
  2560. UpnpWebFileHandle fileHnd,
  2561. /*! [in] The buffer with the bytes to write. */
  2562. char *buf,
  2563. /*! [in] The number of bytes to write. */
  2564. size_t buflen);
  2565. /*!
  2566. * \brief Sets the write callback function to be used to access a virtual
  2567. * directory.
  2568. *
  2569. * \return An integer representing one of the following:
  2570. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2571. * \li \c UPNP_E_INVALID_ARGUMENT: \b callback is not a valid pointer.
  2572. */
  2573. EXPORT_SPEC int UpnpVirtualDir_set_WriteCallback(VDCallback_Write callback);
  2574. /*!
  2575. * \brief Seek callback function prototype.
  2576. */
  2577. typedef int (*VDCallback_Seek) (
  2578. /*! [in] The handle of the file to move the file pointer. */
  2579. UpnpWebFileHandle fileHnd,
  2580. /*! [in] The number of bytes to move in the file. Positive values
  2581. * move foward and negative values move backward. Note that
  2582. * this must be positive if the \b origin is \c SEEK_SET. */
  2583. off_t offset,
  2584. /*! [in] The position to move relative to. It can be \c SEEK_CUR
  2585. * to move relative to the current position, \c SEEK_END to
  2586. * move relative to the end of the file, or \c SEEK_SET to
  2587. * specify an absolute offset. */
  2588. int origin);
  2589. /*!
  2590. * \brief Sets the seek callback function to be used to access a virtual
  2591. * directory.
  2592. *
  2593. * \return An integer representing one of the following:
  2594. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2595. * \li \c UPNP_E_INVALID_ARGUMENT: \b callback is not a valid pointer.
  2596. */
  2597. EXPORT_SPEC int UpnpVirtualDir_set_SeekCallback(VDCallback_Seek callback);
  2598. /*!
  2599. * \brief Close callback function prototype.
  2600. */
  2601. typedef int (*VDCallback_Close)(
  2602. /*! [in] The handle of the file to close. */
  2603. UpnpWebFileHandle fileHnd);
  2604. /*!
  2605. * \brief Sets the close callback function to be used to access a virtual
  2606. * directory.
  2607. *
  2608. * \return An integer representing one of the following:
  2609. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2610. * \li \c UPNP_E_INVALID_ARGUMENT: \b callback is not a valid pointer.
  2611. */
  2612. EXPORT_SPEC int UpnpVirtualDir_set_CloseCallback(VDCallback_Close callback);
  2613. /*!
  2614. * \brief The {\bf UpnpVirtualDirCallbacks} structure contains the pointers to
  2615. * file-related callback functions a device application can register to
  2616. * virtualize URLs.
  2617. */
  2618. struct UpnpVirtualDirCallbacks
  2619. {
  2620. VDCallback_GetInfo get_info;
  2621. VDCallback_Open open;
  2622. VDCallback_Read read;
  2623. VDCallback_Write write;
  2624. VDCallback_Seek seek;
  2625. VDCallback_Close close;
  2626. };
  2627. /*!
  2628. * \brief Enables or disables the webserver.
  2629. *
  2630. * \return An integer representing one of the following:
  2631. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2632. * \li \c UPNP_E_INVALID_ARGUMENT: \b enable is not valid.
  2633. */
  2634. EXPORT_SPEC int UpnpEnableWebserver(
  2635. /*! [in] \c TRUE to enable, \c FALSE to disable. */
  2636. int enable);
  2637. /*!
  2638. * \brief Returns \c TRUE if the webserver is enabled, or \c FALSE if it is not.
  2639. *
  2640. * \return An integer representing one of the following:
  2641. * \li \c TRUE: The webserver is enabled.
  2642. * \li \c FALSE: The webserver is not enabled
  2643. */
  2644. EXPORT_SPEC int UpnpIsWebserverEnabled(void);
  2645. /*!
  2646. * \brief Sets the callback functions to be used to access a virtual directory.
  2647. *
  2648. * \return An integer representing one of the following:
  2649. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2650. * \li \c UPNP_E_INVALID_PARAM: one of the callbacks is not valid.
  2651. */
  2652. EXPORT_SPEC int UpnpSetVirtualDirCallbacks(
  2653. /*! [in] A structure that contains the callback functions. */
  2654. struct UpnpVirtualDirCallbacks *callbacks );
  2655. /*!
  2656. * \brief Adds a virtual directory mapping.
  2657. *
  2658. * All webserver requests containing the given directory are read using
  2659. * functions contained in a \b VirtualDirCallbacks structure registered
  2660. * via \b UpnpSetVirtualDirCallbacks.
  2661. *
  2662. * \note This function is not available when the web server is not
  2663. * compiled into the UPnP Library.
  2664. *
  2665. * \return An integer representing one of the following:
  2666. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2667. * \li \c UPNP_E_INVALID_ARGUMENT: \b dirName is not valid.
  2668. */
  2669. EXPORT_SPEC int UpnpAddVirtualDir(
  2670. /*! [in] The name of the new directory mapping to add. */
  2671. const char *dirName);
  2672. /*!
  2673. * \brief Removes a virtual directory mapping made with \b UpnpAddVirtualDir.
  2674. *
  2675. * \return An integer representing one of the following:
  2676. * \li \c UPNP_E_SUCCESS: The operation completed successfully.
  2677. * \li \c UPNP_E_INVALID_ARGUMENT: \b dirName is not valid.
  2678. */
  2679. EXPORT_SPEC int UpnpRemoveVirtualDir(
  2680. /*! [in] The name of the virtual directory mapping to remove. */
  2681. const char *dirName);
  2682. /*!
  2683. * \brief Removes all virtual directory mappings.
  2684. */
  2685. EXPORT_SPEC void UpnpRemoveAllVirtualDirs(void);
  2686. /* @} Web Server API */
  2687. #ifdef __cplusplus
  2688. }
  2689. #endif /* __cplusplus */
  2690. /* @} UPnPAPI UPnP API */
  2691. #endif /* UPNP_H */