Esempio n. 1
0
const char *tetra_get_cmce_pdut_name(uint16_t pdut, int uplink)
{
	if (uplink == 0)
		return get_value_string(cmce_pdut_d_names, pdut);
	else
		return get_value_string(cmce_pdut_u_names, pdut);
}
Esempio n. 2
0
static void vty_dump_llme(struct vty *vty, struct gprs_llc_llme *llme)
{
	unsigned int i;
	struct timespec now_tp = {0};
	clock_gettime(CLOCK_MONOTONIC, &now_tp);

	vty_out(vty, "TLLI %08x (Old TLLI %08x) BVCI=%u NSEI=%u %s: "
		"IOV-UI=0x%06x CKSN=%d Age=%d: State %s%s", llme->tlli,
		llme->old_tlli, llme->bvci, llme->nsei,
		get_value_string(gprs_cipher_names, llme->algo), llme->iov_ui,
		llme->cksn, llme->age_timestamp == GPRS_LLME_RESET_AGE ? 0 :
		(int)(now_tp.tv_sec - (time_t)llme->age_timestamp),
		get_value_string(gprs_llc_state_strs, llme->state), VTY_NEWLINE);

	for (i = 0; i < ARRAY_SIZE(valid_sapis); i++) {
		struct gprs_llc_lle *lle;
		uint8_t sapi = valid_sapis[i];

		if (sapi >= ARRAY_SIZE(llme->lle))
			continue;

		lle = &llme->lle[sapi];
		vty_dump_lle(vty, lle);
	}
}
Esempio n. 3
0
char *osmo_xlm_prim_name(struct osmo_prim_hdr *oph)
{
	const char *name = get_value_string(osmo_xlm_prim_names, oph->primitive);

	snprintf(prim_name_buf, sizeof(prim_name_buf), "%s.%s", name,
		 get_value_string(osmo_prim_op_names, oph->operation));

	return prim_name_buf;
}
Esempio n. 4
0
static void l1if_req_timeout(void *data)
{
	struct wait_l1_conf *wlc = data;

	if (wlc->is_sys_prim)
		LOGP(DL1C, LOGL_FATAL, "Timeout waiting for SYS primitive %s\n",
			get_value_string(lc15bts_sysprim_names, wlc->conf_prim_id));
	else
		LOGP(DL1C, LOGL_FATAL, "Timeout waiting for L1 primitive %s\n",
			get_value_string(lc15bts_l1prim_names, wlc->conf_prim_id));
	exit(23);
}
Esempio n. 5
0
center::center(std::string filename, std::string key){
	isrun = true;

	boost::shared_ptr<config::config> _config = boost::make_shared<config::config>(filename);
	if (_config == nullptr){
		throw std::exception(("cannot find config file" + filename).c_str());
	}


	auto center_config = _config->get_value_dict("center");
	if (center_config == 0){
		throw std::exception("cannot find center config");
	} else{
		try{
			center_addr.first = center_config->get_value_string("ip");
			center_addr.second = (short)center_config->get_value_int("port");
		} catch(...){
			throw std::exception("center config field error");
		}
	}

	servernum = 0;

	_service = juggle::create_service();
	_process = boost::make_shared<juggle::process>();
	_channelservice = boost::make_shared<achieve::channelservice>();

	_svrsessioncontainer = boost::make_shared<achieve::sessioncontainer>(_channelservice, _process);

	auto key_config = _config->get_value_dict("key");
	if (key_config == 0){
		throw std::exception("cannot find this config");
	} else{
		auto set = boost::make_shared<std::vector<std::pair<std::string, short> > >();
		auto dict = _config->get_value_dict("blacklist");
		for (size_t i = 0; i < dict->get_list_size(); i++){
			auto e = dict->get_list_dict(i);
			auto ip = e->get_value_string("ip");
			auto port = (short)e->get_value_int("port");
			set->push_back(std::make_pair(ip, port));
		}
		_writeacceptor = boost::make_shared<acceptor::writeacceptor>(key_config->get_value_string("ip"), key_config->get_value_int("port"), set, _channelservice, _svrsessioncontainer);
	}
	_timerservice = timer::timerservice::createinstance();

	_module = boost::make_shared<module::center>(_process);
	_module->sigregister_db.connect(boost::bind(&center::register_db, this, _1, _2));
	_module->sigregister_gate.connect(boost::bind(&center::register_gate, this, _1, _2));
	_module->sigregister_routing.connect(boost::bind(&center::register_routing, this, _1, _2));
	_module->sigregister_logic.connect(boost::bind(&center::register_logic, this, _1, _2));
}
/*! \brief write a human-readable OML header to the debug log
 *  \param[in] ss Logging sub-system
 *  \param[in] foh A-bis OML FOM header
 */
