aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/include/openbsc/Makefile.am2
-rw-r--r--openbsc/include/openbsc/bsc_msc.h30
-rw-r--r--openbsc/src/Makefile.am5
-rw-r--r--openbsc/src/bsc_msc.c72
-rw-r--r--openbsc/src/bsc_msc_ip.c49
5 files changed, 109 insertions, 49 deletions
diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am
index 8c9cd2e48..0c7b36f06 100644
--- a/openbsc/include/openbsc/Makefile.am
+++ b/openbsc/include/openbsc/Makefile.am
@@ -5,4 +5,4 @@ noinst_HEADERS = abis_nm.h abis_rsl.h debug.h db.h gsm_04_08.h gsm_data.h \
gsm_utils.h ipaccess.h rs232.h openbscdefines.h rtp_proxy.h \
bsc_rll.h mncc.h talloc.h transaction.h ussd.h gsm_04_80.h \
silent_call.h mgcp.h meas_rep.h bitvec.h rest_octets.h \
- system_information.h handover.h bssap.h
+ system_information.h handover.h bssap.h bsc_msc.h
diff --git a/openbsc/include/openbsc/bsc_msc.h b/openbsc/include/openbsc/bsc_msc.h
new file mode 100644
index 000000000..9b523c749
--- /dev/null
+++ b/openbsc/include/openbsc/bsc_msc.h
@@ -0,0 +1,30 @@
+/* Routines to talk to the MSC using the IPA Protocol */
+/*
+ * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010 by on-waves.com
+ * 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.
+ *
+ */
+
+#ifndef BSC_MSC_H
+#define BSC_MSC_H
+
+#include "select.h"
+
+int connect_to_msc(struct bsc_fd *fd, const char *ip, int port);
+
+#endif
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index 40591397a..b6a8536a5 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -26,7 +26,8 @@ libsccp_a_SOURCES = sccp/sccp.c
bsc_hack_SOURCES = bsc_hack.c bsc_init.c vty_interface.c vty_interface_layer3.c
bsc_hack_LDADD = libmsc.a libbsc.a libmsc.a libvty.a -ldl -ldbi $(LIBCRYPT)
-bsc_msc_ip_SOURCES = bssap.c bsc_msc_ip.c bsc_init.c vty_interface.c vty_interface_bsc.c
+bsc_msc_ip_SOURCES = bssap.c bsc_msc_ip.c bsc_init.c vty_interface.c vty_interface_bsc.c \
+ bsc_msc.c
bsc_msc_ip_LDADD = libbsc.a libvty.a libsccp.a
bs11_config_SOURCES = bs11_config.c abis_nm.c gsm_data.c msgb.c debug.c \
@@ -42,5 +43,5 @@ isdnsync_SOURCES = isdnsync.c
bsc_mgcp_SOURCES = bsc_mgcp.c msgb.c talloc.c debug.c select.c timer.c telnet_interface.c
bsc_mgcp_LDADD = libvty.a
-bsc_nat_SOURCES = nat/bsc_nat.c
+bsc_nat_SOURCES = nat/bsc_nat.c bsc_msc.c
bsc_nat_LDADD = libbsc.a libsccp.a
diff --git a/openbsc/src/bsc_msc.c b/openbsc/src/bsc_msc.c
new file mode 100644
index 000000000..48b918ba6
--- /dev/null
+++ b/openbsc/src/bsc_msc.c
@@ -0,0 +1,72 @@
+/* Routines to talk to the MSC using the IPA Protocol */
+/*
+ * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010 by on-waves.com
+ * 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 <openbsc/bsc_msc.h>
+
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+int connect_to_msc(struct bsc_fd *fd, const char *ip, int port)
+{
+ struct sockaddr_in sin;
+ int on = 1, ret;
+
+ printf("Attempting to connect MSC at %s:%d\n", ip, port);
+
+ fd->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ fd->when = BSC_FD_READ;
+ fd->data = NULL;
+ fd->priv_nr = 1;
+
+ if (fd->fd < 0) {
+ perror("Creating TCP socket failed");
+ return fd->fd;
+ }
+
+
+ memset(&sin, 0, sizeof(sin));
+ sin.sin_family = AF_INET;
+ sin.sin_port = htons(port);
+ inet_aton(ip, &sin.sin_addr);
+
+ setsockopt(fd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+ ret = connect(fd->fd, (struct sockaddr *) &sin, sizeof(sin));
+
+ if (ret < 0) {
+ perror("Connection failed");
+ return ret;
+ }
+
+ ret = bsc_register_fd(fd);
+ if (ret < 0) {
+ perror("Registering the fd failed");
+ close(fd->fd);
+ return ret;
+ }
+
+ return ret;
+}
+
+
diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c
index 491d56c85..73a31ffc3 100644
--- a/openbsc/src/bsc_msc_ip.c
+++ b/openbsc/src/bsc_msc_ip.c
@@ -45,6 +45,7 @@
#include <openbsc/paging.h>
#include <openbsc/signal.h>
#include <openbsc/chan_alloc.h>
+#include <openbsc/bsc_msc.h>
#include <sccp/sccp.h>
@@ -605,51 +606,6 @@ static int ipaccess_a_fd_cb(struct bsc_fd *bfd, unsigned int what)
return 0;
}
-/*
- * Connect to the MSC
- */
-static int connect_to_msc(const char *ip, int port)
-{
- struct sockaddr_in sin;
- int on = 1, ret;
-
- printf("Attempting to connect MSC at %s:%d\n", ip, port);
-
- msc_connection.fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- msc_connection.cb = ipaccess_a_fd_cb;
- msc_connection.when = BSC_FD_READ;
- msc_connection.data = NULL;
- msc_connection.priv_nr = 1;
-
- if (msc_connection.fd < 0) {
- perror("Creating TCP socket failed");
- return msc_connection.fd;
- }
-
-
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_port = htons(port);
- inet_aton(ip, &sin.sin_addr);
-
- setsockopt(msc_connection.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
- ret = connect(msc_connection.fd, (struct sockaddr *) &sin, sizeof(sin));
-
- if (ret < 0) {
- perror("Connection failed");
- return ret;
- }
-
- ret = bsc_register_fd(&msc_connection);
- if (ret < 0) {
- perror("Registering the fd failed");
- close(msc_connection.fd);
- return ret;
- }
-
- return ret;
-}
-
static void print_help()
{
printf(" Some useful help...\n");
@@ -796,7 +752,8 @@ int main(int argc, char **argv)
/* initialize ipaccess handling */
register_signal_handler(SS_ABISIP, handle_abisip_signal, NULL);
- rc = connect_to_msc(msc_address, 5000);
+ msc_connection.cb = ipaccess_a_fd_cb;
+ rc = connect_to_msc(&msc_connection, msc_address, 5000);
if (rc < 0) {
fprintf(stderr, "Opening the MSC connection failed.\n");
exit(1);