libosmogsm  0.9.6.277-11f2
Osmocom GSM library
 All Data Structures Files Functions Variables Enumerations Enumerator Modules Pages
Sms

Point-to-Point (PP) Short Message Service (SMS) as per TS 04.11. More...

Data Structures

struct  smcdownstate
 
struct  smcdatastate
 
struct  smrdownstate
 
struct  smrdatastate
 

Macros

#define MAX_SMS_RETRY   2
 
#define SMC_LOG_STR   "SMC(%" PRIu64 ") "
 
#define SMCDOWNSLLEN   (sizeof(smcdownstatelist) / sizeof(struct smcdownstate))
 
#define SMCDATASLLEN   (sizeof(smcdatastatelist) / sizeof(struct smcdatastate))
 
#define SMRDOWNSLLEN   (sizeof(smrdownstatelist) / sizeof(struct smrdownstate))
 
#define SMRDATASLLEN   (sizeof(smrdatastatelist) / sizeof(struct smrdatastate))
 
#define GSM411_ALLOC_SIZE   1024
 
#define GSM411_ALLOC_HEADROOM   128
 

Functions

struct gsm341_ms_message * gsm0341_build_msg (void *ctx, uint8_t geo_scope, uint8_t msg_code, uint8_t update, uint16_t msg_id, uint8_t dcs, uint8_t page_total, uint8_t page_cur, uint8_t *data, uint8_t len)
 Encode a 3GPP TS 03.41 SMS-CB message. More...
 
static void cp_timer_expired (void *data)
 
void gsm411_smc_init (struct gsm411_smc_inst *inst, uint64_t id, int network, int(*mn_recv)(struct gsm411_smc_inst *inst, int msg_type, struct msgb *msg), int(*mm_send)(struct gsm411_smc_inst *inst, int msg_type, struct msgb *msg, int cp_msg_type))
 
void gsm411_smc_clear (struct gsm411_smc_inst *inst)
 
static void new_cp_state (struct gsm411_smc_inst *inst, enum gsm411_cp_state state)
 
static int gsm411_tx_cp_error (struct gsm411_smc_inst *inst, uint8_t cause)
 
static int gsm411_mnsms_est_req (struct gsm411_smc_inst *inst, struct msgb *msg)
 
static int gsm411_mmsms_send_msg (struct gsm411_smc_inst *inst)
 
static int gsm411_mmsms_est_cnf (struct gsm411_smc_inst *inst, struct msgb *msg)
 
static int gsm411_mmsms_cp_ack (struct gsm411_smc_inst *inst, struct msgb *msg)
 
static int gsm411_mmsms_cp_data (struct gsm411_smc_inst *inst, struct msgb *msg)
 
static int gsm411_mnsms_data_req (struct gsm411_smc_inst *inst, struct msgb *msg)
 
static int gsm411_mnsms_rel_req (struct gsm411_smc_inst *inst, struct msgb *msg)
 
static int gsm411_mmsms_cp_error (struct gsm411_smc_inst *inst, struct msgb *msg)
 
static int gsm411_mmsms_rel_ind (struct gsm411_smc_inst *inst, struct msgb *msg)
 
static int gsm411_mnsms_abort_req (struct gsm411_smc_inst *inst, struct msgb *msg)
 
int gsm411_smc_send (struct gsm411_smc_inst *inst, int msg_type, struct msgb *msg)
 
int gsm411_smc_recv (struct gsm411_smc_inst *inst, int msg_type, struct msgb *msg, int cp_msg_type)
 
static void rp_timer_expired (void *data)
 
void gsm411_smr_init (struct gsm411_smr_inst *inst, uint64_t id, int network, int(*rl_recv)(struct gsm411_smr_inst *inst, int msg_type, struct msgb *msg), int(*mn_send)(struct gsm411_smr_inst *inst, int msg_type, struct msgb *msg))
 
void gsm411_smr_clear (struct gsm411_smr_inst *inst)
 
static void new_rp_state (struct gsm411_smr_inst *inst, enum gsm411_rp_state state)
 
static int gsm411_rp_sendmsg (struct gsm411_smr_inst *inst, struct msgb *msg, uint8_t rp_msg_type, uint8_t rp_msg_ref, int mnsms_msg_type)
 
static int gsm411_send_rp_error (struct gsm411_smr_inst *inst, uint8_t msg_ref, uint8_t cause)
 
static int gsm411_send_release (struct gsm411_smr_inst *inst)
 
static int gsm411_send_abort (struct gsm411_smr_inst *inst)
 
