Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | /* GSM Network Management (OML) messages on the A-bis interface |
| 2 | * 3GPP TS 12.21 version 8.0.0 Release 1999 / ETSI TS 100 623 V8.0.0 */ |
| 3 | |
| 4 | /* (C) 2008 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 5 | * |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 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 General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | #include <errno.h> |
| 26 | #include <stdio.h> |
| 27 | #include <sys/types.h> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 28 | #include <netinet/in.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 29 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 30 | #include <openbsc/gsm_data.h> |
| 31 | #include <openbsc/debug.h> |
| 32 | #include <openbsc/msgb.h> |
| 33 | #include <openbsc/tlv.h> |
| 34 | #include <openbsc/abis_nm.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 35 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 36 | #define OM_ALLOC_SIZE 1024 |
| 37 | #define OM_HEADROOM_SIZE 128 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 38 | |
| 39 | /* unidirectional messages from BTS to BSC */ |
| 40 | static const enum abis_nm_msgtype reports[] = { |
| 41 | NM_MT_SW_ACTIVATED_REP, |
| 42 | NM_MT_TEST_REP, |
| 43 | NM_MT_STATECHG_EVENT_REP, |
| 44 | NM_MT_FAILURE_EVENT_REP, |
| 45 | }; |
| 46 | |
| 47 | /* messages without ACK/NACK */ |
| 48 | static const enum abis_nm_msgtype no_ack_nack[] = { |
| 49 | NM_MT_MEAS_RES_REQ, |
| 50 | NM_MT_STOP_MEAS, |
| 51 | NM_MT_START_MEAS, |
| 52 | }; |
| 53 | |
| 54 | /* Attributes that the BSC can set, not only get, according to Section 9.4 */ |
| 55 | static const enum abis_nm_attr nm_att_settable[] = { |
| 56 | NM_ATT_ADD_INFO, |
| 57 | NM_ATT_ADD_TEXT, |
| 58 | NM_ATT_DEST, |
| 59 | NM_ATT_EVENT_TYPE, |
| 60 | NM_ATT_FILE_DATA, |
| 61 | NM_ATT_GET_ARI, |
| 62 | NM_ATT_HW_CONF_CHG, |
| 63 | NM_ATT_LIST_REQ_ATTR, |
| 64 | NM_ATT_MDROP_LINK, |
| 65 | NM_ATT_MDROP_NEXT, |
| 66 | NM_ATT_NACK_CAUSES, |
| 67 | NM_ATT_OUTST_ALARM, |
| 68 | NM_ATT_PHYS_CONF, |
| 69 | NM_ATT_PROB_CAUSE, |
| 70 | NM_ATT_RAD_SUBC, |
| 71 | NM_ATT_SOURCE, |
| 72 | NM_ATT_SPEC_PROB, |
| 73 | NM_ATT_START_TIME, |
| 74 | NM_ATT_TEST_DUR, |
| 75 | NM_ATT_TEST_NO, |
| 76 | NM_ATT_TEST_REPORT, |
| 77 | NM_ATT_WINDOW_SIZE, |
| 78 | NM_ATT_SEVERITY, |
| 79 | NM_ATT_MEAS_RES, |
| 80 | NM_ATT_MEAS_TYPE, |
| 81 | }; |
| 82 | |
| 83 | static int is_in_arr(enum abis_nm_msgtype mt, const enum abis_nm_msgtype *arr, int size) |
| 84 | { |
| 85 | int i; |
| 86 | |
| 87 | for (i = 0; i < size; i++) { |
| 88 | if (arr[i] == mt) |
| 89 | return 1; |
| 90 | } |
| 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | /* is this msgtype the usual ACK/NACK type ? */ |
| 96 | static int is_ack_nack(enum abis_nm_msgtype mt) |
| 97 | { |
| 98 | return !is_in_arr(mt, no_ack_nack, ARRAY_SIZE(no_ack_nack)); |
| 99 | } |
| 100 | |
| 101 | /* is this msgtype a report ? */ |
| 102 | static int is_report(enum abis_nm_msgtype mt) |
| 103 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 104 | return is_in_arr(mt, reports, ARRAY_SIZE(reports)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | #define MT_ACK(x) (x+1) |
| 108 | #define MT_NACK(x) (x+2) |
| 109 | |
| 110 | static void fill_om_hdr(struct abis_om_hdr *oh, u_int8_t len) |
| 111 | { |
| 112 | oh->mdisc = ABIS_OM_MDISC_FOM; |
| 113 | oh->placement = ABIS_OM_PLACEMENT_ONLY; |
| 114 | oh->sequence = 0; |
| 115 | oh->length = len; |
| 116 | } |
| 117 | |
| 118 | static void fill_om_fom_hdr(struct abis_om_hdr *oh, u_int8_t len, |
| 119 | u_int8_t msg_type, u_int8_t obj_class, |
| 120 | u_int8_t bts_nr, u_int8_t trx_nr, u_int8_t ts_nr) |
| 121 | { |
| 122 | struct abis_om_fom_hdr *foh = |
| 123 | (struct abis_om_fom_hdr *) oh->data; |
| 124 | |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 125 | fill_om_hdr(oh, len+sizeof(*foh)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 126 | foh->msg_type = msg_type; |
| 127 | foh->obj_class = obj_class; |
| 128 | foh->obj_inst.bts_nr = bts_nr; |
| 129 | foh->obj_inst.trx_nr = trx_nr; |
| 130 | foh->obj_inst.ts_nr = ts_nr; |
| 131 | } |
| 132 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 133 | static struct msgb *nm_msgb_alloc(void) |
| 134 | { |
| 135 | return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE); |
| 136 | } |
| 137 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 138 | /* Send a OML NM Message from BSC to BTS */ |
| 139 | int abis_nm_sendmsg(struct gsm_bts *bts, struct msgb *msg) |
| 140 | { |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 141 | return _abis_nm_sendmsg(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | /* Receive a OML NM Message from BTS */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 145 | static int abis_nm_rcvmsg_fom(struct msgb *mb) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 146 | { |
| 147 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 148 | u_int8_t mt = foh->msg_type; |
| 149 | |
| 150 | /* check for unsolicited message */ |
| 151 | if (is_report(mt)) { |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 152 | DEBUGP(DNM, "reporting NM MT 0x%02x\n", mt); |
| 153 | //nmh->cfg->report_cb(mb, foh); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 154 | return 0; |
| 155 | } |
| 156 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 157 | #if 0 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 158 | /* check if last message is to be acked */ |
| 159 | if (is_ack_nack(nmh->last_msgtype)) { |
| 160 | if (mt == MT_ACK(nmh->last_msgtype)) { |
| 161 | fprintf(stderr, "received ACK (0x%x)\n", |
| 162 | foh->msg_type); |
| 163 | /* we got our ACK, continue sending the next msg */ |
| 164 | } else if (mt == MT_NACK(nmh->last_msgtype)) { |
| 165 | /* we got a NACK, signal this to the caller */ |
| 166 | fprintf(stderr, "received NACK (0x%x)\n", |
| 167 | foh->msg_type); |
| 168 | /* FIXME: somehow signal this to the caller */ |
| 169 | } else { |
| 170 | /* really strange things happen */ |
| 171 | return -EINVAL; |
| 172 | } |
| 173 | } |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 174 | #endif |
| 175 | |
| 176 | return 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | /* High-Level API */ |
| 180 | /* Entry-point where L2 OML from BTS enters the NM code */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 181 | int abis_nm_rcvmsg(struct msgb *msg) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 182 | { |
| 183 | int rc; |
| 184 | struct abis_om_hdr *oh = msgb_l2(msg); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 185 | unsigned int l2_len = msg->tail - (u_int8_t *)msgb_l2(msg); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 186 | unsigned int hlen = sizeof(*oh) + sizeof(struct abis_om_fom_hdr); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 187 | |
| 188 | /* Various consistency checks */ |
| 189 | if (oh->placement != ABIS_OM_PLACEMENT_ONLY) { |
| 190 | fprintf(stderr, "ABIS OML placement 0x%x not supported\n", |
| 191 | oh->placement); |
| 192 | return -EINVAL; |
| 193 | } |
| 194 | if (oh->sequence != 0) { |
| 195 | fprintf(stderr, "ABIS OML sequence 0x%x != 0x00\n", |
| 196 | oh->sequence); |
| 197 | return -EINVAL; |
| 198 | } |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 199 | #if 0 |
| 200 | if (oh->length + hlen > l2_len) { |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 201 | fprintf(stderr, "ABIS OML truncated message (%u > %u)\n", |
| 202 | oh->length + sizeof(*oh), l2_len); |
| 203 | return -EINVAL; |
| 204 | } |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 205 | if (oh->length + hlen < l2_len) |
| 206 | fprintf(stderr, "ABIS OML message with extra trailer?!? (oh->len=%d, sizeof_oh=%d l2_len=%d\n", oh->length, sizeof(*oh), l2_len); |
| 207 | #endif |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 208 | msg->l3h = (unsigned char *)oh + sizeof(*oh); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 209 | |
| 210 | switch (oh->mdisc) { |
| 211 | case ABIS_OM_MDISC_FOM: |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 212 | rc = abis_nm_rcvmsg_fom(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 213 | break; |
| 214 | case ABIS_OM_MDISC_MMI: |
| 215 | case ABIS_OM_MDISC_TRAU: |
| 216 | case ABIS_OM_MDISC_MANUF: |
| 217 | default: |
| 218 | fprintf(stderr, "unknown ABIS OML message discriminator 0x%x\n", |
| 219 | oh->mdisc); |
| 220 | return -EINVAL; |
| 221 | } |
| 222 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 223 | msgb_free(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 224 | return rc; |
| 225 | } |
| 226 | |
| 227 | #if 0 |
| 228 | /* initialized all resources */ |
| 229 | struct abis_nm_h *abis_nm_init(struct abis_nm_cfg *cfg) |
| 230 | { |
| 231 | struct abis_nm_h *nmh; |
| 232 | |
| 233 | nmh = malloc(sizeof(*nmh)); |
| 234 | if (!nmh) |
| 235 | return NULL; |
| 236 | |
| 237 | nmh->cfg = cfg; |
| 238 | |
| 239 | return nmh; |
| 240 | } |
| 241 | |
| 242 | /* free all resources */ |
| 243 | void abis_nm_fini(struct abis_nm_h *nmh) |
| 244 | { |
| 245 | free(nmh); |
| 246 | } |
| 247 | #endif |
| 248 | |
| 249 | /* Here we are trying to define a high-level API that can be used by |
| 250 | * the actual BSC implementation. However, the architecture is currently |
| 251 | * still under design. Ideally the calls to this API would be synchronous, |
| 252 | * while the underlying stack behind the APi runs in a traditional select |
| 253 | * based state machine. |
| 254 | */ |
| 255 | |
| 256 | /* 6.2 Software Load: FIXME */ |
| 257 | |
| 258 | |
| 259 | #if 0 |
| 260 | struct abis_nm_sw { |
| 261 | /* this will become part of the SW LOAD INITIATE */ |
| 262 | u_int8_t obj_class; |
| 263 | u_int8_t obj_instance[3]; |
| 264 | u_int8_t sw_description[255]; |
| 265 | u_int16_t window_size; |
| 266 | /* the actual data that is to be sent subsequently */ |
| 267 | unsigned char *sw; |
| 268 | unsigned int sw_len; |
| 269 | }; |
| 270 | |
| 271 | /* Load the specified software into the BTS */ |
| 272 | int abis_nm_sw_load(struct abis_nm_h *h, struct abis_nm_sw *sw); |
| 273 | { |
| 274 | /* FIXME: Implementation */ |
| 275 | } |
| 276 | |
| 277 | /* Activate the specified software into the BTS */ |
| 278 | int abis_nm_sw_activate(struct abis_nm_h *h) |
| 279 | { |
| 280 | |
| 281 | } |
| 282 | #endif |
| 283 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 284 | static void fill_nm_channel(struct abis_nm_channel *ch, u_int8_t bts_port, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 285 | u_int8_t ts_nr, u_int8_t subslot_nr) |
| 286 | { |
| 287 | ch->attrib = NM_ATT_CHANNEL; |
| 288 | ch->bts_port = bts_port; |
| 289 | ch->timeslot = ts_nr; |
| 290 | ch->subslot = subslot_nr; |
| 291 | } |
| 292 | |
| 293 | int abis_nm_establish_tei(struct gsm_bts *bts, u_int8_t trx_nr, |
| 294 | u_int8_t e1_port, u_int8_t e1_timeslot, u_int8_t e1_subslot, |
| 295 | u_int8_t tei) |
| 296 | { |
| 297 | struct abis_om_hdr *oh; |
| 298 | struct abis_nm_channel *ch; |
| 299 | u_int8_t *tei_attr; |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 300 | u_int8_t len = sizeof(*ch) + 2; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 301 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 302 | |
| 303 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 304 | fill_om_fom_hdr(oh, len, NM_MT_ESTABLISH_TEI, NM_OC_RADIO_CARRIER, |
| 305 | bts->bts_nr, trx_nr, 0xff); |
| 306 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 307 | msgb_tv_put(msg, NM_ATT_TEI, tei); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 308 | |
| 309 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 310 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 311 | |
| 312 | return abis_nm_sendmsg(bts, msg); |
| 313 | } |
| 314 | |
| 315 | /* connect signalling of one (BTS,TRX) to a particular timeslot on the E1 */ |
| 316 | int abis_nm_conn_terr_sign(struct gsm_bts_trx *trx, |
| 317 | u_int8_t e1_port, u_int8_t e1_timeslot, u_int8_t e1_subslot) |
| 318 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 319 | struct gsm_bts *bts = trx->bts; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 320 | struct abis_om_hdr *oh; |
| 321 | struct abis_nm_channel *ch; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 322 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 323 | |
| 324 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 325 | fill_om_fom_hdr(oh, sizeof(*oh), NM_MT_CONN_TERR_SIGN, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 326 | NM_OC_RADIO_CARRIER, bts->bts_nr, trx->nr, 0xff); |
| 327 | |
| 328 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 329 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 330 | |
| 331 | return abis_nm_sendmsg(bts, msg); |
| 332 | } |
| 333 | |
| 334 | #if 0 |
| 335 | int abis_nm_disc_terr_sign(struct abis_nm_h *h, struct abis_om_obj_inst *inst, |
| 336 | struct abis_nm_abis_channel *chan) |
| 337 | { |
| 338 | } |
| 339 | #endif |
| 340 | |
| 341 | int abis_nm_conn_terr_traf(struct gsm_bts_trx_ts *ts, |
| 342 | u_int8_t e1_port, u_int8_t e1_timeslot, |
| 343 | u_int8_t e1_subslot) |
| 344 | { |
| 345 | struct gsm_bts *bts = ts->trx->bts; |
| 346 | struct abis_om_hdr *oh; |
| 347 | struct abis_nm_channel *ch; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 348 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 349 | |
| 350 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 351 | fill_om_fom_hdr(oh, sizeof(*ch), NM_MT_CONN_TERR_TRAF, |
| 352 | NM_OC_BASEB_TRANSC, bts->bts_nr, ts->trx->nr, ts->nr); |
| 353 | |
| 354 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 355 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 356 | |
| 357 | return abis_nm_sendmsg(bts, msg); |
| 358 | } |
| 359 | |
| 360 | #if 0 |
| 361 | int abis_nm_disc_terr_traf(struct abis_nm_h *h, struct abis_om_obj_inst *inst, |
| 362 | struct abis_nm_abis_channel *chan, |
| 363 | u_int8_t subchan) |
| 364 | { |
| 365 | } |
| 366 | #endif |
| 367 | |
| 368 | int abis_nm_set_channel_attr(struct gsm_bts_trx_ts *ts, u_int8_t chan_comb) |
| 369 | { |
| 370 | struct gsm_bts *bts = ts->trx->bts; |
| 371 | struct abis_om_hdr *oh; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 372 | u_int16_t arfcn = htons(ts->trx->arfcn); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 373 | u_int8_t zero = 0x00; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 374 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 375 | u_int8_t len = 4 + 2 + 2 + 2 + 2 +3; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 376 | |
| 377 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 378 | fill_om_fom_hdr(oh, len, NM_MT_SET_CHAN_ATTR, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 379 | NM_OC_BASEB_TRANSC, bts->bts_nr, |
| 380 | ts->trx->nr, ts->nr); |
| 381 | /* FIXME: don't send ARFCN list, hopping sequence, mAIO, ...*/ |
| 382 | msgb_tlv16_put(msg, NM_ATT_ARFCN_LIST, 1, &arfcn); |
| 383 | msgb_tv_put(msg, NM_ATT_CHAN_COMB, chan_comb); |
| 384 | msgb_tv_put(msg, NM_ATT_HSN, 0x00); |
| 385 | msgb_tv_put(msg, NM_ATT_MAIO, 0x00); |
| 386 | msgb_tv_put(msg, NM_ATT_TSC, 0x07); /* training sequence */ |
| 387 | msgb_tlv_put(msg, 0x59, 1, &zero); |
| 388 | |
| 389 | return abis_nm_sendmsg(bts, msg); |
| 390 | } |
| 391 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 392 | int abis_nm_raw_msg(struct gsm_bts *bts, int len, u_int8_t *rawmsg) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 393 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 394 | struct msgb *msg = nm_msgb_alloc(); |
| 395 | struct abis_om_hdr *oh; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 396 | u_int8_t *data; |
| 397 | |
| 398 | oh = (struct abis_om_hdr *) msgb_put(msg, sizeof(*oh)); |
| 399 | fill_om_hdr(oh, len); |
| 400 | data = msgb_put(msg, len); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 401 | memcpy(data, rawmsg, len); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 402 | |
| 403 | return abis_nm_sendmsg(bts, msg); |
| 404 | } |
| 405 | |
| 406 | /* Siemens specific commands */ |
| 407 | static int __simple_cmd(struct gsm_bts *bts, u_int8_t msg_type) |
| 408 | { |
| 409 | struct abis_om_hdr *oh; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 410 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 411 | |
| 412 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 413 | fill_om_fom_hdr(oh, 0, msg_type, NM_OC_SITE_MANAGER, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 414 | 0xff, 0xff, 0xff); |
| 415 | |
| 416 | return abis_nm_sendmsg(bts, msg); |
| 417 | } |
| 418 | |
| 419 | int abis_nm_event_reports(struct gsm_bts *bts, int on) |
| 420 | { |
| 421 | if (on == 0) |
| 422 | return __simple_cmd(bts, 0x63); |
| 423 | else |
| 424 | return __simple_cmd(bts, 0x66); |
| 425 | } |
| 426 | |
| 427 | int abis_nm_reset_resource(struct gsm_bts *bts) |
| 428 | { |
| 429 | return __simple_cmd(bts, 0x74); |
| 430 | } |
| 431 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 432 | int abis_nm_db_transmission(struct gsm_bts *bts, int begin) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 433 | { |
| 434 | if (begin) |
| 435 | return __simple_cmd(bts, 0xA3); |
| 436 | else |
| 437 | return __simple_cmd(bts, 0xA6); |
| 438 | } |