discovery.h 4.95 KB
Newer Older
1 2 3
/*
 * This file is part of the Nice GLib ICE library.
 *
4 5 6
 * (C) 2008-2009 Collabora Ltd.
 *  Contact: Youness Alaoui
 * (C) 2007-2009 Nokia Corporation. All rights reserved.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *  Contact: Kai Vehmanen
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is the Nice GLib ICE library.
 *
 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
 * Corporation. All Rights Reserved.
 *
 * Contributors:
25
 *   Youness Alaoui, Collabora Ltd.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
 *   Kai Vehmanen, Nokia
 *
 * Alternatively, the contents of this file may be used under the terms of the
 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
 * case the provisions of LGPL are applicable instead of those above. If you
 * wish to allow use of your version of this file only under the terms of the
 * LGPL and not to allow others to use your version of this file under the
 * MPL, indicate your decision by deleting the provisions above and replace
 * them with the notice and other provisions required by the LGPL. If you do
 * not delete the provisions above, a recipient may use your version of this
 * file under either the MPL or the LGPL.
 */

#ifndef _NICE_DISCOVERY_H
#define _NICE_DISCOVERY_H

/* note: this is a private header to libnice */

44
#include "stream.h"
45 46
#include "agent.h"

47
typedef struct
48
{
49 50 51 52 53 54 55
  NiceAgent *agent;         /* back pointer to owner */
  NiceCandidateType type;   /* candidate type STUN or TURN */
  NiceSocket *nicesock;  /* XXX: should be taken from local cand: existing socket to use */
  NiceAddress server;       /* STUN/TURN server address */
  GTimeVal next_tick;       /* next tick timestamp */
  gboolean pending;         /* is discovery in progress? */
  gboolean done;            /* is discovery complete? */
56
  NiceStream *stream;
57
  NiceComponent *component;
58
  TurnServer *turn;
59
  StunAgent stun_agent;
60
  StunTimer timer;
61
  uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE_IPV6];
62
  StunMessage stun_message;
63
  uint8_t stun_resp_buffer[STUN_MAX_MESSAGE_SIZE];
64
  StunMessage stun_resp_msg;
65
} CandidateDiscovery;
66

67 68
typedef struct
{
69 70 71 72
  NiceAgent *agent;         /* back pointer to owner */
  NiceSocket *nicesock;     /* existing socket to use */
  NiceAddress server;       /* STUN/TURN server address */
  NiceCandidate *candidate; /* candidate to refresh */
73
  NiceStream *stream;
74
  NiceComponent *component;
75
  StunAgent stun_agent;
76 77
  GSource *timer_source;
  GSource *tick_source;
78
  StunTimer timer;
79
  uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE_IPV6];
80 81 82 83 84 85 86
  StunMessage stun_message;
  uint8_t stun_resp_buffer[STUN_MAX_MESSAGE_SIZE];
  StunMessage stun_resp_msg;
} CandidateRefresh;

void refresh_free (NiceAgent *agent);
void refresh_prune_stream (NiceAgent *agent, guint stream_id);
87
void refresh_prune_candidate (NiceAgent *agent, NiceCandidate *candidate);
88
void refresh_prune_socket (NiceAgent *agent, NiceSocket *sock);
89 90 91
void refresh_cancel (CandidateRefresh *refresh);


92
void discovery_free (NiceAgent *agent);
93
void discovery_prune_stream (NiceAgent *agent, guint stream_id);
94
void discovery_prune_socket (NiceAgent *agent, NiceSocket *sock);
95 96
void discovery_schedule (NiceAgent *agent);

97 98 99 100 101 102 103 104
typedef enum {
  HOST_CANDIDATE_SUCCESS,
  HOST_CANDIDATE_FAILED,
  HOST_CANDIDATE_CANT_CREATE_SOCKET,
  HOST_CANDIDATE_REDUNDANT
} HostCandidateResult;

HostCandidateResult
105
discovery_add_local_host_candidate (
106 107 108
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
109
  NiceAddress *address,
110 111
  NiceCandidateTransport transport,
  NiceCandidate **candidate);
112

113 114 115 116 117 118
NiceCandidate*
discovery_add_relay_candidate (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  NiceAddress *address,
119
  NiceCandidateTransport transport,
120 121
  NiceSocket *base_socket,
  TurnServer *turn);
122

123
NiceCandidate*
124 125 126 127 128
discovery_add_server_reflexive_candidate (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  NiceAddress *address,
129
  NiceCandidateTransport transport,
130 131
  NiceSocket *base_socket,
  gboolean nat_assisted);
132

133 134 135 136 137 138 139 140 141
void
discovery_discover_tcp_server_reflexive_candidates (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  NiceAddress *address,
  NiceSocket *base_socket);

NiceCandidate*
142 143 144 145 146
discovery_add_peer_reflexive_candidate (
  NiceAgent *agent,
  guint stream_id,
  guint component_id,
  NiceAddress *address,
147
  NiceSocket *base_socket,
148 149
  NiceCandidate *local,
  NiceCandidate *remote);
150 151 152 153

NiceCandidate *
discovery_learn_remote_peer_reflexive_candidate (
  NiceAgent *agent,
154
  NiceStream *stream,
155
  NiceComponent *component,
156 157
  guint32 priority, 
  const NiceAddress *remote_address,
158
  NiceSocket *udp_socket,
159 160
  NiceCandidate *local,
  NiceCandidate *remote);
161

162
#endif /*_NICE_CONNCHECK_H */