static int gsm411_send_report (struct gsm411_smr_inst *inst)
 
static int gsm411_rl_data_req (struct gsm411_smr_inst *inst, struct msgb *msg)
 
static int gsm411_rl_report_req (struct gsm411_smr_inst *inst, struct msgb *msg)
 
static int gsm411_mnsms_est_ind (struct gsm411_smr_inst *inst, struct msgb *msg)
 
static int gsm411_mnsms_data_ind_tx (struct gsm411_smr_inst *inst, struct msgb *msg)
 
static int gsm411_mnsms_error_ind_tx (struct gsm411_smr_inst *inst, struct msgb *msg)
 
static int gsm411_mnsms_error_ind_rx (struct gsm411_smr_inst *inst, struct msgb *msg)
 
int gsm411_smr_send (struct gsm411_smr_inst *inst, int msg_type, struct msgb *msg)
 
int gsm411_smr_recv (struct gsm411_smr_inst *inst, int msg_type, struct msgb *msg)
 
struct msgb * gsm411_msgb_alloc (void)
 Allocate a message buffer for use as TS 04.11 message. More...
 
uint8_t gsm411_bcdify (uint8_t value)
 Turn int into semi-octet representation: 98 => 0x89. More...
 
uint8_t gsm411_unbcdify (uint8_t value)
 Turn semi-octet representation into int: 0x89 => 98. More...
 
void gsm340_gen_scts (uint8_t *scts, time_t time)
 Generate 03.40 TP-SCTS. More...
 
time_t gsm340_scts (uint8_t *scts)
 Decode 03.40 TP-SCTS (into utc/gmt timestamp) More...
 
static unsigned long gsm340_vp_default (void)
 
static unsigned long gsm340_vp_relative (uint8_t *sms_vp)
 
static unsigned long gsm340_vp_absolute (uint8_t *sms_vp)
 
static unsigned long gsm340_vp_relative_integer (uint8_t *sms_vp)
 
static unsigned long gsm340_vp_relative_semioctet (uint8_t *sms_vp)
 
unsigned long gsm340_validity_period (uint8_t sms_vpf, uint8_t *sms_vp)
 decode validity period. return minutes More...
 
enum sms_alphabet gsm338_get_sms_alphabet (uint8_t dcs)
 determine coding alphabet dependent on GSM 03.38 Section 4 DCS More...
 
int gsm340_gen_oa (uint8_t *oa, unsigned int oa_len, uint8_t type, uint8_t plan, const char *number)
 generate a TPDU address field compliant with 03.40 sec. 9.1.2.5 More...
 
int gsm411_push_rp_header (struct msgb *msg, uint8_t rp_msg_type, uint8_t rp_msg_ref)
 Prefix msgb with a RP header. More...
 
int gsm411_push_cp_header (struct msgb *msg, uint8_t proto, uint8_t trans, uint8_t msg_type)
 Prefix msgb with a 04.08/04.11 CP header. More...
 

Variables

const char * smc_state_names []
 
const struct value_string gsm411_cp_cause_strs []
 
static const struct smcdownstate smcdownstatelist []
 
static const struct smcdatastate smcdatastatelist []
 
static const char * smr_state_names []
 
const struct value_string gsm411_rp_cause_strs []
 
static const struct smrdownstate smrdownstatelist []
 
static const struct smrdatastate smrdatastatelist []
 

Detailed Description

Point-to-Point (PP) Short Message Service (SMS) as per TS 04.11.

Function Documentation

struct gsm341_ms_message* gsm0341_build_msg ( void *  ctx,
uint8_t  geo_scope,
uint8_t  msg_code,
uint8_t  update,
uint16_t  msg_id,
uint8_t  dcs,
uint8_t  page_total,
uint8_t  page_cur,
uint8_t *  data,
uint8_t  len 
)

Encode a 3GPP TS 03.41 SMS-CB message.

Parameters
[in]ctxtalloc allocation context
[in]geo_scopeGeographic Scope
[in]msg_codeMessage Code
[in]updateIs this an update?
[in]msg_idMessage ID
[in]dcsData Coding Scheme
[in]page_totalTotal number of pages
[in]page_curCurrent Page (up to page_total)
[in]dataMessage data (copied 1:1)
[in]lenLength of data in bytes (up to 88)
Returns
callee-allocated TS 03.41 message with encoded data
enum sms_alphabet gsm338_get_sms_alphabet ( uint8_t  dcs)

determine coding alphabet dependent on GSM 03.38 Section 4 DCS

