From da5c50062f608384fbfd0fc55652fdfa91b5793b Mon Sep 17 00:00:00 2001 From: Richard Aas Date: Mon, 2 Feb 2015 07:26:18 +0000 Subject: [PATCH] ice: rename struct cand to ice_cand --- include/re_ice.h | 4 ++-- src/ice/cand.c | 46 ++++++++++++++++++++++++---------------------- src/ice/candpair.c | 10 +++++----- src/ice/chklist.c | 6 +++--- src/ice/comp.c | 12 +++++++----- src/ice/connchk.c | 4 ++-- src/ice/gather.c | 4 ++-- src/ice/ice.h | 42 ++++++++++++++++++++++-------------------- src/ice/icem.c | 4 ++-- src/ice/icesdp.c | 4 ++-- src/ice/stunsrv.c | 8 ++++---- 11 files changed, 75 insertions(+), 69 deletions(-) diff --git a/include/re_ice.h b/include/re_ice.h index 1deca1c..b4ca53b 100644 --- a/include/re_ice.h +++ b/include/re_ice.h @@ -95,9 +95,9 @@ const struct sa *icem_cand_default(struct icem *icem, unsigned compid); const struct sa *icem_selected_laddr(const struct icem *icem, unsigned compid); -struct cand; +struct ice_cand; bool ice_remotecands_avail(const struct icem *icem); -int ice_cand_encode(struct re_printf *pf, const struct cand *cand); +int ice_cand_encode(struct re_printf *pf, const struct ice_cand *cand); int ice_remotecands_encode(struct re_printf *pf, const struct icem *icem); diff --git a/src/ice/cand.c b/src/ice/cand.c index 83ad362..b9800e4 100644 --- a/src/ice/cand.c +++ b/src/ice/cand.c @@ -25,7 +25,7 @@ static void cand_destructor(void *arg) { - struct cand *cand = arg; + struct ice_cand *cand = arg; list_unlink(&cand->le); mem_deref(cand->foundation); @@ -37,7 +37,7 @@ static void cand_destructor(void *arg) /** Foundation is a hash of IP address and candidate type */ -static int compute_foundation(struct cand *cand) +static int compute_foundation(struct ice_cand *cand) { uint32_t v; @@ -48,12 +48,12 @@ static int compute_foundation(struct cand *cand) } -static int cand_alloc(struct cand **candp, struct icem *icem, +static int cand_alloc(struct ice_cand **candp, struct icem *icem, enum ice_cand_type type, unsigned compid, uint32_t prio, const char *ifname, enum ice_transp transp, const struct sa *addr) { - struct cand *cand; + struct ice_cand *cand; int err; if (!icem) @@ -91,7 +91,7 @@ int icem_lcand_add_base(struct icem *icem, unsigned compid, uint16_t lprio, const struct sa *addr) { struct icem_comp *comp; - struct cand *cand; + struct ice_cand *cand; int err; comp = icem_comp_find(icem, compid); @@ -113,11 +113,11 @@ int icem_lcand_add_base(struct icem *icem, unsigned compid, uint16_t lprio, } -int icem_lcand_add(struct icem *icem, struct cand *base, +int icem_lcand_add(struct icem *icem, struct ice_cand *base, enum ice_cand_type type, const struct sa *addr) { - struct cand *cand; + struct ice_cand *cand; int err; if (!base) @@ -140,7 +140,7 @@ int icem_rcand_add(struct icem *icem, enum ice_cand_type type, unsigned compid, uint32_t prio, const struct sa *addr, const struct sa *rel_addr, const struct pl *foundation) { - struct cand *rcand; + struct ice_cand *rcand; int err; if (!icem || !foundation) @@ -168,10 +168,11 @@ int icem_rcand_add(struct icem *icem, enum ice_cand_type type, unsigned compid, } -int icem_rcand_add_prflx(struct cand **rcp, struct icem *icem, unsigned compid, - uint32_t prio, const struct sa *addr) +int icem_rcand_add_prflx(struct ice_cand **rcp, struct icem *icem, + unsigned compid, uint32_t prio, + const struct sa *addr) { - struct cand *rcand; + struct ice_cand *rcand; int err; if (!icem || !addr) @@ -206,14 +207,14 @@ int icem_rcand_add_prflx(struct cand **rcp, struct icem *icem, unsigned compid, } -struct cand *icem_cand_find(const struct list *lst, unsigned compid, - const struct sa *addr) +struct ice_cand *icem_cand_find(const struct list *lst, unsigned compid, + const struct sa *addr) { struct le *le; for (le = list_head(lst); le; le = le->next) { - struct cand *cand = le->data; + struct ice_cand *cand = le->data; if (compid && cand->compid != compid) continue; @@ -231,8 +232,8 @@ struct cand *icem_cand_find(const struct list *lst, unsigned compid, /** * Find the highest priority LCAND on the check-list of type HOST/RELAY */ -struct cand *icem_lcand_find_checklist(const struct icem *icem, - unsigned compid) +struct ice_cand *icem_lcand_find_checklist(const struct icem *icem, + unsigned compid) { struct le *le; @@ -266,7 +267,7 @@ int icem_cands_debug(struct re_printf *pf, const struct list *lst) for (le = list_head(lst); le && !err; le = le->next) { - const struct cand *cand = le->data; + const struct ice_cand *cand = le->data; err |= re_hprintf(pf, " {%u} fnd=%-2s prio=%08x %24H", cand->compid, cand->foundation, cand->prio, @@ -282,17 +283,18 @@ int icem_cands_debug(struct re_printf *pf, const struct list *lst) } -int icem_cand_print(struct re_printf *pf, const struct cand *c) +int icem_cand_print(struct re_printf *pf, const struct ice_cand *cand) { int err = 0; - if (!c) + if (!cand) return 0; - if (c->ifname) - err |= re_hprintf(pf, "%s:", c->ifname); + if (cand->ifname) + err |= re_hprintf(pf, "%s:", cand->ifname); - err |= re_hprintf(pf, "%s:%J", ice_cand_type2name(c->type), &c->addr); + err |= re_hprintf(pf, "%s:%J", + ice_cand_type2name(cand->type), &cand->addr); return err; } diff --git a/src/ice/candpair.c b/src/ice/candpair.c index d1fbe56..ec251d7 100644 --- a/src/ice/candpair.c +++ b/src/ice/candpair.c @@ -80,7 +80,7 @@ static void list_add_sorted(struct list *list, struct candpair *cp) int icem_candpair_alloc(struct candpair **cpp, struct icem *icem, - struct cand *lcand, struct cand *rcand) + struct ice_cand *lcand, struct ice_cand *rcand) { struct candpair *cp; struct icem_comp *comp; @@ -115,7 +115,7 @@ int icem_candpair_alloc(struct candpair **cpp, struct icem *icem, int icem_candpair_clone(struct candpair **cpp, struct candpair *cp0, - struct cand *lcand, struct cand *rcand) + struct ice_cand *lcand, struct ice_cand *rcand) { struct candpair *cp; @@ -283,8 +283,8 @@ bool icem_candpair_cmp(const struct candpair *cp1, const struct candpair *cp2) * note: assume list is sorted by priority */ struct candpair *icem_candpair_find(const struct list *lst, - const struct cand *lcand, - const struct cand *rcand) + const struct ice_cand *lcand, + const struct ice_cand *rcand) { struct le *le; @@ -355,7 +355,7 @@ struct candpair *icem_candpair_find_compid(const struct list *lst, * Find a remote candidate in the checklist or validlist */ struct candpair *icem_candpair_find_rcand(struct icem *icem, - const struct cand *rcand) + const struct ice_cand *rcand) { struct candpair *cp; diff --git a/src/ice/chklist.c b/src/ice/chklist.c index c6dcdca..5c9235b 100644 --- a/src/ice/chklist.c +++ b/src/ice/chklist.c @@ -39,12 +39,12 @@ static int candpairs_form(struct icem *icem) for (le = icem->lcandl.head; le; le = le->next) { - struct cand *lcand = le->data; + struct ice_cand *lcand = le->data; struct le *rle; for (rle = icem->rcandl.head; rle; rle = rle->next) { - struct cand *rcand = rle->data; + struct ice_cand *rcand = rle->data; if (lcand->compid != rcand->compid) continue; @@ -63,7 +63,7 @@ static int candpairs_form(struct icem *icem) /* Replace server reflexive candidates by its base */ -static const struct sa *cand_srflx_addr(const struct cand *c) +static const struct sa *cand_srflx_addr(const struct ice_cand *c) { return (ICE_CAND_TYPE_SRFLX == c->type) ? &c->base->addr : &c->addr; } diff --git a/src/ice/comp.c b/src/ice/comp.c index 9f4b6a0..d32bdac 100644 --- a/src/ice/comp.c +++ b/src/ice/comp.c @@ -78,15 +78,16 @@ static void destructor(void *arg) } -static struct cand *cand_default(const struct list *lcandl, unsigned compid) +static struct ice_cand *cand_default(const struct list *lcandl, + unsigned compid) { - struct cand *def = NULL; + struct ice_cand *def = NULL; struct le *le; /* NOTE: list must be sorted by priority */ for (le = list_head(lcandl); le; le = le->next) { - struct cand *cand = le->data; + struct ice_cand *cand = le->data; if (cand->compid != compid) continue; @@ -156,7 +157,7 @@ int icem_comp_alloc(struct icem_comp **cp, struct icem *icem, int id, int icem_comp_set_default_cand(struct icem_comp *comp) { - struct cand *cand; + struct ice_cand *cand; if (!comp) return EINVAL; @@ -172,7 +173,8 @@ int icem_comp_set_default_cand(struct icem_comp *comp) } -void icem_comp_set_default_rcand(struct icem_comp *comp, struct cand *rcand) +void icem_comp_set_default_rcand(struct icem_comp *comp, + struct ice_cand *rcand) { if (!comp) return; diff --git a/src/ice/connchk.c b/src/ice/connchk.c index 7ef779b..fd466fb 100644 --- a/src/ice/connchk.c +++ b/src/ice/connchk.c @@ -45,7 +45,7 @@ static struct candpair *construct_valid_pair(struct icem *icem, const struct sa *mapped, const struct sa *dest) { - struct cand *lcand, *rcand; + struct ice_cand *lcand, *rcand; struct candpair *cp2; int err; @@ -205,7 +205,7 @@ static void stunc_resp_handler(int err, uint16_t scode, const char *reason, int icem_conncheck_send(struct candpair *cp, bool use_cand, bool trigged) { - struct cand *lcand = cp->lcand; + struct ice_cand *lcand = cp->lcand; struct icem *icem = cp->icem; struct ice *ice = icem->ice; char username_buf[64]; diff --git a/src/ice/gather.c b/src/ice/gather.c index 5e87718..1705acf 100644 --- a/src/ice/gather.c +++ b/src/ice/gather.c @@ -58,7 +58,7 @@ static void stun_resp_handler(int err, uint16_t scode, const char *reason, struct icem_comp *comp = arg; struct icem *icem = comp->icem; struct stun_attr *attr; - struct cand *lcand; + struct ice_cand *lcand; --icem->nstun; @@ -118,7 +118,7 @@ static void turnc_handler(int err, uint16_t scode, const char *reason, { struct icem_comp *comp = arg; struct icem *icem = comp->icem; - struct cand *lcand; + struct ice_cand *lcand; (void)msg; --icem->nstun; diff --git a/src/ice/ice.h b/src/ice/ice.h index ab1e112..3037de9 100644 --- a/src/ice/ice.h +++ b/src/ice/ice.h @@ -65,8 +65,8 @@ struct ice { struct icem_comp { struct le le; /**< Linked-list element */ struct icem *icem; /**< Parent ICE media */ - struct cand *def_lcand; /**< Default local candidate */ - struct cand *def_rcand; /**< Default remote candidate */ + struct ice_cand *def_lcand; /**< Default local candidate */ + struct ice_cand *def_rcand; /**< Default remote candidate */ struct candpair *cp_sel; /**< Selected candidate-pair */ struct udp_helper *uh; /**< UDP helper */ void *sock; /**< Transport socket */ @@ -103,7 +103,7 @@ struct icem { }; /** Defines a candidate */ -struct cand { +struct ice_cand { struct le le; /**< List element */ enum ice_cand_type type; /**< Candidate type */ uint32_t prio; /**< Priority of this candidate */ @@ -112,9 +112,9 @@ struct cand { struct sa rel; /**< Related IP address and port number */ struct sa addr; /**< Transport address */ enum ice_transp transp; /**< Transport protocol */ - struct cand *base; /**< Links to base candidate, if any */ /* extra for local */ + struct ice_cand *base; /**< Links to base candidate, if any */ char *ifname; /**< Network interface, for diagnostics */ }; @@ -123,8 +123,8 @@ struct candpair { struct le le; /**< List element */ struct icem *icem; /**< Pointer to parent ICE media */ struct icem_comp *comp; /**< Pointer to media-stream component */ - struct cand *lcand; /**< Local candidate */ - struct cand *rcand; /**< Remote candidate */ + struct ice_cand *lcand; /**< Local candidate */ + struct ice_cand *rcand; /**< Remote candidate */ bool def; /**< Default flag */ bool valid; /**< Valid flag */ bool nominated; /**< Nominated flag */ @@ -140,27 +140,28 @@ struct candpair { int icem_lcand_add_base(struct icem *icem, unsigned compid, uint16_t lprio, const char *ifname, enum ice_transp transp, const struct sa *addr); -int icem_lcand_add(struct icem *icem, struct cand *base, +int icem_lcand_add(struct icem *icem, struct ice_cand *base, enum ice_cand_type type, const struct sa *addr); int icem_rcand_add(struct icem *icem, enum ice_cand_type type, unsigned compid, uint32_t prio, const struct sa *addr, const struct sa *rel_addr, const struct pl *foundation); -int icem_rcand_add_prflx(struct cand **rcp, struct icem *icem, unsigned compid, - uint32_t prio, const struct sa *addr); -struct cand *icem_cand_find(const struct list *lst, unsigned compid, - const struct sa *addr); -struct cand *icem_lcand_find_checklist(const struct icem *icem, - unsigned compid); +int icem_rcand_add_prflx(struct ice_cand **rcp, struct icem *icem, + unsigned compid, uint32_t prio, + const struct sa *addr); +struct ice_cand *icem_cand_find(const struct list *lst, unsigned compid, + const struct sa *addr); +struct ice_cand *icem_lcand_find_checklist(const struct icem *icem, + unsigned compid); int icem_cands_debug(struct re_printf *pf, const struct list *lst); -int icem_cand_print(struct re_printf *pf, const struct cand *c); +int icem_cand_print(struct re_printf *pf, const struct ice_cand *cand); /* candpair */ int icem_candpair_alloc(struct candpair **cpp, struct icem *icem, - struct cand *lcand, struct cand *rcand); + struct ice_cand *lcand, struct ice_cand *rcand); int icem_candpair_clone(struct candpair **cpp, struct candpair *cp0, - struct cand *lcand, struct cand *rcand); + struct ice_cand *lcand, struct ice_cand *rcand); void icem_candpair_prio_order(struct list *lst); void icem_candpair_cancel(struct candpair *cp); void icem_candpair_make_valid(struct candpair *cp); @@ -173,14 +174,14 @@ bool icem_candpair_cmp(const struct candpair *cp1, const struct candpair *cp2); bool icem_candpair_cmp_fnd(const struct candpair *cp1, const struct candpair *cp2); struct candpair *icem_candpair_find(const struct list *lst, - const struct cand *lcand, - const struct cand *rcand); + const struct ice_cand *lcand, + const struct ice_cand *rcand); struct candpair *icem_candpair_find_st(const struct list *lst, unsigned compid, enum candpair_state state); struct candpair *icem_candpair_find_compid(const struct list *lst, unsigned compid); struct candpair *icem_candpair_find_rcand(struct icem *icem, - const struct cand *rcand); + const struct ice_cand *rcand); int icem_candpair_debug(struct re_printf *pf, const struct candpair *cp); int icem_candpairs_debug(struct re_printf *pf, const struct list *list); @@ -204,7 +205,8 @@ void icem_checklist_update(struct icem *icem); int icem_comp_alloc(struct icem_comp **cp, struct icem *icem, int id, void *sock); int icem_comp_set_default_cand(struct icem_comp *comp); -void icem_comp_set_default_rcand(struct icem_comp *comp, struct cand *rcand); +void icem_comp_set_default_rcand(struct icem_comp *comp, + struct ice_cand *rcand); void icem_comp_set_selected(struct icem_comp *comp, struct candpair *cp); struct icem_comp *icem_comp_find(const struct icem *icem, unsigned compid); void icem_comp_keepalive(struct icem_comp *comp, bool enable); diff --git a/src/ice/icem.c b/src/ice/icem.c index 0a8fc39..0490455 100644 --- a/src/ice/icem.c +++ b/src/ice/icem.c @@ -165,7 +165,7 @@ int icem_cand_add(struct icem *icem, unsigned compid, uint16_t lprio, static void *unique_handler(struct le *le1, struct le *le2) { - struct cand *c1 = le1->data, *c2 = le2->data; + struct ice_cand *c1 = le1->data, *c2 = le2->data; if (c1->base != c2->base || !sa_cmp(&c1->addr, &c2->addr, SA_ALL)) return NULL; @@ -218,7 +218,7 @@ const struct sa *icem_cand_default(struct icem *icem, unsigned compid) bool icem_verify_support(struct icem *icem, unsigned compid, const struct sa *raddr) { - struct cand *rcand; + struct ice_cand *rcand; bool match; if (!icem) diff --git a/src/ice/icesdp.c b/src/ice/icesdp.c index 64e5ac2..e2412c2 100644 --- a/src/ice/icesdp.c +++ b/src/ice/icesdp.c @@ -64,7 +64,7 @@ static enum ice_transp transp_resolve(const struct pl *transp) * * @return 0 if success, otherwise errorcode */ -int ice_cand_encode(struct re_printf *pf, const struct cand *cand) +int ice_cand_encode(struct re_printf *pf, const struct ice_cand *cand) { int err; @@ -119,7 +119,7 @@ int ice_remotecands_encode(struct re_printf *pf, const struct icem *icem) for (le = icem->rcandl.head; le && !err; le = le->next) { - const struct cand *rcand = le->data; + const struct ice_cand *rcand = le->data; err = re_hprintf(pf, "%s%d %j %u", icem->rcandl.head==le ? "" : " ", diff --git a/src/ice/stunsrv.c b/src/ice/stunsrv.c index 11459a1..6862d91 100644 --- a/src/ice/stunsrv.c +++ b/src/ice/stunsrv.c @@ -25,8 +25,8 @@ static const char *sw = "ice stunsrv v" VERSION " (" ARCH "/" OS ")"; -static void triggered_check(struct icem *icem, struct cand *lcand, - struct cand *rcand) +static void triggered_check(struct icem *icem, struct ice_cand *lcand, + struct ice_cand *rcand) { struct candpair *cp = NULL; int err; @@ -96,7 +96,7 @@ static int handle_stun_full(struct ice *ice, struct icem *icem, struct icem_comp *comp, const struct sa *src, uint32_t prio, bool use_cand, bool tunnel) { - struct cand *lcand = NULL, *rcand; + struct ice_cand *lcand = NULL, *rcand; struct candpair *cp = NULL; int err; @@ -177,7 +177,7 @@ static int handle_stun_lite(struct icem *icem, struct icem_comp *comp, const struct sa *src, bool use_cand) { - struct cand *lcand, *rcand; + struct ice_cand *lcand, *rcand; struct candpair *cp; int err;