Globus Toolkit  6.0.1493989444
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 #if HAVE_GIO_GIO_H
33 #include <gio/gio.h>
34 #endif
35 
36 #define ICE_SUCCESS 0
37 #define ICE_FAILURE -1
38 
39 struct icedata {
40  NiceAgent *agent;
41  GMainLoop *gloop;
42  GMainContext *gcontext;
43  GThread *gloopthread;
44  guint stream_id;
45 
46  NiceAddress *bind_addr;
47  NiceAddress *remote_addr;
48  gpointer sockptr;
49 
50  gboolean selected_pair_done;
51  gboolean gather_done;
52  gboolean negotiate_done;
53  GMutex *state_mutex;
54  GCond *gather_cv;
55  GCond *negotiate_cv;
56 };
57 
58 /*
59  userfrag(513) -- rfc5389 15.3
60  + sep(1) -- colon
61  + password(80) -- pjnath limit
62  + max candidates *
63  (
64  space(1)
65  + foundation(32) + sep(1) -- rfc5245 15.1
66  + prio(10) + sep(1) -- rfc5245 4.1.2, 15.1
67  + addr(45) + sep(1)
68  + port(5) + sep(1)
69  + type(5) -- rfc5245 15.1
70  ) + null(1)
71 
72  (foundation):(prio):(addr):(port):(type)
73 */
74 #define LOCAL_DATA_SIZE (513 + 1 + 80 \
75  + NICE_AGENT_MAX_REMOTE_CANDIDATES * ( \
76  1 + 33 + 11 + INET6_ADDRSTRLEN + 6 + 7) \
77  + 1)
78 
79 
80 int ice_lib_init();
81 void ice_lib_shutdown();
82 
83 /* upas */
84 int ice_init(struct icedata *icedata, const char *stun_host,
85  unsigned int stun_port, int controlling);
86 int ice_get_local_data(struct icedata *ice_data, char *out, size_t outsize);
87 
88 /* uprt */
89 int ice_negotiate(struct icedata *ice_data, int argc, char *rdata[]);
90 int ice_get_negotiated_addrs(struct icedata *ice_data,
91  struct sockaddr *laddr,
92  socklen_t *laddrlen,
93  struct sockaddr *raddr,
94  socklen_t *raddrlen);
95 
96 int ice_get_negotiated_sock(struct icedata *ice_data, int *sock_dup);
97 
98 /* cleanup */
99 void ice_destroy(struct icedata *ice_data);
100 
101 char **ice_parse_args(char *line, int *argc);
102 
103 #endif