Parameters
[in]dcsData Coding Scheme in 03.38 encoding
Returns
libosmogsm internal enum sms_alphabet
int gsm340_gen_oa ( uint8_t *  oa,
unsigned int  oa_len,
uint8_t  type,
uint8_t  plan,
const char *  number 
)

generate a TPDU address field compliant with 03.40 sec. 9.1.2.5

Parameters
[out]oacaller-provided output buffer
[in]oa_lencaller-specified length of oa in bytes
[in]typeGSM340_TYPE_*
[in]planNumbering Plan
[in]numberstring containing number number of bytes of oa that have been used

References gsm48_encode_bcd_number().

void gsm340_gen_scts ( uint8_t *  scts,
time_t  time 
)

Generate 03.40 TP-SCTS.

Parameters
[out]sctsCaller-provided buffer to store SCTS (7 octets)
[in]timeto encode

References gsm411_bcdify().

time_t gsm340_scts ( uint8_t *  scts)

Decode 03.40 TP-SCTS (into utc/gmt timestamp)

Parameters
[in]sctsSMS Center Time Stamp
Returns
time in UTC time_t format

References gsm411_unbcdify().

unsigned long gsm340_validity_period ( uint8_t  sms_vpf,
uint8_t *  sms_vp 
)

decode validity period. return minutes

Parameters
[in]sms_vpfValidity Period Format in 03.40 encoding
[in]sms_vpValidity Period Information Element
Returns
validity period in minutes
uint8_t gsm411_bcdify ( uint8_t  value)

Turn int into semi-octet representation: 98 => 0x89.

Parameters
[in]integervalue representing decimal number 0..99
Returns
BSC encoded as nibbles, swapped

Referenced by gsm340_gen_scts().

struct msgb* gsm411_msgb_alloc ( void  )

Allocate a message buffer for use as TS 04.11 message.

Returns
allocated message buffer
int gsm411_push_cp_header ( struct msgb *  msg,
uint8_t  proto,
uint8_t  trans,
uint8_t  msg_type 
)

Prefix msgb with a 04.08/04.11 CP header.

Parameters
msgMessage Buffer containing message
[in]protoProtocol
[in]transTransaction
[in]msg_typeMessage Type 0
int gsm411_push_rp_header ( struct msgb *  msg,
uint8_t  rp_msg_type,
uint8_t  rp_msg_ref 
)

Prefix msgb with a RP header.

Parameters
msgMessage Buffer containing message
[in]rp_msg_typeRP Message Type
[in]rp_msg_refRP Message Reference
Returns
0
uint8_t gsm411_unbcdify ( uint8_t  value)

Turn semi-octet representation into int: 0x89 => 98.

Parameters
[in]valuebyte containing two BCD nibbles in revere order
Returns
integer representing decoded, re-ordered nibbles

Referenced by gsm340_scts().

Variable Documentation