void abis_nm_debugp_foh(int ss, struct abis_om_fom_hdr *foh)
{
	DEBUGP(ss, "OC=%s(%02x) INST=(%02x,%02x,%02x) ",
		get_value_string(abis_nm_obj_class_names, foh->obj_class),
		foh->obj_class, foh->obj_inst.bts_nr, foh->obj_inst.trx_nr,
		foh->obj_inst.ts_nr);
}
Esempio n. 7
0
int sysmobts_led_set(enum sysmobts_led nr, int on)
{
	char tmp[PATH_MAX+1];
	const char *filename;
	int fd;
	uint8_t byte;

	if (on)
		byte = '1';
	else
		byte = '0';

	filename = get_value_string(sysmobts_led_names, nr);
	if (!filename)
		return -EINVAL;

	snprintf(tmp, sizeof(tmp)-1, "/sys/class/leds/%s/brightness", filename);
	tmp[sizeof(tmp)-1] = '\0';

	fd = open(tmp, O_WRONLY);
	if (fd < 0)
		return -ENODEV;

	write(fd, &byte, 1);

	close(fd);

	return 0;
}
int Lua_Calaos::getIOValue(lua_State *L)
{
    int nb = lua_gettop(L);

    if (nb == 1 && lua_isstring(L, 1))
    {
        std::string o = lua_tostring(L, 1);
        if (ioMap.find(o) == ioMap.end())
        {
            std::string err = "getIOValue(): invalid IO id: " + o;
            lua_pushstring(L, err.c_str());
            lua_error(L);
        }
        else
        {
            auto io = ioMap[o];
            if (io.params["var_type"] == "float")
                lua_pushnumber(L, io.get_value_double());
            else if (io.params["var_type"] == "bool")
                lua_pushboolean(L, io.get_value_bool());
            else
                lua_pushstring(L, io.get_value_string().c_str());
        }
    }
    else
    {
        std::string err = "getIOValue(): invalid argument. Requires an IO id.";
        lua_pushstring(L, err.c_str());
        lua_error(L);
    }

    return 1;
}
Esempio n. 9
0
/* Confirmation of a PDP Context Delete */
static int delete_pdp_conf(struct pdp_t *pdp, void *cbp, int cause)
{
	struct sgsn_signal_data sig_data;
	struct sgsn_pdp_ctx *pctx = cbp;
	int rc = 0;

	LOGPDPCTXP(LOGL_INFO, pctx, "Received DELETE PDP CTX CONF, cause=%d(%s)\n",
		cause, get_value_string(gtp_cause_strs, cause));

	memset(&sig_data, 0, sizeof(sig_data));
	sig_data.pdp = pctx;
	osmo_signal_dispatch(SS_SGSN, S_SGSN_PDP_DEACT, &sig_data);

	if (pctx->mm) {
		/* Deactivate the SNDCP layer */
		sndcp_sm_deactivate_ind(&pctx->mm->llme->lle[pctx->sapi], pctx->nsapi);

		/* Confirm deactivation of PDP context to MS */
		rc = gsm48_tx_gsm_deact_pdp_acc(pctx);
	} else {
		LOGPDPCTXP(LOGL_NOTICE, pctx,
			   "Not deactivating SNDCP layer since the MM context "
			   "is not available\n");
	}

	/* unlink the now non-existing library handle from the pdp
	 * context */
	pctx->lib = NULL;

	sgsn_pdp_ctx_free(pctx);

	return rc;
}
Esempio n. 10
0
/* Chapter 12.10 */
static int rf_port_stats_compl_cb(struct octphy_hdl *fl1, struct msgb *resp,
				  void *data)
{
	tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr =
		(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) resp->l2h;

	mOCTVC1_HW_MSG_RF_PORT_STATS_RSP_SWAP(psr);

	LOGP(DL1C, LOGL_INFO, "RF-PORT-STATS.resp Idx=%u RadioStandard=%s, "
		"Rx(Bytes=%u, Overflow=%u, AvgBps=%u, Period=%uus, Freq=%u) "
		"Tx(Bytes=%i, Underflow=%u, AvgBps=%u, Period=%uus, Freq=%u)\n",
		psr->ulPortIndex,
		get_value_string(radio_std_vals, psr->ulRadioStandard),
		psr->RxStats.ulRxByteCnt, psr->RxStats.ulRxOverflowCnt,
		psr->RxStats.ulRxAverageBytePerSecond,
		psr->RxStats.ulRxAveragePeriodUs,
		psr->RxStats.ulFrequencyKhz,
		psr->TxStats.ulTxByteCnt, psr->TxStats.ulTxUnderflowCnt,
		psr->TxStats.ulTxAverageBytePerSecond,
		psr->TxStats.ulTxAveragePeriodUs,
		psr->TxStats.ulFrequencyKhz);

	msgb_free(resp);
	return 0;
}
Esempio n. 11
0
int oc2gbts_par_set_buf(enum oc2gbts_par par, const uint8_t *buf,
			 unsigned int size)
{
        char fpath[PATH_MAX];
        FILE *fp;
        int rc;

        if (par >= _NUM_OC2GBTS_PAR)
                return -ENODEV;

        snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(oc2gbts_par_names, par));
        fpath[sizeof(fpath)-1] = '\0';

        fp = fopen(fpath, "wb");
        if (fp == NULL) {
                return -errno;
	}

        rc = fwrite(buf, 1, size, fp);

        fsync(fileno(fp));
        fclose(fp);

        return rc;
}
Esempio n. 12
0
int oc2gbts_par_set_int(enum oc2gbts_par par, int val)
{
	char fpath[PATH_MAX];
	FILE *fp;
	int rc;

	if (par >= _NUM_OC2GBTS_PAR)
		return -ENODEV;

	snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(oc2gbts_par_names, par));
	fpath[sizeof(fpath)-1] = '\0';

	fp = fopen(fpath, "w");
	if (fp == NULL) {
		return -errno;
	}

	rc = fprintf(fp, "%d", val);
	if (rc < 0) {
		fclose(fp);
		return -EIO;
	}
	fsync(fileno(fp));
	fclose(fp);
	return 0;
}
Esempio n. 13
0
int lc15bts_par_get_int(enum lc15bts_par par, int *ret)
{
	char fpath[PATH_MAX];
	FILE *fp;
	int rc;

	if (par >= _NUM_LC15BTS_PAR)
		return -ENODEV;

	snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(lc15bts_par_names, par));
	fpath[sizeof(fpath)-1] = '\0';

	fp = fopen(fpath, "r");
	if (fp == NULL) {
		return -errno;
	}

	rc = fscanf(fp, "%d", ret);
	if (rc != 1) {
		fclose(fp);
		return -EIO;
	}
	fclose(fp);
	return 0;
}
Esempio n. 14
0
/* Chapter 12.15 */
static int get_clock_sync_compl_cb(struct octphy_hdl *fl1, struct msgb *resp,
				   void *data)
{
	tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_INFO_RSP *cir =
		(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_INFO_RSP *) resp->l2h;

	mOCTVC1_HW_MSG_CLOCK_SYNC_MGR_INFO_RSP_SWAP(cir);

	LOGP(DL1C, LOGL_INFO, "CLOCK-SYNC-MGR-INFO.resp Reference=%s ",
		get_value_string(clocksync_source_vals, cir->ulClkSourceRef));
	LOGPC(DL1C, LOGL_INFO, "Selection=%s)\n",
		get_value_string(clocksync_sel_vals, cir->ulClkSourceSelection));

	msgb_free(resp);
	return 0;
}
Esempio n. 15
0
/*! \brief get human-readable name of FSM event
 *  \param[in] fsm FSM descriptor of event
 *  \param[in] event Event integer value
 *  \returns string rendering of the event
 */
