aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-03-18 19:25:42 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-03-18 19:25:42 +0100
commit3c0d6b3f6253d57a5e3a7045b0ac6d49fbe3f9e9 (patch)
tree499632af1a1ef6aaf4a5d783061b8eb39449aea8
parent83227e4dde874d02601e129fdb4f5bc5a95c0e20 (diff)
link_sets: Create a new file with just the generic linkset in there
-rw-r--r--src/Makefile.am4
-rw-r--r--src/links.c86
-rw-r--r--src/linkset.c113
3 files changed, 115 insertions, 88 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d2e211d..4955227 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,7 +16,7 @@ cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \
msc_conn.c link_udp.c snmp_mtp.c debug.c isup.c \
mtp_link.c counter.c sccp_state.c bsc.c ss7_application.c \
vty_interface_legacy.c vty_interface_cmds.c mgcp_patch.c \
- mgcp_callagent.c isup_filter.c
+ mgcp_callagent.c isup_filter.c linkset.c
cellmgr_ng_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) \
$(LIBOSMOSCCP_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto
@@ -26,7 +26,7 @@ osmo_stp_SOURCES = main_stp.c mtp_layer3.c thread.c pcap.c link_udp.c snmp_mtp.c
bss_patch.c bssap_sccp.c bsc_sccp.c bsc_ussd.c input/ipaccess.c \
mtp_link.c counter.c bsc.c ss7_application.c \
vty_interface.c vty_interface_cmds.c mgcp_patch.c \
- mgcp_callagent.c isup_filter.c
+ mgcp_callagent.c isup_filter.c linkset.c
osmo_stp_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) \
$(LIBOSMOSCCP_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto -lm2ua -lsctp
diff --git a/src/links.c b/src/links.c
index 4d3cdf0..59b45c8 100644
--- a/src/links.c
+++ b/src/links.c
@@ -26,9 +26,6 @@
#include <mtp_data.h>
#include <mtp_level3.h>
#include <mtp_pcap.h>
-#include <snmp_mtp.h>
-
-#include <osmocom/core/talloc.h>
extern struct bsc_data *bsc;
@@ -88,89 +85,6 @@ void mtp_link_restart(struct mtp_link *link)
link->reset(link);
}
-struct mtp_link_set *link_set_create(struct bsc_data *bsc)
-{
- struct mtp_link_set *set;
-
- set = mtp_link_set_alloc(bsc);
- set->name = talloc_strdup(set, "MTP");
-
- set->ni = MTP_NI_NATION_NET;
- set->spare = 0;
-
- set->supported_ssn[1] = 1;
- set->supported_ssn[7] = 1;
- set->supported_ssn[8] = 1;
- set->supported_ssn[146] = 1;
- set->supported_ssn[254] = 1;
-
- return set;
-}
-
-int link_set_init_links(struct bsc_data *bsc, struct mtp_link_set *set)
-{
- int i;
- struct mtp_udp_link *lnk;
- struct mtp_link *blnk;
-
-
- if (!bsc->udp_src_port) {
- LOGP(DINP, LOGL_ERROR, "You need to set a UDP address.\n");
- return -1;
- }
-
- LOGP(DINP, LOGL_NOTICE, "Using UDP MTP mode.\n");
-
- if (link_global_init(&bsc->udp_data) != 0)
- return -1;
-
- if (link_global_bind(&bsc->udp_data, bsc->udp_src_port) != 0)
- return -1;
-
- for (i = 1; i <= bsc->udp_nr_links; ++i) {
- blnk = mtp_link_alloc(set);
- lnk = mtp_udp_link_init(blnk);
-
- lnk->link_index = i;
-
- /* now connect to the transport */
- if (snmp_mtp_peer_name(lnk->session, bsc->udp_ip) != 0)
- return -1;
-
- if (link_udp_init(lnk, bsc->udp_ip, bsc->udp_port) != 0)
- return -1;
- }
-
- return 0;
-}
-
-int link_set_shutdown_links(struct mtp_link_set *set)
-{
- struct mtp_link *lnk;
-
- llist_for_each_entry(lnk, &set->links, entry)
- lnk->shutdown(lnk);
- return 0;
-}
-
-int link_set_reset_links(struct mtp_link_set *set)
-{
- struct mtp_link *lnk;
-
- llist_for_each_entry(lnk, &set->links, entry)
- lnk->reset(lnk);
- return 0;
-}
-
-int link_set_clear_links(struct mtp_link_set *set)
-{
- struct mtp_link *lnk;
-
- llist_for_each_entry(lnk, &set->links, entry)
- lnk->clear_queue(lnk);
- return 0;
-}
-
int mtp_handle_pcap(struct mtp_link *link, int dir, const uint8_t *data, int len)
{
if (link->pcap_fd >= 0)
diff --git a/src/linkset.c b/src/linkset.c
new file mode 100644
index 0000000..6ed91c1
--- /dev/null
+++ b/src/linkset.c
@@ -0,0 +1,113 @@
+/* link set management code */
+/*
+ * (C) 2010-2013 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010-2013 by On-Waves
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <bsc_data.h>
+#include <cellmgr_debug.h>
+#include <mtp_level3.h>
+#include <snmp_mtp.h>
+
+#include <osmocom/core/talloc.h>
+
+
+struct mtp_link_set *link_set_create(struct bsc_data *bsc)
+{
+ struct mtp_link_set *set;
+
+ set = mtp_link_set_alloc(bsc);
+ set->name = talloc_strdup(set, "MTP");
+
+ set->ni = MTP_NI_NATION_NET;
+ set->spare = 0;
+
+ set->supported_ssn[1] = 1;
+ set->supported_ssn[7] = 1;
+ set->supported_ssn[8] = 1;
+ set->supported_ssn[146] = 1;
+ set->supported_ssn[254] = 1;
+
+ return set;
+}
+
+int link_set_init_links(struct bsc_data *bsc, struct mtp_link_set *set)
+{
+ int i;
+ struct mtp_udp_link *lnk;
+ struct mtp_link *blnk;
+
+
+ if (!bsc->udp_src_port) {
+ LOGP(DINP, LOGL_ERROR, "You need to set a UDP address.\n");
+ return -1;
+ }
+
+ LOGP(DINP, LOGL_NOTICE, "Using UDP MTP mode.\n");
+
+ if (link_global_init(&bsc->udp_data) != 0)
+ return -1;
+
+ if (link_global_bind(&bsc->udp_data, bsc->udp_src_port) != 0)
+ return -1;
+
+ for (i = 1; i <= bsc->udp_nr_links; ++i) {
+ blnk = mtp_link_alloc(set);
+ lnk = mtp_udp_link_init(blnk);
+
+ lnk->link_index = i;
+
+ /* now connect to the transport */
+ if (snmp_mtp_peer_name(lnk->session, bsc->udp_ip) != 0)
+ return -1;
+
+ if (link_udp_init(lnk, bsc->udp_ip, bsc->udp_port) != 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+int link_set_shutdown_links(struct mtp_link_set *set)
+{
+ struct mtp_link *lnk;
+
+ llist_for_each_entry(lnk, &set->links, entry)
+ lnk->shutdown(lnk);
+ return 0;
+}
+
+int link_set_reset_links(struct mtp_link_set *set)
+{
+ struct mtp_link *lnk;
+
+ llist_for_each_entry(lnk, &set->links, entry)
+ lnk->reset(lnk);
+ return 0;
+}
+
+int link_set_clear_links(struct mtp_link_set *set)
+{
+ struct mtp_link *lnk;
+
+ llist_for_each_entry(lnk, &set->links, entry)
+ lnk->clear_queue(lnk);
+ return 0;
+}
+