diff options
| author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-10-18 16:56:43 +0200 | 
|---|---|---|
| committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-10-18 17:04:49 +0200 | 
| commit | c64970ede515eb615d969bb5107b145f3f4d3a1f (patch) | |
| tree | 2de847fbcf33ea5abbbbdf4da124173c584ac6d9 /src | |
| parent | 1a4ea5b4364b756276da5d378d81e3b15a1d5f84 (diff) | |
gsm0480: Add method create own number response
Diffstat (limited to 'src')
| -rw-r--r-- | src/gsm0480.c | 50 | 
1 files changed, 50 insertions, 0 deletions
diff --git a/src/gsm0480.c b/src/gsm0480.c index b4ba8305..b6b345cb 100644 --- a/src/gsm0480.c +++ b/src/gsm0480.c @@ -409,3 +409,53 @@ static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,  	}  	return rc;  } + +struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, const char *text) +{ +	struct msgb *msg; +	struct gsm48_hdr *gh; +	uint8_t *ptr8; +	int response_len; + +	msg = msgb_alloc_headroom(1024, 128, "GSM 04.80"); +	if (!msg) +		return NULL; + +	/* First put the payload text into the message */ +	ptr8 = msgb_put(msg, 0); +	response_len = gsm_7bit_encode(ptr8, text); +	msgb_put(msg, response_len); + +	/* Then wrap it as an Octet String */ +	msgb_wrap_with_TL(msg, ASN1_OCTET_STRING_TAG); + +	/* Pre-pend the DCS octet string */ +	msgb_push_TLV1(msg, ASN1_OCTET_STRING_TAG, 0x0F); + +	/* Then wrap these as a Sequence */ +	msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG); + +	/* Pre-pend the operation code */ +	msgb_push_TLV1(msg, GSM0480_OPERATION_CODE, +			GSM0480_OP_CODE_PROCESS_USS_REQ); + +	/* Wrap the operation code and IA5 string as a sequence */ +	msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG); + +	/* Pre-pend the invoke ID */ +	msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, invoke_id); + +	/* Wrap this up as a Return Result component */ +	msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_RESULT); + +	/* Wrap the component in a Facility message */ +	msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY); + +	/* And finally pre-pend the L3 header */ +	gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh)); +	gh->proto_discr = GSM48_PDISC_NC_SS | trans_id +					| (1<<7);  /* TI direction = 1 */ +	gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE; + +	return msg; +}  | 
