aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-07-31 05:25:35 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-04 06:08:40 +0800
commitcbf7d18bb9319e2069c3cd48fd227ba3e29e9c1d (patch)
tree7c5da93176e0299a3839061c7351524a49f98524 /src
parent9ed3e1b3f37f446206ad0f438ffdecf588a32590 (diff)
Use libosmocore instead of the old temporary laF0rge1 lib..
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am15
-rw-r--r--src/bss_patch.c2
-rw-r--r--src/bssap_sccp.c4
-rw-r--r--src/input/ipaccess.c6
-rw-r--r--src/link_udp.c4
-rw-r--r--src/main.c78
-rw-r--r--src/mgcp/mgcp_network.c9
-rw-r--r--src/mgcp/mgcp_protocol.c12
-rw-r--r--src/mgcp_ss7.c52
-rw-r--r--src/msc_conn.c5
-rw-r--r--src/mtp_layer3.c4
-rw-r--r--src/snmp_mtp.c2
-rw-r--r--src/thread.c2
-rw-r--r--src/write_queue.c91
14 files changed, 113 insertions, 173 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 472c6ba..5872598 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,15 +1,16 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall $(LAFORGE_CFLAGS) $(SCCP_CFLAGS) \
- $(NEXUSWARE_C7_CFLAGS) $(NEXUSWARE_UNIPORTE_CFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(LIBOSMOVTY_CFLAGS) \
+ $(NEXUSWARE_C7_CFLAGS) $(NEXUSWARE_UNIPORTE_CFLAGS) $(UNIPORTE)
sbin_PROGRAMS = cellmgr_ng mgcp_mgw
-mgcp_mgw_SOURCES = mgcp_ss7.c write_queue.c mgcp/mgcp_protocol.c mgcp/mgcp_network.c thread.c
-mgcp_mgw_LDADD = $(LAFORGE_LIBS) $(NEXUSWARE_C7_LIBS) $(NEXUSWARE_UNIPORTE_LIBS) -lvty -lpthread
+mgcp_mgw_SOURCES = mgcp_ss7.c mgcp/mgcp_protocol.c mgcp/mgcp_network.c thread.c
+mgcp_mgw_LDADD = $(LAFORGE_LIBS) $(NEXUSWARE_C7_LIBS) $(NEXUSWARE_UNIPORTE_LIBS) \
+ $(LIBOSMOVTY_LIBS) $(LIBOSMOCORE_LIBS) -lpthread
cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \
bss_patch.c \
- openbsc_nat/bssap.c openbsc_nat/tlv_parser.c write_queue.c bssap_sccp.c \
+ openbsc_nat/bssap.c openbsc_nat/tlv_parser.c bssap_sccp.c \
msc_conn.c link_udp.c snmp_mtp.c
-cellmgr_ng_LDADD = $(LAFORGE_LIBS) $(SCCP_LIBS) $(NEXUSWARE_C7_LIBS) \
- -lpthread -lnetsnmp -lcrypto -lvty
+cellmgr_ng_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \
+ -lpthread -lnetsnmp -lcrypto
diff --git a/src/bss_patch.c b/src/bss_patch.c
index c4deeb2..5ae58aa 100644
--- a/src/bss_patch.c
+++ b/src/bss_patch.c
@@ -21,12 +21,12 @@
*/
#include <bss_patch.h>
+#include <cellmgr_debug.h>
#include <string.h>
#include <openbsc_nat/bssap.h>
#include <openbsc_nat/tlv.h>
-#include <laf0rge1/debug.h>
#include <sccp/sccp.h>
#include <arpa/inet.h>
diff --git a/src/bssap_sccp.c b/src/bssap_sccp.c
index e6b7271..3f4a8dd 100644
--- a/src/bssap_sccp.c
+++ b/src/bssap_sccp.c
@@ -21,9 +21,9 @@
*/
#include <bssap_sccp.h>
+#include <cellmgr_debug.h>
-#include <laf0rge1/msgb.h>
-#include <laf0rge1/debug.h>
+#include <osmocore/msgb.h>
#include <openbsc_nat/bssap.h>
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index b603015..1c0f1ae 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -32,9 +32,9 @@
#include <sys/ioctl.h>
#include <arpa/inet.h>
-#include <laf0rge1/select.h>
-#include <laf0rge1/msgb.h>
-#include <laf0rge1/talloc.h>
+#include <osmocore/select.h>
+#include <osmocore/msgb.h>
+#include <osmocore/talloc.h>
#include <ipaccess.h>
diff --git a/src/link_udp.c b/src/link_udp.c
index 17c90ac..f0532ac 100644
--- a/src/link_udp.c
+++ b/src/link_udp.c
@@ -25,9 +25,9 @@
#include <mtp_data.h>
#include <mtp_pcap.h>
#include <snmp_mtp.h>
+#include <cellmgr_debug.h>
-#include <laf0rge1/debug.h>
-#include <laf0rge1/talloc.h>
+#include <osmocore/talloc.h>
#include <sys/socket.h>
#include <netinet/in.h>
diff --git a/src/main.c b/src/main.c
index cb78653..1f5be89 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,12 +27,12 @@
#include <bssap_sccp.h>
#include <bsc_data.h>
#include <snmp_mtp.h>
+#include <cellmgr_debug.h>
-#include <laf0rge1/debug.h>
-#include <laf0rge1/talloc.h>
+#include <osmocore/talloc.h>
-#include <vty/command.h>
-#include <vty/vty.h>
+#include <osmocom/vty/command.h>
+#include <osmocom/vty/vty.h>
#include <openbsc_nat/bssap.h>
@@ -54,7 +54,7 @@
#endif
#include <getopt.h>
-static struct debug_target *stderr_target;
+static struct log_target *stderr_target;
static int dpc = 1;
static int opc = 0;
@@ -66,6 +66,12 @@ static int once = 0;
static int flood = 0;
static struct timer_list flood_timer;
+static struct vty_app_info vty_info = {
+ .name = "Cellmgr-ng",
+ .version = "0.0.1",
+ .go_parent_cb = NULL,
+};
+
/*
* One SCCP connection.
* Use for connection tracking and fixups...
@@ -816,19 +822,21 @@ int main(int argc, char **argv)
mtp_link_init();
thread_init();
- debug_init();
- stderr_target = debug_target_create_stderr();
- debug_add_target(stderr_target);
+ log_init(&log_info);
+ stderr_target = log_target_create_stderr();
+ log_add_target(stderr_target);
/* enable filters */
- debug_set_all_filter(stderr_target, 1);
- debug_set_category_filter(stderr_target, DINP, 1, LOGL_INFO);
- debug_set_category_filter(stderr_target, DSCCP, 1, LOGL_INFO);
- debug_set_category_filter(stderr_target, DMSC, 1, LOGL_INFO);
- debug_set_category_filter(stderr_target, DMGCP, 1, LOGL_INFO);
- debug_set_print_timestamp(stderr_target, 1);
- debug_set_use_color(stderr_target, 0);
+ log_set_all_filter(stderr_target, 1);
+ log_set_category_filter(stderr_target, DINP, 1, LOGL_INFO);
+ log_set_category_filter(stderr_target, DSCCP, 1, LOGL_INFO);
+ log_set_category_filter(stderr_target, DMSC, 1, LOGL_INFO);
+ log_set_category_filter(stderr_target, DMGCP, 1, LOGL_INFO);
+ log_set_print_timestamp(stderr_target, 1);
+ log_set_use_color(stderr_target, 0);
+
+ sccp_set_log_area(DSCCP);
bsc.setup = 0;
bsc.msc_address = "127.0.0.1";
@@ -846,7 +854,7 @@ int main(int argc, char **argv)
srand(time(NULL));
cell_vty_init();
- if (vty_read_config_file(config) < 0) {
+ if (vty_read_config_file(config, NULL) < 0) {
fprintf(stderr, "Failed to read the VTY config.\n");
return -1;
}
@@ -902,8 +910,12 @@ int main(int argc, char **argv)
}
/* vty code */
+enum cellmgr_node {
+ CELLMGR_NODE = _LAST_OSMOVTY_NODE,
+};
+
static struct cmd_node cell_node = {
- GSMNET_NODE,
+ CELLMGR_NODE,
"%s(cellmgr)#",
1,
};
@@ -916,7 +928,7 @@ static int config_write_cell()
DEFUN(cfg_cell, cfg_cell_cmd,
"cellmgr", "Configure the Cellmgr")
{
- vty->node = GSMNET_NODE;
+ vty->node = CELLMGR_NODE;
return CMD_SUCCESS;
}
@@ -1054,25 +1066,25 @@ DEFUN(cfg_msc_time, cfg_msc_time_cmd,
static void cell_vty_init(void)
{
cmd_init(1);
- vty_init();
+ vty_init(&vty_info);
install_element(CONFIG_NODE, &cfg_cell_cmd);
install_node(&cell_node, config_write_cell);
- install_element(GSMNET_NODE, &cfg_net_dpc_cmd);
- install_element(GSMNET_NODE, &cfg_net_opc_cmd);
- install_element(GSMNET_NODE, &cfg_udp_dst_ip_cmd);
- install_element(GSMNET_NODE, &cfg_udp_dst_port_cmd);
- install_element(GSMNET_NODE, &cfg_udp_src_port_cmd);
- install_element(GSMNET_NODE, &cfg_udp_reset_cmd);
- install_element(GSMNET_NODE, &cfg_sltm_once_cmd);
- install_element(GSMNET_NODE, &cfg_msc_ip_cmd);
- install_element(GSMNET_NODE, &cfg_msc_token_cmd);
- install_element(GSMNET_NODE, &cfg_msc_ip_dscp_cmd);
- install_element(GSMNET_NODE, &cfg_msc_ip_tos_cmd);
- install_element(GSMNET_NODE, &cfg_ping_time_cmd);
- install_element(GSMNET_NODE, &cfg_pong_time_cmd);
- install_element(GSMNET_NODE, &cfg_msc_time_cmd);
+ install_element(CELLMGR_NODE, &cfg_net_dpc_cmd);
+ install_element(CELLMGR_NODE, &cfg_net_opc_cmd);
+ install_element(CELLMGR_NODE, &cfg_udp_dst_ip_cmd);
+ install_element(CELLMGR_NODE, &cfg_udp_dst_port_cmd);
+ install_element(CELLMGR_NODE, &cfg_udp_src_port_cmd);
+ install_element(CELLMGR_NODE, &cfg_udp_reset_cmd);
+ install_element(CELLMGR_NODE, &cfg_sltm_once_cmd);
+ install_element(CELLMGR_NODE, &cfg_msc_ip_cmd);
+ install_element(CELLMGR_NODE, &cfg_msc_token_cmd);
+ install_element(CELLMGR_NODE, &cfg_msc_ip_dscp_cmd);
+ install_element(CELLMGR_NODE, &cfg_msc_ip_tos_cmd);
+ install_element(CELLMGR_NODE, &cfg_ping_time_cmd);
+ install_element(CELLMGR_NODE, &cfg_pong_time_cmd);
+ install_element(CELLMGR_NODE, &cfg_msc_time_cmd);
}
void subscr_put() {}
diff --git a/src/mgcp/mgcp_network.c b/src/mgcp/mgcp_network.c
index 1ea5f99..0c86de5 100644
--- a/src/mgcp/mgcp_network.c
+++ b/src/mgcp/mgcp_network.c
@@ -34,10 +34,11 @@
#include <mgcp/mgcp.h>
#include <mgcp/mgcp_internal.h>
-#include <laf0rge1/debug.h>
-#include <laf0rge1/msgb.h>
-#include <laf0rge1/talloc.h>
-#include <laf0rge1/select.h>
+#include <cellmgr_debug.h>
+
+#include <osmocore/msgb.h>
+#include <osmocore/talloc.h>
+#include <osmocore/select.h>
#warning "Make use of the rtp proxy code"
diff --git a/src/mgcp/mgcp_protocol.c b/src/mgcp/mgcp_protocol.c
index ea99543..618503e 100644
--- a/src/mgcp/mgcp_protocol.c
+++ b/src/mgcp/mgcp_protocol.c
@@ -30,13 +30,17 @@
#include <limits.h>
#include <unistd.h>
-#include <laf0rge1/debug.h>
-#include <laf0rge1/msgb.h>
-#include <laf0rge1/talloc.h>
-#include <laf0rge1/select.h>
+#include <cellmgr_debug.h>
+
#include <mgcp/mgcp.h>
#include <mgcp/mgcp_internal.h>
+#include <osmocore/msgb.h>
+#include <osmocore/talloc.h>
+#include <osmocore/select.h>
+#include <osmocore/utils.h>
+
+
/**
* Macro for tokenizing MGCP messages and SDP in one go.
*
diff --git a/src/mgcp_ss7.c b/src/mgcp_ss7.c
index 36421c6..89aaeac 100644
--- a/src/mgcp_ss7.c
+++ b/src/mgcp_ss7.c
@@ -24,15 +24,14 @@
#include <mgcp/mgcp.h>
#include <mgcp/mgcp_internal.h>
-#include <write_queue.h>
+#include <cellmgr_debug.h>
-#include <laf0rge1/debug.h>
-#include <laf0rge1/select.h>
-#include <laf0rge1/talloc.h>
-#include <laf0rge1/timer.h>
+#include <osmocore/select.h>
+#include <osmocore/talloc.h>
+#include <osmocore/timer.h>
-#include <vty/command.h>
-#include <vty/vty.h>
+#include <osmocom/vty/command.h>
+#include <osmocom/vty/vty.h>
/* uniporte includes */
#ifndef NO_UNIPORTE
@@ -55,7 +54,7 @@
#endif
#include <getopt.h>
-static struct debug_target *stderr_target;
+static struct log_target *stderr_target;
static int payload = 126;
static int number_endpoints = 32;
static char *mgw_ip = "172.18.0.30";
@@ -766,26 +765,26 @@ static void handle_options(int argc, char **argv)
int main(int argc, char **argv)
{
struct mgcp_ss7 *mgcp;
- debug_init();
- stderr_target = debug_target_create_stderr();
- debug_add_target(stderr_target);
+ log_init(&log_info);
+ stderr_target = log_target_create_stderr();
+ log_add_target(stderr_target);
/* enable filters */
- debug_set_all_filter(stderr_target, 1);
- debug_set_category_filter(stderr_target, DINP, 1, LOGL_INFO);
- debug_set_category_filter(stderr_target, DSCCP, 1, LOGL_INFO);
- debug_set_category_filter(stderr_target, DMSC, 1, LOGL_INFO);
- debug_set_category_filter(stderr_target, DMGCP, 1, LOGL_INFO);
- debug_set_print_timestamp(stderr_target, 1);
- debug_set_use_color(stderr_target, 0);
+ log_set_all_filter(stderr_target, 1);
+ log_set_category_filter(stderr_target, DINP, 1, LOGL_INFO);
+ log_set_category_filter(stderr_target, DSCCP, 1, LOGL_INFO);
+ log_set_category_filter(stderr_target, DMSC, 1, LOGL_INFO);
+ log_set_category_filter(stderr_target, DMGCP, 1, LOGL_INFO);
+ log_set_print_timestamp(stderr_target, 1);
+ log_set_use_color(stderr_target, 0);
handle_options(argc, argv);
signal(SIGPIPE, SIG_IGN);
mgcp_mgw_vty_init();
- if (vty_read_config_file(config_file) < 0) {
+ if (vty_read_config_file(config_file, NULL) < 0) {
fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file);
return -1;
}
@@ -805,6 +804,10 @@ int main(int argc, char **argv)
}
/* VTY code */
+enum cellmgr_node {
+ MGCP_NODE = _LAST_OSMOVTY_NODE,
+};
+
struct cmd_node mgcp_node = {
MGCP_NODE,
"%s(mgcp)#",
@@ -918,10 +921,17 @@ static int config_write_mgcp()
return CMD_SUCCESS;
}
+static struct vty_app_info vty_info = {
+ .name = "mgcp_ss7",
+ .version = "0.0.1",
+ .go_parent_cb = NULL,
+};
+
+
static void mgcp_mgw_vty_init(void)
{
cmd_init(1);
- vty_init();
+ vty_init(&vty_info);
install_element(CONFIG_NODE, &cfg_mgcp_cmd);
install_node(&mgcp_node, config_write_mgcp);
@@ -937,3 +947,5 @@ static void mgcp_mgw_vty_init(void)
void subscr_put() {}
void vty_event() {}
+
+const char *openbsc_copyright = "";
diff --git a/src/msc_conn.c b/src/msc_conn.c
index 75b981b..b569bf1 100644
--- a/src/msc_conn.c
+++ b/src/msc_conn.c
@@ -25,9 +25,10 @@
#include <bssap_sccp.h>
#include <ipaccess.h>
#include <mtp_data.h>
+#include <cellmgr_debug.h>
-#include <laf0rge1/debug.h>
-#include <laf0rge1/tlv.h>
+#include <osmocore/tlv.h>
+#include <osmocore/utils.h>
#include <arpa/inet.h>
#include <sys/socket.h>
diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c
index 446e0e9..113cabd 100644
--- a/src/mtp_layer3.c
+++ b/src/mtp_layer3.c
@@ -21,9 +21,9 @@
*/
#include <mtp_data.h>
#include <mtp_level3.h>
+#include <cellmgr_debug.h>
-#include <laf0rge1/debug.h>
-#include <laf0rge1/talloc.h>
+#include <osmocore/talloc.h>
#include <sccp/sccp.h>
diff --git a/src/snmp_mtp.c b/src/snmp_mtp.c
index d2ff495..3e69a64 100644
--- a/src/snmp_mtp.c
+++ b/src/snmp_mtp.c
@@ -19,7 +19,7 @@
*
*/
#include <snmp_mtp.h>
-#include <laf0rge1/talloc.h>
+#include <osmocore/talloc.h>
static void add_pdu_var(netsnmp_pdu *pdu, const char *mib_name, int id, const char *value)
{
diff --git a/src/thread.c b/src/thread.c
index 8175a49..9563fd5 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -20,7 +20,7 @@
*/
#include <thread.h>
-#include <laf0rge1/talloc.h>
+#include <osmocore/talloc.h>
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/src/write_queue.c b/src/write_queue.c
deleted file mode 100644
index ac529a3..0000000
--- a/src/write_queue.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Generic write queue implementation */
-/*
- * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2010 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 <write_queue.h>
-
-#include <laf0rge1/debug.h>
-
-int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what)
-{
- struct write_queue *queue;
-
- queue = container_of(fd, struct write_queue, bfd);
-
- if (what & BSC_FD_READ)
- queue->read_cb(fd);
-
- if (what & BSC_FD_WRITE) {
- struct msgb *msg;
-
- fd->when &= ~BSC_FD_WRITE;
- msg = msgb_dequeue(&queue->msg_queue);
- if (!msg)
- return -1;
-
- --queue->current_length;
- queue->write_cb(fd, msg);
- msgb_free(msg);
-
- if (!llist_empty(&queue->msg_queue))
- fd->when |= BSC_FD_WRITE;
- }
-
- return 0;
-}
-
-void write_queue_init(struct write_queue *queue, int max_length)
-{
- queue->max_length = max_length;
- queue->current_length = 0;
- queue->read_cb = NULL;
- queue->write_cb = NULL;
- queue->bfd.cb = write_queue_bfd_cb;
- queue->paused = 0;
- INIT_LLIST_HEAD(&queue->msg_queue);
-}
-
-int write_queue_enqueue(struct write_queue *queue, struct msgb *data)
-{
- if (queue->current_length + 1 >= queue->max_length)
- LOGP(DMSC, LOGL_ERROR, "The queue is full. Dropping not yet implemented.\n");
-
- ++queue->current_length;
- msgb_enqueue(&queue->msg_queue, data);
-
- if (!queue->paused)
- queue->bfd.when |= BSC_FD_WRITE;
-
- return 0;
-}
-
-void write_queue_pause(struct write_queue *queue)
-{
- queue->paused = 1;
- queue->bfd.when &= ~BSC_FD_WRITE;
-}
-
-void write_queue_unpause(struct write_queue *queue)
-{
- queue->paused = 0;
- if (!llist_empty(&queue->msg_queue))
- queue->bfd.when |= BSC_FD_WRITE;
-}