const char *osmo_fsm_event_name(struct osmo_fsm *fsm, uint32_t event)
{
	static char buf[32];
	if (!fsm->event_names) {
		snprintf(buf, sizeof(buf), "%u", event);
		return buf;
	} else
		return get_value_string(fsm->event_names, event);
}
Esempio n. 16
0
static int m3ua_rx_xfer(struct osmo_ss7_asp *asp, struct xua_msg *xua)
{
	uint32_t rctx = xua_msg_get_u32(xua, M3UA_IEI_ROUTE_CTX);
	struct m3ua_data_hdr *dh;
	struct osmo_ss7_as *as;

	LOGPASP(asp, DLM3UA, LOGL_DEBUG, "m3ua_rx_xfer\n");

	if (xua->hdr.msg_type != M3UA_XFER_DATA) {
		LOGPASP(asp, DLM3UA, LOGL_ERROR,
			"%s(): unsupported message type: %s\n",
			__func__,
			get_value_string(m3ua_xfer_msgt_names, xua->hdr.msg_type));
		return M3UA_ERR_UNSUPP_MSG_TYPE;
	}

	/* Use routing context IE to look up the AS for which the
	 * message was received. */
	as = osmo_ss7_as_find_by_rctx(asp->inst, rctx);
	if (!as) {
		LOGPASP(asp, DLM3UA, LOGL_ERROR,
			"%s(): invalid routing context: %u\n",
			__func__, rctx);
		return M3UA_ERR_INVAL_ROUT_CTX;
	}

	/* Verify that this ASP is part of the AS. */
	if (!osmo_ss7_as_has_asp(as, asp)) {
		LOGPASP(asp, DLM3UA, LOGL_ERROR,
			"%s(): This Application Server Process is not part of the AS resolved by"
			" routing context %u\n",
			__func__, rctx);
		return M3UA_ERR_NO_CONFGD_AS_FOR_ASP;
	}

	/* FIXME: check for AS state == ACTIVE */

	/* store the MTP-level information in the xua_msg for use by
	 * higher layer protocols */
	dh = data_hdr_from_m3ua(xua);
	OSMO_ASSERT(dh);
	m3ua_dh_to_xfer_param(&xua->mtp, dh);
	LOGPASP(asp, DLM3UA, LOGL_DEBUG,
		"%s(): M3UA data header: opc=%u=%s dpc=%u=%s\n",
		__func__, xua->mtp.opc, osmo_ss7_pointcode_print(asp->inst, xua->mtp.opc),
		xua->mtp.dpc, osmo_ss7_pointcode_print2(asp->inst, xua->mtp.dpc));

	/* remove ROUTE_CTX as in the routing case we want to add a new
	 * routing context on the outbound side */
	xua_msg_free_tag(xua, M3UA_IEI_ROUTE_CTX);

	return m3ua_hmdc_rx_from_l2(asp->inst, xua);
	/* xua will be freed by caller m3ua_rx_msg() */
}
Esempio n. 17
0
int storage_add_payload_data(void* data, int payload)
{
#if SCH_STORAGE_MODE == 2
    char* tok_sym[30];
    char* tok_var[30];
    char order[50];
    strcpy(order, data_map[payload].data_order);
    char var_names[200];
    strcpy(var_names, data_map[payload].var_names);
    int nparams = get_payloads_tokens(tok_sym, tok_var, order, var_names, payload);

    char values[500];
    char names[500];
    strcpy(names, "(tstz,");
    strcpy(values, "(current_timestamp,");

    int j;
    for(j=0; j < nparams; ++j) {
        int param_size = get_sizeof_type(tok_sym[j]);
        char buff[param_size];
        memcpy(buff, data+(j*param_size), param_size);

        char name[20];
        sprintf(name, " %s", tok_var[j]);
        strcat(names, name);

        char val[20];
        get_value_string(val, tok_sym[j], buff);
        strcat(values, val);

        if(j != nparams-1){
            strcat(names, ",");
            strcat(values, ",");
        }
    }

    strcat(names, ")");
    strcat(values, ")");
    char insert_row[200];
    sprintf(insert_row, "INSERT INTO %s %s VALUES %s",data_map[payload].table, names, values);
    LOGI(tag, "%s", insert_row);
    // TODO: manage connection error in res
    PGresult *res = PQexec(conn, insert_row);
    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
        LOGE(tag, "command INSERT failed: %s", PQerrorMessage(conn));
        PQclear(res);
        return -1;
    }
    PQclear(res);
    int ret = 0;
