ice: make ice role type public (#43)
- add "ice/ICE" prefix to enum ice_role and values - export enum ice_role to public API
This commit is contained in:
parent
cb936d9fb2
commit
1fe13a9dd4
10 changed files with 32 additions and 30 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 "???";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue