Exemplo n.º 1
0
static int ki_isup_to_json(sip_msg_t *_m, int proto)
{
	struct isup_state isup_state = { 0, };
	const uint8_t *data;
	int opc, dpc, mtp_type, int_len, rc;
	size_t len;

	free((char *) isup_last);
	srjson_DeleteDoc(isup_json);
	isup_last = NULL;
	isup_json = NULL;
	mtp_type = 0;

	data = fetch_payload(_m, "$var(payload)", &int_len);
	if (!data)
		return -1;

	if (int_len < 0) {
		LM_ERR("Payload length low %d\n", int_len);
		return -1;
	}
	len = int_len;

	data = ss7_extract_payload(data, &len, proto, &opc, &dpc, &mtp_type);
	if (!data)
		return -1;

	if (mtp_type != MTP_ISUP) {
		LM_DBG("Non ISUP payload %d\n", mtp_type);
		return -1;
	}

	/* parse isup... */
	isup_state.json = srjson_NewDoc(NULL);
	if (!isup_state.json) {
		LM_ERR("Failed to allocate JSON document\n");
		return -1;
	}
	isup_state.json->root = srjson_CreateObject(isup_state.json);
	if (!isup_state.json->root) {
		LM_ERR("Failed to allocate JSON object\n");
		srjson_DeleteDoc(isup_state.json);
		return -1;
	}

	rc = isup_parse(data, len, &isup_state);
	if (rc != 0) {
		srjson_DeleteDoc(isup_state.json);
		return rc;
	}
	srjson_AddNumberToObject(isup_state.json, isup_state.json->root, "opc", opc);
	srjson_AddNumberToObject(isup_state.json, isup_state.json->root, "dpc", dpc);
	isup_last = srjson_PrintUnformatted(isup_state.json, isup_state.json->root);
	isup_json = isup_state.json;
	return 1;
}
Exemplo n.º 2
0
static int ss7_parse_isup(msg_t *msg, char *param1, char *param2)
{
	uint8_t *data;
	size_t len;
	int opc, dpc, type;

	data = ss7_extract_payload(msg, &len, &opc, &dpc, &type);
	if (!data)
		return -1;
	if (type != MTP_ISUP) {
		LDEBUG("ISUP service indicator not ISUP but %d", type);
		return -1;
	}

	/* data[0:1] is now the CIC and data[2] the type */
	return 1;
}