aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-01-02 20:24:08 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-01-17 11:21:11 +0100
commitc8405692b381e4079eeaf52f38610a6a24f64773 (patch)
tree1e60aff422dfe1dd703f2b0eecb7230e401faa1d /src
parent569f1e171df2f055d0be5fc637e050a523a9ae8a (diff)
mtp: Propagate link and linkset failures in two stages
Handle a single link failure in links.c and if all the links have failed propagate it up. This is preparing the multiple links support.
Diffstat (limited to 'src')
-rw-r--r--src/link_udp.c10
-rw-r--r--src/links.c12
-rw-r--r--src/main.c34
-rw-r--r--src/main_udt.c24
4 files changed, 40 insertions, 40 deletions
diff --git a/src/link_udp.c b/src/link_udp.c
index e5e476c..3fbc726 100644
--- a/src/link_udp.c
+++ b/src/link_udp.c
@@ -91,12 +91,12 @@ static int udp_read_cb(struct bsc_fd *fd)
if (hdr->data_type == UDP_DATA_RETR_COMPL || hdr->data_type == UDP_DATA_RETR_IMPOS) {
LOGP(DINP, LOGL_ERROR, "Link retrieval done. Restarting the link.\n");
- bsc_link_down(link);
- bsc_link_up(link);
+ mtp_link_down(link);
+ mtp_link_up(link);
goto exit;
} else if (hdr->data_type > UDP_DATA_MSU_PRIO_3) {
LOGP(DINP, LOGL_ERROR, "Link failure. retrieved message.\n");
- bsc_link_down(link);
+ mtp_link_down(link);
goto exit;
}
@@ -132,7 +132,7 @@ static void do_start(void *_data)
link->forced_down = 0;
snmp_mtp_activate(link->udp.session, link->udp.link_index);
- bsc_link_up(link);
+ mtp_link_up(link);
}
static int udp_link_reset(struct link_data *link)
@@ -140,7 +140,7 @@ static int udp_link_reset(struct link_data *link)
LOGP(DINP, LOGL_NOTICE, "Will restart SLTM transmission in %d seconds.\n",
link->udp.reset_timeout);
snmp_mtp_deactivate(link->udp.session, link->udp.link_index);
- bsc_link_down(link);
+ mtp_link_down(link);
/* restart the link in 90 seconds... to force a timeout on the BSC */
link->link_activate.cb = do_start;
diff --git a/src/links.c b/src/links.c
index adc74d1..233f323 100644
--- a/src/links.c
+++ b/src/links.c
@@ -27,6 +27,17 @@
extern struct bsc_data bsc;
+void mtp_link_down(struct link_data *link)
+{
+ mtp_linkset_down(link->the_link);
+ link->clear_queue(link);
+}
+
+void mtp_link_up(struct link_data *link)
+{
+ mtp_linkset_up(link->the_link);
+}
+
void mtp_link_set_sccp_down(struct mtp_link_set *link)
{
}
@@ -63,6 +74,7 @@ int link_init(struct bsc_data *bsc)
bsc->link.the_link->sltm_once = bsc->once;
bsc->link.the_link->ni = bsc->ni_ni;
bsc->link.the_link->spare = bsc->ni_spare;
+ bsc->link.the_link->bsc = bsc;
bsc->link.bsc = bsc;
bsc->link.udp.link_index = 1;
diff --git a/src/main.c b/src/main.c
index c764cc2..7a66cd8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,7 @@
/* Bloated main routine, refactor */
/*
- * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2010 by On-Waves
+ * (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010-2011 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
@@ -284,34 +284,28 @@ void release_bsc_resources(struct bsc_data *bsc)
}
}
-void bsc_link_down(struct link_data *data)
+void mtp_linkset_down(struct mtp_link_set *set)
{
- int was_up;
- struct mtp_link_set *link = data->the_link;
-
- link->available = 0;
- was_up = link->sccp_up;
- mtp_link_set_stop(link);
- clear_connections(data->bsc);
- mgcp_reset(data->bsc);
-
- data->clear_queue(data);
+ set->available = 0;
+ mtp_link_set_stop(set);
+ clear_connections(set->bsc);
+ mgcp_reset(set->bsc);
/* If we have an A link send a reset to the MSC */
- msc_send_reset(data->bsc);
+ msc_send_reset(set->bsc);
}
-void bsc_link_up(struct link_data *data)
+void mtp_linkset_up(struct mtp_link_set *set)
{
- data->the_link->available = 1;
+ set->available = 1;
/* we have not gone through link down */
- if (data->bsc->msc_link_down) {
- clear_connections(data->bsc);
- bsc_resources_released(data->bsc);
+ if (set->bsc->msc_link_down) {
+ clear_connections(set->bsc);
+ bsc_resources_released(set->bsc);
}
- mtp_link_set_reset(data->the_link);
+ mtp_link_set_reset(set);
}
/**
diff --git a/src/main_udt.c b/src/main_udt.c
index 1536301..40fe616 100644
--- a/src/main_udt.c
+++ b/src/main_udt.c
@@ -1,7 +1,7 @@
/* Relay UDT/all SCCP messages */
/*
- * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2010 by On-Waves
+ * (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010-2011 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
@@ -70,25 +70,19 @@ void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *_msg, int
msc_send_direct(&bsc, _msg);
}
-void bsc_link_down(struct link_data *data)
+void mtp_linkset_down(struct mtp_link_set *set)
{
- int was_up;
- struct mtp_link_set *link = data->the_link;
-
- link->available = 0;
- was_up = link->sccp_up;
- mtp_link_set_stop(link);
-
- data->clear_queue(data);
+ set->available = 0;
+ mtp_link_set_stop(set);
/* If we have an A link send a reset to the MSC */
- msc_send_reset(data->bsc);
+ msc_send_reset(set->bsc);
}
-void bsc_link_up(struct link_data *data)
+void mtp_linkset_up(struct mtp_link_set *set)
{
- data->the_link->available = 1;
- mtp_link_set_reset(data->the_link);
+ set->available = 1;
+ mtp_link_set_reset(set);
}
static void print_usage()