blob: a99facdf98de30db4ddbad0d4f7f689b2f0e0f37 [file] [log] [blame]
Neels Hofmeyraae68b22017-07-05 14:38:52 +02001/* OpenBSC Iu related interface to quagga VTY */
2/* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20#include <stdlib.h>
21#include <string.h>
22
23#include <osmocom/core/logging.h>
24#include <osmocom/vty/command.h>
25#include <osmocom/vty/logging.h>
26#include <osmocom/sigtran/osmo_ss7.h>
27#include <osmocom/sigtran/sccp_sap.h>
28
29#include <osmocom/ranap/iu_client.h>
30
31static enum ranap_nsap_addr_enc *g_rab_assign_addr_enc = NULL;
32
33DEFUN(cfg_iu_asn1_debug,
34 cfg_iu_asn1_debug_cmd,
35 "asn1 debug (1|0)",
36 "ASN.1 settings\n"
37 "Enable ASN.1 debug messages\n"
38 "Log ASN.1 debug messages to stderr\n"
39 "Do not log ASN.1 debug messages to stderr\n")
40{
41 asn_debug = atoi(argv[0]);
42 return CMD_SUCCESS;
43}
44
45DEFUN(cfg_iu_asn1_xer_print,
46 cfg_iu_asn1_xer_print_cmd,
47 "asn1 xer-print (1|0)",
48 "ASN.1 settings\n"
49 "Log human readable representations of all ASN.1 messages to stderr\n"
50 "Log XML representation of all ASN.1 messages to stderr\n"
51 "Do not log decoded ASN.1 messages to stderr\n")
52{
53 asn1_xer_print = atoi(argv[0]);
54 return CMD_SUCCESS;
55}
56
57#define IU_STR "Iu interface protocol options\n"
58DEFUN(cfg_iu_rab_assign_addr_enc, cfg_iu_rab_assign_addr_enc_cmd,
59 "iu rab-assign-addr-enc (x213|v4raw)",
60 IU_STR
61 "Choose RAB Assignment's Transport Layer Address encoding\n"
62 "ITU-T X.213 compliant address encoding (default)\n"
63 "32bit length raw IPv4 address (for ip.access nano3G)\n")
64{
65 if (!g_rab_assign_addr_enc) {
66 vty_out(vty, "%%RAB Assignment Transport Layer Address"
67 " encoding not available%s", VTY_NEWLINE);
68 return CMD_WARNING;
69 }
70
71 if (strcmp(argv[0], "v4raw") == 0)
72 *g_rab_assign_addr_enc = RANAP_NSAP_ADDR_ENC_V4RAW;
73 else
74 *g_rab_assign_addr_enc = RANAP_NSAP_ADDR_ENC_X213;
75 return CMD_SUCCESS;
76}
77
Neels Hofmeyraae68b22017-07-05 14:38:52 +020078int ranap_iu_vty_config_write(struct vty *vty, const char *indent)
79{
80 if (!g_rab_assign_addr_enc) {
81 vty_out(vty, "%%RAB Assignment Transport Layer Address"
82 " encoding not available%s", VTY_NEWLINE);
83 return CMD_WARNING;
84 }
85
86 switch (*g_rab_assign_addr_enc) {
87 case RANAP_NSAP_ADDR_ENC_V4RAW:
88 vty_out(vty, "%siu rab-assign-addr-enc v4raw%s", indent,
89 VTY_NEWLINE);
90 break;
91 case RANAP_NSAP_ADDR_ENC_X213:
92 /* default value, no need to write anything */
93 break;
94 default:
95 LOGP(0, LOGL_ERROR, "Invalid value for"
96 " iu.rab_assign_addr_enc: %d\n",
97 *g_rab_assign_addr_enc);
98 return CMD_WARNING;
99 }
100
Neels Hofmeyraae68b22017-07-05 14:38:52 +0200101 if (asn_debug)
102 vty_out(vty, "%sasn1 debug 1%s", indent, VTY_NEWLINE);
103
104 if (asn1_xer_print)
105 vty_out(vty, "%sasn1 xer-print 1%s", indent, VTY_NEWLINE);
106
107 return CMD_SUCCESS;
108}
109
110void ranap_iu_vty_init(int iu_parent_node, enum ranap_nsap_addr_enc *rab_assign_addr_enc)
111{
112 g_rab_assign_addr_enc = rab_assign_addr_enc;
113
114 install_element(iu_parent_node, &cfg_iu_rab_assign_addr_enc_cmd);
Neels Hofmeyraae68b22017-07-05 14:38:52 +0200115
116 /* Technically, these are global ASN.1 settings and not necessarily limited to the Iu interface.
117 * Practically, only Iu users will use ASN.1 in Osmocom programs -- at least so far. So it is
118 * easiest to have these commands under 'iu'. */
119 install_element(iu_parent_node, &cfg_iu_asn1_debug_cmd);
120 install_element(iu_parent_node, &cfg_iu_asn1_xer_print_cmd);
121}