#endif
    return 0;
}
Esempio n. 18
0
static int dump_fcp_template(struct tlv_parsed *tp)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(tp->lv); i++) {
		if (TLVP_PRESENT(tp, i))
			printf("Tag 0x%02x (%s): %s\n", i,
				get_value_string(ts102221_fcp_vals, i),
				osmo_hexdump(TLVP_VAL(tp, i), TLVP_LEN(tp, i)));
	}

	return 0;
}
Esempio n. 19
0
static void vty_dump_lle(struct vty *vty, struct gprs_llc_lle *lle)
{
	struct gprs_llc_params *par = &lle->params;
	vty_out(vty, " SAPI %2u State %s VUsend=%u, VUrecv=%u", lle->sapi, 
		get_value_string(gprs_llc_state_strs, lle->state),
		lle->vu_send, lle->vu_recv);
	vty_out(vty, " Vsent=%u Vack=%u Vrecv=%u, RetransCtr=%u%s",
		lle->v_sent, lle->v_ack, lle->v_recv,
		lle->retrans_ctr, VTY_NEWLINE);
	vty_out(vty, "  T200=%u, N200=%u, N201-U=%u, N201-I=%u, mD=%u, "
		"mU=%u, kD=%u, kU=%u%s", par->t200_201, par->n200,
		par->n201_u, par->n201_i, par->mD, par->mU, par->kD,
		par->kU, VTY_NEWLINE);
}
static int gsm411_tx_cp_error(struct gsm411_smc_inst *inst, uint8_t cause)
{
	struct msgb *nmsg = gsm411_msgb_alloc();
	uint8_t *causep;

	LOGP(DLSMS, LOGL_NOTICE, "TX CP-ERROR, cause %d (%s)\n", cause,
		get_value_string(gsm411_cp_cause_strs, cause));

	causep = msgb_put(nmsg, 1);
	*causep = cause;

	return inst->mm_send(inst, GSM411_MMSMS_DATA_REQ, nmsg,
		GSM411_MT_CP_ERROR);
}
Esempio n. 21
0
static int m3ua_rx_mgmt_ntfy(struct osmo_ss7_asp *asp, struct xua_msg *xua)
{
	struct osmo_xlm_prim_notify ntfy;
	const char *type_name, *info_name;
	struct osmo_xlm_prim *prim;

	m3ua_decode_notify(&ntfy, asp, xua);

	type_name = get_value_string(m3ua_ntfy_type_names, ntfy.status_type);

	switch (ntfy.status_type) {
	case M3UA_NOTIFY_T_STATCHG:
		info_name = get_value_string(m3ua_ntfy_stchg_names,
						ntfy.status_info);
		break;
	case M3UA_NOTIFY_T_OTHER:
		info_name = get_value_string(m3ua_ntfy_other_names,
						ntfy.status_info);
		break;
	default:
		info_name = "NULL";
		break;
	}
	LOGPASP(asp, DLM3UA, LOGL_NOTICE, "Received NOTIFY Type %s:%s (%s)\n",
		type_name, info_name,
		ntfy.info_string ? ntfy.info_string : "");

	/* report this to layer manager */
	prim = xua_xlm_prim_alloc(OSMO_XLM_PRIM_M_NOTIFY, PRIM_OP_INDICATION);
	prim->u.notify = ntfy;
	xua_asp_send_xlm_prim(asp,prim);

	if (ntfy.info_string)
		talloc_free(ntfy.info_string);

	return 0;
}
Esempio n. 22
0
static int ctrl_clkinfo_cb(struct gsm_bts_trx *trx, struct msgb *resp,
			   void *data)
{
	SuperFemto_Prim_t *sysp = msgb_sysprim(resp);
	struct ctrl_cmd_def *cd = data;
	struct ctrl_cmd *cmd = cd->cmd;

	LOGP(DL1C, LOGL_NOTICE,
		"RfClockInfo iClkCor=%d/clkSrc=%s Err=%d/ErrRes=%d/clkSrc=%s\n",
		sysp->u.rfClockInfoCnf.rfTrx.iClkCor,
		get_value_string(femtobts_clksrc_names,
				sysp->u.rfClockInfoCnf.rfTrx.clkSrc),
		sysp->u.rfClockInfoCnf.rfTrxClkCal.iClkErr,
		sysp->u.rfClockInfoCnf.rfTrxClkCal.iClkErrRes,
		get_value_string(femtobts_clksrc_names,
				sysp->u.rfClockInfoCnf.rfTrxClkCal.clkSrc));

	if (ctrl_cmd_def_is_zombie(cd)) {
		msgb_free(resp);
		return 0;
	}

	cmd->reply = talloc_asprintf(cmd, "%d,%s,%d,%d,%s",
		sysp->u.rfClockInfoCnf.rfTrx.iClkCor,
		get_value_string(femtobts_clksrc_names,
				sysp->u.rfClockInfoCnf.rfTrx.clkSrc),
		sysp->u.rfClockInfoCnf.rfTrxClkCal.iClkErr,
		sysp->u.rfClockInfoCnf.rfTrxClkCal.iClkErrRes,
		get_value_string(femtobts_clksrc_names,
				sysp->u.rfClockInfoCnf.rfTrxClkCal.clkSrc));

	ctrl_cmd_def_send(cd);

	msgb_free(resp);

	return 0;
}
Esempio n. 23
0
static int gsm411_send_rp_error(struct gsm411_smr_inst *inst,
				uint8_t msg_ref, uint8_t cause)
{
	struct msgb *msg = gsm411_msgb_alloc();

	msgb_tv_put(msg, 1, cause);

	LOGP(DLSMS, LOGL_NOTICE,
		SMR_LOG_STR "TX: SMS RP ERROR, cause %d (%s)\n", inst->id,
		cause, get_value_string(gsm411_rp_cause_strs, cause));

	return gsm411_rp_sendmsg(inst, msg,
		(inst->network) ? GSM411_MT_RP_ERROR_MT : GSM411_MT_RP_ERROR_MO,
		msg_ref, GSM411_MNSMS_DATA_REQ);
}
Esempio n. 24
0
static int config_write_gbproxy(struct vty *vty)
{
	vty_out(vty, "gbproxy%s", VTY_NEWLINE);

	vty_out(vty, " sgsn nsei %u%s", g_cfg->nsip_sgsn_nsei,
		VTY_NEWLINE);

	if (g_cfg->core_mcc > 0)
		vty_out(vty, " core-mobile-country-code %d%s",
			g_cfg->core_mcc, VTY_NEWLINE);
	if (g_cfg->core_mnc > 0)
		vty_out(vty, " core-mobile-network-code %d%s",
			g_cfg->core_mnc, VTY_NEWLINE);
	if (g_cfg->core_apn != NULL) {
	       if (g_cfg->core_apn_size > 0) {
		       char str[500] = {0};
		       vty_out(vty, " core-access-point-name %s",
			       gprs_apn_to_str(str, g_cfg->core_apn,
						 g_cfg->core_apn_size));
	       } else {
		       vty_out(vty, " core-access-point-name none");
	       }
	       if (g_cfg->match_re)
		       vty_out(vty, " match-imsi %s%s",
			       g_cfg->match_re, VTY_NEWLINE);
	       else
		       vty_out(vty, "%s", VTY_NEWLINE);
	}

	if (g_cfg->patch_ptmsi > 0)
		vty_out(vty, " patch-ptmsi%s",
			VTY_NEWLINE);

	if (g_cfg->tlli_max_age > 0)
		vty_out(vty, " tlli-list max-age %d%s",
			g_cfg->tlli_max_age, VTY_NEWLINE);
	if (g_cfg->tlli_max_len > 0)
		vty_out(vty, " tlli-list max-length %d%s",
			g_cfg->tlli_max_len, VTY_NEWLINE);

	if (g_cfg->patch_mode != GBPROX_PATCH_DEFAULT)
		vty_out(vty, " patch-mode %s%s",
			get_value_string(patch_modes, g_cfg->patch_mode),
			VTY_NEWLINE);

	return CMD_SUCCESS;
}
Esempio n. 25
0
/* The GGSN has confirmed the creation of a PDP Context */
static int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause)
{
	struct sgsn_pdp_ctx *pctx = cbp;
	uint8_t reject_cause;
	int rc;

	DEBUGP(DGPRS, "Received CREATE PDP CTX CONF, cause=%d(%s)\n",
		cause, get_value_string(gtp_cause_strs, cause));

	/* Check for cause value if it was really successful */
	if (cause < 0) {
		LOGP(DGPRS, LOGL_NOTICE, "Create PDP ctx req timed out\n");
		if (pdp && pdp->version == 1) {
			pdp->version = 0;
			gtp_create_context_req(sgsn->gsn, pdp, cbp);
			return 0;
		} else {
			reject_cause = GSM_CAUSE_NET_FAIL;
			goto reject;
		}
	}

	/* Check for cause value if it was really successful */
	if (cause != GTPCAUSE_ACC_REQ) {
		reject_cause = cause_map(gtp2sm_cause_map, cause,
					 GSM_CAUSE_ACT_REJ_GGSN);
		goto reject;
	}

	/* Activate the SNDCP layer */
	sndcp_sm_activate_ind(&pctx->mm->llme->lle[pctx->sapi], pctx->nsapi);

	/* Send PDP CTX ACT to MS */
	return gsm48_tx_gsm_act_pdp_acc(pctx);

reject:
	pctx->state = PDP_STATE_NONE;
	if (pdp)
		pdp_freepdp(pdp);
	/* Send PDP CTX ACT REJ to MS */
	rc = gsm48_tx_gsm_act_pdp_rej(pctx->mm, pctx->ti, reject_cause,
					0, NULL);
	sgsn_pdp_ctx_free(pctx);

	return EOF;
}
Esempio n. 26
0
void print_tree(IndexTreeNode *root_node, unsigned depth)
{
   char *value_str;
   int i;
   char buffer[256];

   if (!root_node)
      return;
   print_tree(root_node->left_node, depth+1);
   for (i = 0; i < depth; i++)
      SLPDLog("   ");
   value_str = get_value_string(root_node);
   sprintf(buffer, "%03d %3d %s\n", tree_depth(root_node), count_values(root_node), value_str);
   SLPDLog(buffer);
   free(value_str);
   print_tree(root_node->right_node, depth+1);
}
Esempio n. 27
0
/* FIXME: read from a B channel TS */
static int handle_tsX_read(struct osmo_fd *bfd)
{
	struct e1inp_line *line = bfd->data;
	unsigned int ts_nr = bfd->priv_nr;
	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
	struct msgb *msg = msgb_alloc(TSX_ALLOC_SIZE, "mISDN TSx");
	struct mISDNhead *hh;
	int ret;

	if (!msg)
		return -ENOMEM;

	hh = (struct mISDNhead *) msg->data;

	ret = recv(bfd->fd, msg->data, TSX_ALLOC_SIZE, 0);
	if (ret < 0) {
		fprintf(stderr, "recvfrom error  %s\n", strerror(errno));
		return ret;
	}

	msgb_put(msg, ret);

	if (hh->prim != PH_CONTROL_IND)
		DEBUGP(DLMIB, "<= BCHAN len = %d, prim(0x%x) id(0x%x): %s\n",
			ret, hh->prim, hh->id,
			get_value_string(prim_names, hh->prim));

	switch (hh->prim) {
	case PH_DATA_IND:
		msg->l2h = msg->data + MISDN_HEADER_LEN;
		DEBUGP(DLMIB, "BCHAN RX: %s\n",
			osmo_hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN));
		/* the number of bytes received indicates that data to send */
		handle_tsX_write(bfd, msgb_l2len(msg));
		return e1inp_rx_ts(e1i_ts, msg, 0, 0);
	case PH_ACTIVATE_IND:
	case PH_DATA_CNF:
		break;
	default:
		break;
	}
	/* FIXME: why do we free signalling msgs in the caller, and trau not? */
	msgb_free(msg);

	return ret;
}
Esempio n. 28
0
logic::logic(std::string filename, std::string key) {
    isrun = true;

    boost::shared_ptr<config::config> _config = boost::make_shared<config::config>(filename);

    auto center_config = _config->get_value_dict("center");
    if (center_config == 0) {
        throw std::exception("cannot find center config");
    } else {
        try {
            center_addr.first = center_config->get_value_string("ip");
            center_addr.second = (short)center_config->get_value_int("port");
        } catch(...) {
            throw std::exception("center config field error");
        }
    }

    _service = juggle::create_service();

    _process = boost::make_shared<juggle::process>();

    _channelservice = boost::make_shared<achieve::channelservice>();

    _gatesessioncontainer = boost::make_shared<achieve::sessioncontainer>(_channelservice, _process);
    _gatesessioncontainer->sigdisconn.connect(boost::bind(&logic::gate_disconn, this, _1));
    _gateconnector = boost::make_shared<connector::connector>(_channelservice, _gatesessioncontainer);

    _dbsessioncontainer = boost::make_shared<achieve::sessioncontainer>(_channelservice, _process);
    _dbsessioncontainer->sigdisconn.connect(boost::bind(&logic::db_disconn, this, _1));
    _dbconnector = boost::make_shared<connector::connector>(_channelservice, _dbsessioncontainer);

    _timerservice = timer::timerservice::createinstance();

    _module = boost::make_shared<module::logic>(_process);

    _module->sigregister_gate.connect(boost::bind(&logic::register_gate, this, _1, _2, _3));
    _module->sigregister_db.connect(boost::bind(&logic::register_db, this, _1, _2, _3));
    _module->sigregister_user.connect(boost::bind(&logic::register_user, this, _1));
    _module->sigunregister_user.connect(boost::bind(&logic::unregister_user, this, _1));

    _centersessioncontainer = boost::make_shared<achieve::sessioncontainer>(_channelservice, _process);
    _centerconnector = boost::make_shared<connector::connector>(_channelservice, _centersessioncontainer);

    add_timer(60 * 1000, boost::bind(&logic::keeplive_check, this, _1));
}
Esempio n. 29
0
/* Chapter 12.13 */
static int rf_ant_rx_compl_cb(struct octphy_hdl *fl1, struct msgb *resp,
				void *data)
{
	tOCTVC1_HW_MSG_RF_PORT_INFO_ANTENNA_RX_CONFIG_RSP *arc =
		(tOCTVC1_HW_MSG_RF_PORT_INFO_ANTENNA_RX_CONFIG_RSP *) resp->l2h;

	mOCTVC1_HW_MSG_RF_PORT_INFO_ANTENNA_RX_CONFIG_RSP_SWAP(arc);

	LOGP(DL1C, LOGL_INFO, "ANT-RX-CONFIG.resp(Port=%u, Ant=%u): %s, "
		"Gain %d dB, GainCtrlMode=%s\n",
		arc->ulPortIndex,  arc->ulAntennaIndex,
		arc->ulEnableFlag ? "Enabled" : "Disabled",
		arc->lRxGaindB/512,
		get_value_string(rx_gain_mode_vals, arc->ulRxGainMode));

	msgb_free(resp);
	return 0;
}
Esempio n. 30
0
static int m3ua_rx_mgmt_err(struct osmo_ss7_asp *asp, struct xua_msg *xua)
{
	uint32_t err_code = xua_msg_get_u32(xua, M3UA_IEI_ERR_CODE);
	struct osmo_xlm_prim *prim;

	LOGPASP(asp, DLM3UA, LOGL_ERROR, "Received MGMT_ERR '%s': %s\n",
		get_value_string(m3ua_err_names, err_code),
		xua_msg_dump(xua, &xua_dialect_m3ua));

	/* report this to layer manager */
	prim = xua_xlm_prim_alloc(OSMO_XLM_PRIM_M_ERROR, PRIM_OP_INDICATION);
	prim->u.error.code = err_code;
	xua_asp_send_xlm_prim(asp, prim);

	/* NEVER return != 0 here, as we cannot respont to an ERR
	 * message with another ERR! */
	return 0;
}