aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-04 12:26:06 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-04 12:27:48 +0100
commitc25c668106e932555770b26783c93afd748212a6 (patch)
tree0c8cecd1d13f4d68d310feb4e56c776da41a361a
parent9d92f0e12c17e040de80faa63ddc7c3211aac6e4 (diff)
gsm0808: Add a method to create a new DTAP message with a msgb
-rw-r--r--include/osmocore/gsm0808.h1
-rw-r--r--src/gsm0808.c23
2 files changed, 24 insertions, 0 deletions
diff --git a/include/osmocore/gsm0808.h b/include/osmocore/gsm0808.h
index 39a439b2..c6d11e10 100644
--- a/include/osmocore/gsm0808.h
+++ b/include/osmocore/gsm0808.h
@@ -37,6 +37,7 @@ struct msgb *gsm0808_create_assignment_completed(uint8_t rr_cause,
uint8_t speech_mode);
struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause);
+struct msgb *gsm0808_create_dtap(struct msgb *msg, uint8_t link_id);
void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id);
const struct tlv_definition *gsm0808_att_tlvdef();
diff --git a/src/gsm0808.c b/src/gsm0808.c
index 3962baaf..7c9fa091 100644
--- a/src/gsm0808.c
+++ b/src/gsm0808.c
@@ -292,6 +292,29 @@ void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id)
hh[2] = msg->len - 3;
}
+struct msgb *gsm0808_create_dtap(struct msgb *msg_l3, uint8_t link_id)
+{
+ struct dtap_header *header;
+ uint8_t *data;
+ struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
+ "dtap");
+ if (!msg)
+ return NULL;
+
+ /* DTAP header */
+ msg->l3h = msgb_put(msg, sizeof(*header));
+ header = (struct dtap_header *) &msg->l3h[0];
+ header->type = BSSAP_MSG_DTAP;
+ header->link_id = link_id;
+ header->length = msgb_l3len(msg_l3);
+
+ /* Payload */
+ data = msgb_put(msg, header->length);
+ memcpy(data, msg_l3->l3h, header->length);
+
+ return msg;
+}
+
static const struct tlv_definition bss_att_tlvdef = {
.def = {
[GSM0808_IE_IMSI] = { TLV_TYPE_TLV },