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