const struct value_string gsm411_cp_cause_strs[]
Initial value:
= {
{ GSM411_CP_CAUSE_NET_FAIL, "Network Failure" },
{ GSM411_CP_CAUSE_CONGESTION, "Congestion" },
{ GSM411_CP_CAUSE_INV_TRANS_ID, "Invalid Transaction ID" },
{ GSM411_CP_CAUSE_SEMANT_INC_MSG, "Semantically Incorrect Message" },
{ GSM411_CP_CAUSE_INV_MAND_INF, "Invalid Mandatory Information" },
{ GSM411_CP_CAUSE_MSGTYPE_NOTEXIST, "Message Type doesn't exist" },
{ GSM411_CP_CAUSE_MSG_INCOMP_STATE,
"Message incompatible with protocol state" },
{ GSM411_CP_CAUSE_IE_NOTEXIST, "IE does not exist" },
{ GSM411_CP_CAUSE_PROTOCOL_ERR, "Protocol Error" },
{ 0, 0 }
}
const struct value_string gsm411_rp_cause_strs[]
Initial value:
= {
{ GSM411_RP_CAUSE_MO_NUM_UNASSIGNED, "(MO) Number not assigned" },
{ GSM411_RP_CAUSE_MO_OP_DET_BARR, "(MO) Operator determined barring" },
{ GSM411_RP_CAUSE_MO_CALL_BARRED, "(MO) Call barred" },
{ GSM411_RP_CAUSE_MO_SMS_REJECTED, "(MO) SMS rejected" },
{ GSM411_RP_CAUSE_MO_DEST_OUT_OF_ORDER, "(MO) Destination out of order" },
{ GSM411_RP_CAUSE_MO_UNIDENTIFIED_SUBSCR, "(MO) Unidentified subscriber" },
{ GSM411_RP_CAUSE_MO_FACILITY_REJ, "(MO) Facility reject" },
{ GSM411_RP_CAUSE_MO_UNKNOWN_SUBSCR, "(MO) Unknown subscriber" },
{ GSM411_RP_CAUSE_MO_NET_OUT_OF_ORDER, "(MO) Network out of order" },
{ GSM411_RP_CAUSE_MO_TEMP_FAIL, "(MO) Temporary failure" },
{ GSM411_RP_CAUSE_MO_CONGESTION, "(MO) Congestion" },
{ GSM411_RP_CAUSE_MO_RES_UNAVAIL, "(MO) Resource unavailable" },
{ GSM411_RP_CAUSE_MO_REQ_FAC_NOTSUBSCR, "(MO) Requested facility not subscribed" },
{ GSM411_RP_CAUSE_MO_REQ_FAC_NOTIMPL, "(MO) Requested facility not implemented" },
{ GSM411_RP_CAUSE_MO_INTERWORKING, "(MO) Interworking" },
{ GSM411_RP_CAUSE_MT_MEM_EXCEEDED, "(MT) Memory Exceeded" },
{ GSM411_RP_CAUSE_INV_TRANS_REF, "Invalid Transaction Reference" },
{ GSM411_RP_CAUSE_SEMANT_INC_MSG, "Semantically Incorrect Message" },
{ GSM411_RP_CAUSE_INV_MAND_INF, "Invalid Mandatory Information" },
{ GSM411_RP_CAUSE_MSGTYPE_NOTEXIST, "Message Type non-existant" },
{ GSM411_RP_CAUSE_MSG_INCOMP_STATE, "Message incompatible with protocol state" },
{ GSM411_RP_CAUSE_IE_NOTEXIST, "Information Element not existing" },
{ GSM411_RP_CAUSE_PROTOCOL_ERR, "Protocol Error" },
{ 0, NULL }
}
const char* smc_state_names[]
Initial value:
= {
"IDLE",
"MM_CONN_PENDING",
"WAIT_CP_ACK",
"MM_ESTABLISHED",
}
const struct smcdownstate smcdownstatelist[]
static
Initial value:
= {
{SBIT(GSM411_CPS_IDLE),
GSM411_MNSMS_EST_REQ,
"MNSMS-EST-REQ", gsm411_mnsms_est_req},
{ALL_STATES,
GSM411_MNSMS_REL_REQ,
"MNSMS-REL-REQ", gsm411_mnsms_rel_req},
{SBIT(GSM411_CPS_MM_ESTABLISHED),
GSM411_MNSMS_DATA_REQ,
"MNSMS-DATA-REQ", gsm411_mnsms_data_req},
{ALL_STATES - SBIT(GSM411_CPS_IDLE),
GSM411_MNSMS_ABORT_REQ,
"MNSMS-ABORT-REQ", gsm411_mnsms_abort_req},
}
const char* smr_state_names[]
static
Initial value:
= {
"IDLE",
"WAIT_FOR_RP_ACK",
"illegal state 2",
"WAIT_TO_TX_RP_ACK",
"WAIT_FOR_RETRANS_T",
}
const struct smrdatastate smrdatastatelist[]
static
Initial value:
= {
{SBIT(GSM411_RPS_IDLE),
GSM411_MNSMS_EST_IND,
"MNSMS-EST-IND", gsm411_mnsms_est_ind},
{SBIT(GSM411_RPS_WAIT_FOR_RP_ACK),
GSM411_MNSMS_DATA_IND,
"MNSMS-DATA-IND", gsm411_mnsms_data_ind_tx},
{SBIT(GSM411_RPS_WAIT_FOR_RP_ACK),
GSM411_MNSMS_ERROR_IND,
"MNSMS-ERROR-IND", gsm411_mnsms_error_ind_tx},
{SBIT(GSM411_RPS_WAIT_TO_TX_RP_ACK),
GSM411_MNSMS_ERROR_IND,
"MNSMS-ERROR-IND", gsm411_mnsms_error_ind_rx},
}
const struct smrdownstate smrdownstatelist[]
static
Initial value:
= {
{SBIT(GSM411_RPS_IDLE),
GSM411_SM_RL_DATA_REQ,
"SM-RL-DATA_REQ", gsm411_rl_data_req},
{SBIT(GSM411_RPS_WAIT_TO_TX_RP_ACK),
GSM411_SM_RL_REPORT_REQ,
"SM-RL-REPORT_REQ", gsm411_rl_report_req},
}