aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-02-15 11:24:05 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-02-17 19:34:27 +0100
commit694337f8939aadeff60d931f827184f6c37f1926 (patch)
tree24dcb1af005b91268cebfe606d3bb051811ccf95
parent599c9a4b9aa3faa0b9c05dfcf6057ad9ccd4dfa6 (diff)
mtp: Allow to find a linkset by number
-rw-r--r--include/mtp_data.h1
-rw-r--r--src/mtp_layer3.c63
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;
+}