diff --git a/include/re_ice.h b/include/re_ice.h index b4ca53b..575adec 100644 --- a/include/re_ice.h +++ b/include/re_ice.h @@ -11,6 +11,13 @@ enum ice_mode { ICE_MODE_LITE }; +/** ICE Role */ +enum ice_role { + ICE_ROLE_UNKNOWN = 0, + ICE_ROLE_CONTROLLING, + ICE_ROLE_CONTROLLED +}; + /** ICE Component ID */ enum ice_compid { ICE_COMPID_RTP = 1, @@ -111,6 +118,7 @@ extern const char ice_attr_ufrag[]; const char *ice_cand_type2name(enum ice_cand_type type); enum ice_cand_type ice_cand_name2type(const char *name); +const char *ice_role2name(enum ice_role role); uint32_t ice_cand_calc_prio(enum ice_cand_type type, uint16_t local, diff --git a/src/ice/candpair.c b/src/ice/candpair.c index a2f8d00..e426702 100644 --- a/src/ice/candpair.c +++ b/src/ice/candpair.c @@ -45,7 +45,7 @@ static void candpair_set_pprio(struct ice_candpair *cp) { uint32_t g, d; - if (ROLE_CONTROLLING == cp->icem->ice->lrole) { + if (ICE_ROLE_CONTROLLING == cp->icem->ice->lrole) { g = cp->lcand->prio; d = cp->rcand->prio; } diff --git a/src/ice/chklist.c b/src/ice/chklist.c index 6a3b6fa..8b7c1bc 100644 --- a/src/ice/chklist.c +++ b/src/ice/chklist.c @@ -282,7 +282,7 @@ void icem_checklist_update(struct icem *icem) icem->state = err ? ICE_CHECKLIST_FAILED : ICE_CHECKLIST_COMPLETED; if (icem->chkh) { - icem->chkh(err, icem->ice->lrole == ROLE_CONTROLLING, + icem->chkh(err, icem->ice->lrole == ICE_ROLE_CONTROLLING, icem->arg); } } diff --git a/src/ice/connchk.c b/src/ice/connchk.c index aaec2dd..3701297 100644 --- a/src/ice/connchk.c +++ b/src/ice/connchk.c @@ -224,14 +224,14 @@ int icem_conncheck_send(struct ice_candpair *cp, bool use_cand, bool trigged) switch (ice->lrole) { - case ROLE_CONTROLLING: + case ICE_ROLE_CONTROLLING: ctrl_attr = STUN_ATTR_CONTROLLING; if (ice->conf.nom == ICE_NOMINATION_AGGRESSIVE) use_cand = true; break; - case ROLE_CONTROLLED: + case ICE_ROLE_CONTROLLED: ctrl_attr = STUN_ATTR_CONTROLLED; break; @@ -308,7 +308,7 @@ static void abort_ice(struct icem *icem, int err) tmr_cancel(&icem->tmr_pace); if (icem->chkh) { - icem->chkh(err, icem->ice->lrole == ROLE_CONTROLLING, + icem->chkh(err, icem->ice->lrole == ICE_ROLE_CONTROLLING, icem->arg); } diff --git a/src/ice/ice.c b/src/ice/ice.c index ad6da44..dce82cd 100644 --- a/src/ice/ice.c +++ b/src/ice/ice.c @@ -37,11 +37,12 @@ static void ice_determine_role(struct ice *ice, bool offerer) return; if (ice->lmode == ice->rmode) - ice->lrole = offerer ? ROLE_CONTROLLING : ROLE_CONTROLLED; + ice->lrole = offerer + ? ICE_ROLE_CONTROLLING : ICE_ROLE_CONTROLLED; else if (ice->lmode == ICE_MODE_FULL) - ice->lrole = ROLE_CONTROLLING; + ice->lrole = ICE_ROLE_CONTROLLING; else - ice->lrole = ROLE_CONTROLLED; + ice->lrole = ICE_ROLE_CONTROLLED; } diff --git a/src/ice/ice.h b/src/ice/ice.h index 19f0ae5..4bddf44 100644 --- a/src/ice/ice.h +++ b/src/ice/ice.h @@ -10,12 +10,6 @@ #endif -enum role { - ROLE_UNKNOWN = 0, - ROLE_CONTROLLING, - ROLE_CONTROLLED -}; - enum ice_checkl_state { ICE_CHECKLIST_NULL = -1, ICE_CHECKLIST_RUNNING, @@ -52,7 +46,7 @@ enum { struct ice { enum ice_mode lmode; /**< Local mode */ enum ice_mode rmode; /**< Remote mode */ - enum role lrole; /**< Local role */ + enum ice_role lrole; /**< Local role */ char lufrag[5]; /**< Local Username fragment */ char lpwd[23]; /**< Local Password */ struct list ml; /**< Media list (struct icem) */ @@ -225,7 +219,6 @@ int icem_conncheck_send(struct ice_candpair *cp, bool use_cand, bool trigged); /* icestr */ const char *ice_mode2name(enum ice_mode mode); -const char *ice_role2name(enum role role); const char *ice_candpair_state2name(enum ice_candpair_state st); const char *ice_checkl_state2name(enum ice_checkl_state cst); diff --git a/src/ice/icesdp.c b/src/ice/icesdp.c index 2ed6f55..84902c2 100644 --- a/src/ice/icesdp.c +++ b/src/ice/icesdp.c @@ -96,7 +96,7 @@ bool ice_remotecands_avail(const struct icem *icem) if (!icem) return false; - return icem->ice->lrole == ROLE_CONTROLLING && + return icem->ice->lrole == ICE_ROLE_CONTROLLING && icem->state == ICE_CHECKLIST_COMPLETED; } @@ -282,7 +282,7 @@ int ice_sdp_decode(struct ice *ice, const char *name, const char *value) return EPROTO; } ice->rmode = ICE_MODE_LITE; - ice->lrole = ROLE_CONTROLLING; + ice->lrole = ICE_ROLE_CONTROLLING; } else if (0 == str_casecmp(name, ice_attr_ufrag)) return ufrag_decode(ice, value); diff --git a/src/ice/icestr.c b/src/ice/icestr.c index 0d92fa0..2d39d29 100644 --- a/src/ice/icestr.c +++ b/src/ice/icestr.c @@ -49,13 +49,13 @@ const char *ice_mode2name(enum ice_mode mode) } -const char *ice_role2name(enum role role) +const char *ice_role2name(enum ice_role role) { switch (role) { - case ROLE_UNKNOWN: return "Unknown"; - case ROLE_CONTROLLING: return "Controlling"; - case ROLE_CONTROLLED: return "Controlled"; + case ICE_ROLE_UNKNOWN: return "Unknown"; + case ICE_ROLE_CONTROLLING: return "Controlling"; + case ICE_ROLE_CONTROLLED: return "Controlled"; default: return "???"; } } diff --git a/src/ice/stunsrv.c b/src/ice/stunsrv.c index c405fc0..18b534a 100644 --- a/src/ice/stunsrv.c +++ b/src/ice/stunsrv.c @@ -145,7 +145,7 @@ static int handle_stun_full(struct ice *ice, struct icem *icem, /* 7.2.1.5. Updating the Nominated Flag */ if (use_cand) { - if (ice->lrole == ROLE_CONTROLLED && + if (ice->lrole == ICE_ROLE_CONTROLLED && cp->state == ICE_CANDPAIR_SUCCEEDED) { if (!cp->nominated) { @@ -235,7 +235,7 @@ int icem_stund_recv(struct icem_comp *comp, const struct sa *src, struct ice *ice = icem->ice; struct stun_attr *attr; struct pl lu, ru; - enum role rrole = ROLE_UNKNOWN; + enum ice_role rrole = ICE_ROLE_UNKNOWN; uint64_t tiebrk = 0; uint32_t prio_prflx; bool use_cand = false; @@ -272,13 +272,13 @@ int icem_stund_recv(struct icem_comp *comp, const struct sa *src, attr = stun_msg_attr(req, STUN_ATTR_CONTROLLED); if (attr) { - rrole = ROLE_CONTROLLED; + rrole = ICE_ROLE_CONTROLLED; tiebrk = attr->v.uint64; } attr = stun_msg_attr(req, STUN_ATTR_CONTROLLING); if (attr) { - rrole = ROLE_CONTROLLING; + rrole = ICE_ROLE_CONTROLLING; tiebrk = attr->v.uint64; } diff --git a/src/ice/util.c b/src/ice/util.c index bcd2a33..0069bcf 100644 --- a/src/ice/util.c +++ b/src/ice/util.c @@ -74,13 +74,13 @@ uint64_t ice_calc_pair_prio(uint32_t g, uint32_t d) void ice_switch_local_role(struct ice *ice) { - enum role new_role; + enum ice_role new_role; struct le *le; - if (ROLE_CONTROLLING == ice->lrole) - new_role = ROLE_CONTROLLED; + if (ICE_ROLE_CONTROLLING == ice->lrole) + new_role = ICE_ROLE_CONTROLLED; else - new_role = ROLE_CONTROLLING; + new_role = ICE_ROLE_CONTROLLING; DEBUG_NOTICE("Switch local role from %s to %s\n", ice_role2name(ice->lrole), ice_role2name(new_role));