diff options
-rw-r--r-- | include/mtp_data.h | 1 | ||||
-rw-r--r-- | src/mtp_layer3.c | 63 |
2 files changed, 38 insertions, 26 deletions
diff --git a/include/mtp_data.h b/include/mtp_data.h index 3330de6..d054de8 100644 --- a/include/mtp_data.h +++ b/include/mtp_data.h @@ -158,5 +158,6 @@ struct msgb *mtp_msg_alloc(struct mtp_link_set *link); /* link management */ struct mtp_link_set *mtp_link_set_alloc(struct bsc_data *bsc); +struct mtp_link_set *mtp_link_set_num(struct bsc_data *bsc, int num); #endif diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c index ecc1370..507990d 100644 --- a/src/mtp_layer3.c +++ b/src/mtp_layer3.c @@ -183,32 +183,6 @@ static struct msgb *mtp_sccp_alloc_scmg(struct mtp_link_set *link, return out; } -struct mtp_link_set *mtp_link_set_alloc(struct bsc_data *bsc) -{ - struct mtp_link_set *link; - - link = talloc_zero(bsc, struct mtp_link_set); - if (!link) - return NULL; - - link->ctrg = rate_ctr_group_alloc(link, - mtp_link_set_rate_ctr_desc(), - bsc->num_linksets + 1); - if (!link->ctrg) { - LOGP(DINP, LOGL_ERROR, "Failed to allocate counter.\n"); - return NULL; - } - - - link->ni = MTP_NI_NATION_NET; - INIT_LLIST_HEAD(&link->links); - - link->no = bsc->num_linksets++; - llist_add(&link->entry, &bsc->linksets); - - return link; -} - void mtp_link_set_stop(struct mtp_link_set *link) { struct mtp_link *lnk; @@ -620,3 +594,40 @@ int mtp_link_set_add_link(struct mtp_link_set *set, struct mtp_link *lnk) mtp_link_set_init_slc(set); return 0; } + +struct mtp_link_set *mtp_link_set_alloc(struct bsc_data *bsc) +{ + struct mtp_link_set *link; + + link = talloc_zero(bsc, struct mtp_link_set); + if (!link) + return NULL; + + link->ctrg = rate_ctr_group_alloc(link, + mtp_link_set_rate_ctr_desc(), + bsc->num_linksets + 1); + if (!link->ctrg) { + LOGP(DINP, LOGL_ERROR, "Failed to allocate counter.\n"); + return NULL; + } + + + link->ni = MTP_NI_NATION_NET; + INIT_LLIST_HEAD(&link->links); + + link->no = bsc->num_linksets++; + llist_add(&link->entry, &bsc->linksets); + + return link; +} + +struct mtp_link_set *mtp_link_set_num(struct bsc_data *bsc, int num) +{ + struct mtp_link_set *set; + + llist_for_each_entry(set, &bsc->linksets, entry) + if (set->no == num) + return set; + + return NULL; +} |