fix/refactor neighbor config

The neighbor configuration storage is fundamentally broken: it requires
all local cells to be configured before being able to list them as
neighbors of each other. Upon config write-back, the neighbor config
however is placed back inline with the other config, and hence a
written-out neighbor config no longer works on program restart.

The cause of this problem is that the config is stored as explicit
pointers between local cells (struct gsm_bts), which of course requires
the pointer to exist before being able to reference it.

Instead, store the actual configuration that the user entered as-is,
without pointers or references to objects that need to be ready. Resolve
the neighbors every time a neighbor is needed.

Hence the user may enter any config at any place in the config file,
even non-working config (like a BTS number that doesn't exist), and the
relation to actual local or remote neighbor cells is made at runtime.

Abort program startup if the initial neighbor configuration contains
errors.

Related: OS#5018
Change-Id: I9ed992f8bfff888b3933733c0576f92d50f2625b
This commit is contained in:
Neels Hofmeyr 2021-03-09 17:11:45 +01:00
parent dc60505bc5
commit 764449ec2e
19 changed files with 924 additions and 1024 deletions

View File

@ -496,10 +496,13 @@ struct gsm_bts {
struct handover_cfg *ho;
/* A list of struct gsm_bts_ref, indicating neighbors of this BTS.
* When the si_common neigh_list is in automatic mode, it is populated from this list as well as
* gsm_network->neighbor_bss_cells. */
struct llist_head local_neighbors;
/* Local and remote neighbor configuration: a list of neighbors as written in the VTY config, not resolved to
* actual cells. Entries may point at non-existing BTS numbers, or yet unconfigured ARFCN+BSIC. The point of
* this list is to keep the config as the user entered it: a) to write it back exactly as entered, and b) to
* allow adding neighbor cells that will only be configured further down in the config file.
* An actual neighbor cell object (local or remote-BSS) is resolved "at runtime" whenever a neighbor is being
* looked up. */
struct llist_head neighbors;
/* BTS-specific overrides for timer values from struct gsm_network. */
uint8_t T3122; /* ASSIGNMENT REJECT wait indication */

View File

@ -31,7 +31,6 @@
#include <osmocom/abis/e1_input.h>
#include <osmocom/bsc/meas_rep.h>
#include <osmocom/bsc/acc.h>
#include <osmocom/bsc/neighbor_ident.h>
#include <osmocom/bsc/osmux.h>
#define GSM_T3122_DEFAULT 10
@ -174,10 +173,16 @@ extern const struct value_string handover_scope_names[];
inline static const char *handover_scope_name(enum handover_scope val)
{ return get_value_string(handover_scope_names, val); }
/* Cell ARFCN + BSIC. */
struct cell_ab {
uint16_t arfcn;
uint8_t bsic;
};
struct handover_out_req {
enum hodec_id from_hodec_id;
struct gsm_lchan *old_lchan;
struct neighbor_ident_key target_nik;
struct cell_ab target_cell_ab;
enum gsm_chan_t new_lchan_type; /*< leave GSM_LCHAN_NONE to use same as old_lchan */
};
@ -205,7 +210,7 @@ struct handover {
enum hodec_id from_hodec_id;
enum handover_scope scope;
enum gsm_chan_t new_lchan_type;
struct neighbor_ident_key target_cell;
struct cell_ab target_cell_ab;
/* For inter-BSC handover, this may reflect more than one Cell ID. Must also be set for intra-BSC handover,
* because it is used as key for penalty timers (e.g. in handover decision 2). */
@ -850,12 +855,6 @@ struct load_counter {
unsigned int used;
};
/* Useful to track N-N relations between BTS, for example neighbors. */
struct gsm_bts_ref {
struct llist_head entry;
struct gsm_bts *bts;
};
/* A single Page of a SMSCB message */
struct bts_smscb_page {
/* SMSCB message we're part of */
@ -1219,8 +1218,6 @@ struct gsm_network {
struct osmo_tdef *tdefs;
} mgw;
/* Remote BSS Cell Identifier Lists */
struct neighbor_ident_list *neighbor_bss_cells;
/* Remote BSS resolution sevice (CTRL iface) */
struct {
char *addr;

View File

@ -82,8 +82,9 @@ enum handover_result bsc_tx_bssmap_ho_complete(struct gsm_subscriber_connection
void bsc_tx_bssmap_ho_failure(struct gsm_subscriber_connection *conn);
int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
const struct gsm0808_cell_id_list2 **remote_target_cell_p,
struct gsm_subscriber_connection *conn, const struct neighbor_ident_key *search_for,
struct gsm0808_cell_id_list2 *remote_target_cells,
struct gsm_subscriber_connection *conn,
const struct cell_ab *search_for,
bool log_errors);
void handover_parse_inter_bsc_mt(struct gsm_subscriber_connection *conn,

View File

@ -7,62 +7,84 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/ctrl/control_cmd.h>
#include <osmocom/bsc/gsm_data.h>
struct vty;
struct gsm_network;
struct gsm_bts;
struct neighbor_ident_list;
struct gsm0808_cell_id_list2;
#define NEIGHBOR_IDENT_KEY_ANY_BTS -1
#define BSIC_ANY 0xff
struct neighbor_ident_key {
int from_bts; /*< BTS nr 0..255 or NEIGHBOR_IDENT_KEY_ANY_BTS */
uint16_t arfcn;
uint8_t bsic;
enum neighbor_type {
NEIGHBOR_TYPE_UNSET = 0,
NEIGHBOR_TYPE_BTS_NR = 1,
NEIGHBOR_TYPE_CELL_ID = 2,
};
const char *neighbor_ident_key_name(const struct neighbor_ident_key *ni_key);
/* One line of VTY neighbor configuration as entered by the user.
* One of three variants:
*
* - just the local-BSS neighbor BTS nr:
* neighbor bts 123
*
* - a neighbor cell identifier *without* ARFCN+BSIC:
* neighbor (lac|lac-ci|cgi|cgi-ps) 1 2 3...
* This is an elaborate / BTS-nr-agnostic way of indicating a local-BSS neighbor cell.
*
* - a neighbor cell identifier *with* ARFCN+BSIC:
* neighbor (lac|lac-ci|cgi|cgi-ps) 1 2 3... arfcn 456 bsic (23|any)
* This can either be
* - a remote-BSS neighbor cell, or
* - a super elaborate way of indicating a local-BSS neighbor, if this cell id exists in the local BSS.
*/
struct neighbor {
struct llist_head entry;
struct neighbor_ident_list *neighbor_ident_init(void *talloc_ctx);
void neighbor_ident_free(struct neighbor_ident_list *nil);
enum neighbor_type type;
union {
uint8_t bts_nr;
struct {
struct gsm0808_cell_id id;
bool ab_present;
struct cell_ab ab;
} cell_id;
};
};
bool neighbor_ident_key_match(const struct neighbor_ident_key *entry,
const struct neighbor_ident_key *search_for,
bool exact_match);
int resolve_local_neighbor(struct gsm_bts **local_neighbor_p, const struct gsm_bts *from_bts,
const struct neighbor *neighbor);
int resolve_remote_neighbors(struct gsm_bts *from_bts, const struct cell_ab *target_ab);
int neighbor_ident_add(struct neighbor_ident_list *nil, const struct neighbor_ident_key *key,
const struct gsm0808_cell_id_list2 *val);
const struct gsm0808_cell_id_list2 *neighbor_ident_get(const struct neighbor_ident_list *nil,
const struct neighbor_ident_key *key);
bool neighbor_ident_del(struct neighbor_ident_list *nil, const struct neighbor_ident_key *key);
void neighbor_ident_clear(struct neighbor_ident_list *nil);
int cell_ab_to_str_buf(char *buf, size_t buflen, const struct cell_ab *cell);
char *cell_ab_to_str_c(void *ctx, const struct cell_ab *cell);
void neighbor_ident_iter(const struct neighbor_ident_list *nil,
bool (* iter_cb )(const struct neighbor_ident_key *key,
const struct gsm0808_cell_id_list2 *val,
void *cb_data),
void *cb_data);
bool cell_ab_match(const struct cell_ab *entry, const struct cell_ab *search_for, bool exact_match);
bool cell_ab_valid(const struct cell_ab *cell);
struct neighbor_ident_key *bts_ident_key(const struct gsm_bts *bts);
int neighbor_to_str_buf(char *buf, size_t buflen, const struct neighbor *n);
char *neighbor_to_str_c(void *ctx, const struct neighbor *n);
bool neighbor_same(const struct neighbor *a, const struct neighbor *b, bool check_cell_ab);
void neighbor_ident_vty_init(struct gsm_network *net, struct neighbor_ident_list *nil);
void bts_cell_ab(struct cell_ab *arfcn_bsic, const struct gsm_bts *bts);
int resolve_neighbors(struct gsm_bts **local_neighbor_p, struct gsm0808_cell_id_list2 *remote_neighbors,
struct gsm_bts *from_bts, const struct cell_ab *target_ab, bool log_errors);
void neighbor_ident_vty_init();
void neighbor_ident_vty_write_bts(struct vty *vty, const char *indent, struct gsm_bts *bts);
void neighbor_ident_vty_write_network(struct vty *vty, const char *indent);
bool neighbor_ident_bts_entry_exists(uint8_t from_bts);
int neighbors_check_cfg();
#define NEIGHBOR_IDENT_VTY_KEY_PARAMS "arfcn <0-1023> bsic (<0-63>|any)"
#define NEIGHBOR_IDENT_VTY_KEY_DOC \
#define CELL_AB_VTY_PARAMS "arfcn <0-1023> bsic (<0-63>|any)"
#define CELL_AB_VTY_DOC \
"ARFCN of neighbor cell\n" "ARFCN value\n" \
"BSIC of neighbor cell\n" "BSIC value\n" \
"for all BSICs / use any BSIC in this ARFCN\n"
bool neighbor_ident_vty_parse_key_params(struct vty *vty, const char **argv,
struct neighbor_ident_key *key);
bool neighbor_ident_bts_parse_key_params(struct vty *vty, struct gsm_bts *bts, const char **argv,
struct neighbor_ident_key *key);
void neighbor_ident_vty_parse_arfcn_bsic(struct cell_ab *ab, const char **argv);
struct ctrl_handle *neighbor_controlif_setup(struct gsm_network *net);
int neighbor_ctrl_cmds_install(struct gsm_network *net);

View File

@ -100,7 +100,6 @@ static struct gsm_network *bsc_network_init(void *ctx)
net->ho = ho_cfg_init(net, NULL);
net->hodec2.congestion_check_interval_s = HO_CFG_CONGESTION_CHECK_DEFAULT;
net->neighbor_bss_cells = neighbor_ident_init(net);
/* init statistics */
net->bsc_ctrs = rate_ctr_group_alloc(net, &bsc_ctrg_desc, 0);

View File

@ -1881,8 +1881,8 @@ static int trigger_ho_or_as(struct vty *vty, struct gsm_lchan *from_lchan, struc
struct handover_out_req req = {
.from_hodec_id = HODEC_USER,
.old_lchan = from_lchan,
.target_nik = *bts_ident_key(to_bts),
};
bts_cell_ab(&req.target_cell_ab, to_bts);
handover_request(&req);
}
return CMD_SUCCESS;
@ -2075,14 +2075,15 @@ DEFUN(assignment_any, assignment_any_cmd,
}
DEFUN(handover_any_to_arfcn_bsic, handover_any_to_arfcn_bsic_cmd,
"handover any to " NEIGHBOR_IDENT_VTY_KEY_PARAMS,
"handover any to " CELL_AB_VTY_PARAMS,
MANUAL_HANDOVER_STR
"Pick any actively used TCH/F or TCH/H lchan to handover to another cell."
" This is likely to fail outside of a lab setup where you are certain that"
" all MS are able to see the target cell.\n"
"'to'\n"
NEIGHBOR_IDENT_VTY_KEY_DOC)
CELL_AB_VTY_DOC)
{
struct cell_ab ab = {};
struct handover_out_req req;
struct gsm_lchan *from_lchan;
@ -2095,12 +2096,8 @@ DEFUN(handover_any_to_arfcn_bsic, handover_any_to_arfcn_bsic_cmd,
.old_lchan = from_lchan,
};
if (!neighbor_ident_bts_parse_key_params(vty, from_lchan->ts->trx->bts,
argv, &req.target_nik)) {
vty_out(vty, "%% BTS %u does not know about this neighbor%s",
from_lchan->ts->trx->bts->nr, VTY_NEWLINE);
return CMD_WARNING;
}
neighbor_ident_vty_parse_arfcn_bsic(&ab, argv);
req.target_cell_ab = ab;
handover_request(&req);
return CMD_SUCCESS;
@ -7775,7 +7772,7 @@ int bsc_vty_init(struct gsm_network *network)
install_element(BTS_NODE, &cfg_bts_rep_no_ul_dl_sacch_cmd);
install_element(BTS_NODE, &cfg_bts_rep_rxqual_cmd);
neighbor_ident_vty_init(network, network->neighbor_bss_cells);
neighbor_ident_vty_init();
/* See also handover commands added on bts level from handover_vty.c */
install_element(BTS_NODE, &cfg_bts_power_ctrl_cmd);

View File

@ -273,7 +273,7 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, struct gsm_bts_sm *bts_sm
INIT_LLIST_HEAD(&bts->abis_queue);
INIT_LLIST_HEAD(&bts->loc_list);
INIT_LLIST_HEAD(&bts->local_neighbors);
INIT_LLIST_HEAD(&bts->neighbors);
INIT_LLIST_HEAD(&bts->oml_fail_rep);
INIT_LLIST_HEAD(&bts->chan_rqd_queue);
@ -442,59 +442,6 @@ void gsm_bts_cell_id_list(struct gsm0808_cell_id_list2 *cell_id_list, const stru
OSMO_ASSERT(rc > 0);
}
static struct gsm_bts_ref *gsm_bts_ref_find(const struct llist_head *list, const struct gsm_bts *bts)
{
struct gsm_bts_ref *ref;
if (!bts)
return NULL;
llist_for_each_entry(ref, list, entry) {
if (ref->bts == bts)
return ref;
}
return NULL;
}
/* Add a BTS reference to the local_neighbors list.
* Return 1 if added, 0 if such an entry already existed, and negative on errors. */
int gsm_bts_local_neighbor_add(struct gsm_bts *bts, struct gsm_bts *neighbor)
{
struct gsm_bts_ref *ref;
if (!bts || !neighbor)
return -ENOMEM;
if (bts == neighbor)
return -EINVAL;
/* Already got this entry? */
ref = gsm_bts_ref_find(&bts->local_neighbors, neighbor);
if (ref)
return 0;
ref = talloc_zero(bts, struct gsm_bts_ref);
if (!ref)
return -ENOMEM;
ref->bts = neighbor;
llist_add_tail(&ref->entry, &bts->local_neighbors);
return 1;
}
/* Remove a BTS reference from the local_neighbors list.
* Return 1 if removed, 0 if no such entry existed, and negative on errors. */
int gsm_bts_local_neighbor_del(struct gsm_bts *bts, const struct gsm_bts *neighbor)
{
struct gsm_bts_ref *ref;
if (!bts || !neighbor)
return -ENOMEM;
ref = gsm_bts_ref_find(&bts->local_neighbors, neighbor);
if (!ref)
return 0;
llist_del(&ref->entry);
talloc_free(ref);
return 1;
}
/* return the gsm_lchan for the CBCH (if it exists at all) */
struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts)
{

View File

@ -201,8 +201,7 @@ static void attempt_handover(struct gsm_meas_rep *mr)
req = (struct handover_out_req){
.from_hodec_id = HODEC1,
.old_lchan = mr->lchan,
.target_nik = {
.from_bts = bts->nr,
.target_cell_ab = {
.arfcn = best_cell->arfcn,
.bsic = best_cell->bsic,
},

View File

@ -83,8 +83,8 @@
#define LOGPHOCAND(candidate, level, fmt, args...) do {\
if ((candidate)->target.bts) \
LOGPHOLCHANTOBTS((candidate)->current.lchan, (candidate)->target.bts, level, fmt, ## args); \
else if ((candidate)->target.cil) \
LOGPHOLCHANTOREMOTE((candidate)->current.lchan, (candidate)->target.cil, level, fmt, ## args); \
else if ((candidate)->target.cell_ids.id_list_len) \
LOGPHOLCHANTOREMOTE((candidate)->current.lchan, &(candidate)->target.cell_ids, level, fmt, ## args); \
} while(0)
@ -120,8 +120,8 @@ struct ho_candidate {
int lchan_frees_tchh;
} current;
struct {
struct neighbor_ident_key nik; /* neighbor ARFCN+BSIC */
const struct gsm0808_cell_id_list2 *cil; /* target cells in remote BSS */
struct cell_ab ab; /* neighbor ARFCN+BSIC */
struct gsm0808_cell_id_list2 cell_ids; /* target cells in remote BSS */
struct gsm_bts *bts;
int rxlev;
int rxlev_afs_bias;
@ -747,9 +747,9 @@ static void check_requirements_remote_bss(struct ho_candidate *c)
/* Requirement A */
/* the handover penalty timer must not run for this bts */
penalty_time = penalty_timers_remaining_list(&c->current.lchan->conn->hodec2.penalty_timers, c->target.cil);
penalty_time = penalty_timers_remaining_list(&c->current.lchan->conn->hodec2.penalty_timers, &c->target.cell_ids);
if (penalty_time) {
LOGPHOLCHANTOREMOTE(c->current.lchan, c->target.cil, LOGL_DEBUG,
LOGPHOLCHANTOREMOTE(c->current.lchan, &c->target.cell_ids, LOGL_DEBUG,
"not a candidate, target BSS still in penalty time"
" (%u seconds left)\n", penalty_time);
return;
@ -879,9 +879,9 @@ static int trigger_local_ho_or_as(struct ho_candidate *c, uint8_t requirements)
req = (struct handover_out_req){
.from_hodec_id = HODEC2,
.old_lchan = c->current.lchan,
.target_nik = *bts_ident_key(c->target.bts),
.new_lchan_type = full_rate? GSM_LCHAN_TCH_F : GSM_LCHAN_TCH_H,
};
bts_cell_ab(&req.target_cell_ab, c->target.bts);
handover_request(&req);
return 0;
}
@ -890,14 +890,14 @@ static int trigger_remote_bss_ho(struct ho_candidate *c, uint8_t requirements)
{
struct handover_out_req req;
LOGPHOLCHANTOREMOTE(c->current.lchan, c->target.cil, LOGL_INFO,
LOGPHOLCHANTOREMOTE(c->current.lchan, &c->target.cell_ids, LOGL_INFO,
"Triggering inter-BSC handover, due to %s\n",
ho_reason_name(global_ho_reason));
req = (struct handover_out_req){
.from_hodec_id = HODEC2,
.old_lchan = c->current.lchan,
.target_nik = c->target.nik,
.target_cell_ab = c->target.ab,
};
handover_request(&req);
return 0;
@ -933,13 +933,13 @@ static inline void debug_candidate(struct ho_candidate *candidate)
candidate->target.free_tch##tchx, candidate->target.min_free_tch##tchx, \
REQUIREMENTS_ARGS(candidate->requirements, TCHX)
if (!candidate->target.bts && !candidate->target.cil)
if (!candidate->target.bts && !candidate->target.cell_ids.id_list_len)
LOGPHOLCHAN(candidate->current.lchan, LOGL_DEBUG, "Empty candidate\n");
if (candidate->target.bts && candidate->target.cil)
if (candidate->target.bts && candidate->target.cell_ids.id_list_len)
LOGPHOLCHAN(candidate->current.lchan, LOGL_ERROR, "Invalid candidate: both local- and remote-BSS target\n");
if (candidate->target.cil)
LOGPHOLCHANTOREMOTE(candidate->current.lchan, candidate->target.cil, LOGL_DEBUG,
if (candidate->target.cell_ids.id_list_len)
LOGPHOLCHANTOREMOTE(candidate->current.lchan, &candidate->target.cell_ids, LOGL_DEBUG,
"RX level %d dBm -> %d dBm\n",
rxlev2dbm(candidate->current.rxlev), rxlev2dbm(candidate->target.rxlev));
@ -1052,9 +1052,8 @@ static void collect_handover_candidate(struct gsm_lchan *lchan, struct neigh_mea
{
struct gsm_bts *bts = lchan->ts->trx->bts;
struct gsm_bts *neighbor_bts;
const struct gsm0808_cell_id_list2 *neighbor_cil;
struct neighbor_ident_key ni = {
.from_bts = bts->nr,
struct gsm0808_cell_id_list2 neighbor_cil;
struct cell_ab target_ab = {
.arfcn = nmp->arfcn,
.bsic = nmp->bsic,
};
@ -1078,9 +1077,9 @@ static void collect_handover_candidate(struct gsm_lchan *lchan, struct neigh_mea
}
find_handover_target_cell(&neighbor_bts, &neighbor_cil,
lchan->conn, &ni, false);
lchan->conn, &target_ab, false);
if (!neighbor_bts && !neighbor_cil) {
if (!neighbor_bts && !neighbor_cil.id_list_len) {
LOGPHOBTS(bts, LOGL_DEBUG, "no neighbor ARFCN %u BSIC %u configured for this cell\n",
nmp->arfcn, nmp->bsic);
return;
@ -1103,9 +1102,9 @@ static void collect_handover_candidate(struct gsm_lchan *lchan, struct neigh_mea
.rxlev = rxlev_current,
},
.target = {
.nik = ni,
.ab = target_ab,
.bts = neighbor_bts,
.cil = neighbor_cil,
.cell_ids = neighbor_cil,
.rxlev = neigh_meas_avg(nmp, ho_get_hodec2_rxlev_neigh_avg_win(bts->ho)),
},
};

View File

@ -146,7 +146,7 @@ const char *handover_status(struct gsm_subscriber_connection *conn)
snprintf(buf, sizeof(buf),
"("LOG_FMT_FROM_LCHAN") --HO-> (%s) " LOG_FMT_HO_SCOPE,
LOG_ARGS_FROM_LCHAN(conn->lchan),
neighbor_ident_key_name(&ho->target_cell),
cell_ab_to_str_c(OTC_SELECT, &ho->target_cell_ab),
LOG_ARGS_HO_SCOPE(conn));
else if (ho->scope & HO_INTER_BSC_IN) {
@ -227,9 +227,6 @@ void handover_request(struct handover_out_req *req)
conn = req->old_lchan->conn;
OSMO_ASSERT(conn && conn->fi);
/* Make sure the handover target neighbor_ident_key contains the correct source bts nr */
req->target_nik.from_bts = req->old_lchan->ts->trx->bts->nr;
/* To make sure we're allowed to start a handover, go through a gscon event dispatch. If that is accepted, the
* same req is passed to handover_start(). */
osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_HANDOVER_START, req);
@ -315,10 +312,10 @@ void handover_start(struct handover_out_req *req)
OSMO_ASSERT(req && req->old_lchan && req->old_lchan->conn);
struct gsm_subscriber_connection *conn = req->old_lchan->conn;
const struct neighbor_ident_key *search_for = &req->target_nik;
const struct cell_ab *search_for = &req->target_cell_ab;
struct handover *ho = &conn->ho;
struct gsm_bts *local_target_cell = NULL;
const struct gsm0808_cell_id_list2 *remote_target_cell = NULL;
struct gsm0808_cell_id_list2 remote_target_cells = {};
if (conn->ho.fi) {
LOG_HO(conn, LOGL_ERROR, "Handover requested while another handover is ongoing; Ignore\n");
@ -335,9 +332,9 @@ void handover_start(struct handover_out_req *req)
ho->from_hodec_id = req->from_hodec_id;
ho->new_lchan_type = req->new_lchan_type == GSM_LCHAN_NONE ?
req->old_lchan->type : req->new_lchan_type;
ho->target_cell = req->target_nik;
ho->target_cell_ab = req->target_cell_ab;
if (find_handover_target_cell(&local_target_cell, &remote_target_cell,
if (find_handover_target_cell(&local_target_cell, &remote_target_cells,
conn, search_for, true)) {
handover_end(conn, HO_RESULT_ERROR);
return;
@ -349,8 +346,8 @@ void handover_start(struct handover_out_req *req)
return;
}
if (remote_target_cell) {
handover_start_inter_bsc_out(conn, remote_target_cell);
if (remote_target_cells.id_list_len) {
handover_start_inter_bsc_out(conn, &remote_target_cells);
return;
}

View File

@ -126,7 +126,7 @@ int bts_handover_count(struct gsm_bts *bts, int ho_scopes)
return count;
}
/* Find out a handover target cell for the given neighbor_ident_key,
/* Find out a handover target cell for the given arfcn_bsic,
* and make sure there are no ambiguous matches.
* Given a source BTS and a target ARFCN+BSIC, find which cell is the right handover target.
* ARFCN+BSIC may be re-used within and/or across BSS, so make sure that only those cells that are explicitly
@ -138,22 +138,20 @@ int bts_handover_count(struct gsm_bts *bts, int ho_scopes)
* to be found.
*/
int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
const struct gsm0808_cell_id_list2 **remote_target_cell_p,
struct gsm_subscriber_connection *conn, const struct neighbor_ident_key *search_for,
struct gsm0808_cell_id_list2 *remote_target_cells,
struct gsm_subscriber_connection *conn,
const struct cell_ab *search_for,
bool log_errors)
{
struct gsm_network *net = conn->network;
struct gsm_bts *from_bts;
struct gsm_bts *local_target_cell = NULL;
const struct gsm0808_cell_id_list2 *remote_target_cell = NULL;
struct gsm_bts_ref *neigh;
bool ho_active;
bool as_active;
struct gsm_bts *from_bts = conn->lchan->ts->trx->bts;
*remote_target_cells = (struct gsm0808_cell_id_list2){};
if (local_target_cell_p)
*local_target_cell_p = NULL;
if (remote_target_cell_p)
*remote_target_cell_p = NULL;
if (!search_for) {
if (log_errors)
@ -161,7 +159,6 @@ int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
return -EINVAL;
}
from_bts = gsm_bts_num(net, search_for->from_bts);
if (!from_bts) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR, "Handover without source cell\n");
@ -174,12 +171,11 @@ int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
if (!ho_active && !as_active) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR, "Cannot start Handover: Handover and Assignment disabled for this source cell (%s)\n",
neighbor_ident_key_name(search_for));
cell_ab_to_str_c(OTC_SELECT, search_for));
return -EINVAL;
}
if (llist_empty(&from_bts->local_neighbors)
&& !neighbor_ident_bts_entry_exists(from_bts->nr)) {
if (llist_empty(&from_bts->neighbors)) {
/* No explicit neighbor entries exist for this BTS. Hence apply the legacy default behavior that all
* local cells are neighbors. */
struct gsm_bts *bts;
@ -192,15 +188,16 @@ int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
for (i = 0; i < 2; i++) {
bool exact_match = !i;
llist_for_each_entry(bts, &net->bts_list, list) {
struct neighbor_ident_key bts_key = *bts_ident_key(bts);
if (neighbor_ident_key_match(&bts_key, search_for, exact_match)) {
struct cell_ab bts_ab;
bts_cell_ab(&bts_ab, bts);
if (cell_ab_match(&bts_ab, search_for, exact_match)) {
if (local_target_cell) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR,
"NEIGHBOR CONFIGURATION ERROR: Multiple local cells match %s"
" (BTS %d and BTS %d)."
" Aborting Handover because of ambiguous network topology.\n",
neighbor_ident_key_name(search_for),
cell_ab_to_str_c(OTC_SELECT, search_for),
local_target_cell->nr, bts->nr);
return -EINVAL;
}
@ -214,7 +211,7 @@ int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
if (!local_target_cell) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR, "Cannot Handover, no cell matches %s\n",
neighbor_ident_key_name(search_for));
cell_ab_to_str_c(OTC_SELECT, search_for));
return -EINVAL;
}
@ -222,14 +219,14 @@ int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
if (log_errors)
LOG_HO(conn, LOGL_ERROR,
"Cannot start re-assignment, Assignment disabled for this cell (%s)\n",
neighbor_ident_key_name(search_for));
cell_ab_to_str_c(OTC_SELECT, search_for));
return -EINVAL;
}
if (local_target_cell != from_bts && !ho_active) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR,
"Cannot start Handover, Handover disabled for this cell (%s)\n",
neighbor_ident_key_name(search_for));
cell_ab_to_str_c(OTC_SELECT, search_for));
return -EINVAL;
}
@ -243,81 +240,60 @@ int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
LOG_HO(conn, LOGL_DEBUG, "There are explicit neighbors configured for this cell\n");
/* Iterate explicit local neighbor cells */
llist_for_each_entry(neigh, &from_bts->local_neighbors, entry) {
struct gsm_bts *neigh_bts = neigh->bts;
struct neighbor_ident_key neigh_bts_key = *bts_ident_key(neigh_bts);
neigh_bts_key.from_bts = from_bts->nr;
LOG_HO(conn, LOGL_DEBUG, "Local neighbor %s\n", neighbor_ident_key_name(&neigh_bts_key));
if (!neighbor_ident_key_match(&neigh_bts_key, search_for, true)) {
LOG_HO(conn, LOGL_DEBUG, "Doesn't match %s\n", neighbor_ident_key_name(search_for));
continue;
}
if (local_target_cell) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR,
"NEIGHBOR CONFIGURATION ERROR: Multiple BTS match %s (BTS %d and BTS %d)."
" Aborting Handover because of ambiguous network topology.\n",
neighbor_ident_key_name(search_for), local_target_cell->nr, neigh_bts->nr);
return -EINVAL;
}
local_target_cell = neigh_bts;
if (resolve_neighbors(&local_target_cell, remote_target_cells, from_bts, search_for, log_errors)) {
LOG_HO(conn, LOGL_ERROR, "Cannot handover BTS %u -> %s: neighbor unknown\n",
from_bts->nr, cell_ab_to_str_c(OTC_SELECT, search_for));
return -ENOENT;
}
/* Any matching remote-BSS neighbor cell? */
remote_target_cell = neighbor_ident_get(net->neighbor_bss_cells, search_for);
/* We have found possibly a local_target_cell (when != NULL), and / or remote_target_cells (when .id_list_len >
* 0). Figure out what to do with them. */
if (remote_target_cell)
LOG_HO(conn, LOGL_DEBUG, "Found remote target cell %s\n",
gsm0808_cell_id_list_name(remote_target_cell));
if (remote_target_cells->id_list_len)
LOG_HO(conn, LOGL_DEBUG, "Found remote target cell(s) %s\n",
gsm0808_cell_id_list_name_c(OTC_SELECT, remote_target_cells));
if (local_target_cell && remote_target_cell) {
if (local_target_cell && remote_target_cells->id_list_len) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR, "NEIGHBOR CONFIGURATION ERROR: Both a local and a remote-BSS cell match %s"
" (BTS %d and remote %s)."
LOG_HO(conn, LOGL_ERROR, "NEIGHBOR CONFIGURATION ERROR: Both a local and a remote-BSS cell"
" match BTS %u -> %s (BTS %d and remote %s)."
" Aborting Handover because of ambiguous network topology.\n",
neighbor_ident_key_name(search_for), local_target_cell->nr,
gsm0808_cell_id_list_name(remote_target_cell));
from_bts->nr, cell_ab_to_str_c(OTC_SELECT, search_for), local_target_cell->bts_nr,
gsm0808_cell_id_list_name_c(OTC_SELECT, remote_target_cells));
return -EINVAL;
}
if (local_target_cell == from_bts && !as_active) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR,
"Cannot start re-assignment, Assignment disabled for this cell (%s)\n",
neighbor_ident_key_name(search_for));
"Cannot start re-assignment, Assignment disabled for this cell (BTS %u)\n",
from_bts->nr);
return -EINVAL;
}
if (((local_target_cell && local_target_cell != from_bts)
|| remote_target_cell)
|| remote_target_cells->id_list_len)
&& !ho_active) {
if (log_errors)
LOG_HO(conn, LOGL_ERROR,
"Cannot start Handover, Handover disabled for this cell (%s)\n",
neighbor_ident_key_name(search_for));
"Cannot start Handover, Handover disabled for this cell (BTS %u -> %s)\n",
from_bts->bts_nr, cell_ab_to_str_c(OTC_SELECT, search_for));
return -EINVAL;
}
/* Return the result. After above checks, only one of local or remote cell has been found. */
if (local_target_cell) {
if (local_target_cell_p)
*local_target_cell_p = local_target_cell;
return 0;
}
if (remote_target_cell) {
if (remote_target_cell_p)
*remote_target_cell_p = remote_target_cell;
if (remote_target_cells->id_list_len)
return 0;
}
if (log_errors)
LOG_HO(conn, LOGL_ERROR, "Cannot handover %s: neighbor unknown\n",
neighbor_ident_key_name(search_for));
cell_ab_to_str_c(OTC_SELECT, search_for));
return -ENODEV;
}

View File

@ -40,88 +40,238 @@
#include <osmocom/bsc/bts.h>
#include <osmocom/bsc/debug.h>
struct neighbor_ident_list {
struct llist_head list;
};
struct neighbor_ident {
struct llist_head entry;
struct neighbor_ident_key key;
struct gsm0808_cell_id_list2 val;
};
#define APPEND_THING(func, args...) do { \
int remain = buflen - (pos - buf); \
int l = func(pos, remain, ##args); \
if (l < 0 || l > remain) \
pos = buf + buflen; \
else \
pos += l; \
} while(0)
#define APPEND_STR(fmt, args...) APPEND_THING(snprintf, fmt, ##args)
const char *_neighbor_ident_key_name(char *buf, size_t buflen, const struct neighbor_ident_key *ni_key)
void bts_cell_ab(struct cell_ab *arfcn_bsic, const struct gsm_bts *bts)
{
char *pos = buf;
APPEND_STR("BTS ");
if (ni_key->from_bts == NEIGHBOR_IDENT_KEY_ANY_BTS)
APPEND_STR("*");
else if (ni_key->from_bts >= 0 && ni_key->from_bts <= 255)
APPEND_STR("%d", ni_key->from_bts);
else
APPEND_STR("invalid(%d)", ni_key->from_bts);
APPEND_STR(" to ");
if (ni_key->bsic == BSIC_ANY)
APPEND_STR("ARFCN %u (any BSIC)", ni_key->arfcn);
else
APPEND_STR("ARFCN %u BSIC %u", ni_key->arfcn, ni_key->bsic & 0x3f);
return buf;
*arfcn_bsic = (struct cell_ab){
.arfcn = bts->c0->arfcn,
.bsic = bts->bsic,
};
}
const char *neighbor_ident_key_name(const struct neighbor_ident_key *ni_key)
/* Find the local gsm_bts pointer that a specific other BTS' neighbor config refers to. Return NULL if there is no such
* local cell in this BSS.
*/
int resolve_local_neighbor(struct gsm_bts **local_neighbor_p, const struct gsm_bts *from_bts,
const struct neighbor *neighbor)
{
static char buf[64];
return _neighbor_ident_key_name(buf, sizeof(buf), ni_key);
struct gsm_bts *bts;
struct gsm_bts *bts_exact = NULL;
struct gsm_bts *bts_wildcard = NULL;
*local_neighbor_p = NULL;
switch (neighbor->type) {
case NEIGHBOR_TYPE_BTS_NR:
bts = gsm_bts_num(bsc_gsmnet, neighbor->bts_nr);
goto check_bts;
case NEIGHBOR_TYPE_CELL_ID:
/* Find cell id below */
break;
default:
return -ENOTSUP;
}
/* NEIGHBOR_TYPE_CELL_ID */
llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
struct gsm0808_cell_id cell_id;
gsm_bts_cell_id(&cell_id, bts);
if (gsm0808_cell_ids_match(&cell_id, &neighbor->cell_id.id, true)) {
if (bts_exact) {
LOGP(DHO, LOGL_ERROR,
"Neighbor config error: Multiple BTS match %s (BTS %u and BTS %u)\n",
gsm0808_cell_id_name_c(OTC_SELECT, &neighbor->cell_id.id),
bts_exact->nr, bts->nr);
return -EINVAL;
} else {
bts_exact = bts;
}
}
if (!bts_wildcard && gsm0808_cell_ids_match(&cell_id, &neighbor->cell_id.id, false))
bts_wildcard = bts;
}
bts = (bts_exact ? : bts_wildcard);
check_bts:
/* A cell cannot be its own neighbor */
if (bts == from_bts) {
LOGP(DHO, LOGL_ERROR,
"Neighbor config error: BTS %u -> %s: this cell is configured as its own neighbor\n",
from_bts->nr, neighbor_to_str_c(OTC_SELECT, neighbor));
return -EINVAL;
}
if (!bts)
return -ENOENT;
/* Double check whether ARFCN + BSIC config matches, if present. */
if (neighbor->cell_id.ab_present) {
struct cell_ab cell_ab;
bts_cell_ab(&cell_ab, bts);
if (!cell_ab_match(&cell_ab, &neighbor->cell_id.ab, false)) {
LOGP(DHO, LOGL_ERROR, "Neighbor config error: Local BTS %d matches %s, but not ARFCN+BSIC %s\n",
bts->nr, gsm0808_cell_id_name_c(OTC_SELECT, &neighbor->cell_id.id),
cell_ab_to_str_c(OTC_SELECT, &cell_ab));
return -EINVAL;
}
}
*local_neighbor_p = bts;
return 0;
}
struct neighbor_ident_list *neighbor_ident_init(void *talloc_ctx)
int resolve_neighbors(struct gsm_bts **local_neighbor_p, struct gsm0808_cell_id_list2 *remote_neighbors,
struct gsm_bts *from_bts, const struct cell_ab *target_ab, bool log_errors)
{
struct neighbor_ident_list *nil = talloc_zero(talloc_ctx, struct neighbor_ident_list);
OSMO_ASSERT(nil);
INIT_LLIST_HEAD(&nil->list);
return nil;
struct neighbor *n;
struct gsm_bts *local_neighbor = NULL;
struct gsm0808_cell_id_list2 remotes = {};
*local_neighbor_p = NULL;
*remote_neighbors = (struct gsm0808_cell_id_list2){ 0 };
llist_for_each_entry(n, &from_bts->neighbors, entry) {
struct gsm_bts *neigh_bts;
if (resolve_local_neighbor(&neigh_bts, from_bts, n) == 0) {
/* This neighbor entry is a local cell neighbor. Do ARFCN and BSIC match? */
struct cell_ab ab;
bts_cell_ab(&ab, neigh_bts);
if (!cell_ab_match(&ab, target_ab, false))
continue;
/* Found a local cell neighbor that matches the target_ab */
/* If we already found one, these are ambiguous local neighbors */
if (local_neighbor) {
if (log_errors)
LOGP(DHO, LOGL_ERROR, "Neighbor config error:"
" Local BTS %d -> %s resolves to local neighbor BTSes %u *and* %u\n",
from_bts->nr, cell_ab_to_str_c(OTC_SELECT, target_ab), local_neighbor->nr,
neigh_bts->nr);
return -ENOTSUP;
}
local_neighbor = neigh_bts;
} else if (n->type == NEIGHBOR_TYPE_CELL_ID && n->cell_id.ab_present) {
/* This neighbor entry is a remote-BSS neighbor. There may be multiple remote neighbors,
* collect those in a gsm0808_cell_id_list2 (remote_target_cells). A limitation is that all of
* them need to be of the same cell id type. */
struct gsm0808_cell_id_list2 add_item;
int rc;
if (!cell_ab_match(&n->cell_id.ab, target_ab, false))
continue;
/* Convert the gsm0808_cell_id to a list, so that we can use gsm0808_cell_id_list_add(). */
gsm0808_cell_id_to_list(&add_item, &n->cell_id.id);
rc = gsm0808_cell_id_list_add(&remotes, &add_item);
if (rc < 0) {
if (log_errors)
LOGP(DHO, LOGL_ERROR, "Neighbor config error:"
" Local BTS %d -> %s resolves to remote-BSS neighbor %s;"
" Could not store this in neighbors list %s\n",
from_bts->nr, cell_ab_to_str_c(OTC_SELECT, target_ab),
gsm0808_cell_id_name_c(OTC_SELECT, &n->cell_id.id),
gsm0808_cell_id_list_name_c(OTC_SELECT, &remotes));
return rc;
}
}
/* else: neighbor entry that does not resolve to anything. */
}
if (local_neighbor_p)
*local_neighbor_p = local_neighbor;
if (remote_neighbors)
*remote_neighbors = remotes;
if (!local_neighbor && !remotes.id_list_len)
return -ENOENT;
return 0;
}
void neighbor_ident_free(struct neighbor_ident_list *nil)
int cell_ab_to_str_buf(char *buf, size_t buflen, const struct cell_ab *cell)
{
if (!nil)
return;
talloc_free(nil);
struct osmo_strbuf sb = { .buf = buf, .len = buflen };
OSMO_STRBUF_PRINTF(sb, "ARFCN-BSIC:%u", cell->arfcn);
if (cell->bsic == BSIC_ANY)
OSMO_STRBUF_PRINTF(sb, "-any");
else {
OSMO_STRBUF_PRINTF(sb, "-%u", cell->bsic);
if (cell->bsic > 0x3f)
OSMO_STRBUF_PRINTF(sb, "[ERANGE>63]");
}
return sb.chars_needed;
}
char *cell_ab_to_str_c(void *ctx, const struct cell_ab *cell)
{
OSMO_NAME_C_IMPL(ctx, 64, "ERROR", cell_ab_to_str_buf, cell)
}
int neighbor_to_str_buf(char *buf, size_t buflen, const struct neighbor *n)
{
struct osmo_strbuf sb = { .buf = buf, .len = buflen };
switch (n->type) {
case NEIGHBOR_TYPE_BTS_NR:
OSMO_STRBUF_PRINTF(sb, "BTS %u", n->bts_nr);
break;
case NEIGHBOR_TYPE_CELL_ID:
OSMO_STRBUF_APPEND_NOLEN(sb, gsm0808_cell_id_name_buf, &n->cell_id.id);
if (n->cell_id.ab_present) {
OSMO_STRBUF_PRINTF(sb, " ");
OSMO_STRBUF_APPEND(sb, cell_ab_to_str_buf, &n->cell_id.ab);
}
break;
case NEIGHBOR_TYPE_UNSET:
OSMO_STRBUF_PRINTF(sb, "UNSET");
break;
default:
OSMO_STRBUF_PRINTF(sb, "INVALID");
break;
}
return sb.chars_needed;
}
char *neighbor_to_str_c(void *ctx, const struct neighbor *n)
{
OSMO_NAME_C_IMPL(ctx, 64, "ERROR", neighbor_to_str_buf, n);
}
bool neighbor_same(const struct neighbor *a, const struct neighbor *b, bool check_cell_ab)
{
if (a == b)
return true;
if (a->type != b->type)
return false;
switch (a->type) {
case NEIGHBOR_TYPE_BTS_NR:
return a->bts_nr == b->bts_nr;
case NEIGHBOR_TYPE_CELL_ID:
if (check_cell_ab
&& (a->cell_id.ab_present != b->cell_id.ab_present
|| !cell_ab_match(&a->cell_id.ab, &b->cell_id.ab, true)))
return false;
return gsm0808_cell_ids_match(&a->cell_id.id, &b->cell_id.id, true);
default:
return a->type == b->type;
}
}
/* Return true when the entry matches the search_for requirements.
* If exact_match is false, a BSIC_ANY entry acts as wildcard to match any search_for on that ARFCN,
* and a BSIC_ANY in search_for likewise returns any one entry that matches the ARFCN;
* also a from_bts == NEIGHBOR_IDENT_KEY_ANY_BTS in either entry or search_for will match.
* If exact_match is true, only identical bsic values and identical from_bts values return a match.
* and a BSIC_ANY in search_for likewise returns any one entry that matches the ARFCN.
* If exact_match is true, only identical bsic values return a match.
* Note, typically wildcard BSICs are only in entry, e.g. the user configured list, and search_for
* contains a specific BSIC, e.g. as received from a Measurement Report. */
bool neighbor_ident_key_match(const struct neighbor_ident_key *entry,
const struct neighbor_ident_key *search_for,
bool exact_match)
bool cell_ab_match(const struct cell_ab *entry,
const struct cell_ab *search_for,
bool exact_match)
{
if (exact_match
&& entry->from_bts != search_for->from_bts)
return false;
if (search_for->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS
&& entry->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS
&& entry->from_bts != search_for->from_bts)
return false;
if (entry->arfcn != search_for->arfcn)
return false;
@ -134,142 +284,67 @@ bool neighbor_ident_key_match(const struct neighbor_ident_key *entry,
return entry->bsic == search_for->bsic;
}
static struct neighbor_ident *_neighbor_ident_get(const struct neighbor_ident_list *nil,
const struct neighbor_ident_key *key,
bool exact_match)
bool cell_ab_valid(const struct cell_ab *cell)
{
struct neighbor_ident *ni;
struct neighbor_ident *wildcard_match = NULL;
if (cell->bsic != BSIC_ANY && cell->bsic > 0x3f)
return false;
return true;
}
/* Do both exact-bsic and wildcard matching in the same iteration:
* Any exact match returns immediately, while for a wildcard match we still go through all
* remaining items in case an exact match exists. */
llist_for_each_entry(ni, &nil->list, entry) {
if (neighbor_ident_key_match(&ni->key, key, true))
return ni;
if (!exact_match) {
if (neighbor_ident_key_match(&ni->key, key, false))
wildcard_match = ni;
int neighbors_check_cfg()
{
/* A local neighbor can be configured by BTS number, or by a cell ID. A local neighbor can omit the ARFCN+BSIC,
* in which case those are taken from that local BTS config. If a local neighbor has ARFCN+BSIC configured, it
* must match the local cell's configuration.
*
* A remote neighbor must always be a cell ID *and* ARFCN+BSIC.
*
* Hence any cell ID with ARFCN+BSIC where the cell ID is not found among the local cells is a remote-BSS
* neighbor.
*/
struct gsm_bts *bts;
bool ok = true;
llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
struct neighbor *neighbor;
struct gsm_bts *local_neighbor;
llist_for_each_entry(neighbor, &bts->neighbors, entry) {
switch (neighbor->type) {
case NEIGHBOR_TYPE_BTS_NR:
if (!gsm_bts_num(bsc_gsmnet, neighbor->bts_nr)) {
LOGP(DHO, LOGL_ERROR, "Neighbor Configuration Error:"
" BTS %u -> BTS %u: There is no BTS nr %u\n",
bts->nr, neighbor->bts_nr, neighbor->bts_nr);
ok = false;
}
break;
default:
switch (resolve_local_neighbor(&local_neighbor, bts, neighbor)) {
case 0:
break;
case -ENOENT:
if (!neighbor->cell_id.ab_present) {
LOGP(DHO, LOGL_ERROR, "Neighbor Configuration Error:"
" BTS %u -> %s: There is no such local neighbor\n",
bts->nr, neighbor_to_str_c(OTC_SELECT, neighbor));
ok = false;
}
break;
default:
/* Error already logged in resolve_local_neighbor() */
ok = false;
break;
}
break;
}
}
}
return wildcard_match;
}
static void _neighbor_ident_free(struct neighbor_ident *ni)
{
llist_del(&ni->entry);
talloc_free(ni);
}
bool neighbor_ident_key_valid(const struct neighbor_ident_key *key)
{
if (key->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS
&& (key->from_bts < 0 || key->from_bts > 255))
return false;
if (key->bsic != BSIC_ANY && key->bsic > 0x3f)
return false;
return true;
}
/*! Add Cell Identifiers to an ARFCN+BSIC entry.
* Exactly one kind of identifier is allowed per ARFCN+BSIC entry, and any number of entries of that kind
* may be added up to the capacity of gsm0808_cell_id_list2, by one or more calls to this function. To
* replace an existing entry, first call neighbor_ident_del(nil, key).
* \returns number of entries in the resulting identifier list, or negative on error:
* see gsm0808_cell_id_list_add() for the meaning of returned error codes;
* return -ENOMEM when the list is not initialized, -ERANGE when the BSIC value is too large. */
int neighbor_ident_add(struct neighbor_ident_list *nil, const struct neighbor_ident_key *key,
const struct gsm0808_cell_id_list2 *val)
{
struct neighbor_ident *ni;
int rc;
if (!nil)
return -ENOMEM;
if (!neighbor_ident_key_valid(key))
return -ERANGE;
ni = _neighbor_ident_get(nil, key, true);
if (!ni) {
ni = talloc_zero(nil, struct neighbor_ident);
OSMO_ASSERT(ni);
*ni = (struct neighbor_ident){
.key = *key,
.val = *val,
};
llist_add_tail(&ni->entry, &nil->list);
return ni->val.id_list_len;
}
rc = gsm0808_cell_id_list_add(&ni->val, val);
if (rc < 0)
return rc;
return ni->val.id_list_len;
}
/*! Find cell identity for given BTS, ARFCN and BSIC, as previously added by neighbor_ident_add().
*/
const struct gsm0808_cell_id_list2 *neighbor_ident_get(const struct neighbor_ident_list *nil,
const struct neighbor_ident_key *key)
{
struct neighbor_ident *ni;
if (!nil)
return NULL;
ni = _neighbor_ident_get(nil, key, false);
if (!ni)
return NULL;
return &ni->val;
}
bool neighbor_ident_del(struct neighbor_ident_list *nil, const struct neighbor_ident_key *key)
{
struct neighbor_ident *ni;
if (!nil)
return false;
ni = _neighbor_ident_get(nil, key, true);
if (!ni)
return false;
_neighbor_ident_free(ni);
return true;
}
void neighbor_ident_clear(struct neighbor_ident_list *nil)
{
struct neighbor_ident *ni;
while ((ni = llist_first_entry_or_null(&nil->list, struct neighbor_ident, entry)))
_neighbor_ident_free(ni);
}
/*! Iterate all neighbor_ident_list entries and call iter_cb for each.
* If iter_cb returns false, the iteration is stopped. */
void neighbor_ident_iter(const struct neighbor_ident_list *nil,
bool (* iter_cb )(const struct neighbor_ident_key *key,
const struct gsm0808_cell_id_list2 *val,
void *cb_data),
void *cb_data)
{
struct neighbor_ident *ni, *ni_next;
if (!nil)
return;
llist_for_each_entry_safe(ni, ni_next, &nil->list, entry) {
if (!iter_cb(&ni->key, &ni->val, cb_data))
return;
}
}
struct neighbor_ident_key *bts_ident_key(const struct gsm_bts *bts)
{
static struct neighbor_ident_key key;
key = (struct neighbor_ident_key){
.from_bts = NEIGHBOR_IDENT_KEY_ANY_BTS,
.arfcn = bts->c0->arfcn,
.bsic = bts->bsic,
};
return &key;
if (!ok)
return -EINVAL;
return 0;
}
/* Neighbor Resolution CTRL iface */
@ -293,13 +368,13 @@ static int get_neighbor_resolve_cgi_ps_from_lac_ci(struct ctrl_cmd *cmd, void *d
{
struct gsm_network *net = (struct gsm_network *)data;
struct gsm_bts *bts_tmp, *bts_found = NULL;
const struct gsm0808_cell_id_list2 *tgt_cell_li = NULL;
char *tmp = NULL, *tok, *saveptr;
struct neighbor_ident_key ni;
struct cell_ab ab;
unsigned lac, cell_id;
struct osmo_cell_global_id_ps local_cgi_ps;
const struct osmo_cell_global_id_ps *cgi_ps = NULL;
struct gsm_bts_ref *neigh;
struct gsm_bts *local_neighbor = NULL;
struct gsm0808_cell_id_list2 remote_neighbors = { 0 };
if (!cmd->variable)
goto fmt_err;
@ -324,13 +399,11 @@ static int get_neighbor_resolve_cgi_ps_from_lac_ci(struct ctrl_cmd *cmd, void *d
if (!(tok = strtok_r(NULL, ".", &saveptr)))
goto fmt_err;
ni.arfcn = atoi(tok);
ab.arfcn = atoi(tok);
if (!(tok = strtok_r(NULL, "\0", &saveptr)))
goto fmt_err;
ni.bsic = atoi(tok);
ni.from_bts = NEIGHBOR_IDENT_KEY_ANY_BTS;
ab.bsic = atoi(tok);
llist_for_each_entry(bts_tmp, &net->bts_list, list) {
if (bts_tmp->location_area_code != lac)
@ -338,39 +411,41 @@ static int get_neighbor_resolve_cgi_ps_from_lac_ci(struct ctrl_cmd *cmd, void *d
if (bts_tmp->cell_identity != cell_id)
continue;
bts_found = bts_tmp;
ni.from_bts = bts_tmp->nr;
break;
}
if (!bts_found)
goto notfound_err;
LOG_BTS(bts_found, DLINP, LOGL_DEBUG, "Resolving neigbhor arfcn=%u bsic=%u\n", ni.arfcn, ni.bsic);
LOG_BTS(bts_found, DLINP, LOGL_DEBUG, "Resolving neighbor BTS %u -> %s\n", bts_found->nr,
cell_ab_to_str_c(OTC_SELECT, &ab));
if (!neighbor_ident_key_valid(&ni))
if (!cell_ab_valid(&ab))
goto fmt_err;
/* Is there a local BTS that matches the key? */
llist_for_each_entry(neigh, &bts_found->local_neighbors, entry) {
struct gsm_bts *neigh_bts = neigh->bts;
struct neighbor_ident_key *neigh_bts_key = bts_ident_key(neigh_bts);
neigh_bts_key->from_bts = ni.from_bts;
if (!neighbor_ident_key_match(neigh_bts_key, &ni, true))
continue;
if (gsm_bts_get_cgi_ps(neigh->bts, &local_cgi_ps) < 0)
continue; /* Not supporting GPRS */
cgi_ps = &local_cgi_ps;
break;
if (resolve_neighbors(&local_neighbor, &remote_neighbors, bts_found, &ab, true))
goto notfound_err;
/* resolve_neighbors() returns either a local_neighbor or remote_neighbors.
* Local-BSS neighbor? */
if (local_neighbor) {
/* Supporting GPRS? */
if (gsm_bts_get_cgi_ps(local_neighbor, &local_cgi_ps) >= 0)
cgi_ps = &local_cgi_ps;
}
/* No local neighbor found, looking for remote neighbors */
if (!cgi_ps) {
tgt_cell_li = neighbor_ident_get(net->neighbor_bss_cells, &ni);
if (!tgt_cell_li || tgt_cell_li->id_discr != CELL_IDENT_WHOLE_GLOBAL_PS || tgt_cell_li->id_list_len < 1)
goto notfound_err;
cgi_ps = &tgt_cell_li->id_list[0].global_ps;
/* Remote-BSS neighbor?
* By spec, there can be multiple remote neighbors for a given ARFCN+BSIC, but so far osmo-bsc enforces only a
* single remote neighbor. */
if (remote_neighbors.id_list_len
&& remote_neighbors.id_discr == CELL_IDENT_WHOLE_GLOBAL_PS) {
cgi_ps = &remote_neighbors.id_list[0].global_ps;
}
/* No neighbor found */
if (!cgi_ps)
goto notfound_err;
ctrl_cmd_reply_printf(cmd, "%s", osmo_cgi_ps_name(cgi_ps));
talloc_free(tmp);
return CTRL_CMD_REPLY;

File diff suppressed because it is too large Load Diff

View File

@ -944,6 +944,11 @@ int main(int argc, char **argv)
exit(1);
}
if (neighbors_check_cfg()) {
fprintf(stderr, "Errors in neighbor configuration, check the DHO log. exiting.\n");
exit(1);
}
/* start control interface after reading config for
* ctrl_vty_get_bind_addr() */
bsc_gsmnet->ctrl = bsc_controlif_setup(bsc_gsmnet,

View File

@ -602,25 +602,6 @@ int generate_cell_chan_list(uint8_t *chan_list, struct gsm_bts *bts)
return bitvec2freq_list(chan_list, bv, bts, false, false);
}
struct generate_bcch_chan_list__ni_iter_data {
struct gsm_bts *bts;
struct bitvec *bv;
};
static bool generate_bcch_chan_list__ni_iter_cb(const struct neighbor_ident_key *key,
const struct gsm0808_cell_id_list2 *val,
void *cb_data)
{
struct generate_bcch_chan_list__ni_iter_data *data = cb_data;
if (key->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS
&& key->from_bts != data->bts->nr)
return true;
bitvec_set_bit_pos(data->bv, key->arfcn, 1);
return true;
}
/*! generate a cell channel list as per Section 10.5.2.22 of 04.08
* \param[out] chan_list caller-provided output buffer
* \param[in] bts BTS descriptor used for input data
@ -646,7 +627,7 @@ static int generate_bcch_chan_list(uint8_t *chan_list, struct gsm_bts *bts,
/* Zero-initialize the bit-vector */
memset(bv->data, 0, bv->data_len);
if (llist_empty(&bts->local_neighbors)) {
if (llist_empty(&bts->neighbors)) {
/* There are no explicit neighbors, assume all BTS are. */
llist_for_each_entry(cur_bts, &bts->network->bts_list, list) {
if (cur_bts == bts)
@ -655,21 +636,21 @@ static int generate_bcch_chan_list(uint8_t *chan_list, struct gsm_bts *bts,
}
} else {
/* Only add explicit neighbor cells */
struct gsm_bts_ref *neigh;
llist_for_each_entry(neigh, &bts->local_neighbors, entry) {
bitvec_set_bit_pos(bv, neigh->bts->c0->arfcn, 1);
struct neighbor *n;
llist_for_each_entry(n, &bts->neighbors, entry) {
if (n->type == NEIGHBOR_TYPE_CELL_ID && n->cell_id.ab_present) {
bitvec_set_bit_pos(bv, n->cell_id.ab.arfcn, 1);
} else {
struct gsm_bts *neigh_bts;
if (resolve_local_neighbor(&neigh_bts, bts, n) == 0)
bitvec_set_bit_pos(bv, n->cell_id.ab.arfcn, 1);
else
LOGP(DHO, LOGL_ERROR,
"Neither local nor remote neighbor: BTS %u -> %s\n",
bts->nr, neighbor_to_str_c(OTC_SELECT, n));
}
}
}
/* Also add neighboring BSS cells' ARFCNs */
{
struct generate_bcch_chan_list__ni_iter_data data = {
.bv = bv,
.bts = bts,
};
neighbor_ident_iter(bts->network->neighbor_bss_cells,
generate_bcch_chan_list__ni_iter_cb, &data);
}
}
/* then we generate a GSM 04.08 frequency list from the bitvec */

View File

@ -39,6 +39,7 @@
#include <search.h>
void *ctx = NULL;
struct gsm_network *bsc_gsmnet = NULL;
enum test {
TEST_SCAN_TO_BTS,
@ -125,6 +126,7 @@ static void test_scan(void)
struct gsm_network *net = gsm_network_init(ctx);
struct gsm_subscriber_connection *conn = talloc_zero(net, struct gsm_subscriber_connection);
bsc_gsmnet = net;
conn->network = net;
/* start testing with proper messages */
@ -176,6 +178,7 @@ out:
}
talloc_free(net);
bsc_gsmnet = NULL;
}
static const struct log_info_cat log_categories[] = {

View File

@ -47,6 +47,8 @@ network
codec-support fr
gprs mode gprs
gprs routing area 5
! local neigh, refers to bts 1:
neighbor cgi-ps 1 1 1 6 123
! remote neigh:
neighbor cgi-ps 23 42 423 2 5 arfcn 23 bsic 32
trx 0
@ -134,9 +136,6 @@ network
timeslot 7
phys_chan_config TCH/F
hopping enabled 0
bts 0
! local neigh, refers to bts 1:
neighbor cgi-ps 1 1 1 6 123
msc 0
type normal
allow-emergency allow

View File

@ -59,6 +59,7 @@
}
struct gsm_network *bsc_gsmnet = NULL;
static inline void gen(struct gsm_bts *bts, const char *s)
{
@ -899,6 +900,7 @@ int main(int argc, char **argv)
printf("Network init failure.\n");
return EXIT_FAILURE;
}
bsc_gsmnet = net;
test_si_range_helpers();
test_arfcn_filter();

View File

@ -94,6 +94,10 @@ OsmoBSC(config-net-bts)# list
neighbor cgi <0-999> <0-999> <0-65535> <0-65535> arfcn <0-1023> bsic (<0-63>|any)
neighbor cgi-ps <0-999> <0-999> <0-65535> <0-255> <0-65535> arfcn <0-1023> bsic (<0-63>|any)
no neighbor bts <0-255>
no neighbor lac <0-65535>
no neighbor lac-ci <0-65535> <0-65535>
no neighbor cgi <0-999> <0-999> <0-65535> <0-65535>
no neighbor cgi-ps <0-999> <0-999> <0-65535> <0-255> <0-65535>
no neighbor arfcn <0-1023> bsic (<0-63>|any)
no neighbors
...
@ -173,8 +177,12 @@ OsmoBSC(config-net-bts)# no neighbor?
neighbor Remove local or remote-BSS neighbor cell
OsmoBSC(config-net-bts)# no neighbor ?
bts Neighbor cell by local BTS number
arfcn ARFCN of neighbor cell
bts Neighbor cell by local BTS number
lac Neighbor cell by LAC
lac-ci Neighbor cell by LAC and CI
cgi Neighbor cell by cgi
cgi-ps Neighbor cell by cgi (Packet Switched, with RAC)
arfcn ARFCN of neighbor cell
OsmoBSC(config-net-bts)# no neighbor bts ?
<0-255> BTS number
@ -199,52 +207,64 @@ OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 64
% Unknown command.
OsmoBSC(config-net-bts)# neighbor bts 0
% Error: cannot add local BTS 0 as neighbor to BTS 0: Invalid argument
OsmoBSC(config-net-bts)# no neighbor bts 0
OsmoBSC(config-net-bts)# show running-config
... !neighbor
OsmoBSC(config-net-bts)# neighbor bts 1
% BTS 0 now has local neighbor BTS 1 with LAC 21 CI 31 and ARFCN 41 BSIC 11
OsmoBSC(config-net-bts)# no neighbor bts 1
% Error: no such neighbor on BTS 0: BTS 1
OsmoBSC(config-net-bts)# ### Add non-existing BTS nr -- is allowed, checking plausibility at runtime
OsmoBSC(config-net-bts)# neighbor bts 123
OsmoBSC(config-net-bts)# ### A neighbor by LAC and by BTS number are two distinct neighbor entries, resolved at runtime
OsmoBSC(config-net-bts)# neighbor lac 22
% BTS 0 now has local neighbor BTS 2 with LAC 22 CI 65535 and ARFCN 42 BSIC 12
OsmoBSC(config-net-bts)# no neighbor bts 2
% Error: no such neighbor on BTS 0: BTS 2
OsmoBSC(config-net-bts)# no neighbor lac 22
OsmoBSC(config-net-bts)# neighbor cgi 901 70 22 65535
% BTS 0 now has local neighbor BTS 2 with LAC 22 CI 65535 and ARFCN 42 BSIC 12
OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
% BTS 0 to ARFCN 23 BSIC 42 now has 1 remote BSS Cell Identifier List entry
OsmoBSC(config-net-bts)# ### adding the same entry again results in no change
OsmoBSC(config-net-bts)# neighbor bts 1
% BTS 0 already had local neighbor BTS 1 with LAC 21 CI 31 and ARFCN 41 BSIC 11
OsmoBSC(config-net-bts)# neighbor lac-ci 21 31
% BTS 0 already had local neighbor BTS 1 with LAC 21 CI 31 and ARFCN 41 BSIC 11
OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
OsmoBSC(config-net-bts)# neighbor bts 123
% BTS 0 already had neighbor BTS 123
OsmoBSC(config-net-bts)# neighbor cgi 23 042 423 6 arfcn 23 bsic 42
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
OsmoBSC(config-net-bts)# neighbor lac-ci 21 31 arfcn 41 bsic 11
OsmoBSC(config-net-bts)# neighbor lac-ci 21 31 arfcn 41 bsic 11
% BTS 0 already had neighbor LAC-CI:21-31 ARFCN-BSIC:41-11
OsmoBSC(config-net-bts)# neighbor lac-ci 21 31 arfcn 22 bsic 32
% BTS 0 already had neighbor LAC-CI:21-31 ARFCN-BSIC:41-11
% ERROR: duplicate Cell ID in neighbor config, with differing ARFCN+BSIC: LAC-CI:21-31 ARFCN-BSIC:22-32
OsmoBSC(config-net-bts)# show running-config
...
neighbor lac-ci 21 31 arfcn 41 bsic 11
...
OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
% BTS 0 already had neighbor CGI:023-42-423-5 ARFCN-BSIC:23-42
OsmoBSC(config-net-bts)# neighbor cgi 23 042 423 5 arfcn 23 bsic 42
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 -> CGI:023-42-423-5 ARFCN-BSIC:23-42
OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 6 arfcn 23 bsic 42
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 -> CGI:023-42-423-5 ARFCN-BSIC:23-42
OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 6 arfcn 42 bsic 1
OsmoBSC(config-net-bts)# neighbor lac 456 arfcn 123 bsic 45
% BTS 0 to ARFCN 123 BSIC 45 now has 1 remote BSS Cell Identifier List entry
OsmoBSC(config-net-bts)# neighbor cgi 23 042 234 56 arfcn 23 bsic 42
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
OsmoBSC(config-net-bts)# neighbor lac-ci 789 10 arfcn 423 bsic any
% BTS 0 to ARFCN 423 (any BSIC) now has 1 remote BSS Cell Identifier List entry
OsmoBSC(config-net-bts)# neighbor lac-ci 789 10 arfcn 423 bsic 63
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 423 BSIC 63 -> LAC-CI[1]:{789-10}
% BTS 0 already had neighbor LAC-CI:789-10 ARFCN-BSIC:423-any
% ERROR: duplicate Cell ID in neighbor config, with differing ARFCN+BSIC: LAC-CI:789-10 ARFCN-BSIC:423-63
OsmoBSC(config-net-bts)# neighbor lac-ci 789 10 arfcn 423 bsic 1
% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 423 BSIC 1 -> LAC-CI[1]:{789-10}
% BTS 0 already had neighbor LAC-CI:789-10 ARFCN-BSIC:423-any
% ERROR: duplicate Cell ID in neighbor config, with differing ARFCN+BSIC: LAC-CI:789-10 ARFCN-BSIC:423-1
OsmoBSC(config-net-bts)# show running-config
...
@ -252,119 +272,125 @@ network
... !neighbor
bts 0
... !neighbor
neighbor bts 1
neighbor bts 2
neighbor bts 123
neighbor cgi 901 70 22 65535
neighbor cgi 023 42 423 5 arfcn 23 bsic 42
neighbor lac-ci 21 31 arfcn 41 bsic 11
neighbor cgi 023 42 423 6 arfcn 42 bsic 1
neighbor lac 456 arfcn 123 bsic 45
neighbor lac-ci 789 10 arfcn 423 bsic any
... !neighbor
OsmoBSC(config-net-bts)# do show bts 0 neighbor arfcn 99 bsic any
% No entry for BTS 0 to ARFCN 99 (any BSIC)
% No entry for BTS 0 -> ARFCN-BSIC:99-any
OsmoBSC(config-net-bts)# do show bts 0 neighbor arfcn 41 bsic any
% BTS 0 to ARFCN 41 (any BSIC) resolves to local BTS 1 lac-ci 21 31
% BTS 0 -> ARFCN-BSIC:41-any resolves to local BTS 1 lac-ci 21 31
OsmoBSC(config-net-bts)# do show bts 0 neighbor arfcn 423 bsic 1
% neighbor lac-ci 789 10 arfcn 423 bsic 1
% BTS 0 -> ARFCN-BSIC:423-1 resolves to remote-BSS neighbors: LAC-CI[1]:{789-10}
OsmoBSC(config-net-bts)# do show bts 0 neighbor arfcn 423 bsic 23
% neighbor lac-ci 789 10 arfcn 423 bsic 23
% BTS 0 -> ARFCN-BSIC:423-23 resolves to remote-BSS neighbors: LAC-CI[1]:{789-10}
OsmoBSC(config-net-bts)# no neighbor arfcn 99 bsic 7
% Cannot remove, no such neighbor: BTS 0 to ARFCN 99 BSIC 7
% Cannot remove: no such neighbor on BTS 0: ARFCN-BSIC:99-7
OsmoBSC(config-net-bts)# no neighbor arfcn 23 bsic 42
% Removed remote BSS neighbor BTS 0 to ARFCN 23 BSIC 42
OsmoBSC(config-net-bts)# show running-config
... !neighbor
neighbor bts 1
neighbor bts 2
neighbor bts 123
neighbor cgi 901 70 22 65535
neighbor lac-ci 21 31 arfcn 41 bsic 11
neighbor cgi 023 42 423 6 arfcn 42 bsic 1
neighbor lac 456 arfcn 123 bsic 45
neighbor lac-ci 789 10 arfcn 423 bsic any
... !neighbor
OsmoBSC(config-net-bts)# no neighbor arfcn 123 bsic 45
% Removed remote BSS neighbor BTS 0 to ARFCN 123 BSIC 45
OsmoBSC(config-net-bts)# show running-config
... !neighbor
neighbor bts 1
neighbor bts 2
neighbor bts 123
neighbor cgi 901 70 22 65535
neighbor lac-ci 21 31 arfcn 41 bsic 11
neighbor cgi 023 42 423 6 arfcn 42 bsic 1
neighbor lac-ci 789 10 arfcn 423 bsic any
... !neighbor
OsmoBSC(config-net-bts)# no neighbor arfcn 423 bsic any
% Removed remote BSS neighbor BTS 0 to ARFCN 423 (any BSIC)
OsmoBSC(config-net-bts)# show running-config
... !neighbor
neighbor bts 1
neighbor bts 2
neighbor bts 123
neighbor cgi 901 70 22 65535
neighbor lac-ci 21 31 arfcn 41 bsic 11
neighbor cgi 023 42 423 6 arfcn 42 bsic 1
... !neighbor
OsmoBSC(config-net-bts)# no neighbor arfcn 423 bsic 63
% Cannot remove, no such neighbor: BTS 0 to ARFCN 423 BSIC 63
% Cannot remove: no such neighbor on BTS 0: ARFCN-BSIC:423-63
OsmoBSC(config-net-bts)# show running-config
... !neighbor
neighbor bts 1
neighbor bts 2
neighbor bts 123
neighbor cgi 901 70 22 65535
neighbor lac-ci 21 31 arfcn 41 bsic 11
neighbor cgi 023 42 423 6 arfcn 42 bsic 1
... !neighbor
OsmoBSC(config-net-bts)# no neighbor arfcn 423 bsic 1
% Cannot remove, no such neighbor: BTS 0 to ARFCN 423 BSIC 1
% Cannot remove: no such neighbor on BTS 0: ARFCN-BSIC:423-1
OsmoBSC(config-net-bts)# show running-config
... !neighbor
neighbor bts 1
neighbor bts 2
neighbor bts 123
neighbor cgi 901 70 22 65535
neighbor lac-ci 21 31 arfcn 41 bsic 11
neighbor cgi 023 42 423 6 arfcn 42 bsic 1
... !neighbor
OsmoBSC(config-net-bts)# no neighbor arfcn 41 bsic any
% Removed local neighbor bts 0 to bts 1
OsmoBSC(config-net-bts)# show running-config
... !neighbor
neighbor bts 2
neighbor bts 123
neighbor cgi 901 70 22 65535
neighbor cgi 023 42 423 6 arfcn 42 bsic 1
... !neighbor
OsmoBSC(config-net-bts)# no neighbor arfcn 41 bsic any
% Cannot remove, no such neighbor: BTS 0 to ARFCN 41 (any BSIC)
% Cannot remove: no such neighbor on BTS 0: ARFCN-BSIC:41-any
OsmoBSC(config-net-bts)# show running-config
... !neighbor
neighbor bts 2
neighbor bts 123
neighbor cgi 901 70 22 65535
neighbor cgi 023 42 423 6 arfcn 42 bsic 1
... !neighbor
OsmoBSC(config-net-bts)# no neighbor arfcn 42 bsic 12
% Removed local neighbor bts 0 to bts 2
OsmoBSC(config-net-bts)# no neighbor bts 123
OsmoBSC(config-net-bts)# no neighbor cgi 901 70 22 65535
OsmoBSC(config-net-bts)# no neighbor arfcn 42 bsic 1
OsmoBSC(config-net-bts)# show running-config
... !neighbor
OsmoBSC(config-net-bts)# neighbor bts 1
% BTS 0 now has local neighbor BTS 1 with LAC 21 CI 31 and ARFCN 41 BSIC 11
OsmoBSC(config-net-bts)# neighbor bts 2
% BTS 0 now has local neighbor BTS 2 with LAC 22 CI 65535 and ARFCN 42 BSIC 12
OsmoBSC(config-net-bts)# neighbor cgi 023 42 423 5 arfcn 23 bsic 42
% BTS 0 to ARFCN 23 BSIC 42 now has 1 remote BSS Cell Identifier List entry
OsmoBSC(config-net-bts)# neighbor lac 456 arfcn 123 bsic 45
% BTS 0 to ARFCN 123 BSIC 45 now has 1 remote BSS Cell Identifier List entry
OsmoBSC(config-net-bts)# neighbor lac-ci 789 10 arfcn 423 bsic any
% BTS 0 to ARFCN 423 (any BSIC) now has 1 remote BSS Cell Identifier List entry
OsmoBSC(config-net-bts)# neighbor cgi-ps 23 42 423 2 5 arfcn 23 bsic 32
% BTS 0 to ARFCN 23 BSIC 32 now has 1 remote BSS Cell Identifier List entry
OsmoBSC(config-net-bts)# no neighbors
% Removed local neighbor bts 0 to bts 1
% Removed local neighbor bts 0 to bts 2
% Removed remote BSS neighbor BTS 0 to ARFCN 23 BSIC 42
% Removed remote BSS neighbor BTS 0 to ARFCN 123 BSIC 45
% Removed remote BSS neighbor BTS 0 to ARFCN 423 (any BSIC)
% Removed remote BSS neighbor BTS 0 to ARFCN 23 BSIC 32
% Removed neighbor: BTS 0 to BTS 1
% Removed neighbor: BTS 0 to BTS 2
% Removed neighbor: BTS 0 to CGI:023-42-423-5 ARFCN-BSIC:23-42
% Removed neighbor: BTS 0 to LAC:456 ARFCN-BSIC:123-45
% Removed neighbor: BTS 0 to LAC-CI:789-10 ARFCN-BSIC:423-any
% Removed neighbor: BTS 0 to CGI-PS:023-42-423-2-5 ARFCN-BSIC:23-32
OsmoBSC(config-net-bts)# show running-config
... !neighbor