Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 1 | /* OsmoBSC handover configuration implementation */ |
| 2 | /* (C) 2017 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 3 | * (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * Author: Neels Hofmeyr <nhofmeyr@sysmocom.de> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU Affero General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <stdbool.h> |
| 24 | #include <talloc.h> |
| 25 | |
| 26 | #include <osmocom/bsc/vty.h> |
| 27 | #include <osmocom/bsc/handover_cfg.h> |
| 28 | #include <osmocom/bsc/gsm_data.h> |
| 29 | |
| 30 | struct handover_cfg { |
| 31 | struct handover_cfg *higher_level_cfg; |
| 32 | |
| 33 | #define HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL, VTY1, VTY2, VTY3, VTY4, VTY5, VTY6) \ |
| 34 | TYPE NAME; \ |
| 35 | bool has_##NAME; |
| 36 | |
| 37 | HO_CFG_ALL_MEMBERS |
| 38 | #undef HO_CFG_ONE_MEMBER |
| 39 | }; |
| 40 | |
| 41 | struct handover_cfg *ho_cfg_init(void *ctx, struct handover_cfg *higher_level_cfg) |
| 42 | { |
| 43 | struct handover_cfg *ho = talloc_zero(ctx, struct handover_cfg); |
| 44 | OSMO_ASSERT(ho); |
| 45 | ho->higher_level_cfg = higher_level_cfg; |
| 46 | return ho; |
| 47 | } |
| 48 | |
| 49 | #define HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL, VTY1, VTY2, VTY_ARG_EVAL, VTY4, VTY5, VTY6) \ |
| 50 | TYPE ho_get_##NAME(struct handover_cfg *ho) \ |
| 51 | { \ |
| 52 | if (ho->has_##NAME) \ |
| 53 | return ho->NAME; \ |
| 54 | if (ho->higher_level_cfg) \ |
| 55 | return ho_get_##NAME(ho->higher_level_cfg); \ |
| 56 | return VTY_ARG_EVAL(#DEFAULT_VAL); \ |
| 57 | } \ |
| 58 | \ |
| 59 | void ho_set_##NAME(struct handover_cfg *ho, TYPE value) \ |
| 60 | { \ |
| 61 | ho->NAME = value; \ |
| 62 | ho->has_##NAME = true; \ |
| 63 | } \ |
| 64 | \ |
| 65 | bool ho_isset_##NAME(struct handover_cfg *ho) \ |
| 66 | { \ |
| 67 | return ho->has_##NAME; \ |
| 68 | } \ |
| 69 | \ |
| 70 | void ho_clear_##NAME(struct handover_cfg *ho) \ |
| 71 | { \ |
| 72 | ho->has_##NAME = false; \ |
| 73 | } \ |
| 74 | \ |
| 75 | bool ho_isset_on_parent_##NAME(struct handover_cfg *ho) \ |
| 76 | { \ |
| 77 | return ho->higher_level_cfg \ |
| 78 | && (ho_isset_##NAME(ho->higher_level_cfg) \ |
| 79 | || ho_isset_on_parent_##NAME(ho->higher_level_cfg)); \ |
| 80 | } |
| 81 | |
| 82 | HO_CFG_ALL_MEMBERS |
| 83 | #undef HO_CFG_ONE_MEMBER |