|
1 /* |
|
2 Copyright (c) 2007, Adobe Systems, Incorporated |
|
3 Copyright (c) 2013, Mozilla |
|
4 |
|
5 All rights reserved. |
|
6 |
|
7 Redistribution and use in source and binary forms, with or without |
|
8 modification, are permitted provided that the following conditions are |
|
9 met: |
|
10 |
|
11 * Redistributions of source code must retain the above copyright |
|
12 notice, this list of conditions and the following disclaimer. |
|
13 |
|
14 * Redistributions in binary form must reproduce the above copyright |
|
15 notice, this list of conditions and the following disclaimer in the |
|
16 documentation and/or other materials provided with the distribution. |
|
17 |
|
18 * Neither the name of Adobe Systems, Network Resonance, Mozilla nor |
|
19 the names of its contributors may be used to endorse or promote |
|
20 products derived from this software without specific prior written |
|
21 permission. |
|
22 |
|
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
24 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
26 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
27 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
28 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
29 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
30 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
31 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
33 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
34 */ |
|
35 |
|
36 #ifndef _nr_resolver_h |
|
37 #define _nr_resolver_h |
|
38 |
|
39 #include "transport_addr.h" |
|
40 |
|
41 #define NR_RESOLVE_PROTOCOL_STUN 1 |
|
42 #define NR_RESOLVE_PROTOCOL_TURN 2 |
|
43 |
|
44 typedef struct nr_resolver_resource_ { |
|
45 char *domain_name; |
|
46 UINT2 port; |
|
47 int stun_turn; |
|
48 UCHAR transport_protocol; |
|
49 } nr_resolver_resource; |
|
50 |
|
51 typedef struct nr_resolver_vtbl_ { |
|
52 int (*destroy)(void **obj); |
|
53 int (*resolve)(void *obj, |
|
54 nr_resolver_resource *resource, |
|
55 int (*cb)(void *cb_arg, nr_transport_addr *addr), |
|
56 void *cb_arg, |
|
57 void **handle); |
|
58 int (*cancel)(void *obj, void *handle); |
|
59 } nr_resolver_vtbl; |
|
60 |
|
61 typedef struct nr_resolver_ { |
|
62 void *obj; |
|
63 nr_resolver_vtbl *vtbl; |
|
64 } nr_resolver; |
|
65 |
|
66 |
|
67 /* |
|
68 The convention here is that the provider of this interface |
|
69 must generate a void *obj, and a vtbl and then call |
|
70 nr_resolver_create_int() to allocate the generic wrapper |
|
71 object. |
|
72 |
|
73 The vtbl must contain implementations for all the functions |
|
74 listed. |
|
75 |
|
76 The nr_resolver_destroy() function (and hence vtbl->destroy) |
|
77 will be called when the consumer of the resolver is done |
|
78 with it. That is the signal that it is safe to clean up |
|
79 the resources associated with obj. No other function will |
|
80 be called afterwards. |
|
81 */ |
|
82 int nr_resolver_create_int(void *obj, nr_resolver_vtbl *vtbl, |
|
83 nr_resolver **resolverp); |
|
84 int nr_resolver_destroy(nr_resolver **resolverp); |
|
85 |
|
86 /* Request resolution of a domain */ |
|
87 int nr_resolver_resolve(nr_resolver *resolver, |
|
88 nr_resolver_resource *resource, |
|
89 int (*cb)(void *cb_arg, nr_transport_addr *addr), |
|
90 void *cb_arg, |
|
91 void **handle); |
|
92 |
|
93 /* Cancel a requested resolution. No callback will fire. */ |
|
94 int nr_resolver_cancel(nr_resolver *resolver, void *handle); |
|
95 #endif |