static bool allocation_status(struct le *le, void *arg) { const uint32_t bsize = hash_bsize(turnd.ht_alloc); struct allocation *al = le->data; struct mbuf *mb = arg; (void)mbuf_printf(mb, "- %04u %s/%J/%J - %J \"%s\" %us (drop %llu/%llu)\n", sa_hash(&al->cli_addr, SA_ALL) & (bsize - 1), net_proto2name(al->proto), &al->cli_addr, &al->srv_addr, &al->rel_addr, al->username, (uint32_t)tmr_get_expire(&al->tmr) / 1000, al->dropc_tx, al->dropc_rx); perm_status(al->perms, mb); chan_status(al->chans, mb); return false; }
static int container_add(const char *name, unsigned idx, enum odict_type type, struct json_handlers *h) { struct odict *o = h->arg, *oc; char index[64]; int err; if (!name) { if (re_snprintf(index, sizeof(index), "%u", idx) < 0) return ENOMEM; name = index; } err = odict_alloc(&oc, hash_bsize(o->ht)); if (err) return err; err = odict_entry_add(o, name, type, oc); mem_deref(oc); h->arg = oc; return err; }