aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmsc/gsm_04_11.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmsc/gsm_04_11.c')
-rw-r--r--src/libmsc/gsm_04_11.c138
1 files changed, 69 insertions, 69 deletions
diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 812e758cd..ba72c37bd 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -32,19 +32,19 @@
#include <time.h>
#include <netinet/in.h>
-#include <osmocore/msgb.h>
-#include <osmocore/tlv.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/tlv.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/db.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/gsm_04_11.h>
#include <openbsc/gsm_04_08.h>
-#include <osmocore/gsm_utils.h>
+#include <osmocom/gsm/gsm_utils.h>
#include <openbsc/abis_rsl.h>
#include <openbsc/signal.h>
#include <openbsc/db.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#include <openbsc/transaction.h>
#include <openbsc/paging.h>
#include <openbsc/bsc_rll.h>
@@ -55,7 +55,7 @@
#define GSM411_ALLOC_HEADROOM 128
void *tall_gsms_ctx;
-static u_int32_t new_callref = 0x40000001;
+static uint32_t new_callref = 0x40000001;
static const struct value_string cp_cause_strs[] = {
{ GSM411_CP_CAUSE_NET_FAIL, "Network Failure" },
@@ -151,7 +151,7 @@ static void send_signal(int sig_no,
sig.trans = trans;
sig.sms = sms;
sig.paging_result = paging_result;
- dispatch_signal(SS_SMS, sig_no, &sig);
+ osmo_signal_dispatch(SS_SMS, sig_no, &sig);
}
/*
@@ -173,9 +173,9 @@ struct msgb *gsm411_msgb_alloc(void)
"GSM 04.11");
}
-static int gsm411_sendmsg(struct gsm_subscriber_connection *conn, struct msgb *msg, u_int8_t link_id)
+static int gsm411_sendmsg(struct gsm_subscriber_connection *conn, struct msgb *msg, uint8_t link_id)
{
- DEBUGP(DSMS, "GSM4.11 TX %s\n", hexdump(msg->data, msg->len));
+ DEBUGP(DSMS, "GSM4.11 TX %s\n", osmo_hexdump(msg->data, msg->len));
msg->l3h = msg->data;
return gsm0808_submit_dtap(conn, msg, link_id, 1);
}
@@ -192,7 +192,7 @@ static void cp_timer_expired(void *data)
/* Prefix msg with a 04.08/04.11 CP header */
static int gsm411_cp_sendmsg(struct msgb *msg, struct gsm_trans *trans,
- u_int8_t msg_type)
+ uint8_t msg_type)
{
struct gsm48_hdr *gh;
@@ -210,7 +210,7 @@ static int gsm411_cp_sendmsg(struct msgb *msg, struct gsm_trans *trans,
trans->sms.cp_timer.data = trans;
trans->sms.cp_timer.cb = cp_timer_expired;
/* 5.3.2.1: Set Timer TC1A */
- bsc_schedule_timer(&trans->sms.cp_timer, GSM411_TMR_TC1A);
+ osmo_timer_schedule(&trans->sms.cp_timer, GSM411_TMR_TC1A);
DEBUGP(DSMS, "TX: CP-DATA ");
break;
case GSM411_MT_CP_ACK:
@@ -228,10 +228,10 @@ static int gsm411_cp_sendmsg(struct msgb *msg, struct gsm_trans *trans,
/* Prefix msg with a RP-DATA header and send as CP-DATA */
static int gsm411_rp_sendmsg(struct msgb *msg, struct gsm_trans *trans,
- u_int8_t rp_msg_type, u_int8_t rp_msg_ref)
+ uint8_t rp_msg_type, uint8_t rp_msg_ref)
{
struct gsm411_rp_hdr *rp;
- u_int8_t len = msg->len;
+ uint8_t len = msg->len;
/* GSM 04.11 RP-DATA header */
rp = (struct gsm411_rp_hdr *)msgb_push(msg, sizeof(*rp));
@@ -243,9 +243,9 @@ static int gsm411_rp_sendmsg(struct msgb *msg, struct gsm_trans *trans,
}
/* Turn int into semi-octet representation: 98 => 0x89 */
-static u_int8_t bcdify(u_int8_t value)
+static uint8_t bcdify(uint8_t value)
{
- u_int8_t ret;
+ uint8_t ret;
ret = value / 10;
ret |= (value % 10) << 4;
@@ -254,9 +254,9 @@ static u_int8_t bcdify(u_int8_t value)
}
/* Turn semi-octet representation into int: 0x89 => 98 */
-static u_int8_t unbcdify(u_int8_t value)
+static uint8_t unbcdify(uint8_t value)
{
- u_int8_t ret;
+ uint8_t ret;
if ((value & 0x0F) > 9 || (value >> 4) > 9)
LOGP(DSMS, LOGL_ERROR,
@@ -269,7 +269,7 @@ static u_int8_t unbcdify(u_int8_t value)
}
/* Generate 03.40 TP-SCTS */
-static void gsm340_gen_scts(u_int8_t *scts, time_t time)
+static void gsm340_gen_scts(uint8_t *scts, time_t time)
{
struct tm *tm = localtime(&time);
@@ -283,11 +283,11 @@ static void gsm340_gen_scts(u_int8_t *scts, time_t time)
}
/* Decode 03.40 TP-SCTS (into utc/gmt timestamp) */
-static time_t gsm340_scts(u_int8_t *scts)
+static time_t gsm340_scts(uint8_t *scts)
{
struct tm tm;
- u_int8_t yr = unbcdify(*scts++);
+ uint8_t yr = unbcdify(*scts++);
if (yr <= 80)
tm.tm_year = 100 + yr;
@@ -315,10 +315,10 @@ static unsigned long gsm340_vp_default(void)
}
/* Decode validity period format 'relative' */
-static unsigned long gsm340_vp_relative(u_int8_t *sms_vp)
+static unsigned long gsm340_vp_relative(uint8_t *sms_vp)
{
/* Chapter 9.2.3.12.1 */
- u_int8_t vp;
+ uint8_t vp;
unsigned long minutes;
vp = *(sms_vp);
@@ -334,7 +334,7 @@ static unsigned long gsm340_vp_relative(u_int8_t *sms_vp)
}
/* Decode validity period format 'absolute' */
-static unsigned long gsm340_vp_absolute(u_int8_t *sms_vp)
+static unsigned long gsm340_vp_absolute(uint8_t *sms_vp)
{
/* Chapter 9.2.3.12.2 */
time_t expires, now;
@@ -350,9 +350,9 @@ static unsigned long gsm340_vp_absolute(u_int8_t *sms_vp)
}
/* Decode validity period format 'relative in integer representation' */
-static unsigned long gsm340_vp_relative_integer(u_int8_t *sms_vp)
+static unsigned long gsm340_vp_relative_integer(uint8_t *sms_vp)
{
- u_int8_t vp;
+ uint8_t vp;
unsigned long minutes;
vp = *(sms_vp);
if (vp == 0) {
@@ -365,7 +365,7 @@ static unsigned long gsm340_vp_relative_integer(u_int8_t *sms_vp)
}
/* Decode validity period format 'relative in semi-octet representation' */
-static unsigned long gsm340_vp_relative_semioctet(u_int8_t *sms_vp)
+static unsigned long gsm340_vp_relative_semioctet(uint8_t *sms_vp)
{
unsigned long minutes;
minutes = unbcdify(*sms_vp++)*60; /* hours */
@@ -375,9 +375,9 @@ static unsigned long gsm340_vp_relative_semioctet(u_int8_t *sms_vp)
}
/* decode validity period. return minutes */
-static unsigned long gsm340_validity_period(u_int8_t sms_vpf, u_int8_t *sms_vp)
+static unsigned long gsm340_validity_period(uint8_t sms_vpf, uint8_t *sms_vp)
{
- u_int8_t fi; /* functionality indicator */
+ uint8_t fi; /* functionality indicator */
switch (sms_vpf) {
case GSM340_TP_VPF_RELATIVE:
@@ -413,9 +413,9 @@ static unsigned long gsm340_validity_period(u_int8_t sms_vpf, u_int8_t *sms_vp)
}
/* determine coding alphabet dependent on GSM 03.38 Section 4 DCS */
-enum sms_alphabet gsm338_get_sms_alphabet(u_int8_t dcs)
+enum sms_alphabet gsm338_get_sms_alphabet(uint8_t dcs)
{
- u_int8_t cgbits = dcs >> 4;
+ uint8_t cgbits = dcs >> 4;
enum sms_alphabet alpha = DCS_NONE;
if ((cgbits & 0xc) == 0) {
@@ -463,7 +463,7 @@ static int gsm340_rx_sms_submit(struct msgb *msg, struct gsm_sms *gsms)
}
/* generate a TPDU address field compliant with 03.40 sec. 9.1.2.5 */
-static int gsm340_gen_oa(u_int8_t *oa, unsigned int oa_len,
+static int gsm340_gen_oa(uint8_t *oa, unsigned int oa_len,
struct gsm_subscriber *subscr)
{
int len_in_bytes;
@@ -482,10 +482,10 @@ static int gsm340_gen_oa(u_int8_t *oa, unsigned int oa_len,
* returns total size of TPDU */
static int gsm340_gen_tpdu(struct msgb *msg, struct gsm_sms *sms)
{
- u_int8_t *smsp;
- u_int8_t oa[12]; /* max len per 03.40 */
- u_int8_t oa_len = 0;
- u_int8_t octet_len;
+ uint8_t *smsp;
+ uint8_t oa[12]; /* max len per 03.40 */
+ uint8_t oa_len = 0;
+ uint8_t octet_len;
unsigned int old_msg_len = msg->len;
/* generate first octet with masked bits */
@@ -552,15 +552,15 @@ static int gsm340_gen_tpdu(struct msgb *msg, struct gsm_sms *sms)
* return value > 0: RP CAUSE for ERROR; < 0: silent error; 0 = success */
static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *msg)
{
- u_int8_t *smsp = msgb_sms(msg);
+ uint8_t *smsp = msgb_sms(msg);
struct gsm_sms *gsms;
- u_int8_t sms_mti, sms_mms, sms_vpf, sms_alphabet, sms_rp;
- u_int8_t *sms_vp;
- u_int8_t da_len_bytes;
- u_int8_t address_lv[12]; /* according to 03.40 / 9.1.2.5 */
+ uint8_t sms_mti, sms_mms, sms_vpf, sms_alphabet, sms_rp;
+ uint8_t *sms_vp;
+ uint8_t da_len_bytes;
+ uint8_t address_lv[12]; /* according to 03.40 / 9.1.2.5 */
int rc = 0;
- counter_inc(conn->bts->network->stats.sms.submitted);
+ osmo_counter_inc(conn->bts->network->stats.sms.submitted);
gsms = sms_alloc();
if (!gsms)
@@ -645,7 +645,7 @@ static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *m
gsms->protocol_id, gsms->data_coding_scheme, gsms->dest_addr,
gsms->user_data_len,
sms_alphabet == DCS_7BIT_DEFAULT ? gsms->text :
- hexdump(gsms->user_data, gsms->user_data_len));
+ osmo_hexdump(gsms->user_data, gsms->user_data_len));
gsms->validity_minutes = gsm340_validity_period(sms_vpf, sms_vp);
@@ -656,7 +656,7 @@ static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *m
gsms->receiver = subscr_get_by_extension(conn->bts->network, gsms->dest_addr);
if (!gsms->receiver) {
rc = 1; /* cause 1: unknown subscriber */
- counter_inc(conn->bts->network->stats.sms.no_receiver);
+ osmo_counter_inc(conn->bts->network->stats.sms.no_receiver);
goto out;
}
@@ -685,7 +685,7 @@ out:
return rc;
}
-static int gsm411_send_rp_ack(struct gsm_trans *trans, u_int8_t msg_ref)
+static int gsm411_send_rp_ack(struct gsm_trans *trans, uint8_t msg_ref)
{
struct msgb *msg = gsm411_msgb_alloc();
@@ -695,7 +695,7 @@ static int gsm411_send_rp_ack(struct gsm_trans *trans, u_int8_t msg_ref)
}
static int gsm411_send_rp_error(struct gsm_trans *trans,
- u_int8_t msg_ref, u_int8_t cause)
+ uint8_t msg_ref, uint8_t cause)
{
struct msgb *msg = gsm411_msgb_alloc();
@@ -710,9 +710,9 @@ static int gsm411_send_rp_error(struct gsm_trans *trans,
/* Receive a 04.11 TPDU inside RP-DATA / user data */
static int gsm411_rx_rp_ud(struct msgb *msg, struct gsm_trans *trans,
struct gsm411_rp_hdr *rph,
- u_int8_t src_len, u_int8_t *src,
- u_int8_t dst_len, u_int8_t *dst,
- u_int8_t tpdu_len, u_int8_t *tpdu)
+ uint8_t src_len, uint8_t *src,
+ uint8_t dst_len, uint8_t *dst,
+ uint8_t tpdu_len, uint8_t *tpdu)
{
int rc = 0;
@@ -728,7 +728,7 @@ static int gsm411_rx_rp_ud(struct msgb *msg, struct gsm_trans *trans,
}
msg->l4h = tpdu;
- DEBUGP(DSMS, "DST(%u,%s)\n", dst_len, hexdump(dst, dst_len));
+ DEBUGP(DSMS, "DST(%u,%s)\n", dst_len, osmo_hexdump(dst, dst_len));
rc = gsm340_rx_tpdu(trans->conn, msg);
if (rc == 0)
@@ -743,8 +743,8 @@ static int gsm411_rx_rp_ud(struct msgb *msg, struct gsm_trans *trans,
static int gsm411_rx_rp_data(struct msgb *msg, struct gsm_trans *trans,
struct gsm411_rp_hdr *rph)
{
- u_int8_t src_len, dst_len, rpud_len;
- u_int8_t *src = NULL, *dst = NULL , *rp_ud = NULL;
+ uint8_t src_len, dst_len, rpud_len;
+ uint8_t *src = NULL, *dst = NULL , *rp_ud = NULL;
/* in the MO case, this should always be zero length */
src_len = rph->data[0];
@@ -812,8 +812,8 @@ static int gsm411_rx_rp_error(struct msgb *msg, struct gsm_trans *trans,
{
struct gsm_network *net = trans->conn->bts->network;
struct gsm_sms *sms = trans->sms.sms;
- u_int8_t cause_len = rph->data[0];
- u_int8_t cause = rph->data[1];
+ uint8_t cause_len = rph->data[0];
+ uint8_t cause = rph->data[1];
/* Error in response to MT RP_DATA, i.e. the MS did not
* successfully receive the SMS. We need to investigate
@@ -846,10 +846,10 @@ static int gsm411_rx_rp_error(struct msgb *msg, struct gsm_trans *trans,
* to store this in our database and wait for a SMMA message */
/* FIXME */
send_signal(S_SMS_MEM_EXCEEDED, trans, sms, 0);
- counter_inc(net->stats.sms.rp_err_mem);
+ osmo_counter_inc(net->stats.sms.rp_err_mem);
} else {
send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0);
- counter_inc(net->stats.sms.rp_err_other);
+ osmo_counter_inc(net->stats.sms.rp_err_other);
}
sms_free(sms);
@@ -886,7 +886,7 @@ static int gsm411_rx_cp_data(struct msgb *msg, struct gsm48_hdr *gh,
struct gsm_trans *trans)
{
struct gsm411_rp_hdr *rp_data = (struct gsm411_rp_hdr*)&gh->data;
- u_int8_t msg_type = rp_data->msg_type & 0x07;
+ uint8_t msg_type = rp_data->msg_type & 0x07;
int rc = 0;
switch (msg_type) {
@@ -936,10 +936,10 @@ static int gsm411_tx_cp_ack(struct gsm_trans *trans)
return rc;
}
-static int gsm411_tx_cp_error(struct gsm_trans *trans, u_int8_t cause)
+static int gsm411_tx_cp_error(struct gsm_trans *trans, uint8_t cause)
{
struct msgb *msg = gsm411_msgb_alloc();
- u_int8_t *causep;
+ uint8_t *causep;
LOGP(DSMS, LOGL_NOTICE, "TX CP-ERROR, cause %d (%s)\n", cause,
get_value_string(cp_cause_strs, cause));
@@ -955,8 +955,8 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn,
struct msgb *msg)
{
struct gsm48_hdr *gh = msgb_l3(msg);
- u_int8_t msg_type = gh->msg_type;
- u_int8_t transaction_id = ((gh->proto_discr >> 4) ^ 0x8); /* flip */
+ uint8_t msg_type = gh->msg_type;
+ uint8_t transaction_id = ((gh->proto_discr >> 4) ^ 0x8); /* flip */
struct gsm_trans *trans;
int rc = 0;
@@ -1008,7 +1008,7 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn,
DEBUGP(DSMS, "Implicit CP-ACK for trans_id=%x\n", i);
/* Finish it for good */
- bsc_del_timer(&ptrans->sms.cp_timer);
+ osmo_timer_del(&ptrans->sms.cp_timer);
ptrans->sms.cp_state = GSM411_CPS_IDLE;
trans_free(ptrans);
}
@@ -1039,7 +1039,7 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn,
/* 5.2.3.2.4: MT state exists when SMC has received CP-ACK */
trans->sms.cp_state = GSM411_CPS_MM_ESTABLISHED;
/* Stop TC1* after CP-ACK has been received */
- bsc_del_timer(&trans->sms.cp_timer);
+ osmo_timer_del(&trans->sms.cp_timer);
if (!trans->sms.is_mt) {
/* FIXME: we have sent one CP-DATA, which was now
@@ -1052,7 +1052,7 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn,
case GSM411_MT_CP_ERROR:
DEBUGPC(DSMS, "RX SMS CP-ERROR, cause %d (%s)\n", gh->data[0],
get_value_string(cp_cause_strs, gh->data[0]));
- bsc_del_timer(&trans->sms.cp_timer);
+ osmo_timer_del(&trans->sms.cp_timer);
trans->sms.cp_state = GSM411_CPS_IDLE;
trans_free(trans);
break;
@@ -1074,8 +1074,8 @@ int gsm411_send_sms(struct gsm_subscriber_connection *conn, struct gsm_sms *sms)
{
struct msgb *msg = gsm411_msgb_alloc();
struct gsm_trans *trans;
- u_int8_t *data, *rp_ud_len;
- u_int8_t msg_ref = 42;
+ uint8_t *data, *rp_ud_len;
+ uint8_t msg_ref = 42;
int transaction_id;
int rc;
@@ -1108,7 +1108,7 @@ int gsm411_send_sms(struct gsm_subscriber_connection *conn, struct gsm_sms *sms)
trans->conn = conn;
/* Hardcode SMSC Originating Address for now */
- data = (u_int8_t *)msgb_put(msg, 8);
+ data = (uint8_t *)msgb_put(msg, 8);
data[0] = 0x07; /* originator length == 7 */
data[1] = 0x91; /* type of number: international, ISDN */
data[2] = 0x44; /* 447785016005 */
@@ -1119,11 +1119,11 @@ int gsm411_send_sms(struct gsm_subscriber_connection *conn, struct gsm_sms *sms)
data[7] = 0x50;
/* Hardcoded Destination Address */
- data = (u_int8_t *)msgb_put(msg, 1);
+ data = (uint8_t *)msgb_put(msg, 1);
data[0] = 0; /* destination length == 0 */
/* obtain a pointer for the rp_ud_len, so we can fill it later */
- rp_ud_len = (u_int8_t *)msgb_put(msg, 1);
+ rp_ud_len = (uint8_t *)msgb_put(msg, 1);
/* generate the 03.40 TPDU */
rc = gsm340_gen_tpdu(msg, sms);
@@ -1139,7 +1139,7 @@ int gsm411_send_sms(struct gsm_subscriber_connection *conn, struct gsm_sms *sms)
DEBUGP(DSMS, "TX: SMS DELIVER\n");
- counter_inc(conn->bts->network->stats.sms.delivered);
+ osmo_counter_inc(conn->bts->network->stats.sms.delivered);
db_sms_inc_deliver_attempts(trans->sms.sms);
return gsm411_rp_sendmsg(msg, trans, GSM411_MT_RP_DATA_MT, msg_ref);
@@ -1208,7 +1208,7 @@ void _gsm411_sms_trans_free(struct gsm_trans *trans)
trans->sms.sms = NULL;
}
- bsc_del_timer(&trans->sms.cp_timer);
+ osmo_timer_del(&trans->sms.cp_timer);
}
void gsm411_sapi_n_reject(struct gsm_subscriber_connection *conn)