Grid Community Toolkit  6.2.1629922860 (tag: v6.2.20210826)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ice.h
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __ICE_I__
18 
19 #define __ICE_I__
20 
21 #ifdef _WIN32
22 #include <winsock2.h>
23 #else
24 #include <sys/socket.h>
25 #include <sys/types.h>
26 #include <arpa/inet.h>
27 #include <netinet/in.h>
28 #include <netdb.h>
29 #endif
30 
31 #include <nice/agent.h>
32 #include <glib.h>
33 
34 #define ICE_SUCCESS 0
35 #define ICE_FAILURE -1
36 
37 struct icedata {
38  NiceAgent *agent;
39  GMainLoop *gloop;
40  GMainContext *gcontext;
41  GThread *gloopthread;
42  guint stream_id;
43 
44  NiceAddress *bind_addr;
45  NiceAddress *remote_addr;
46  gpointer sockptr;
47 
48  gboolean selected_pair_done;
49  gboolean gather_done;
50  gboolean negotiate_done;
51  GMutex *state_mutex;
52  GCond *gather_cv;
53  GCond *negotiate_cv;
54 };
55 
56 /*
57  userfrag(513) -- rfc5389 15.3
58  + sep(1) -- colon
59  + password(80) -- pjnath limit
60  + max candidates *
61  (
62  space(1)
63  + foundation(32) + sep(1) -- rfc5245 15.1
64  + prio(10) + sep(1) -- rfc5245 4.1.2, 15.1
65  + addr(45) + sep(1)
66  + port(5) + sep(1)
67  + type(5) -- rfc5245 15.1
68  ) + null(1)
69 
70  (foundation):(prio):(addr):(port):(type)
71 */
72 #define LOCAL_DATA_SIZE (513 + 1 + 80 \
73  + NICE_AGENT_MAX_REMOTE_CANDIDATES * ( \
74  1 + 33 + 11 + INET6_ADDRSTRLEN + 6 + 7) \
75  + 1)
76 
77 
78 int ice_lib_init();
79 void ice_lib_shutdown();
80 
81 /* upas */
82 int ice_init(struct icedata *icedata, const char *stun_host,
83  unsigned int stun_port, int controlling);
84 int ice_get_local_data(struct icedata *ice_data, char *out, size_t outsize);
85 
86 /* uprt */
87 int ice_negotiate(struct icedata *ice_data, int argc, char *rdata[]);
88 int ice_get_negotiated_addrs(struct icedata *ice_data,
89  struct sockaddr *laddr,
90  socklen_t *laddrlen,
91  struct sockaddr *raddr,
92  socklen_t *raddrlen);
93 
94 int ice_get_negotiated_sock(struct icedata *ice_data, int *sock_dup);
95 
96 /* cleanup */
97 void ice_destroy(struct icedata *ice_data);
98 
99 char **ice_parse_args(char *line, int *argc);
100 
101 #endif