diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-02-15 11:18:38 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-02-17 19:34:27 +0100 |
commit | 599c9a4b9aa3faa0b9c05dfcf6057ad9ccd4dfa6 (patch) | |
tree | 40716cc4f1523af395aaa4902458faabc74389e2 /src | |
parent | 2ff47b8606d93a301cf6cecb0d32fa4b77f5c5c9 (diff) |
mtp: Allocate the MTPLinkSet as a child of the BSC
In preparation of the VTY code change, make the mtp linkset
a child of the bsc.
Diffstat (limited to 'src')
-rw-r--r-- | src/bsc.c | 2 | ||||
-rw-r--r-- | src/links.c | 2 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/main_stp.c | 9 | ||||
-rw-r--r-- | src/mtp_layer3.c | 17 | ||||
-rw-r--r-- | src/vty_interface.c | 14 |
6 files changed, 19 insertions, 29 deletions
@@ -35,7 +35,7 @@ struct bsc_data *bsc_data_create() return NULL; } - INIT_LLIST_HEAD(&bsc->links); + INIT_LLIST_HEAD(&bsc->linksets); bsc->dpc = 1; bsc->opc = 0; bsc->sccp_opc = -1; diff --git a/src/links.c b/src/links.c index b694b8c..b74d843 100644 --- a/src/links.c +++ b/src/links.c @@ -106,7 +106,7 @@ struct mtp_link_set *link_init(struct bsc_data *bsc) struct mtp_udp_link *lnk; struct mtp_link_set *set; - set = mtp_link_set_alloc(); + set = mtp_link_set_alloc(bsc); set->name = talloc_strdup(set, "MTP"); set->dpc = bsc->dpc; set->opc = bsc->opc; @@ -85,7 +85,7 @@ static void sigint() printf("Terminating.\n"); handled = 1; if (bsc && bsc->setup) { - llist_for_each_entry(set, &bsc->links, entry) + llist_for_each_entry(set, &bsc->linksets, entry) link_shutdown_all(set); } @@ -175,7 +175,6 @@ int main(int argc, char **argv) struct mtp_link_set *set; - mtp_link_set_init(); thread_init(); log_init(&log_info); @@ -222,7 +221,6 @@ int main(int argc, char **argv) if (!set) return -1; - llist_add(&set->entry, &bsc->links); set->fw = &bsc->msc_forward; bsc->msc_forward.bsc = set; diff --git a/src/main_stp.c b/src/main_stp.c index 43491b8..a26823d 100644 --- a/src/main_stp.c +++ b/src/main_stp.c @@ -112,7 +112,7 @@ static void sigint() printf("Terminating.\n"); handled = 1; if (bsc && bsc->setup) { - llist_for_each_entry(set, &bsc->links, entry) + llist_for_each_entry(set, &bsc->linksets, entry) link_shutdown_all(set); } exit(0); @@ -182,7 +182,7 @@ static struct mtp_link_set *find_link_set(struct bsc_data *bsc, { struct mtp_link_set *set; - llist_for_each_entry(set, &bsc->links, entry) + llist_for_each_entry(set, &bsc->linksets, entry) if (strncmp(buf, set->name, len) == 0) return set; @@ -308,7 +308,6 @@ int main(int argc, char **argv) struct mtp_link_set *m2ua_set; struct mtp_m2ua_link *lnk; - mtp_link_set_init(); thread_init(); log_init(&log_info); @@ -356,9 +355,8 @@ int main(int argc, char **argv) set = link_init(bsc); if (!set) return -1; - llist_add(&set->entry, &bsc->links); - m2ua_set = mtp_link_set_alloc(); + m2ua_set = mtp_link_set_alloc(bsc); m2ua_set->dpc = 92; m2ua_set->opc = 9; m2ua_set->sccp_opc = 9; @@ -367,7 +365,6 @@ int main(int argc, char **argv) m2ua_set->bsc = bsc; m2ua_set->pcap_fd = bsc->pcap_fd; m2ua_set->name = talloc_strdup(m2ua_set, "M2UA"); - llist_add(&m2ua_set->entry, &bsc->links); /* setup things */ set->pass_all_isup = bsc->isup_pass; diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c index 71db16d..ecc1370 100644 --- a/src/mtp_layer3.c +++ b/src/mtp_layer3.c @@ -33,8 +33,6 @@ #include <string.h> -static void *tall_mtp_ctx = NULL; - static int mtp_int_submit(struct mtp_link_set *link, int pc, int sls, int type, const uint8_t *data, unsigned int length); void mtp_link_submit(struct mtp_link *link, struct msgb *msg) @@ -185,23 +183,17 @@ static struct msgb *mtp_sccp_alloc_scmg(struct mtp_link_set *link, return out; } -void mtp_link_set_init(void) +struct mtp_link_set *mtp_link_set_alloc(struct bsc_data *bsc) { - tall_mtp_ctx = talloc_named_const(NULL, 1, "mtp-link"); -} - -struct mtp_link_set *mtp_link_set_alloc(void) -{ - static int linkset_no = 0; struct mtp_link_set *link; - link = talloc_zero(tall_mtp_ctx, struct mtp_link_set); + 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(), - linkset_no++); + bsc->num_linksets + 1); if (!link->ctrg) { LOGP(DINP, LOGL_ERROR, "Failed to allocate counter.\n"); return NULL; @@ -211,6 +203,9 @@ struct mtp_link_set *mtp_link_set_alloc(void) link->ni = MTP_NI_NATION_NET; INIT_LLIST_HEAD(&link->links); + link->no = bsc->num_linksets++; + llist_add(&link->entry, &bsc->linksets); + return link; } diff --git a/src/vty_interface.c b/src/vty_interface.c index 3d2b6a6..fbf0200 100644 --- a/src/vty_interface.c +++ b/src/vty_interface.c @@ -266,7 +266,7 @@ DEFUN(cfg_isup_pass, cfg_isup_pass_cmd, bsc->isup_pass = atoi(argv[0]); - llist_for_each_entry(set, &bsc->links, entry) + llist_for_each_entry(set, &bsc->linksets, entry) set->pass_all_isup = bsc->isup_pass; return CMD_SUCCESS; @@ -291,7 +291,7 @@ DEFUN(show_stats, show_stats_cmd, { struct mtp_link_set *set; - llist_for_each_entry(set, &bsc->links, entry) + llist_for_each_entry(set, &bsc->linksets, entry) dump_stats(vty, set); return CMD_SUCCESS; @@ -330,7 +330,7 @@ DEFUN(show_linksets, show_linksets_cmd, { struct mtp_link_set *set; - llist_for_each_entry(set, &bsc->links, entry) + llist_for_each_entry(set, &bsc->linksets, entry) dump_state(vty, set); return CMD_SUCCESS; } @@ -365,7 +365,7 @@ DEFUN(show_slc, show_slc_cmd, struct mtp_link_set *set = NULL; int i; - set = find_link_set(&bsc->links, argv[0]); + set = find_link_set(&bsc->linksets, argv[0]); if (!set) { vty_out(vty, "Failed to find linkset.%s", VTY_NEWLINE); @@ -392,7 +392,7 @@ DEFUN(pcap_set, pcap_set_cmd, { struct mtp_link_set *set = NULL; - set = find_link_set(&bsc->links, argv[0]); + set = find_link_set(&bsc->linksets, argv[0]); if (!set) { vty_out(vty, "Failed to find linkset.%s", VTY_NEWLINE); @@ -420,7 +420,7 @@ DEFUN(pcap_set_stop, pcap_set_stop_cmd, { struct mtp_link_set *set = NULL; - set = find_link_set(&bsc->links, argv[0]); + set = find_link_set(&bsc->linksets, argv[0]); if (!set) { vty_out(vty, "Failed to find linkset.%s", VTY_NEWLINE); @@ -436,7 +436,7 @@ DEFUN(pcap_set_stop, pcap_set_stop_cmd, #define FIND_LINK(vty, type, nr) ({ \ struct mtp_link_set *set = NULL; \ struct mtp_link *link = NULL, *tmp; \ - set = find_link_set(&bsc->links, type); \ + set = find_link_set(&bsc->linksets, type); \ if (!set) { \ vty_out(vty, "Unknown linkset %s.%s", type, VTY_NEWLINE); \ return CMD_WARNING; \ |