Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 1 | /* 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> |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 21 | #include <string.h> |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 22 | |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 23 | #include <osmocom/core/logging.h> |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 24 | #include <osmocom/vty/command.h> |
| 25 | #include <osmocom/vty/logging.h> |
Philipp Maier | efe85d3 | 2017-04-09 12:32:51 +0200 | [diff] [blame^] | 26 | #include <osmocom/sigtran/osmo_ss7.h> |
| 27 | #include <osmocom/sigtran/sccp_sap.h> |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 28 | |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 29 | #include <openbsc/iu.h> |
| 30 | |
| 31 | static enum nsap_addr_enc *g_rab_assign_addr_enc = NULL; |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 32 | |
| 33 | DEFUN(logging_asn_debug, |
| 34 | logging_asn_debug_cmd, |
| 35 | "logging asn1-debug (1|0)", |
| 36 | LOGGING_STR |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 37 | "Log ASN.1 debug messages to stderr\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 | |
| 45 | DEFUN(logging_asn_xer_print, |
| 46 | logging_asn_xer_print_cmd, |
| 47 | "logging asn1-xer-print (1|0)", |
| 48 | LOGGING_STR |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 49 | "Log human readable representations of all ASN.1 messages to stderr\n" |
| 50 | "Log decoded ASN.1 messages to stderr\n" |
| 51 | "Do not log decoded ASN.1 messages to stderr\n") |
| 52 | { |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 53 | asn1_xer_print = atoi(argv[0]); |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 54 | return CMD_SUCCESS; |
| 55 | } |
| 56 | |
Philipp Maier | efe85d3 | 2017-04-09 12:32:51 +0200 | [diff] [blame^] | 57 | #define IU_STR "Iu interface protocol options\n" |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 58 | DEFUN(cfg_iu_rab_assign_addr_enc, cfg_iu_rab_assign_addr_enc_cmd, |
| 59 | "iu rab-assign-addr-enc (x213|v4raw)", |
Philipp Maier | efe85d3 | 2017-04-09 12:32:51 +0200 | [diff] [blame^] | 60 | IU_STR |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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") |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 64 | { |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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 = NSAP_ADDR_ENC_V4RAW; |
| 73 | else |
| 74 | *g_rab_assign_addr_enc = NSAP_ADDR_ENC_X213; |
| 75 | return CMD_SUCCESS; |
| 76 | } |
| 77 | |
Philipp Maier | efe85d3 | 2017-04-09 12:32:51 +0200 | [diff] [blame^] | 78 | extern struct osmo_sccp_addr local_sccp_addr; |
| 79 | |
| 80 | /* Note from the future: change-id Ib8c4fcdb4766c5e575618b95ce16dce51063206b will move this file to |
| 81 | * osmo-iuh, and there, change-id I3bb7fc1cd5261d214c6ba0cccfe95f637e6db087 will drop this vty command |
| 82 | * and use the point code defined via libosmo-sccp vty commands instead. */ |
| 83 | DEFUN(cfg_iu_local_addr_pc, cfg_iu_local_addr_pc_cmd, |
| 84 | "iu local-address point-code PC", |
| 85 | IU_STR "Local SCCP Address\n" "Set local point code\n" "point code\n") |
| 86 | { |
| 87 | local_sccp_addr.presence = OSMO_SCCP_ADDR_T_PC | OSMO_SCCP_ADDR_T_SSN; |
| 88 | local_sccp_addr.ri = OSMO_SCCP_RI_SSN_PC; |
| 89 | local_sccp_addr.pc = osmo_ss7_pointcode_parse(NULL, argv[0]); |
| 90 | |
| 91 | return CMD_SUCCESS; |
| 92 | } |
| 93 | |
| 94 | /* TODO: GT address configuration, in line with 4.5.1.1.1 of TS 25.410 */ |
| 95 | |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 96 | int iu_vty_config_write(struct vty *vty, const char *indent) |
| 97 | { |
| 98 | if (!g_rab_assign_addr_enc) { |
| 99 | vty_out(vty, "%%RAB Assignment Transport Layer Address" |
| 100 | " encoding not available%s", VTY_NEWLINE); |
| 101 | return CMD_WARNING; |
| 102 | } |
| 103 | |
| 104 | switch (*g_rab_assign_addr_enc) { |
| 105 | case NSAP_ADDR_ENC_V4RAW: |
| 106 | vty_out(vty, "%siu rab-assign-addr-enc v4raw%s", indent, |
| 107 | VTY_NEWLINE); |
| 108 | break; |
| 109 | case NSAP_ADDR_ENC_X213: |
| 110 | /* default value, no need to write anything */ |
| 111 | break; |
| 112 | default: |
| 113 | LOGP(0, LOGL_ERROR, "Invalid value for" |
| 114 | " net.iu.rab_assign_addr_enc: %d\n", |
| 115 | *g_rab_assign_addr_enc); |
| 116 | return CMD_WARNING; |
| 117 | } |
| 118 | |
Philipp Maier | efe85d3 | 2017-04-09 12:32:51 +0200 | [diff] [blame^] | 119 | vty_out(vty, "%siu local-address point-code %s%s", indent, |
| 120 | osmo_ss7_pointcode_print(NULL, local_sccp_addr.pc), VTY_NEWLINE); |
| 121 | |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 122 | return CMD_SUCCESS; |
| 123 | } |
| 124 | |
| 125 | void iu_vty_init(int iu_parent_node, enum nsap_addr_enc *rab_assign_addr_enc) |
| 126 | { |
| 127 | g_rab_assign_addr_enc = rab_assign_addr_enc; |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 128 | |
| 129 | install_element(CFG_LOG_NODE, &logging_asn_debug_cmd); |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 130 | install_element(CFG_LOG_NODE, &logging_asn_xer_print_cmd); |
| 131 | install_element(iu_parent_node, &cfg_iu_rab_assign_addr_enc_cmd); |
Philipp Maier | efe85d3 | 2017-04-09 12:32:51 +0200 | [diff] [blame^] | 132 | install_element(iu_parent_node, &cfg_iu_local_addr_pc_cmd); |
Neels Hofmeyr | 9bc42ec | 2016-08-29 13:02:12 +0200 | [diff] [blame] | 133 | } |