static int print_duration(struct re_printf *pf, const struct call *call) { const uint32_t dur = call_duration(call); const uint32_t sec = dur%60%60; const uint32_t min = dur/60%60; const uint32_t hrs = dur/60/60; return re_hprintf(pf, "%u:%02u:%02u", hrs, min, sec); }
int sip_transp_debug(struct re_printf *pf, const struct sip *sip) { int err; err = re_hprintf(pf, "transports:\n"); list_apply(&sip->transpl, true, debug_handler, pf); return err; }
static int errstatus_print(struct re_printf *pf, err_status_t e) { const char *s; switch (e) { case err_status_ok: s = "ok"; break; case err_status_fail: s = "fail"; break; case err_status_auth_fail: s = "auth_fail"; break; case err_status_cipher_fail: s = "cipher_fail"; break; case err_status_replay_fail: s = "replay_fail"; break; default: return re_hprintf(pf, "err=%d", e); } return re_hprintf(pf, "%s", s); }
static bool debug_handler(struct le *le, void *arg) { const struct rtp_member *mbr = le->data; struct re_printf *pf = arg; int err; err = re_hprintf(pf, " member 0x%08x: lost=%d Jitter=%.1fms" " RTT=%.1fms\n", mbr->src, mbr->cum_lost, (double)mbr->jit/1000, (double)mbr->rtt/1000); if (mbr->s) { err |= re_hprintf(pf, " IP=%J psent=%u rcvd=%u\n", &mbr->s->rtp_peer, mbr->s->psent, mbr->s->received); } return err != 0; }
int call_info(struct re_printf *pf, const struct call *call) { if (!call) return 0; return re_hprintf(pf, "%H %9s %s %s", print_duration, call, state_name(call->state), call->on_hold ? "(on hold)" : " ", call->peer_uri); }
static int print_summary(struct re_printf *pf, const struct audio_loop *al) { const double scale = al->srate * al->ch; int err; err = re_hprintf(pf, "~~~~~ Audioloop summary: ~~~~~\n"); err |= re_hprintf(pf, "%u Hz %uch %s\n\n", al->srate, al->ch, aufmt_name(al->fmt)); /* Source */ if (al->ausrc) { struct ausrc *as = ausrc_get(al->ausrc); err |= re_hprintf(pf, "* Source\n" " module %s\n" " samples %llu\n" " duration %.3f sec\n" "\n" , as->name, al->n_read, (double)al->n_read / scale); } /* Player */ if (al->auplay) { struct auplay *ap = auplay_get(al->auplay); err |= re_hprintf(pf, "* Player\n" " module %s\n" " samples %llu\n" " duration %.3f sec\n" "\n" , ap->name, al->n_write, (double)al->n_write / scale); } return err; }
static int html_print_head(struct re_printf *pf, void *unused) { (void)unused; return re_hprintf(pf, "<html>\n" "<head>\n" "<title>Baresip v" BARESIP_VERSION "</title>\n" "</head>\n"); }
static int cmd_ua_debug(struct re_printf *pf, void *unused) { const struct ua *ua = uag_current(); (void)unused; if (ua) return ua_debug(pf, ua); else return re_hprintf(pf, "(no user-agent)\n"); }
/** * Print all calls for a given User-Agent */ int ua_print_calls(struct re_printf *pf, const struct ua *ua) { struct le *le; int err = 0; err |= re_hprintf(pf, "\n--- List of active calls (%u): ---\n", list_count(&ua->calls)); for (le = ua->calls.head; le; le = le->next) { const struct call *call = le->data; err |= re_hprintf(pf, " %H\n", call_info, call); } err |= re_hprintf(pf, "\n"); return err; }
int icem_candpairs_debug(struct re_printf *pf, const struct list *list) { struct le *le; int err; if (!list) return 0; err = re_hprintf(pf, " (%u)\n", list_count(list)); for (le = list->head; le && !err; le = le->next) { const struct candpair *cp = le->data; err = re_hprintf(pf, " %H\n", icem_candpair_debug, cp); } return err; }
static int reload_config(struct re_printf *pf, void *arg) { int err; (void)arg; err = re_hprintf(pf, "reloading config file ..\n"); if (err) return err; err = conf_configure(); if (err) { (void)re_hprintf(pf, "reload_config failed: %m\n", err); return err; } (void)re_hprintf(pf, "done\n"); return 0; }
static int auloop_stop(struct re_printf *pf, void *arg) { (void)arg; if (gal) { (void)re_hprintf(pf, "audio-loop stopped\n"); gal = mem_deref(gal); } return 0; }
static bool debug_handler(struct le *le, void *arg) { const struct sip_transport *transp = le->data; struct re_printf *pf = arg; (void)re_hprintf(pf, " %J (%s)\n", &transp->laddr, sip_transp_name(transp->tp)); return false; }
bool flow_debug_handler(char *key, void *val, void *arg) { struct re_printf *pf = arg; struct flow *flow = val; int err = 0; err |= re_hprintf(pf, " %H\n", flow_debug, flow); if (flow->userflow) { err |= re_hprintf(pf, " name=\"%s\"\n", flow->userflow->name); err |= re_hprintf(pf, " mf=[%H]", mediaflow_debug, userflow_mediaflow(flow->userflow)); } err |= re_hprintf(pf, "\n"); return err != 0; }
int ua_debug(struct re_printf *pf, const struct ua *ua) { struct le *le; int err; if (!ua) return 0; err = re_hprintf(pf, "--- %s ---\n", ua->acc->aor); err |= re_hprintf(pf, " cuser: %s\n", ua->cuser); err |= re_hprintf(pf, " pub-gruu: %s\n", ua->pub_gruu); err |= re_hprintf(pf, " af: %s\n", net_af2name(ua->af)); err |= re_hprintf(pf, " %H", ua_print_supported, ua); err |= account_debug(pf, ua->acc); for (le = ua->regl.head; le; le = le->next) err |= reg_debug(pf, le->data); return err; }
static int cmd_quit(struct re_printf *pf, void *unused) { int err; (void)unused; err = re_hprintf(pf, "Quit\n"); ua_stop_all(false); return err; }
static int aurx_print_pipeline(struct re_printf *pf, const struct aurx *aurx) { struct le *le; int err; if (!aurx) return 0; err = re_hprintf(pf, "audio rx pipeline: %10s", aurx->auplay ? aurx->auplay->ap->name : "play"); for (le = list_head(&aurx->filtl); le; le = le->next) { struct aufilt_dec_st *st = le->data; if (st->af->dech) { err |= re_hprintf(pf, " <--- %s", st->af->name); } } err |= re_hprintf(pf, " <--- %s\n", aurx->ac ? aurx->ac->name : "decoder"); return err; }
int sdp_format_debug(struct re_printf *pf, const struct sdp_format *fmt) { int err; if (!fmt) return 0; err = re_hprintf(pf, "%3s", fmt->id); if (fmt->name) err |= re_hprintf(pf, " %s/%u/%u", fmt->name, fmt->srate, fmt->ch); if (fmt->params) err |= re_hprintf(pf, " (%s)", fmt->params); if (fmt->sup) err |= re_hprintf(pf, " *"); return err; }
/** * Debug loadable modules * * @param pf Print handler for debug output * @param unused Unused parameter * * @return 0 if success, otherwise errorcode */ int mod_debug(struct re_printf *pf, void *unused) { struct le *le; int err; (void)unused; err = re_hprintf(pf, "\n--- Modules (%u) ---\n", list_count(&modl)); for (le = modl.head; le && !err; le = le->next) { const struct mod *m = le->data; const struct mod_export *me = m->me; err = re_hprintf(pf, " %16s type=%-12s ref=%u\n", me->name, me->type, mem_nrefs(m)); } err |= re_hprintf(pf, "\n"); return err; }
int stream_debug(struct re_printf *pf, const struct stream *s) { struct sa rrtcp; int err; if (!s) return 0; err = re_hprintf(pf, " %s dir=%s pt_enc=%d\n", sdp_media_name(s->sdp), sdp_dir_name(sdp_media_dir(s->sdp)), s->pt_enc); sdp_media_raddr_rtcp(s->sdp, &rrtcp); err |= re_hprintf(pf, " remote: %J/%J\n", sdp_media_raddr(s->sdp), &rrtcp); err |= rtp_debug(pf, s->rtp); err |= jbuf_debug(pf, s->jbuf); return err; }
static int autx_print_pipeline(struct re_printf *pf, const struct autx *autx) { struct le *le; int err; if (!autx) return 0; err = re_hprintf(pf, "audio tx pipeline: %10s", autx->ausrc ? autx->ausrc->as->name : "src"); for (le = list_head(&autx->filtl); le; le = le->next) { struct aufilt_enc_st *st = le->data; if (st->af->ench) { err |= re_hprintf(pf, " ---> %s", st->af->name); } } err |= re_hprintf(pf, " ---> %s\n", autx->ac ? autx->ac->name : "encoder"); 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 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: [%s]%H", ice_checkl_state2name(icem->state), icem_candpairs_debug, &icem->checkl); err |= re_hprintf(pf, " Valid list: %H", icem_candpairs_debug, &icem->validl); for (le = icem->compl.head; le; le = le->next) { const struct icem_comp *comp = le->data; if (comp->cp_sel) { err |= re_hprintf(pf, " Selected: %H\n", icem_candpair_debug, comp->cp_sel); } } err |= stun_debug(pf, icem->stun); return err; }
/** * 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; }
int stun_uri_encode(struct re_printf *pf, const struct stun_uri *uri) { const char *scheme; uint16_t dport; int err; if (!uri) return 0; dport = uri->secure ? 5349 : 3478; switch (uri->scheme) { case STUN_SCHEME_STUN: scheme = "stun"; break; case STUN_SCHEME_TURN: scheme = "turn"; break; default: return EINVAL; } err = re_hprintf(pf, "%s%s:%j", scheme, uri->secure ? "s" : "", &uri->addr); if (err) return err; if (sa_port(&uri->addr) != dport) { err |= re_hprintf(pf, ":%u", sa_port(&uri->addr)); } if (uri->proto == IPPROTO_TCP) err |= re_hprintf(pf, "?transport=tcp"); return err; }
int stream_jbuf_stat(struct re_printf *pf, const struct stream *s) { struct jbuf_stat stat; int err; if (!s) return EINVAL; err = re_hprintf(pf, " %s:", sdp_media_name(s->sdp)); err |= jbuf_stats(s->jbuf, &stat); if (err) { err = re_hprintf(pf, "Jbuf stat: (not available)"); } else { err = re_hprintf(pf, "Jbuf stat: put=%u get=%u or=%u ur=%u", stat.n_put, stat.n_get, stat.n_overflow, stat.n_underflow); } return err; }
static bool debug_handler(struct le *le, void *arg) { struct sip_ctrans *ct = le->data; struct re_printf *pf = arg; (void)re_hprintf(pf, " %-10s %-10s %2llus (%s)\n", ct->met, statename(ct->state), tmr_get_expire(&ct->tmr)/1000, ct->branch); return false; }
/** * 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; }
int icem_cands_debug(struct re_printf *pf, const struct list *lst) { struct le *le; int err; err = re_hprintf(pf, " (%u)\n", list_count(lst)); for (le = list_head(lst); le && !err; le = le->next) { const struct cand *cand = le->data; err |= re_hprintf(pf, " {%u} fnd=%-2s prio=%08x %24H", cand->compid, cand->foundation, cand->prio, icem_cand_print, cand); if (sa_isset(&cand->rel, SA_ADDR)) err |= re_hprintf(pf, " (rel-addr=%J)", &cand->rel); err |= re_hprintf(pf, "\n"); } return err; }
int contacts_print(struct re_printf *pf, void *unused) { struct le *le; int err; (void)unused; err = re_hprintf(pf, "\n--- Contacts: (%u) ---\n", list_count(contact_list())); for (le = list_head(contact_list()); le && !err; le = le->next) { const struct contact *c = le->data; const struct sip_addr *addr = &c->addr; err = re_hprintf(pf, "%20s %r <%r>\n", contact_presence_str(c->status), &addr->dname, &addr->auri); } err |= re_hprintf(pf, "\n"); return err; }
int flow_debug(struct re_printf *pf, const struct flow *flow) { int err = 0; err |= re_hprintf(pf, "ix=%2u: flowid=%s\n" " |%c%c%c%c| %s\n" " remote_user=%s" , flow->ix, flow->flowid, flow->creator ? 'C' : ' ', flow->deleted ? 'D' : ' ', flow->active ? 'A' : ' ', flow->estab ? 'E' : ' ', flow_estab_name(flow->est_st), flow->remoteid ? flow->remoteid : "unknown" ); if (flow->err) err |= re_hprintf(pf, " (error=%m)", flow->err); return err; }