2 * This file is part of the Nice GLib ICE library.
4 * (C) 2006-2009 Collabora Ltd.
5 * Contact: Youness Alaoui
6 * (C) 2006-2009 Nokia Corporation. All rights reserved.
7 * Contact: Kai Vehmanen
9 * The contents of this file are subject to the Mozilla Public License Version
10 * 1.1 (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 * http://www.mozilla.org/MPL/
14 * Software distributed under the License is distributed on an "AS IS" basis,
15 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
16 * for the specific language governing rights and limitations under the
19 * The Original Code is the Nice GLib ICE library.
21 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
22 * Corporation. All Rights Reserved.
25 * Dafydd Harries, Collabora Ltd.
26 * Youness Alaoui, Collabora Ltd.
29 * Alternatively, the contents of this file may be used under the terms of the
30 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
31 * case the provisions of LGPL are applicable instead of those above. If you
32 * wish to allow use of your version of this file only under the terms of the
33 * LGPL and not to allow others to use your version of this file under the
34 * MPL, indicate your decision by deleting the provisions above and replace
35 * them with the notice and other provisions required by the LGPL. If you do
36 * not delete the provisions above, a recipient may use your version of this
37 * file under either the MPL or the LGPL.
40 #ifndef _NICE_CONNCHECK_H
41 #define _NICE_CONNCHECK_H
43 /* note: this is a private header to libnice */
47 #include "stun/stunagent.h"
48 #include "stun/usages/timer.h"
50 #define NICE_CANDIDATE_PAIR_MAX_FOUNDATION NICE_CANDIDATE_MAX_FOUNDATION*2
54 * @NICE_CHECK_WAITING: Waiting to be scheduled.
55 * @NICE_CHECK_IN_PROGRESS: Connection checks started.
56 * @NICE_CHECK_SUCCEEDED: Connection successfully checked.
57 * @NICE_CHECK_FAILED: No connectivity; retransmissions ceased.
58 * @NICE_CHECK_FROZEN: Waiting to be scheduled to %NICE_CHECK_WAITING.
59 * @NICE_CHECK_DISCOVERED: A valid candidate pair not on the check list.
61 * States for checking a candidate pair.
65 NICE_CHECK_WAITING = 1,
66 NICE_CHECK_IN_PROGRESS,
70 NICE_CHECK_DISCOVERED,
73 typedef struct _CandidateCheckPair CandidateCheckPair;
74 typedef struct _StunTransaction StunTransaction;
76 struct _StunTransaction
78 gint64 next_tick; /* next tick timestamp */
80 uint8_t buffer[STUN_MAX_MESSAGE_SIZE_IPV6];
84 struct _CandidateCheckPair
89 NiceCandidate *remote;
91 gchar foundation[NICE_CANDIDATE_PAIR_MAX_FOUNDATION];
95 gboolean use_candidate_on_next_check;
96 gboolean mark_nominated_on_response_arrival;
97 gboolean retransmit; /* if the first stun request must be retransmitted */
98 CandidateCheckPair *discovered_pair;
99 CandidateCheckPair *succeeded_pair;
101 guint32 stun_priority;
102 GSList *stun_transactions; /* a list of ongoing stun requests */
105 int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, NiceComponent *component, NiceCandidate *remote);
106 int conn_check_add_for_local_candidate (NiceAgent *agent, guint stream_id, NiceComponent *component, NiceCandidate *local);
107 gboolean conn_check_add_for_candidate_pair (NiceAgent *agent, guint stream_id, NiceComponent *component, NiceCandidate *local, NiceCandidate *remote);
108 void conn_check_free (NiceAgent *agent);
109 void conn_check_schedule_next (NiceAgent *agent);
110 int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair);
111 void conn_check_prune_stream (NiceAgent *agent, NiceStream *stream);
112 gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceSocket *udp_socket, const NiceAddress *from, gchar *buf, guint len);
113 gint conn_check_compare (const CandidateCheckPair *a, const CandidateCheckPair *b);
114 void conn_check_remote_candidates_set(NiceAgent *agent, NiceStream *stream, NiceComponent *component);
115 void conn_check_remote_credentials_set(NiceAgent *agent, NiceStream *stream);
116 NiceCandidateTransport conn_check_match_transport (NiceCandidateTransport transport);
118 conn_check_prune_socket (NiceAgent *agent, NiceStream *stream, NiceComponent *component,
121 void recalculate_pair_priorities (NiceAgent *agent);
122 void conn_check_update_selected_pair (NiceAgent *agent,
123 NiceComponent *component, CandidateCheckPair *pair);
124 void conn_check_update_check_list_state_for_ready (NiceAgent *agent,
125 NiceStream *stream, NiceComponent *component);
126 void conn_check_unfreeze_related (NiceAgent *agent, CandidateCheckPair *pair);
127 guint conn_check_stun_transactions_count (NiceAgent *agent);
130 #endif /*_NICE_CONNCHECK_H */