media/mtransport/third_party/nICEr/src/ice/ice_candidate.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /*
michael@0 2 Copyright (c) 2007, Adobe Systems, Incorporated
michael@0 3 All rights reserved.
michael@0 4
michael@0 5 Redistribution and use in source and binary forms, with or without
michael@0 6 modification, are permitted provided that the following conditions are
michael@0 7 met:
michael@0 8
michael@0 9 * Redistributions of source code must retain the above copyright
michael@0 10 notice, this list of conditions and the following disclaimer.
michael@0 11
michael@0 12 * Redistributions in binary form must reproduce the above copyright
michael@0 13 notice, this list of conditions and the following disclaimer in the
michael@0 14 documentation and/or other materials provided with the distribution.
michael@0 15
michael@0 16 * Neither the name of Adobe Systems, Network Resonance nor the names of its
michael@0 17 contributors may be used to endorse or promote products derived from
michael@0 18 this software without specific prior written permission.
michael@0 19
michael@0 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 31 */
michael@0 32
michael@0 33
michael@0 34
michael@0 35 #ifndef _ice_candidate_h
michael@0 36 #define _ice_candidate_h
michael@0 37 #ifdef __cplusplus
michael@0 38 using namespace std;
michael@0 39 extern "C" {
michael@0 40 #endif /* __cplusplus */
michael@0 41
michael@0 42 typedef enum {HOST=1, SERVER_REFLEXIVE, PEER_REFLEXIVE, RELAYED, CTYPE_MAX} nr_ice_candidate_type;
michael@0 43
michael@0 44 struct nr_ice_candidate_ {
michael@0 45 char *label;
michael@0 46 char codeword[5];
michael@0 47 int state;
michael@0 48 #define NR_ICE_CAND_STATE_CREATED 1
michael@0 49 #define NR_ICE_CAND_STATE_INITIALIZING 2
michael@0 50 #define NR_ICE_CAND_STATE_INITIALIZED 3
michael@0 51 #define NR_ICE_CAND_STATE_FAILED 4
michael@0 52 #define NR_ICE_CAND_PEER_CANDIDATE_UNPAIRED 9
michael@0 53 #define NR_ICE_CAND_PEER_CANDIDATE_PAIRED 10
michael@0 54 struct nr_ice_ctx_ *ctx;
michael@0 55 nr_ice_socket *isock; /* The socket to read from
michael@0 56 (it contains all other candidates
michael@0 57 on this socket) */
michael@0 58 nr_socket *osock; /* The socket to write to */
michael@0 59 nr_ice_media_stream *stream; /* The media stream this is associated with */
michael@0 60 nr_ice_component *component; /* The component this is associated with */
michael@0 61 nr_ice_candidate_type type; /* The type of the candidate (S 4.1.1) */
michael@0 62 UCHAR component_id; /* The component id (S 4.1.2.1) */
michael@0 63 nr_transport_addr addr; /* The advertised address;
michael@0 64 JDR calls this the candidate */
michael@0 65 nr_transport_addr base; /* The base address (S 2.1)*/
michael@0 66 char *foundation; /* Foundation for the candidate (S 4) */
michael@0 67 UINT4 priority; /* The priority value (S 5.4 */
michael@0 68 nr_ice_stun_server *stun_server;
michael@0 69 nr_transport_addr stun_server_addr; /* Resolved STUN server address */
michael@0 70 void *delay_timer;
michael@0 71 void *resolver_handle;
michael@0 72
michael@0 73 /* Holding data for STUN and TURN */
michael@0 74 union {
michael@0 75 struct {
michael@0 76 nr_stun_client_ctx *stun;
michael@0 77 void *stun_handle;
michael@0 78 } srvrflx;
michael@0 79 struct {
michael@0 80 nr_turn_client_ctx *turn;
michael@0 81 nr_ice_turn_server *server;
michael@0 82 nr_ice_candidate *srvflx_candidate;
michael@0 83 nr_socket *turn_sock;
michael@0 84 void *turn_handle;
michael@0 85 } relayed;
michael@0 86 } u;
michael@0 87
michael@0 88 NR_async_cb done_cb;
michael@0 89 void *cb_arg;
michael@0 90
michael@0 91 NR_async_cb ready_cb;
michael@0 92 void *ready_cb_arg;
michael@0 93 void *ready_cb_timer;
michael@0 94
michael@0 95 TAILQ_ENTRY(nr_ice_candidate_) entry_sock;
michael@0 96 TAILQ_ENTRY(nr_ice_candidate_) entry_comp;
michael@0 97 };
michael@0 98
michael@0 99 extern char *nr_ice_candidate_type_names[];
michael@0 100
michael@0 101
michael@0 102 int nr_ice_candidate_create(struct nr_ice_ctx_ *ctx,nr_ice_component *component, nr_ice_socket *isock, nr_socket *osock, nr_ice_candidate_type ctype, nr_ice_stun_server *stun_server, UCHAR component_id, nr_ice_candidate **candp);
michael@0 103 int nr_ice_candidate_initialize(nr_ice_candidate *cand, NR_async_cb ready_cb, void *cb_arg);
michael@0 104 void nr_ice_candidate_compute_codeword(nr_ice_candidate *cand);
michael@0 105 int nr_ice_candidate_process_stun(nr_ice_candidate *cand, UCHAR *msg, int len, nr_transport_addr *faddr);
michael@0 106 int nr_ice_candidate_destroy(nr_ice_candidate **candp);
michael@0 107 void nr_ice_candidate_destroy_cb(NR_SOCKET s, int h, void *cb_arg);
michael@0 108 int nr_ice_format_candidate_attribute(nr_ice_candidate *cand, char *attr, int maxlen);
michael@0 109 int nr_ice_peer_candidate_from_attribute(nr_ice_ctx *ctx,char *attr,nr_ice_media_stream *stream,nr_ice_candidate **candp);
michael@0 110 int nr_ice_peer_peer_rflx_candidate_create(nr_ice_ctx *ctx,char *label, nr_ice_component *comp,nr_transport_addr *addr, nr_ice_candidate **candp);
michael@0 111 int nr_ice_candidate_compute_priority(nr_ice_candidate *cand);
michael@0 112
michael@0 113 #ifdef __cplusplus
michael@0 114 }
michael@0 115 #endif /* __cplusplus */
michael@0 116 #endif
michael@0 117

mercurial