void ice_switch_local_role(struct ice *ice) { enum role new_role; struct le *le; if (ROLE_CONTROLLING == ice->lrole) new_role = ROLE_CONTROLLED; else new_role = ROLE_CONTROLLING; DEBUG_NOTICE("Switch local role from %s to %s\n", ice_role2name(ice->lrole), ice_role2name(new_role)); ice->lrole = new_role; /* recompute pair priorities for all media streams */ for (le = ice->ml.head; le; le = le->next) { struct icem *icem = le->data; icem_candpair_prio_order(&icem->checkl); } }
/** * Print debug information for the ICE Session * * @param pf Print function for debug output * @param ice ICE Session * * @return 0 if success, otherwise errorcode */ int ice_debug(struct re_printf *pf, const struct ice *ice) { struct le *le; int err = 0; if (!ice) return 0; err |= re_hprintf(pf, " local_mode=%s, remote_mode=%s", ice_mode2name(ice->lmode), ice_mode2name(ice->rmode)); err |= re_hprintf(pf, ", local_role=%s\n", ice_role2name(ice->lrole)); err |= re_hprintf(pf, " local_ufrag=\"%s\" local_pwd=\"%s\"\n", ice->lufrag, ice->lpwd); for (le = ice->ml.head; le; le = le->next) err |= icem_debug(pf, le->data); err |= stun_debug(pf, ice->stun); return err; }
/** * Print debug information for the ICE Media * * @param pf Print function for debug output * @param icem ICE Media object * * @return 0 if success, otherwise errorcode */ int icem_debug(struct re_printf *pf, const struct icem *icem) { struct le *le; int err = 0; if (!icem) return 0; err |= re_hprintf(pf, "----- ICE Media <%s> -----\n", icem->name); err |= re_hprintf(pf, " local_mode=%s, remote_mode=%s", ice_mode2name(icem->lmode), ice_mode2name(icem->rmode)); err |= re_hprintf(pf, ", local_role=%s\n", ice_role2name(icem->lrole)); err |= re_hprintf(pf, " local_ufrag=\"%s\" local_pwd=\"%s\"\n", icem->lufrag, icem->lpwd); err |= re_hprintf(pf, " Components: (%u)\n", list_count(&icem->compl)); for (le = icem->compl.head; le; le = le->next) { struct icem_comp *comp = le->data; err |= re_hprintf(pf, " %H\n", icecomp_debug, comp); } err |= re_hprintf(pf, " Local Candidates: %H", icem_cands_debug, &icem->lcandl); err |= re_hprintf(pf, " Remote Candidates: %H", icem_cands_debug, &icem->rcandl); err |= re_hprintf(pf, " Check list: [state=%s]%H", ice_checkl_state2name(icem->state), icem_candpairs_debug, &icem->checkl); err |= re_hprintf(pf, " Valid list: %H", icem_candpairs_debug, &icem->validl); err |= stun_debug(pf, icem->stun); return err; }