aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-01-02 16:41:11 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-01-17 11:21:10 +0100
commitb6edf97481737d5846bdd65bda15d8762ffc0c78 (patch)
tree9a866b9564a64dd11cebc85e94b5aa44eef590d3
parent016ba29ec23c65ff3ccbd12e6128384567d34406 (diff)
linkset: Prepare the UDP support to support multiple links.
-rw-r--r--include/bsc_data.h1
-rw-r--r--include/snmp_mtp.h4
-rw-r--r--src/link_udp.c6
-rw-r--r--src/links.c4
-rw-r--r--src/snmp_mtp.c8
5 files changed, 13 insertions, 10 deletions
diff --git a/include/bsc_data.h b/include/bsc_data.h
index 7ac39f8..32fc94f 100644
--- a/include/bsc_data.h
+++ b/include/bsc_data.h
@@ -52,6 +52,7 @@ struct link_data {
struct write_queue write_queue;
struct sockaddr_in remote;
struct snmp_mtp_session *session;
+ int link_index;
int reset_timeout;
} udp;
};
diff --git a/include/snmp_mtp.h b/include/snmp_mtp.h
index fea3c66..a42b08e 100644
--- a/include/snmp_mtp.h
+++ b/include/snmp_mtp.h
@@ -32,7 +32,7 @@ void snmp_mtp_start_c7_datalink(struct snmp_mtp_session *, int link_id);
void snmp_mtp_stop_c7_datalink(struct snmp_mtp_session *, int link_id);
struct snmp_mtp_session *snmp_mtp_session_create(char *host);
-void snmp_mtp_deactivate(struct snmp_mtp_session *);
-void snmp_mtp_activate(struct snmp_mtp_session *);
+void snmp_mtp_deactivate(struct snmp_mtp_session *, int link_id);
+void snmp_mtp_activate(struct snmp_mtp_session *, int link_id);
#endif
diff --git a/src/link_udp.c b/src/link_udp.c
index b5da7f9..7fcf6f1 100644
--- a/src/link_udp.c
+++ b/src/link_udp.c
@@ -131,7 +131,7 @@ static void do_start(void *_data)
struct link_data *link = (struct link_data *) _data;
link->forced_down = 0;
- snmp_mtp_activate(link->udp.session);
+ snmp_mtp_activate(link->udp.session, link->udp.link_index);
bsc_link_up(link);
}
@@ -139,7 +139,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);
+ snmp_mtp_deactivate(link->udp.session, link->udp.link_index);
bsc_link_down(link);
/* restart the link in 90 seconds... to force a timeout on the BSC */
@@ -156,7 +156,7 @@ static int udp_link_write(struct link_data *link, struct msgb *msg)
hdr = (struct udp_data_hdr *) msgb_push(msg, sizeof(*hdr));
hdr->format_type = UDP_FORMAT_SIMPLE_UDP;
hdr->data_type = UDP_DATA_MSU_PRIO_0;
- hdr->data_link_index = htons(1);
+ hdr->data_link_index = htons(link->udp.link_index);
hdr->user_context = 0;
hdr->data_length = htonl(msgb_l2len(msg));
diff --git a/src/links.c b/src/links.c
index 9ddd98d..8816f71 100644
--- a/src/links.c
+++ b/src/links.c
@@ -65,6 +65,7 @@ int link_init(struct bsc_data *bsc)
bsc->link.the_link->ni = bsc->ni_ni;
bsc->link.the_link->spare = bsc->ni_spare;
bsc->link.bsc = bsc;
+ bsc->link.udp.link_index = 1;
if (!bsc->src_port) {
LOGP(DINP, LOGL_ERROR, "You need to set a UDP address.\n");
@@ -88,7 +89,8 @@ 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.udp.session);
+ snmp_mtp_deactivate(bsc->link.udp.session,
+ bsc->link.udp.link_index);
bsc->start_timer.cb = start_rest;
bsc->start_timer.data = &bsc;
bsc_schedule_timer(&bsc->start_timer, bsc->link.udp.reset_timeout, 0);
diff --git a/src/snmp_mtp.c b/src/snmp_mtp.c
index 6d85f31..ba3a219 100644
--- a/src/snmp_mtp.c
+++ b/src/snmp_mtp.c
@@ -100,12 +100,12 @@ struct snmp_mtp_session *snmp_mtp_session_create(char *host)
return session;
}
-void snmp_mtp_deactivate(struct snmp_mtp_session *session)
+void snmp_mtp_deactivate(struct snmp_mtp_session *session, int index)
{
- snmp_mtp_stop_c7_datalink(session, 1);
+ snmp_mtp_stop_c7_datalink(session, index);
}
-void snmp_mtp_activate(struct snmp_mtp_session *session)
+void snmp_mtp_activate(struct snmp_mtp_session *session, int index)
{
- snmp_mtp_start_c7_datalink(session, 1);
+ snmp_mtp_start_c7_datalink(session, index);
}