aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/links.c62
-rw-r--r--src/main.c6
-rw-r--r--src/main_udt.c2
-rw-r--r--src/mtp_layer3.c13
4 files changed, 62 insertions, 21 deletions
diff --git a/src/links.c b/src/links.c
index b9458e5..6764b54 100644
--- a/src/links.c
+++ b/src/links.c
@@ -51,14 +51,15 @@ void mtp_link_set_submit(struct link_data *link, struct msgb *msg)
link->write(link, msg);
}
-void mtp_link_set_restart(struct mtp_link_set *set)
+void mtp_link_restart(struct link_data *link)
{
LOGP(DINP, LOGL_ERROR, "Need to restart the SS7 link.\n");
- set->link->reset(set->link);
+ link->reset(link);
}
static void start_rest(void *start)
{
+ struct link_data *data;
bsc.setup = 1;
if (msc_init(&bsc, 1) != 0) {
@@ -66,11 +67,14 @@ static void start_rest(void *start)
exit(3);
}
- bsc.link_set->link->start(bsc.link_set->link);
+ llist_for_each_entry(data, &bsc.link_set->links, entry)
+ data->start(data);
}
int link_init(struct bsc_data *bsc)
{
+ struct link_data *lnk;
+
bsc->link_set = mtp_link_set_alloc();
bsc->link_set->dpc = bsc->dpc;
bsc->link_set->opc = bsc->opc;
@@ -80,12 +84,13 @@ int link_init(struct bsc_data *bsc)
bsc->link_set->spare = bsc->ni_spare;
bsc->link_set->bsc = bsc;
- bsc->link_set->link = talloc_zero(bsc->link_set, struct link_data);
- bsc->link_set->link->bsc = bsc;
- bsc->link_set->link->udp.link_index = 1;
- bsc->link_set->link->pcap_fd = bsc->pcap_fd;
- bsc->link_set->link->udp.reset_timeout = bsc->udp_reset_timeout;
- bsc->link_set->link->the_link = bsc->link_set;
+ lnk = talloc_zero(bsc->link_set, struct link_data);
+ lnk->bsc = bsc;
+ lnk->udp.link_index = 1;
+ lnk->pcap_fd = bsc->pcap_fd;
+ lnk->udp.reset_timeout = bsc->udp_reset_timeout;
+ lnk->the_link = bsc->link_set;
+ mtp_link_set_add_link(bsc->link_set, lnk);
if (!bsc->src_port) {
LOGP(DINP, LOGL_ERROR, "You need to set a UDP address.\n");
@@ -95,12 +100,12 @@ int link_init(struct bsc_data *bsc)
LOGP(DINP, LOGL_NOTICE, "Using UDP MTP mode.\n");
/* setup SNMP first, it is blocking */
- bsc->link_set->link->udp.session = snmp_mtp_session_create(bsc->udp_ip);
- if (!bsc->link_set->link->udp.session)
+ lnk->udp.session = snmp_mtp_session_create(bsc->udp_ip);
+ if (!lnk->udp.session)
return -1;
/* now connect to the transport */
- if (link_udp_init(bsc->link_set->link, bsc->src_port, bsc->udp_ip, bsc->udp_port) != 0)
+ if (link_udp_init(lnk, bsc->src_port, bsc->udp_ip, bsc->udp_port) != 0)
return -1;
/*
@@ -109,12 +114,39 @@ int link_init(struct bsc_data *bsc)
* SLTM and it begins a reset. Then we will take it up
* again and do the usual business.
*/
- snmp_mtp_deactivate(bsc->link_set->link->udp.session,
- bsc->link_set->link->udp.link_index);
+ snmp_mtp_deactivate(lnk->udp.session,
+ lnk->udp.link_index);
bsc->start_timer.cb = start_rest;
bsc->start_timer.data = &bsc;
- bsc_schedule_timer(&bsc->start_timer, bsc->link_set->link->udp.reset_timeout, 0);
+ bsc_schedule_timer(&bsc->start_timer, lnk->udp.reset_timeout, 0);
LOGP(DMSC, LOGL_NOTICE, "Making sure SLTM will timeout.\n");
return 0;
}
+
+int link_shutdown_all(struct mtp_link_set *set)
+{
+ struct link_data *lnk;
+
+ llist_for_each_entry(lnk, &set->links, entry)
+ lnk->shutdown(lnk);
+ return 0;
+}
+
+int link_reset_all(struct mtp_link_set *set)
+{
+ struct link_data *lnk;
+
+ llist_for_each_entry(lnk, &set->links, entry)
+ lnk->reset(lnk);
+ return 0;
+}
+
+int link_clear_all(struct mtp_link_set *set)
+{
+ struct link_data *lnk;
+
+ llist_for_each_entry(lnk, &set->links, entry)
+ lnk->clear_queue(lnk);
+ return 0;
+}
diff --git a/src/main.c b/src/main.c
index a8edb97..3163527 100644
--- a/src/main.c
+++ b/src/main.c
@@ -194,7 +194,7 @@ static void clear_connections(struct bsc_data *bsc)
free_con(con);
}
- bsc->link_set->link->clear_queue(bsc->link_set->link);
+ link_clear_all(bsc->link_set);
}
void bsc_resources_released(struct bsc_data *bsc)
@@ -212,7 +212,7 @@ static void bsc_reset_timeout(void *_data)
LOGP(DINP, LOGL_ERROR, "The BSC did not answer the GSM08.08 reset. Restart MTP\n");
mtp_link_set_stop(bsc->link_set);
clear_connections(bsc);
- bsc->link_set->link->reset(bsc->link_set->link);
+ link_reset_all(bsc->link_set);
bsc_resources_released(bsc);
return;
}
@@ -547,7 +547,7 @@ static void sigint()
printf("Terminating.\n");
handled = 1;
if (bsc.setup)
- bsc.link_set->link->shutdown(bsc.link_set->link);
+ link_shutdown_all(bsc.link_set);
exit(0);
out:
diff --git a/src/main_udt.c b/src/main_udt.c
index b8d754e..f13d4dd 100644
--- a/src/main_udt.c
+++ b/src/main_udt.c
@@ -104,7 +104,7 @@ static void sigint()
printf("Terminating.\n");
handled = 1;
if (bsc.setup)
- bsc.link_set->link->shutdown(bsc.link_set->link);
+ link_shutdown_all(bsc.link_set);
exit(0);
out:
diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c
index e6eb2c3..bbf1f26 100644
--- a/src/mtp_layer3.c
+++ b/src/mtp_layer3.c
@@ -20,6 +20,7 @@
*/
#include <mtp_data.h>
#include <mtp_level3.h>
+#include <bsc_data.h>
#include <cellmgr_debug.h>
#include <isup_types.h>
@@ -220,7 +221,7 @@ static void mtp_sltm_t1_timeout(void *_link)
link->running = 0;
bsc_del_timer(&link->t2_timer);
mtp_link_set_sccp_down(link);
- mtp_link_set_restart(link);
+ mtp_link_restart(link->slc[0]);
}
}
@@ -264,6 +265,8 @@ struct mtp_link_set *mtp_link_set_alloc(void)
link->t2_timer.cb = mtp_sltm_t2_timeout;
link->delay_timer.data = link;
link->delay_timer.cb = mtp_delayed_start;
+ INIT_LLIST_HEAD(&link->links);
+
return link;
}
@@ -552,5 +555,11 @@ void mtp_link_set_init_slc(struct mtp_link_set *set)
{
int i;
for (i = 0; i < ARRAY_SIZE(set->slc); ++i)
- set->slc[i] = set->link;
+ set->slc[i] = (struct link_data *) set->links.next;
+}
+
+void mtp_link_set_add_link(struct mtp_link_set *set, struct link_data *lnk)
+{
+ llist_add_tail(&lnk->entry, &set->links);
+ mtp_link_set_init_slc(set);
}