From e263187a3641c7f7ead5a390490c0e89e430ed39 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 21 Aug 2014 18:25:11 +0200 Subject: Fix bsc_ctrl_node_lookup after libctrl changes As bsc_ctrl_node_lookup() is called for each iteration, the variables 'bts' and 'trx' are no longer static accross multiple calls, which means we need a different way to determine if we are in the right node while matching for a trx or a ts. --- openbsc/src/libbsc/bsc_ctrl_lookup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'openbsc/src/libbsc/bsc_ctrl_lookup.c') diff --git a/openbsc/src/libbsc/bsc_ctrl_lookup.c b/openbsc/src/libbsc/bsc_ctrl_lookup.c index 6d3c57ca0..b504cccd5 100644 --- a/openbsc/src/libbsc/bsc_ctrl_lookup.c +++ b/openbsc/src/libbsc/bsc_ctrl_lookup.c @@ -51,7 +51,7 @@ static int bsc_ctrl_node_lookup(void *data, vector vline, int *node_type, * and/or use strtol to check if number conversion was successful * Right now something like net.bts_stats will not work */ if (!strcmp(token, "bts")) { - if (!net) + if (*node_type != CTRL_NODE_ROOT || !net) goto err_missing; (*i)++; if (!ctrl_parse_get_num(vline, *i, &num)) @@ -63,8 +63,9 @@ static int bsc_ctrl_node_lookup(void *data, vector vline, int *node_type, *node_data = bts; *node_type = CTRL_NODE_BTS; } else if (!strcmp(token, "trx")) { - if (!bts) + if (*node_type != CTRL_NODE_BTS || !*node_data) goto err_missing; + bts = *node_data; (*i)++; if (!ctrl_parse_get_num(vline, *i, &num)) goto err_index; @@ -75,8 +76,9 @@ static int bsc_ctrl_node_lookup(void *data, vector vline, int *node_type, *node_data = trx; *node_type = CTRL_NODE_TRX; } else if (!strcmp(token, "ts")) { - if (!trx) + if (*node_type != CTRL_NODE_TRX || !*node_data) goto err_missing; + trx = *node_data; (*i)++; if (!ctrl_parse_get_num(vline, *i, &num)) goto err_index; -- cgit v1.2.3