Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Oct 5, 2023
1 parent 6275458 commit 0efe3b7
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions include/re_ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ typedef void (ice_connchk_h)(int err, bool update, void *arg);
int icem_alloc(struct icem **icemp, enum ice_role role, int proto, int layer,
uint64_t tiebrk, const char *lufrag, const char *lpwd,
ice_connchk_h *chkh, void *arg);
void icem_dbg_id(struct icem *icem, struct pl *id);
struct ice_conf *icem_conf(struct icem *icem);
enum ice_role icem_local_role(const struct icem *icem);
void icem_set_conf(struct icem *icem, const struct ice_conf *conf);
Expand Down
3 changes: 2 additions & 1 deletion src/ice/candpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,10 @@ struct ice_candpair *icem_candpair_find(const struct list *lst,
for (le = list_head(lst); le; le = le->next) {

struct ice_candpair *cp = le->data;
struct pl *debug_id = cp->icem ? cp->icem->dbg_id : NULL;

if (!cp->lcand || !cp->rcand) {
DEBUG_WARNING("corrupt candpair %p\n", cp);
DEBUG_WARNING_ID("corrupt candpair %p\n", cp);
continue;
}

Expand Down
7 changes: 5 additions & 2 deletions src/ice/comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ void icem_comp_set_selected(struct icem_comp *comp, struct ice_candpair *cp)
if (!comp || !cp)
return;

struct pl *debug_id = comp->icem->dbg_id;

if (cp->state != ICE_CANDPAIR_SUCCEEDED) {
DEBUG_WARNING("{%s.%u} set_selected: invalid state '%s'"
DEBUG_WARNING_ID("{%s.%u} set_selected: invalid state '%s'"
" [%H]\n",
comp->icem->name, comp->id,
ice_candpair_state2name(cp->state),
Expand Down Expand Up @@ -271,7 +273,8 @@ void icecomp_printf(struct icem_comp *comp, const char *fmt, ...)
return;

va_start(ap, fmt);
(void)re_printf("{%11s.%u} %v", comp->icem->name, comp->id, fmt, &ap);
dbg_printf_id(comp->icem->dbg_id, DBG_NOTICE, "{%11s.%u} %v",
comp->icem->name, comp->id, fmt, &ap);
va_end(ap);
}

Expand Down
21 changes: 16 additions & 5 deletions src/ice/connchk.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,20 @@ static struct ice_candpair *construct_valid_pair(struct icem *icem,
struct ice_candpair *cp2;
int err;

if (!icem)
return NULL;

struct pl *debug_id = icem->dbg_id;

lcand = icem_cand_find(&icem->lcandl, cp->lcand->compid, mapped);
rcand = icem_cand_find(&icem->rcandl, cp->rcand->compid, dest);

if (!lcand) {
DEBUG_WARNING("no such local candidate: %J\n", mapped);
DEBUG_WARNING_ID("no such local candidate: %J\n", mapped);
return NULL;
}
if (!rcand) {
DEBUG_WARNING("no such remote candidate: %J\n", dest);
DEBUG_WARNING_ID("no such remote candidate: %J\n", dest);
return NULL;
}

Expand Down Expand Up @@ -108,6 +113,11 @@ static struct ice_candpair *construct_valid_pair(struct icem *icem,
static void handle_success(struct icem *icem, struct ice_candpair *cp,
const struct sa *laddr)
{
if (!icem)
return;

struct pl *debug_id = icem->dbg_id;

if (!icem_cand_find(&icem->lcandl, cp->lcand->compid, laddr)) {

int err;
Expand All @@ -118,13 +128,13 @@ static void handle_success(struct icem *icem, struct ice_candpair *cp,
err = icem_lcand_add(icem, cp->lcand,
ICE_CAND_TYPE_PRFLX, laddr);
if (err) {
DEBUG_WARNING("failed to add PRFLX: %m\n", err);
DEBUG_WARNING_ID("failed to add PRFLX: %m\n", err);
}
}

cp = construct_valid_pair(icem, cp, laddr, &cp->rcand->addr);
if (!cp) {
DEBUG_WARNING("{%s} no valid candidate pair for %J\n",
DEBUG_WARNING_ID("{%s} no valid candidate pair for %J\n",
icem->name, laddr);
return;
}
Expand Down Expand Up @@ -157,6 +167,7 @@ static void stunc_resp_handler(int err, uint16_t scode, const char *reason,
{
struct ice_candpair *cp = arg;
struct icem *icem = cp->icem;
struct pl *debug_id = cp->icem->dbg_id;
struct stun_attr *attr;

(void)reason;
Expand All @@ -178,7 +189,7 @@ static void stunc_resp_handler(int err, uint16_t scode, const char *reason,
case 0: /* Success case */
attr = stun_msg_attr(msg, STUN_ATTR_XOR_MAPPED_ADDR);
if (!attr) {
DEBUG_WARNING("no XOR-MAPPED-ADDR in response\n");
DEBUG_WARNING_ID("no XOR-MAPPED-ADDR in response\n");
icem_candpair_failed(cp, EBADMSG, 0);
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/ice/ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct icem {
void *arg; /**< Handler argument */
char name[32]; /**< Name of the media stream */
bool rcand_wait; /**< Waiting for remote candidate */
struct pl *dbg_id; /**< Debug identifier */
};

/** Defines a candidate */
Expand Down
17 changes: 17 additions & 0 deletions src/ice/icem.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static void icem_destructor(void *data)
mem_deref(icem->rufrag);
mem_deref(icem->rpwd);
mem_deref(icem->stun);
mem_deref(icem->dbg_id);
}


Expand Down Expand Up @@ -144,6 +145,22 @@ int icem_alloc(struct icem **icemp, enum ice_role role, int proto, int layer,
}


/**
* Set ICE configuration debug identifier
*
* @param icem ICE Media object
* @param id Debug identifier
*
*/
void icem_dbg_id(struct icem *icem, struct pl *id)
{
if (!icem)
return;

icem->dbg_id = mem_ref(id);
}


/**
* Get the ICE Configuration
*
Expand Down

0 comments on commit 0efe3b7

Please sign in to comment.