static void send_bssgp_supend(enum bssgp_pdu_type pdu_type, uint32_t tlli) { struct msgb *msg = bssgp_msgb_alloc(); uint32_t tlli_be = htonl(tlli); uint8_t rai[] = {0x0f, 0xf1, 0x80, 0x20, 0x37, 0x00}; msgb_v_put(msg, pdu_type); msgb_tvlv_put(msg, BSSGP_IE_TLLI, sizeof(tlli_be), (uint8_t *)&tlli_be); msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, sizeof(rai), &rai[0]); msgb_bssgp_send_and_free(msg); }
static void ussd_pong(struct bsc_nat_ussd_con *conn) { struct msgb *msg; msg = msgb_alloc_headroom(4096, 128, "pong message"); if (!msg) { LOGP(DNAT, LOGL_ERROR, "Failed to allocate pong msg\n"); return; } msgb_v_put(msg, IPAC_MSGT_PONG); bsc_do_write(&conn->queue, msg, IPAC_PROTO_IPACCESS); }
static void send_bssgp_status(enum gprs_bssgp_cause cause, uint16_t *bvci) { struct msgb *msg = bssgp_msgb_alloc(); uint8_t cause_ = cause; msgb_v_put(msg, BSSGP_PDUT_STATUS); msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause_); if (bvci) { uint16_t bvci_ = htons(*bvci); msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &bvci_); } msgb_bssgp_send_and_free(msg); }
static void ussd_start_auth(struct bsc_nat_ussd_con *conn) { struct msgb *msg; conn->auth_timeout.data = conn; conn->auth_timeout.cb = ussd_auth_cb; osmo_timer_schedule(&conn->auth_timeout, conn->nat->auth_timeout, 0); msg = msgb_alloc_headroom(4096, 128, "auth message"); if (!msg) { LOGP(DNAT, LOGL_ERROR, "Failed to allocate auth msg\n"); return; } msgb_v_put(msg, IPAC_MSGT_ID_GET); bsc_do_write(&conn->queue, msg, IPAC_PROTO_IPACCESS); }
static void test_bssgp_bad_reset() { struct msgb *msg; uint16_t bvci_be = htons(2); uint8_t cause = BSSGP_CAUSE_OML_INTERV; printf("----- %s START\n", __func__); msg = bssgp_msgb_alloc(); msgb_v_put(msg, BSSGP_PDUT_BVC_RESET); msgb_tvlv_put(msg, BSSGP_IE_BVCI, sizeof(bvci_be), (uint8_t *)&bvci_be); msgb_tvlv_put(msg, BSSGP_IE_CAUSE, sizeof(cause), &cause); msgb_bvci(msg) = 0xbad; msgb_bssgp_send_and_free(msg); printf("----- %s END\n", __func__); }
struct msgb *bsc_msc_id_get_resp(int fixed, const char *token, const uint8_t *res, int len) { struct msgb *msg; if (!token) { LOGP(DMSC, LOGL_ERROR, "No token specified.\n"); return NULL; } msg = msgb_alloc_headroom(4096, 128, "id resp"); if (!msg) { LOGP(DMSC, LOGL_ERROR, "Failed to create the message.\n"); return NULL; } /* * The situation is bizarre. The encoding doesn't follow the * TLV structure. It is more like a LV and old versions had * it wrong but we want new versions to old servers so we * introduce the quirk here. */ msg->l2h = msgb_v_put(msg, IPAC_MSGT_ID_RESP); if (fixed) { msgb_put_u8(msg, 0); msgb_put_u8(msg, strlen(token) + 2); msgb_tv_fixed_put(msg, IPAC_IDTAG_UNITNAME, strlen(token) + 1, (uint8_t *) token); if (len > 0) { msgb_put_u8(msg, 0); msgb_put_u8(msg, len + 1); msgb_tv_fixed_put(msg, 0x24, len, res); } } else { msgb_l16tv_put(msg, strlen(token) + 1, IPAC_IDTAG_UNITNAME, (uint8_t *) token); } return msg; }