m3ua: Make the traffic-mode configurable
This commit is contained in:
parent
0bcf47ba05
commit
6a441c86fe
|
@ -22,6 +22,7 @@ struct mtp_m3ua_client_link {
|
|||
struct sockaddr_in remote;
|
||||
int link_index;
|
||||
int routing_context;
|
||||
uint32_t traffic_mode;
|
||||
|
||||
|
||||
/* state of the link */
|
||||
|
@ -30,3 +31,7 @@ struct mtp_m3ua_client_link {
|
|||
};
|
||||
|
||||
struct mtp_m3ua_client_link *mtp_m3ua_client_link_init(struct mtp_link *link);
|
||||
|
||||
|
||||
const char *m3ua_traffic_mode_name(uint32_t mode);
|
||||
uint32_t m3ua_traffic_mode_num(const char *argv);
|
||||
|
|
|
@ -26,7 +26,8 @@ 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 sctp_m3ua_client.c
|
||||
mgcp_callagent.c isup_filter.c sctp_m3ua_client.c \
|
||||
sctp_m3ua_misc.c
|
||||
osmo_stp_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) \
|
||||
$(LIBOSMOSCCP_LIBS) $(NEXUSWARE_C7_LIBS) \
|
||||
-lpthread -lnetsnmp -lcrypto -lxua -lsctp
|
||||
|
|
|
@ -368,6 +368,7 @@ struct mtp_m3ua_client_link *mtp_m3ua_client_link_init(struct mtp_link *blnk)
|
|||
|
||||
osmo_wqueue_init(&lnk->queue, 10);
|
||||
lnk->queue.bfd.fd = -1;
|
||||
lnk->traffic_mode = 2;
|
||||
return lnk;
|
||||
}
|
||||
|
||||
|
@ -423,7 +424,7 @@ static void m3ua_send_aspac(struct mtp_m3ua_client_link *link)
|
|||
aspac->hdr.msg_class = M3UA_CLS_ASPTM;
|
||||
aspac->hdr.msg_type = M3UA_ASPTM_ACTIV;
|
||||
|
||||
traffic_mode = htonl(2);
|
||||
traffic_mode = htonl(link->traffic_mode);
|
||||
xua_msg_add_data(aspac, 11, 4, (uint8_t *) &traffic_mode);
|
||||
|
||||
routing_ctx = htonl(link->routing_context);
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* (C) 2015 by Holger Hans Peter Freyther
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation; either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "sctp_m3ua.h"
|
||||
|
||||
/*
|
||||
* Conversion
|
||||
*/
|
||||
const char *m3ua_traffic_mode_name(uint32_t mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case 1:
|
||||
return "override";
|
||||
case 2:
|
||||
return "loadshare";
|
||||
case 3:
|
||||
return "broadcast";
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
uint32_t m3ua_traffic_mode_num(const char *name)
|
||||
{
|
||||
if (name[0] == 'o')
|
||||
return 1;
|
||||
if (name[0] == 'l')
|
||||
return 2;
|
||||
if (name[0] == 'b')
|
||||
return 3;
|
||||
abort();
|
||||
}
|
||||
|
|
@ -201,6 +201,9 @@ static void write_link(struct vty *vty, struct mtp_link *link)
|
|||
m3ua_client->link_index, VTY_NEWLINE);
|
||||
vty_out(vty, " m3ua-client routing-context %d%s",
|
||||
m3ua_client->routing_context, VTY_NEWLINE);
|
||||
vty_out(vty, " m3ua-client traffic-mode %s%s",
|
||||
m3ua_traffic_mode_name(m3ua_client->traffic_mode),
|
||||
VTY_NEWLINE);
|
||||
break;
|
||||
case SS7_LTYPE_NONE:
|
||||
break;
|
||||
|
@ -883,6 +886,23 @@ DEFUN(cfg_link_m3ua_client_routing_ctx, cfg_link_m3ua_client_routing_ctx_cmd,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_link_m3ua_client_traffic_mode, cfg_link_m3ua_client_traffic_mode_cmd,
|
||||
"m3ua-client traffic-mode (override|loadshare|broadcast)",
|
||||
"M3UA Client\n" "Traffic Mode\n" "Override" "Loadshare\n" "Broadcast\n")
|
||||
{
|
||||
struct mtp_link *link = vty->index;
|
||||
struct mtp_m3ua_client_link *m3ua_link;
|
||||
|
||||
if (link->type != SS7_LTYPE_M3UA_CLIENT) {
|
||||
vty_out(vty, "%%This only applies to M3UA client links.%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
m3ua_link = link->data;
|
||||
m3ua_link->traffic_mode = m3ua_traffic_mode_num(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_ss7_msc, cfg_ss7_msc_cmd,
|
||||
"msc <0-100>",
|
||||
"MSC Connection\n" "MSC Number\n")
|
||||
|
@ -1305,6 +1325,7 @@ void cell_vty_init(void)
|
|||
install_element(LINK_NODE, &cfg_link_m3ua_client_dest_port_cmd);
|
||||
install_element(LINK_NODE, &cfg_link_m3ua_client_link_index_cmd);
|
||||
install_element(LINK_NODE, &cfg_link_m3ua_client_routing_ctx_cmd);
|
||||
install_element(LINK_NODE, &cfg_link_m3ua_client_traffic_mode_cmd);
|
||||
|
||||
install_element(SS7_NODE, &cfg_ss7_msc_cmd);
|
||||
install_node(&msc_node, config_write_msc);
|
||||
|
|
|
@ -3,4 +3,6 @@ noinst_PROGRAMS = mtp_parse_test
|
|||
|
||||
EXTRA_DIST = mtp_parse_test.ok
|
||||
|
||||
mtp_parse_test_SOURCES = mtp_parse_test.c
|
||||
mtp_parse_test_SOURCES = mtp_parse_test.c $(top_srcdir)/src/sctp_m3ua_misc.c
|
||||
mtp_parse_test_LDADD = \
|
||||
$(LIBOSMOCORE_LIBS)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/* MTP Layer3 parsing tests */
|
||||
#include "sctp_m3ua.h"
|
||||
|
||||
#include <osmocom/mtp/mtp_level3.h>
|
||||
#include <osmocom/core/utils.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
@ -7,8 +10,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
struct mtp_test {
|
||||
const uint8_t *input;
|
||||
const uint16_t length;
|
||||
|
@ -578,6 +579,17 @@ static void check_prohib(const uint8_t *data, const struct mtp_level_3_prohib *t
|
|||
abort();
|
||||
}
|
||||
|
||||
void test_m3ua_traffic_mode(void)
|
||||
{
|
||||
OSMO_ASSERT(strcmp(m3ua_traffic_mode_name(1), "override") == 0);
|
||||
OSMO_ASSERT(strcmp(m3ua_traffic_mode_name(2), "loadshare") == 0);
|
||||
OSMO_ASSERT(strcmp(m3ua_traffic_mode_name(3), "broadcast") == 0);
|
||||
|
||||
OSMO_ASSERT(m3ua_traffic_mode_num("override") == 1);
|
||||
OSMO_ASSERT(m3ua_traffic_mode_num("loadshare") == 2);
|
||||
OSMO_ASSERT(m3ua_traffic_mode_num("broadcast") == 3);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
uint32_t addr;
|
||||
|
@ -636,6 +648,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
test_m3ua_traffic_mode();
|
||||
printf("All tests passed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
Reference in New Issue