aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-02-28 12:11:02 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-02-28 19:40:53 +0100
commit0e939fec4237483df4c51fb58c87f35b3115db50 (patch)
tree2d1290ccced656d0e9a7248998bcf14f2897be5e /openbsc
parentab3bb9d444dddcd3754e4cc3641c4ebfdcda5f38 (diff)
mgcp: Introduce a trunk config for multiple trunks.
A trunk will always have 32 endpoints to be used and we allow a sparse allocation of endpoints.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/mgcp.h3
-rw-r--r--openbsc/include/openbsc/mgcp_internal.h3
-rw-r--r--openbsc/include/openbsc/vty.h1
-rw-r--r--openbsc/src/common_vty.c8
-rw-r--r--openbsc/src/mgcp/mgcp_protocol.c33
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c96
6 files changed, 140 insertions, 4 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index df849798..54a3a6ee 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -103,6 +103,8 @@ struct mgcp_port_range {
};
struct mgcp_trunk_config {
+ struct llist_head entry;
+
struct mgcp_config *cfg;
int trunk_nr;
@@ -150,6 +152,7 @@ struct mgcp_config {
/* trunk handling */
struct mgcp_trunk_config trunk;
+ struct llist_head trunks;
};
/* config management */
diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h
index cefbc3e3..7c6bb542 100644
--- a/openbsc/include/openbsc/mgcp_internal.h
+++ b/openbsc/include/openbsc/mgcp_internal.h
@@ -147,5 +147,8 @@ static inline int endp_back_channel(int endpoint)
return endpoint + 60;
}
+struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int index);
+struct mgcp_trunk_config *mgcp_trunk_num(struct mgcp_config *cfg, int index);
+
#endif
diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h
index 6ed5f058..516c8c2a 100644
--- a/openbsc/include/openbsc/vty.h
+++ b/openbsc/include/openbsc/vty.h
@@ -34,6 +34,7 @@ enum bsc_vty_node {
NAT_BSC_NODE,
MSC_NODE,
OM2K_NODE,
+ TRUNK_NODE,
};
extern int bsc_vty_is_config_node(struct vty *vty, int node);
diff --git a/openbsc/src/common_vty.c b/openbsc/src/common_vty.c
index 25ab3c0a..84375a22 100644
--- a/openbsc/src/common_vty.c
+++ b/openbsc/src/common_vty.c
@@ -86,6 +86,9 @@ enum node_type bsc_vty_go_parent(struct vty *vty)
case MSC_NODE:
vty->node = GSMNET_NODE;
break;
+ case TRUNK_NODE:
+ vty->node = MGCP_NODE;
+ break;
default:
vty->node = CONFIG_NODE;
}
@@ -154,6 +157,10 @@ gDEFUN(ournode_exit,
case MSC_NODE:
vty->node = GSMNET_NODE;
break;
+ case TRUNK_NODE:
+ vty->node = MGCP_NODE;
+ vty->index = NULL;
+ break;
default:
break;
}
@@ -175,6 +182,7 @@ gDEFUN(ournode_end,
case TRX_NODE:
case TS_NODE:
case MGCP_NODE:
+ case TRUNK_NODE:
case GBPROXY_NODE:
case SGSN_NODE:
case NS_NODE:
diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c
index aa028c3b..8e5c9501 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -874,9 +874,42 @@ struct mgcp_config *mgcp_config_alloc(void)
cfg->trunk.audio_name = talloc_strdup(cfg, "AMR/8000");
cfg->trunk.audio_payload = 126;
+ INIT_LLIST_HEAD(&cfg->trunks);
+
return cfg;
}
+struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int nr)
+{
+ struct mgcp_trunk_config *trunk;
+
+ trunk = talloc_zero(cfg, struct mgcp_trunk_config);
+ if (!trunk) {
+ LOGP(DMGCP, LOGL_ERROR, "Failed to allocate.\n");
+ return NULL;
+ }
+
+ trunk->cfg = cfg;
+ trunk->trunk_type = MGCP_TRUNK_E1;
+ trunk->trunk_nr = nr;
+ trunk->audio_name = talloc_strdup(cfg, "AMR/8000");
+ trunk->audio_payload = 126;
+ trunk->number_endpoints = 33;
+ llist_add_tail(&trunk->entry, &cfg->trunks);
+ return trunk;
+}
+
+struct mgcp_trunk_config *mgcp_trunk_num(struct mgcp_config *cfg, int index)
+{
+ struct mgcp_trunk_config *trunk;
+
+ llist_for_each_entry(trunk, &cfg->trunks, entry)
+ if (trunk->trunk_nr == index)
+ return trunk;
+
+ return NULL;
+}
+
static void mgcp_rtp_end_reset(struct mgcp_rtp_end *end)
{
if (end->local_alloc == PORT_ALLOC_DYNAMIC) {
diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c
index 1f42d116..7052e847 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -54,6 +54,12 @@ struct cmd_node mgcp_node = {
1,
};
+struct cmd_node trunk_node = {
+ TRUNK_NODE,
+ "%s(trunk)#",
+ 1,
+};
+
static int config_write_mgcp(struct vty *vty)
{
vty_out(vty, "mgcp%s", VTY_NEWLINE);
@@ -360,6 +366,78 @@ DEFUN(cfg_mgcp_transcoder_remote_base,
return CMD_SUCCESS;
}
+DEFUN(cfg_mgcp_trunk, cfg_mgcp_trunk_cmd,
+ "trunk <1-64>",
+ "Configure a SS7 trunk\n" "Trunk Nr\n")
+{
+ struct mgcp_trunk_config *trunk;
+ int index = atoi(argv[0]);
+
+ trunk = mgcp_trunk_num(g_cfg, index);
+ if (!trunk)
+ trunk = mgcp_trunk_alloc(g_cfg, index);
+
+ if (!trunk) {
+ vty_out(vty, "%%Unable to allocate trunk %u.%s",
+ index, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ vty->node = TRUNK_NODE;
+ vty->index = trunk;
+ return CMD_SUCCESS;
+}
+
+static int config_write_trunk(struct vty *vty)
+{
+ struct mgcp_trunk_config *trunk;
+
+ llist_for_each_entry(trunk, &g_cfg->trunks, entry) {
+ vty_out(vty, " trunk %d%s", trunk->trunk_nr, VTY_NEWLINE);
+ vty_out(vty, " sdp audio payload number %d%s",
+ trunk->audio_payload, VTY_NEWLINE);
+ vty_out(vty, " sdp audio payload name %s%s",
+ trunk->audio_name, VTY_NEWLINE);
+ vty_out(vty, " loop %d%s",
+ trunk->audio_loop, VTY_NEWLINE);
+ }
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_trunk_payload_number,
+ cfg_trunk_payload_number_cmd,
+ "sdp audio payload number <1-255>",
+ "SDP related\n" "Audio\n" "Payload\n" "Payload Number\n")
+{
+ struct mgcp_trunk_config *trunk = vty->index;
+ unsigned int payload = atoi(argv[0]);
+
+ trunk->audio_payload = payload;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_trunk_payload_name,
+ cfg_trunk_payload_name_cmd,
+ "sdp audio payload name NAME",
+ "SDP related\n" "Audio\n" "Payload\n" "Payload Name\n")
+{
+ struct mgcp_trunk_config *trunk = vty->index;
+
+ bsc_replace_string(g_cfg, &trunk->audio_name, argv[0]);
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_trunk_loop,
+ cfg_trunk_loop_cmd,
+ "loop (0|1)",
+ "Loop the audio")
+{
+ struct mgcp_trunk_config *trunk = vty->index;
+
+ trunk->audio_loop = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
DEFUN(loop_endp,
loop_endp_cmd,
@@ -504,14 +582,24 @@ int mgcp_vty_init(void)
install_element(MGCP_NODE, &cfg_mgcp_rtp_transcoder_base_cmd);
install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_dscp_cmd);
install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_tos_cmd);
- install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd);
- install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd);
- install_element(MGCP_NODE, &cfg_mgcp_loop_cmd);
- install_element(MGCP_NODE, &cfg_mgcp_number_endp_cmd);
install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd);
install_element(MGCP_NODE, &cfg_mgcp_transcoder_cmd);
install_element(MGCP_NODE, &cfg_mgcp_no_transcoder_cmd);
install_element(MGCP_NODE, &cfg_mgcp_transcoder_remote_base_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_loop_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_number_endp_cmd);
+
+ install_element(MGCP_NODE, &cfg_mgcp_trunk_cmd);
+ install_node(&trunk_node, config_write_trunk);
+ install_default(TRUNK_NODE);
+ install_element(TRUNK_NODE, &ournode_exit_cmd);
+ install_element(TRUNK_NODE, &ournode_end_cmd);
+ install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd);
+ install_element(TRUNK_NODE, &cfg_trunk_payload_name_cmd);
+ install_element(TRUNK_NODE, &cfg_trunk_loop_cmd);
+
return 0;
}