summaryrefslogtreecommitdiff
path: root/modules/ice
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-04-28 09:02:39 +0200
committerGitHub <noreply@github.com>2017-04-28 09:02:39 +0200
commit0169798285f53bd4d01be10cf0e95f46f2d4b56a (patch)
treed2970981fea2bde12402f37299fd038a58e04836 /modules/ice
parent8875fc1255de4036db1e82df9b7aaccb064daf45 (diff)
Ice refactor (#239)
* ice: remove ice session (struct ice) * ice: api changes
Diffstat (limited to 'modules/ice')
-rw-r--r--modules/ice/ice.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/modules/ice/ice.c b/modules/ice/ice.c
index 4b3b1ac..519f46b 100644
--- a/modules/ice/ice.c
+++ b/modules/ice/ice.c
@@ -34,7 +34,10 @@ struct mnat_sess {
struct sa srv;
struct stun_dns *dnsq;
struct sdp_session *sdp;
- struct ice *ice;
+ char lufrag[8];
+ char lpwd[32];
+ uint64_t tiebrk;
+ bool offerer;
char *user;
char *pass;
int mediac;
@@ -121,7 +124,6 @@ static void session_destructor(void *arg)
mem_deref(sess->dnsq);
mem_deref(sess->user);
mem_deref(sess->pass);
- mem_deref(sess->ice);
mem_deref(sess->sdp);
}
@@ -301,12 +303,10 @@ static int session_alloc(struct mnat_sess **sessp, struct dnsc *dnsc,
if (err)
goto out;
- err = ice_alloc(&sess->ice, ice.mode, offerer);
- if (err)
- goto out;
-
- ice_conf(sess->ice)->nom = ice.nom;
- ice_conf(sess->ice)->debug = ice.debug;
+ rand_str(sess->lufrag, sizeof(sess->lufrag));
+ rand_str(sess->lpwd, sizeof(sess->lpwd));
+ sess->tiebrk = rand_u64();
+ sess->offerer = offerer;
if (ICE_MODE_LITE == ice.mode) {
err |= sdp_session_set_lattr(ss, true,
@@ -314,9 +314,9 @@ static int session_alloc(struct mnat_sess **sessp, struct dnsc *dnsc,
}
err |= sdp_session_set_lattr(ss, true,
- ice_attr_ufrag, ice_ufrag(sess->ice));
+ ice_attr_ufrag, sess->lufrag);
err |= sdp_session_set_lattr(ss, true,
- ice_attr_pwd, ice_pwd(sess->ice));
+ ice_attr_pwd, sess->lpwd);
if (err)
goto out;
@@ -491,14 +491,15 @@ static int ice_start(struct mnat_sess *sess)
struct le *le;
int err = 0;
- ice_printf(NULL, "ICE Start: %H", ice_debug, sess->ice);
-
/* Update SDP media */
if (sess->started) {
LIST_FOREACH(&sess->medial, le) {
struct mnat_media *m = le->data;
+ ice_printf(NULL, "ICE Start: %H",
+ icem_debug, m->icem);
+
icem_update(m->icem);
refresh_laddr(m,
@@ -522,6 +523,12 @@ static int ice_start(struct mnat_sess *sess)
err = icem_conncheck_start(m->icem);
if (err)
return err;
+
+ /* set the pair states
+ -- first media stream only */
+ if (sess->medial.head == le) {
+ ice_candpair_set_states(m->icem);
+ }
}
}
else {
@@ -556,11 +563,16 @@ static int media_alloc(struct mnat_media **mp, struct mnat_sess *sess,
m->compv[0].sock = mem_ref(sock1);
m->compv[1].sock = mem_ref(sock2);
- err = icem_alloc(&m->icem, sess->ice, proto, 0,
+ err = icem_alloc(&m->icem, ice.mode, sess->offerer,
+ proto, 0,
+ sess->tiebrk, sess->lufrag, sess->lpwd,
gather_handler, conncheck_handler, m);
if (err)
goto out;
+ icem_conf(m->icem)->nom = ice.nom;
+ icem_conf(m->icem)->debug = ice.debug;
+
icem_set_name(m->icem, sdp_media_name(sdpm));
for (i=0; i<2; i++) {
@@ -586,7 +598,15 @@ static int media_alloc(struct mnat_media **mp, struct mnat_sess *sess,
static bool sdp_attr_handler(const char *name, const char *value, void *arg)
{
struct mnat_sess *sess = arg;
- return 0 != ice_sdp_decode(sess->ice, name, value);
+ struct le *le;
+
+ for (le = sess->medial.head; le; le = le->next) {
+ struct mnat_media *m = le->data;
+
+ (void)ice_sdp_decode(m->icem, name, value);
+ }
+
+ return false;
}