aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-12-20 15:59:02 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-01-01 14:22:27 +0100
commitaa92ad5bade8a7d70e6761bf75e86a9017e8e366 (patch)
treee43cd3c0c070ac1f6b07a6d06206c6caf9cf19e6
parenta95dd278d3ce4837f429b8f061ff8db570031884 (diff)
linkset: Hide up/down behind the concept of a link set
Hide the link up/down behind a linkset up/down. Only if all links are down the linkset will go down, if one link goes up we will be happy to use it.
-rw-r--r--include/bsc_data.h4
-rw-r--r--src/links.c42
-rw-r--r--src/main.c31
-rw-r--r--src/main_udt.c19
4 files changed, 60 insertions, 36 deletions
diff --git a/include/bsc_data.h b/include/bsc_data.h
index f712cb3..73bcb5b 100644
--- a/include/bsc_data.h
+++ b/include/bsc_data.h
@@ -134,6 +134,10 @@ void release_bsc_resources(struct bsc_data *bsc);
void bsc_link_down(struct link_data *data);
void bsc_link_up(struct link_data *data);
+/* linkset related */
+void bsc_linkset_down(struct bsc_data *bsc);
+void bsc_linkset_up(struct bsc_data *bsc);
+
/* msc related functions */
int msc_init(struct bsc_data *bsc, int mgcp);
void msc_send_rlc(struct bsc_data *bsc, struct sccp_source_reference *src, struct sccp_source_reference *dest);
diff --git a/src/links.c b/src/links.c
index 65a89a6..88f1d5a 100644
--- a/src/links.c
+++ b/src/links.c
@@ -229,3 +229,45 @@ void linkset_clear_pending(struct bsc_data *bsc)
}
}
}
+
+/* One of the links of the linkset failed */
+void bsc_link_down(struct link_data *data)
+{
+ struct link_data *link;
+ struct bsc_data *bsc;
+ int one_up = 0;
+
+ bsc = data->bsc;
+ data->the_link->available = 0;
+
+ llist_for_each_entry(link, &bsc->links, entry)
+ one_up |= link->the_link->available;
+
+
+ mtp_link_stop(data->the_link);
+
+ if (!one_up)
+ bsc_linkset_down(bsc);
+
+ data->clear_queue(data);
+}
+
+/* One of the links of the linkset is back */
+void bsc_link_up(struct link_data *data)
+{
+ struct link_data *link;
+ struct bsc_data *bsc;
+ int one_up = 0;
+
+ bsc = data->bsc;
+ llist_for_each_entry(link, &bsc->links, entry)
+ one_up |= link->the_link->available;
+
+ data->the_link->available = 1;
+
+ /* if at least one link is back... report it as up */
+ if (!one_up)
+ bsc_linkset_up(bsc);
+
+ mtp_link_reset(data->the_link);
+}
diff --git a/src/main.c b/src/main.c
index 0e40926..5c13a21 100644
--- a/src/main.c
+++ b/src/main.c
@@ -299,37 +299,26 @@ void release_bsc_resources(struct bsc_data *bsc)
msc_clear_queue(bsc);
}
-void bsc_link_down(struct link_data *data)
+void bsc_linkset_down(struct bsc_data *bsc)
{
- int was_up;
- struct mtp_link *link = data->the_link;
-
- link->available = 0;
- was_up = link->sccp_up;
- mtp_link_stop(link);
- clear_connections(data->bsc);
- mgcp_reset(data->bsc);
-
- data->clear_queue(data);
+ clear_connections(bsc);
/* clear pending messages from the MSC */
- msc_clear_queue(data->bsc);
+ msc_clear_queue(bsc);
/* If we have an A link send a reset to the MSC */
- msc_send_reset(data->bsc);
+ msc_send_reset(bsc);
+
+ mgcp_reset(bsc);
}
-void bsc_link_up(struct link_data *data)
+void bsc_linkset_up(struct bsc_data *bsc)
{
- data->the_link->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 (bsc->msc_link_down) {
+ clear_connections(bsc);
+ bsc_resources_released(bsc);
}
-
- mtp_link_reset(data->the_link);
}
/**
diff --git a/src/main_udt.c b/src/main_udt.c
index 3c7d296..3e2e6fb 100644
--- a/src/main_udt.c
+++ b/src/main_udt.c
@@ -78,28 +78,17 @@ void mtp_link_forward_sccp(struct mtp_link *link, struct msgb *_msg, int sls)
msc_send_direct(&bsc, _msg);
}
-void bsc_link_down(struct link_data *data)
+void bsc_linkset_down(struct bsc_data *bsc)
{
- int was_up;
- struct mtp_link *link = data->the_link;
-
- link->available = 0;
- was_up = link->sccp_up;
- mtp_link_stop(link);
-
- data->clear_queue(data);
-
/* clear pending messages from the MSC */
- msc_clear_queue(data->bsc);
+ msc_clear_queue(bsc);
/* If we have an A link send a reset to the MSC */
- msc_send_reset(data->bsc);
+ msc_send_reset(bsc);
}
-void bsc_link_up(struct link_data *data)
+void bsc_linkset_up(struct bsc_data *data)
{
- data->the_link->available = 1;
- mtp_link_reset(data->the_link);
}
static void print_usage()