media/mtransport/third_party/nICEr/src/net/nr_resolver.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2 Copyright (c) 2007, Adobe Systems, Incorporated
     3 Copyright (c) 2013, Mozilla
     5 All rights reserved.
     7 Redistribution and use in source and binary forms, with or without
     8 modification, are permitted provided that the following conditions are
     9 met:
    11 * Redistributions of source code must retain the above copyright
    12   notice, this list of conditions and the following disclaimer.
    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.
    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.
    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 */
    36 #ifndef _nr_resolver_h
    37 #define _nr_resolver_h
    39 #include "transport_addr.h"
    41 #define NR_RESOLVE_PROTOCOL_STUN 1
    42 #define NR_RESOLVE_PROTOCOL_TURN 2
    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;
    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;
    61 typedef struct nr_resolver_ {
    62   void *obj;
    63   nr_resolver_vtbl *vtbl;
    64 } nr_resolver;
    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.
    73   The vtbl must contain implementations for all the functions
    74   listed.
    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);
    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);
    93 /* Cancel a requested resolution. No callback will fire. */
    94 int nr_resolver_cancel(nr_resolver *resolver, void *handle);
    95 #endif

mercurial