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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/mtransport/third_party/nICEr/src/net/nr_resolver.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +/*
     1.5 +Copyright (c) 2007, Adobe Systems, Incorporated
     1.6 +Copyright (c) 2013, Mozilla
     1.7 +
     1.8 +All rights reserved.
     1.9 +
    1.10 +Redistribution and use in source and binary forms, with or without
    1.11 +modification, are permitted provided that the following conditions are
    1.12 +met:
    1.13 +
    1.14 +* Redistributions of source code must retain the above copyright
    1.15 +  notice, this list of conditions and the following disclaimer.
    1.16 +
    1.17 +* Redistributions in binary form must reproduce the above copyright
    1.18 +  notice, this list of conditions and the following disclaimer in the
    1.19 +  documentation and/or other materials provided with the distribution.
    1.20 +
    1.21 +* Neither the name of Adobe Systems, Network Resonance, Mozilla nor
    1.22 +  the names of its contributors may be used to endorse or promote
    1.23 +  products derived from this software without specific prior written
    1.24 +  permission.
    1.25 +
    1.26 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.27 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.28 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.29 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    1.30 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.31 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.32 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.33 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.34 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.35 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.36 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.37 +*/
    1.38 +
    1.39 +#ifndef _nr_resolver_h
    1.40 +#define _nr_resolver_h
    1.41 +
    1.42 +#include "transport_addr.h"
    1.43 +
    1.44 +#define NR_RESOLVE_PROTOCOL_STUN 1
    1.45 +#define NR_RESOLVE_PROTOCOL_TURN 2
    1.46 +
    1.47 +typedef struct nr_resolver_resource_ {
    1.48 +  char *domain_name;
    1.49 +  UINT2 port;
    1.50 +  int stun_turn;
    1.51 +  UCHAR transport_protocol;
    1.52 +} nr_resolver_resource;
    1.53 +
    1.54 +typedef struct nr_resolver_vtbl_ {
    1.55 +  int (*destroy)(void **obj);
    1.56 +  int (*resolve)(void *obj,
    1.57 +                 nr_resolver_resource *resource,
    1.58 +                 int (*cb)(void *cb_arg, nr_transport_addr *addr),
    1.59 +                 void *cb_arg,
    1.60 +                 void **handle);
    1.61 +  int (*cancel)(void *obj, void *handle);
    1.62 +} nr_resolver_vtbl;
    1.63 +
    1.64 +typedef struct nr_resolver_ {
    1.65 +  void *obj;
    1.66 +  nr_resolver_vtbl *vtbl;
    1.67 +} nr_resolver;
    1.68 +
    1.69 +
    1.70 +/*
    1.71 +  The convention here is that the provider of this interface
    1.72 +  must generate a void *obj, and a vtbl and then call
    1.73 +  nr_resolver_create_int() to allocate the generic wrapper
    1.74 +  object.
    1.75 +
    1.76 +  The vtbl must contain implementations for all the functions
    1.77 +  listed.
    1.78 +
    1.79 +  The nr_resolver_destroy() function (and hence vtbl->destroy)
    1.80 +  will be called when the consumer of the resolver is done
    1.81 +  with it. That is the signal that it is safe to clean up
    1.82 +  the resources associated with obj. No other function will
    1.83 +  be called afterwards.
    1.84 +*/
    1.85 +int nr_resolver_create_int(void *obj, nr_resolver_vtbl *vtbl,
    1.86 +                           nr_resolver **resolverp);
    1.87 +int nr_resolver_destroy(nr_resolver **resolverp);
    1.88 +
    1.89 +/* Request resolution of a domain */
    1.90 +int nr_resolver_resolve(nr_resolver *resolver,
    1.91 +                        nr_resolver_resource *resource,
    1.92 +                        int (*cb)(void *cb_arg, nr_transport_addr *addr),
    1.93 +                        void *cb_arg,
    1.94 +                        void **handle);
    1.95 +
    1.96 +/* Cancel a requested resolution. No callback will fire. */
    1.97 +int nr_resolver_cancel(nr_resolver *resolver, void *handle);
    1.98 +#endif

mercurial