1 ///////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000-2003 Intel Corporation
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 // * Neither name of Intel Corporation nor the names of its contributors
15 // may be used to endorse or promote products derived from this software
16 // without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 ///////////////////////////////////////////////////////////////////////////
32 // Modified by Angel Vidal Veiga (kry@amule.org) for the aMule project.
33 // Really crippled version of the original header. Keep just what we need.
41 #include <sys/types.h>
42 #include <netinet/in.h>
50 /// @name Constants, Structures, and Types
53 /** @name UPNP_E_SUCCESS [0]
54 * {\tt UPNP_E_SUCCESS} signifies that the operation completed successfully.
55 * For asynchronous functions, this only means that the packet generated by
56 * the operation was successfully transmitted on the network. The result of
57 * the entire operation comes as part of the callback for that operation.
60 #define UPNP_E_SUCCESS 0
63 /** Returned when a control point application registers with {\bf
64 * UpnpRegisterClient}. Client handles can only be used with
65 * functions that operate with a client handle. */
67 typedef int UpnpClient_Handle
;
69 /** @name UPnP_EventType
70 @memo The reason code for an event callback.
71 @doc The {\bf Event} parameter will be different depending on the
72 reason for the callback. The descriptions for each event
73 type describe the contents of the {\bf Event} parameter.
76 enum Upnp_EventType_e
{
82 /** Received by a device when a control point issues a control
83 * request. The {\bf Event} parameter contains a pointer to a {\bf
84 * Upnp_Action_Request} structure containing the action. The application
85 * stores the results of the action in this structure. */
87 UPNP_CONTROL_ACTION_REQUEST
,
89 /** A {\bf UpnpSendActionAsync} call completed. The {\bf Event}
90 * parameter contains a pointer to a {\bf Upnp_Action_Complete} structure
91 * with the results of the action. */
93 UPNP_CONTROL_ACTION_COMPLETE
,
95 /** Received by a device when a query for a single service variable
96 * arrives. The {\bf Event} parameter contains a pointer to a {\bf
97 * Upnp_State_Var_Request} structure containing the name of the variable
100 UPNP_CONTROL_GET_VAR_REQUEST
,
102 /** A {\bf UpnpGetServiceVarStatus} call completed. The {\bf Event}
103 * parameter contains a pointer to a {\bf Upnp_State_Var_Complete} structure
104 * containing the value for the variable. */
106 UPNP_CONTROL_GET_VAR_COMPLETE
,
109 // Discovery callbacks
112 /** Received by a control point when a new device or service is available.
113 * The {\bf Event} parameter contains a pointer to a {\bf
114 * Upnp_Discovery} structure with the information about the device
117 UPNP_DISCOVERY_ADVERTISEMENT_ALIVE
,
119 /** Received by a control point when a device or service shuts down. The {\bf
120 * Event} parameter contains a pointer to a {\bf Upnp_Discovery}
121 * structure containing the information about the device or
124 UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE
,
126 /** Received by a control point when a matching device or service responds.
127 * The {\bf Event} parameter contains a pointer to a {\bf
128 * Upnp_Discovery} structure containing the information about
129 * the reply to the search request. */
131 UPNP_DISCOVERY_SEARCH_RESULT
,
133 /** Received by a control point when the search timeout expires. The
134 * SDK generates no more callbacks for this search after this
135 * event. The {\bf Event} parameter is {\tt NULL}. */
137 UPNP_DISCOVERY_SEARCH_TIMEOUT
,
140 // Eventing callbacks
143 /** Received by a device when a subscription arrives.
144 * The {\bf Event} parameter contains a pointer to a {\bf
145 * Upnp_Subscription_Request} structure. At this point, the
146 * subscription has already been accepted. {\bf UpnpAcceptSubscription}
147 * needs to be called to confirm the subscription and transmit the
148 * initial state table. This can be done during this callback. The SDK
149 * generates no events for a subscription unless the device
150 * application calls {\bf UpnpAcceptSubscription}.
153 UPNP_EVENT_SUBSCRIPTION_REQUEST
,
155 /** Received by a control point when an event arrives. The {\bf
156 * Event} parameter contains a {\bf Upnp_Event} structure
157 * with the information about the event. */
161 /** A {\bf UpnpRenewSubscriptionAsync} call completed. The status of
162 * the renewal is in the {\bf Event} parameter as a {\bf
163 * Upnp_Event_Subscription} structure. */
165 UPNP_EVENT_RENEWAL_COMPLETE
,
167 /** A {\bf UpnpSubscribeAsync} call completed. The status of the
168 * subscription is in the {\bf Event} parameter as a {\bf
169 * Upnp_Event_Subscription} structure. */
171 UPNP_EVENT_SUBSCRIBE_COMPLETE
,
173 /** A {\bf UpnpUnSubscribeAsync} call completed. The status of the
174 * subscription is in the {\bf Event} parameter as a {\bf
175 * Upnp_Event_Subscribe} structure. */
177 UPNP_EVENT_UNSUBSCRIBE_COMPLETE
,
179 /** The auto-renewal of a client subscription failed.
180 * The {\bf Event} parameter is a {\bf Upnp_Event_Subscribe} structure
181 * with the error code set appropriately. The subscription is no longer
184 UPNP_EVENT_AUTORENEWAL_FAILED
,
186 /** A client subscription has expired. This will only occur
187 * if auto-renewal of subscriptions is disabled.
188 * The {\bf Event} parameter is a {\bf Upnp_Event_Subscribe}
189 * structure. The subscription is no longer valid. */
191 UPNP_EVENT_SUBSCRIPTION_EXPIRED
195 typedef enum Upnp_EventType_e Upnp_EventType
;
197 /** The {\bf Upnp_SID} holds the subscription identifier for a subscription
198 between a client and a device. The SID is a string representation of
199 a globally unique id (GUID) and should not be modified.
202 typedef char Upnp_SID
[44];
204 /** All callback functions share the same prototype, documented below.
205 * Note that any memory passed to the callback function
206 * is valid only during the callback and should be copied if it
207 * needs to persist. This callback function needs to be thread
208 * safe. The context of the callback is always on a valid thread
209 * context and standard synchronization methods can be used. Note,
210 * however, because of this the callback cannot call SDK functions
211 * unless explicitly noted.
214 int CallbackFxn( Upnp_EventType EventType, void* Event, void* Cookie );
217 * where {\bf EventType} is the event that triggered the callback,
218 * {\bf Event} is a structure that denotes event-specific information for that
219 * event, and {\bf Cookie} is the user data passed when the callback was
222 * See {\bf Upnp_EventType} for more information on the callback values and
223 * the associated {\bf Event} parameter.
225 * The return value of the callback is currently ignored. It may be used
226 * in the future to communicate results back to the SDK.
229 typedef int (*Upnp_FunPtr
) (
230 IN Upnp_EventType EventType
,
236 // This typedef is required by Doc++ to parse the last entry of the
237 // Upnp_Discovery structure correctly.
240 struct Upnp_Discovery
242 /** The result code of the {\bf UpnpSearchAsync} call. */
245 /** The expiration time of the advertisement. */
248 /** The unique device identifier. */
249 char DeviceId
[LINE_SIZE
];
251 /** The device type. */
252 char DeviceType
[LINE_SIZE
];
254 /** The service type. */
255 char ServiceType
[LINE_SIZE
];
257 /** The service version. */
258 char ServiceVer
[LINE_SIZE
];
260 /** The URL to the UPnP description document for the device. */
261 char Location
[LINE_SIZE
];
263 /** The operating system the device is running. */
266 /** Date when the response was generated. */
267 char Date
[LINE_SIZE
];
269 /** Confirmation that the MAN header was understood by the device. */
272 /** The host address of the device responding to the search. */
273 struct sockaddr_in DestAddr
;
276 struct Upnp_Action_Complete
278 /** The result of the operation. */
281 /** The control URL for service. */
282 char CtrlUrl
[NAME_SIZE
];
284 /** The DOM document describing the action. */
285 IXML_Document
*ActionRequest
;
287 /** The DOM document describing the result of the action. */
288 IXML_Document
*ActionResult
;
291 /** Represents the reply for the current value of a state variable in an
292 asynchronous call. */
294 struct Upnp_State_Var_Complete
296 /** The result of the operation. */
299 /** The control URL for the service. */
300 char CtrlUrl
[NAME_SIZE
];
302 /** The name of the variable. */
303 char StateVarName
[NAME_SIZE
];
305 /** The current value of the variable or error string in case of error. */
306 DOMString CurrentVal
;
309 /** Returned along with a {\bf UPNP_EVENT_RECEIVED} callback. */
313 /** The subscription ID for this subscription. */
316 /** The event sequence number. */
319 /** The DOM tree representing the changes generating the event. */
320 IXML_Document
*ChangedVariables
;
324 /** Returned along with a {\bf UPNP_EVENT_SUBSCRIBE_COMPLETE} or {\bf
325 * UPNP_EVENT_UNSUBSCRIBE_COMPLETE} callback. */
327 struct Upnp_Event_Subscribe
{
329 /** The SID for this subscription. For subscriptions, this only
330 * contains a valid SID if the {\bf Upnp_EventSubscribe.result} field
331 * contains a {\tt UPNP_E_SUCCESS} result code. For unsubscriptions,
332 * this contains the SID from which the subscription is being
337 /** The result of the operation. */
340 /** The event URL being subscribed to or removed from. */
341 char PublisherUrl
[NAME_SIZE
];
343 /** The actual subscription time (for subscriptions only). */
348 //@} // Constants, Structures, and Types
352 // File_checked_for_headers