Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 1 | /* |
Holger Hans Peter Freyther | 611f775 | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 2 | * (C) 2013-2015 by Holger Hans Peter Freyther |
| 3 | * (C) 2013-2015 by sysmocom s.f.m.c. GmbH |
Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU Affero General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU Affero General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Affero General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | */ |
Harald Welte | 5919b6a | 2014-08-20 23:47:15 +0200 | [diff] [blame] | 21 | #include <errno.h> |
Holger Hans Peter Freyther | 9edd06d | 2015-02-10 21:37:16 +0100 | [diff] [blame] | 22 | #include <time.h> |
Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 23 | |
Harald Welte | 5919b6a | 2014-08-20 23:47:15 +0200 | [diff] [blame] | 24 | #include <osmocom/ctrl/control_cmd.h> |
Holger Hans Peter Freyther | 5ff537c | 2013-01-09 17:30:11 +0100 | [diff] [blame] | 25 | #include <openbsc/ipaccess.h> |
Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 26 | #include <openbsc/gsm_data.h> |
Holger Hans Peter Freyther | 1f67232 | 2014-03-26 14:24:42 +0100 | [diff] [blame] | 27 | #include <openbsc/abis_nm.h> |
| 28 | #include <openbsc/debug.h> |
Holger Hans Peter Freyther | 9fe9846 | 2014-12-05 12:03:24 +0100 | [diff] [blame] | 29 | #include <openbsc/chan_alloc.h> |
Holger Hans Peter Freyther | 9edd06d | 2015-02-10 21:37:16 +0100 | [diff] [blame] | 30 | #include <openbsc/osmo_bsc_rf.h> |
| 31 | #include <openbsc/osmo_msc_data.h> |
Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 32 | |
| 33 | #define CTRL_CMD_VTY_STRING(cmdname, cmdstr, dtype, element) \ |
| 34 | CTRL_HELPER_GET_STRING(cmdname, dtype, element) \ |
| 35 | CTRL_HELPER_SET_STRING(cmdname, dtype, element) \ |
| 36 | static struct ctrl_cmd_element cmd_##cmdname = { \ |
| 37 | .name = cmdstr, \ |
Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 38 | .get = get_##cmdname, \ |
| 39 | .set = set_##cmdname, \ |
| 40 | .verify = verify_vty_description_string, \ |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Check that there are no newlines or comments or other things |
| 45 | * that could make the VTY configuration unparsable. |
| 46 | */ |
| 47 | static int verify_vty_description_string(struct ctrl_cmd *cmd, |
| 48 | const char *value, void *data) |
| 49 | { |
| 50 | int i; |
| 51 | const size_t len = strlen(value); |
| 52 | |
| 53 | for (i = 0; i < len; ++i) { |
| 54 | switch(value[i]) { |
| 55 | case '#': |
| 56 | case '\n': |
| 57 | case '\r': |
| 58 | cmd->reply = "String includes illegal character"; |
| 59 | return -1; |
| 60 | default: |
| 61 | break; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); |
| 69 | CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); |
| 70 | CTRL_CMD_VTY_STRING(net_short_name, "short-name", struct gsm_network, name_short); |
| 71 | CTRL_CMD_VTY_STRING(net_long_name, "long-name", struct gsm_network, name_long); |
| 72 | |
Holger Hans Peter Freyther | 5ff537c | 2013-01-09 17:30:11 +0100 | [diff] [blame] | 73 | static int set_net_apply_config(struct ctrl_cmd *cmd, void *data) |
| 74 | { |
| 75 | struct gsm_network *net = cmd->node; |
| 76 | struct gsm_bts *bts; |
| 77 | |
| 78 | llist_for_each_entry(bts, &net->bts_list, list) { |
| 79 | if (!is_ipaccess_bts(bts)) |
| 80 | continue; |
| 81 | |
Holger Hans Peter Freyther | fb508c6 | 2016-03-16 15:27:38 +0100 | [diff] [blame] | 82 | /* |
| 83 | * The ip.access nanoBTS seems to be unrelaible on BSSGP |
| 84 | * so let's us just reboot it. For the sysmoBTS we can just |
| 85 | * restart the process as all state is gone. |
| 86 | */ |
| 87 | if (!is_sysmobts_v2(bts) && strcmp(cmd->value, "restart") == 0) { |
| 88 | struct gsm_bts_trx *trx; |
| 89 | llist_for_each_entry_reverse(trx, &bts->trx_list, list) |
| 90 | abis_nm_ipaccess_restart(trx); |
| 91 | } else |
| 92 | ipaccess_drop_oml(bts); |
Holger Hans Peter Freyther | 5ff537c | 2013-01-09 17:30:11 +0100 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | cmd->reply = "Tried to drop the BTS"; |
| 96 | return CTRL_CMD_REPLY; |
| 97 | } |
| 98 | |
Max | 78a5803 | 2017-01-11 18:37:55 +0100 | [diff] [blame^] | 99 | CTRL_CMD_DEFINE_WO_NOVRF(net_apply_config, "apply-configuration"); |
Holger Hans Peter Freyther | 5ff537c | 2013-01-09 17:30:11 +0100 | [diff] [blame] | 100 | |
Holger Hans Peter Freyther | eab2a3f | 2014-03-04 17:16:58 +0100 | [diff] [blame] | 101 | static int verify_net_mcc_mnc_apply(struct ctrl_cmd *cmd, const char *value, void *d) |
| 102 | { |
| 103 | char *tmp, *saveptr, *mcc, *mnc; |
| 104 | |
| 105 | tmp = talloc_strdup(cmd, value); |
| 106 | if (!tmp) |
| 107 | return 1; |
| 108 | |
| 109 | mcc = strtok_r(tmp, ",", &saveptr); |
| 110 | mnc = strtok_r(NULL, ",", &saveptr); |
| 111 | talloc_free(tmp); |
| 112 | |
| 113 | if (!mcc || !mnc) |
| 114 | return 1; |
| 115 | return 0; |
| 116 | } |
| 117 | |
Holger Hans Peter Freyther | eab2a3f | 2014-03-04 17:16:58 +0100 | [diff] [blame] | 118 | static int set_net_mcc_mnc_apply(struct ctrl_cmd *cmd, void *data) |
| 119 | { |
| 120 | struct gsm_network *net = cmd->node; |
| 121 | char *tmp, *saveptr, *mcc_str, *mnc_str; |
| 122 | int mcc, mnc; |
| 123 | |
| 124 | tmp = talloc_strdup(cmd, cmd->value); |
| 125 | if (!tmp) |
| 126 | goto oom; |
| 127 | |
| 128 | |
| 129 | mcc_str = strtok_r(tmp, ",", &saveptr); |
| 130 | mnc_str = strtok_r(NULL, ",", &saveptr); |
| 131 | |
| 132 | mcc = atoi(mcc_str); |
| 133 | mnc = atoi(mnc_str); |
| 134 | |
| 135 | talloc_free(tmp); |
| 136 | |
| 137 | if (net->network_code == mnc && net->country_code == mcc) { |
| 138 | cmd->reply = "Nothing changed"; |
| 139 | return CTRL_CMD_REPLY; |
| 140 | } |
| 141 | |
| 142 | net->network_code = mnc; |
| 143 | net->country_code = mcc; |
| 144 | |
| 145 | return set_net_apply_config(cmd, data); |
| 146 | |
| 147 | oom: |
| 148 | cmd->reply = "OOM"; |
| 149 | return CTRL_CMD_ERROR; |
| 150 | } |
Max | 78a5803 | 2017-01-11 18:37:55 +0100 | [diff] [blame^] | 151 | CTRL_CMD_DEFINE_WO(net_mcc_mnc_apply, "mcc-mnc-apply"); |
Holger Hans Peter Freyther | eab2a3f | 2014-03-04 17:16:58 +0100 | [diff] [blame] | 152 | |
Holger Hans Peter Freyther | ba8679d | 2014-11-10 11:41:03 +0100 | [diff] [blame] | 153 | /* BTS related commands below */ |
| 154 | CTRL_CMD_DEFINE_RANGE(bts_lac, "location-area-code", struct gsm_bts, location_area_code, 0, 65535); |
Holger Hans Peter Freyther | 982bb29 | 2014-11-21 10:54:42 +0100 | [diff] [blame] | 155 | CTRL_CMD_DEFINE_RANGE(bts_ci, "cell-identity", struct gsm_bts, cell_identity, 0, 65535); |
Holger Hans Peter Freyther | ba8679d | 2014-11-10 11:41:03 +0100 | [diff] [blame] | 156 | |
Holger Hans Peter Freyther | 87b35d5 | 2014-11-21 10:20:29 +0100 | [diff] [blame] | 157 | static int set_bts_apply_config(struct ctrl_cmd *cmd, void *data) |
| 158 | { |
| 159 | struct gsm_bts *bts = cmd->node; |
| 160 | |
| 161 | if (!is_ipaccess_bts(bts)) { |
| 162 | cmd->reply = "BTS is not IP based"; |
| 163 | return CTRL_CMD_ERROR; |
| 164 | } |
| 165 | |
| 166 | ipaccess_drop_oml(bts); |
| 167 | cmd->reply = "Tried to drop the BTS"; |
| 168 | return CTRL_CMD_REPLY; |
| 169 | } |
| 170 | |
Max | 78a5803 | 2017-01-11 18:37:55 +0100 | [diff] [blame^] | 171 | CTRL_CMD_DEFINE_WO_NOVRF(bts_apply_config, "apply-configuration"); |
Holger Hans Peter Freyther | d0284c8 | 2014-11-21 11:18:45 +0100 | [diff] [blame] | 172 | |
| 173 | static int set_bts_si(struct ctrl_cmd *cmd, void *data) |
| 174 | { |
| 175 | struct gsm_bts *bts = cmd->node; |
Alexander Chemeris | 143ac5f | 2015-05-30 14:40:54 -0400 | [diff] [blame] | 176 | int rc; |
Holger Hans Peter Freyther | d0284c8 | 2014-11-21 11:18:45 +0100 | [diff] [blame] | 177 | |
Alexander Chemeris | 143ac5f | 2015-05-30 14:40:54 -0400 | [diff] [blame] | 178 | rc = gsm_bts_set_system_infos(bts); |
| 179 | if (rc != 0) { |
| 180 | cmd->reply = "Failed to generate SI"; |
| 181 | return CTRL_CMD_ERROR; |
Holger Hans Peter Freyther | d0284c8 | 2014-11-21 11:18:45 +0100 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | cmd->reply = "Generated new System Information"; |
| 185 | return CTRL_CMD_REPLY; |
| 186 | } |
Max | 78a5803 | 2017-01-11 18:37:55 +0100 | [diff] [blame^] | 187 | CTRL_CMD_DEFINE_WO_NOVRF(bts_si, "send-new-system-informations"); |
Holger Hans Peter Freyther | 9fe9846 | 2014-12-05 12:03:24 +0100 | [diff] [blame] | 188 | |
| 189 | static int get_bts_chan_load(struct ctrl_cmd *cmd, void *data) |
| 190 | { |
| 191 | int i; |
| 192 | struct pchan_load pl; |
| 193 | struct gsm_bts *bts; |
| 194 | const char *space = ""; |
| 195 | |
| 196 | bts = cmd->node; |
| 197 | memset(&pl, 0, sizeof(pl)); |
Neels Hofmeyr | 7c0b45b | 2016-09-25 17:01:20 +0200 | [diff] [blame] | 198 | bts_chan_load(&pl, bts); |
Holger Hans Peter Freyther | 9fe9846 | 2014-12-05 12:03:24 +0100 | [diff] [blame] | 199 | |
| 200 | cmd->reply = talloc_strdup(cmd, ""); |
| 201 | |
| 202 | for (i = 0; i < ARRAY_SIZE(pl.pchan); ++i) { |
| 203 | const struct load_counter *lc = &pl.pchan[i]; |
| 204 | |
| 205 | /* These can never have user load */ |
| 206 | if (i == GSM_PCHAN_NONE) |
| 207 | continue; |
| 208 | if (i == GSM_PCHAN_CCCH) |
| 209 | continue; |
| 210 | if (i == GSM_PCHAN_PDCH) |
| 211 | continue; |
Holger Hans Peter Freyther | 5f3657d | 2015-01-31 19:42:42 +0100 | [diff] [blame] | 212 | if (i == GSM_PCHAN_UNKNOWN) |
| 213 | continue; |
Holger Hans Peter Freyther | 9fe9846 | 2014-12-05 12:03:24 +0100 | [diff] [blame] | 214 | |
| 215 | cmd->reply = talloc_asprintf_append(cmd->reply, |
| 216 | "%s%s,%u,%u", |
| 217 | space, gsm_pchan_name(i), lc->used, lc->total); |
| 218 | if (!cmd->reply) |
| 219 | goto error; |
| 220 | space = " "; |
| 221 | } |
| 222 | |
| 223 | return CTRL_CMD_REPLY; |
| 224 | |
| 225 | error: |
| 226 | cmd->reply = "Memory allocation failure"; |
| 227 | return CTRL_CMD_ERROR; |
| 228 | } |
| 229 | |
Max | 78a5803 | 2017-01-11 18:37:55 +0100 | [diff] [blame^] | 230 | CTRL_CMD_DEFINE_RO(bts_chan_load, "channel-load"); |
Holger Hans Peter Freyther | 0c47d9e | 2014-12-05 14:44:21 +0100 | [diff] [blame] | 231 | |
| 232 | static int get_bts_oml_conn(struct ctrl_cmd *cmd, void *data) |
| 233 | { |
| 234 | struct gsm_bts *bts = cmd->node; |
| 235 | |
| 236 | cmd->reply = bts->oml_link ? "connected" : "disconnected"; |
| 237 | return CTRL_CMD_REPLY; |
| 238 | } |
| 239 | |
Max | 78a5803 | 2017-01-11 18:37:55 +0100 | [diff] [blame^] | 240 | CTRL_CMD_DEFINE_RO(bts_oml_conn, "oml-connection-state"); |
Holger Hans Peter Freyther | 0c47d9e | 2014-12-05 14:44:21 +0100 | [diff] [blame] | 241 | |
Holger Hans Peter Freyther | 611f775 | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 242 | static int verify_bts_gprs_mode(struct ctrl_cmd *cmd, const char *value, void *_data) |
| 243 | { |
| 244 | int valid; |
| 245 | enum bts_gprs_mode mode; |
| 246 | struct gsm_bts *bts = cmd->node; |
| 247 | |
| 248 | mode = bts_gprs_mode_parse(value, &valid); |
| 249 | if (!valid) { |
| 250 | cmd->reply = "Mode is not known"; |
| 251 | return 1; |
| 252 | } |
| 253 | |
| 254 | if (!bts_gprs_mode_is_compat(bts, mode)) { |
| 255 | cmd->reply = "bts does not support this mode"; |
| 256 | return 1; |
| 257 | } |
| 258 | |
| 259 | return 0; |
| 260 | } |
| 261 | |
| 262 | static int get_bts_gprs_mode(struct ctrl_cmd *cmd, void *data) |
| 263 | { |
| 264 | struct gsm_bts *bts = cmd->node; |
| 265 | |
| 266 | cmd->reply = talloc_strdup(cmd, bts_gprs_mode_name(bts->gprs.mode)); |
| 267 | return CTRL_CMD_REPLY; |
| 268 | } |
| 269 | |
| 270 | static int set_bts_gprs_mode(struct ctrl_cmd *cmd, void *data) |
| 271 | { |
| 272 | struct gsm_bts *bts = cmd->node; |
| 273 | |
| 274 | bts->gprs.mode = bts_gprs_mode_parse(cmd->value, NULL); |
| 275 | return get_bts_gprs_mode(cmd, data); |
| 276 | } |
| 277 | |
| 278 | CTRL_CMD_DEFINE(bts_gprs_mode, "gprs-mode"); |
| 279 | |
Holger Hans Peter Freyther | 9edd06d | 2015-02-10 21:37:16 +0100 | [diff] [blame] | 280 | static int get_bts_rf_state(struct ctrl_cmd *cmd, void *data) |
| 281 | { |
| 282 | const char *oper, *admin, *policy; |
| 283 | struct gsm_bts *bts = cmd->node; |
| 284 | |
| 285 | if (!bts) { |
| 286 | cmd->reply = "bts not found."; |
| 287 | return CTRL_CMD_ERROR; |
| 288 | } |
| 289 | |
| 290 | oper = osmo_bsc_rf_get_opstate_name(osmo_bsc_rf_get_opstate_by_bts(bts)); |
| 291 | admin = osmo_bsc_rf_get_adminstate_name(osmo_bsc_rf_get_adminstate_by_bts(bts)); |
| 292 | policy = osmo_bsc_rf_get_policy_name(osmo_bsc_rf_get_policy_by_bts(bts)); |
| 293 | |
| 294 | cmd->reply = talloc_asprintf(cmd, "%s,%s,%s", oper, admin, policy); |
| 295 | if (!cmd->reply) { |
| 296 | cmd->reply = "OOM."; |
| 297 | return CTRL_CMD_ERROR; |
| 298 | } |
| 299 | |
| 300 | return CTRL_CMD_REPLY; |
| 301 | } |
| 302 | CTRL_CMD_DEFINE_RO(bts_rf_state, "rf_state"); |
| 303 | |
| 304 | static int get_net_rf_lock(struct ctrl_cmd *cmd, void *data) |
| 305 | { |
Holger Hans Peter Freyther | d476a80 | 2015-02-10 23:03:25 +0100 | [diff] [blame] | 306 | struct gsm_network *net = cmd->node; |
| 307 | struct gsm_bts *bts; |
| 308 | const char *policy_name; |
| 309 | |
| 310 | policy_name = osmo_bsc_rf_get_policy_name(net->bsc_data->rf_ctrl->policy); |
| 311 | |
| 312 | llist_for_each_entry(bts, &net->bts_list, list) { |
| 313 | struct gsm_bts_trx *trx; |
| 314 | |
| 315 | /* Exclude the BTS from the global lock */ |
| 316 | if (bts->excl_from_rf_lock) |
| 317 | continue; |
| 318 | |
| 319 | llist_for_each_entry(trx, &bts->trx_list, list) { |
| 320 | if (trx->mo.nm_state.availability == NM_AVSTATE_OK && |
| 321 | trx->mo.nm_state.operational != NM_OPSTATE_DISABLED) { |
| 322 | cmd->reply = talloc_asprintf(cmd, |
| 323 | "state=on,policy=%s,bts=%u,trx=%u", |
| 324 | policy_name, bts->nr, trx->nr); |
| 325 | return CTRL_CMD_REPLY; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | cmd->reply = talloc_asprintf(cmd, "state=off,policy=%s", |
| 331 | policy_name); |
| 332 | return CTRL_CMD_REPLY; |
Holger Hans Peter Freyther | 9edd06d | 2015-02-10 21:37:16 +0100 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | #define TIME_FORMAT_RFC2822 "%a, %d %b %Y %T %z" |
| 336 | |
| 337 | static int set_net_rf_lock(struct ctrl_cmd *cmd, void *data) |
| 338 | { |
| 339 | int locked = atoi(cmd->value); |
| 340 | struct gsm_network *net = cmd->node; |
| 341 | time_t now = time(NULL); |
| 342 | char now_buf[64]; |
| 343 | struct osmo_bsc_rf *rf; |
| 344 | |
| 345 | if (!net) { |
| 346 | cmd->reply = "net not found."; |
| 347 | return CTRL_CMD_ERROR; |
| 348 | } |
| 349 | |
| 350 | rf = net->bsc_data->rf_ctrl; |
| 351 | |
| 352 | if (!rf) { |
| 353 | cmd->reply = "RF Ctrl is not enabled in the BSC Configuration"; |
| 354 | return CTRL_CMD_ERROR; |
| 355 | } |
| 356 | |
| 357 | talloc_free(rf->last_rf_lock_ctrl_command); |
| 358 | strftime(now_buf, sizeof(now_buf), TIME_FORMAT_RFC2822, gmtime(&now)); |
| 359 | rf->last_rf_lock_ctrl_command = |
| 360 | talloc_asprintf(rf, "rf_locked %u (%s)", locked, now_buf); |
| 361 | |
| 362 | osmo_bsc_rf_schedule_lock(rf, locked == 1 ? '0' : '1'); |
| 363 | |
| 364 | cmd->reply = talloc_asprintf(cmd, "%u", locked); |
| 365 | if (!cmd->reply) { |
| 366 | cmd->reply = "OOM."; |
| 367 | return CTRL_CMD_ERROR; |
| 368 | } |
| 369 | |
| 370 | return CTRL_CMD_REPLY; |
| 371 | } |
| 372 | |
| 373 | static int verify_net_rf_lock(struct ctrl_cmd *cmd, const char *value, void *data) |
| 374 | { |
| 375 | int locked = atoi(cmd->value); |
| 376 | |
| 377 | if ((locked != 0) && (locked != 1)) |
| 378 | return 1; |
| 379 | |
| 380 | return 0; |
| 381 | } |
| 382 | CTRL_CMD_DEFINE(net_rf_lock, "rf_locked"); |
Holger Hans Peter Freyther | 611f775 | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 383 | |
Holger Hans Peter Freyther | bbd8ea1 | 2015-02-10 21:55:37 +0100 | [diff] [blame] | 384 | static int get_net_bts_num(struct ctrl_cmd *cmd, void *data) |
| 385 | { |
| 386 | struct gsm_network *net = cmd->node; |
| 387 | |
| 388 | cmd->reply = talloc_asprintf(cmd, "%u", net->num_bts); |
| 389 | return CTRL_CMD_REPLY; |
| 390 | } |
| 391 | CTRL_CMD_DEFINE_RO(net_bts_num, "number-of-bts"); |
| 392 | |
Holger Hans Peter Freyther | 2de4689 | 2014-03-23 11:17:27 +0100 | [diff] [blame] | 393 | /* TRX related commands below here */ |
| 394 | CTRL_HELPER_GET_INT(trx_max_power, struct gsm_bts_trx, max_power_red); |
Holger Hans Peter Freyther | 2de4689 | 2014-03-23 11:17:27 +0100 | [diff] [blame] | 395 | static int verify_trx_max_power(struct ctrl_cmd *cmd, const char *value, void *_data) |
| 396 | { |
| 397 | int tmp = atoi(value); |
| 398 | |
| 399 | if (tmp < 0 || tmp > 22) { |
| 400 | cmd->reply = "Value must be between 0 and 22"; |
| 401 | return -1; |
| 402 | } |
| 403 | |
| 404 | if (tmp & 1) { |
| 405 | cmd->reply = "Value must be even"; |
| 406 | return -1; |
| 407 | } |
| 408 | |
| 409 | return 0; |
| 410 | } |
Holger Hans Peter Freyther | b96705b | 2013-01-09 19:55:04 +0100 | [diff] [blame] | 411 | CTRL_CMD_DEFINE_RANGE(trx_arfcn, "arfcn", struct gsm_bts_trx, arfcn, 0, 1023); |
Holger Hans Peter Freyther | 1f67232 | 2014-03-26 14:24:42 +0100 | [diff] [blame] | 412 | |
| 413 | static int set_trx_max_power(struct ctrl_cmd *cmd, void *_data) |
| 414 | { |
| 415 | struct gsm_bts_trx *trx = cmd->node; |
| 416 | int old_power; |
| 417 | |
| 418 | /* remember the old value, set the new one */ |
| 419 | old_power = trx->max_power_red; |
| 420 | trx->max_power_red = atoi(cmd->value); |
| 421 | |
| 422 | /* Maybe update the value */ |
| 423 | if (old_power != trx->max_power_red) { |
| 424 | LOGP(DCTRL, LOGL_NOTICE, |
| 425 | "%s updating max_pwr_red(%d)\n", |
| 426 | gsm_trx_name(trx), trx->max_power_red); |
| 427 | abis_nm_update_max_power_red(trx); |
| 428 | } |
| 429 | |
| 430 | return get_trx_max_power(cmd, _data); |
| 431 | } |
Holger Hans Peter Freyther | 2de4689 | 2014-03-23 11:17:27 +0100 | [diff] [blame] | 432 | CTRL_CMD_DEFINE(trx_max_power, "max-power-reduction"); |
| 433 | |
Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 434 | int bsc_base_ctrl_cmds_install(void) |
| 435 | { |
| 436 | int rc = 0; |
| 437 | rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mnc); |
| 438 | rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc); |
| 439 | rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_short_name); |
| 440 | rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_long_name); |
Holger Hans Peter Freyther | 5ff537c | 2013-01-09 17:30:11 +0100 | [diff] [blame] | 441 | rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_apply_config); |
Holger Hans Peter Freyther | eab2a3f | 2014-03-04 17:16:58 +0100 | [diff] [blame] | 442 | rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc_mnc_apply); |
Holger Hans Peter Freyther | 9edd06d | 2015-02-10 21:37:16 +0100 | [diff] [blame] | 443 | rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_rf_lock); |
Holger Hans Peter Freyther | bbd8ea1 | 2015-02-10 21:55:37 +0100 | [diff] [blame] | 444 | rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_bts_num); |
Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 445 | |
Holger Hans Peter Freyther | ba8679d | 2014-11-10 11:41:03 +0100 | [diff] [blame] | 446 | rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_lac); |
Holger Hans Peter Freyther | 982bb29 | 2014-11-21 10:54:42 +0100 | [diff] [blame] | 447 | rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_ci); |
Holger Hans Peter Freyther | 87b35d5 | 2014-11-21 10:20:29 +0100 | [diff] [blame] | 448 | rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_apply_config); |
Holger Hans Peter Freyther | d0284c8 | 2014-11-21 11:18:45 +0100 | [diff] [blame] | 449 | rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_si); |
Holger Hans Peter Freyther | 9fe9846 | 2014-12-05 12:03:24 +0100 | [diff] [blame] | 450 | rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_chan_load); |
Holger Hans Peter Freyther | 0c47d9e | 2014-12-05 14:44:21 +0100 | [diff] [blame] | 451 | rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_oml_conn); |
Holger Hans Peter Freyther | 611f775 | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 452 | rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_gprs_mode); |
Holger Hans Peter Freyther | 9edd06d | 2015-02-10 21:37:16 +0100 | [diff] [blame] | 453 | rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_rf_state); |
Holger Hans Peter Freyther | ba8679d | 2014-11-10 11:41:03 +0100 | [diff] [blame] | 454 | |
Holger Hans Peter Freyther | 2de4689 | 2014-03-23 11:17:27 +0100 | [diff] [blame] | 455 | rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_max_power); |
Holger Hans Peter Freyther | b96705b | 2013-01-09 19:55:04 +0100 | [diff] [blame] | 456 | rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_arfcn); |
| 457 | |
Holger Hans Peter Freyther | 1ba8fa6 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 458 | return rc; |
| 459 | } |