From 1b904b69fd790f0e3fe81bc25e7b60394ff8e32b Mon Sep 17 00:00:00 2001 From: PhatPhuckDave <> Date: Mon, 22 Jul 2024 22:43:48 +0200 Subject: [PATCH] Implement size in submit_pdu --- pdu/pdu.go | 1 + pdu/submit.go | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pdu/pdu.go b/pdu/pdu.go index 9a51c00..0f4c15b 100644 --- a/pdu/pdu.go +++ b/pdu/pdu.go @@ -10,6 +10,7 @@ type ( EncodeInto(*[]uint8) Encode() []uint8 Decode([]uint8) + // Size in bytes Size() uint32 } diff --git a/pdu/submit.go b/pdu/submit.go index a205cfd..8e572ef 100644 --- a/pdu/submit.go +++ b/pdu/submit.go @@ -66,5 +66,25 @@ func (p *SUBMIT_SM) EncodeInto(buf *[]byte) { func (p *SUBMIT_SM) Decode(data []byte) { } func (p *SUBMIT_SM) Size() uint32 { - return 0 + var size uint32 + size += 16 // header + size += uint32(len(p.service_type) * 1) + size += 1 // source_addr_ton + size += 1 // source_addr_npi + size += uint32(len(p.source_addr) * 1) + size += 1 // dest_addr_ton + size += 1 // dest_addr_npi + size += uint32(len(p.destination_addr) * 1) + size += 1 // esm_class + size += 1 // protocol_id + size += 1 // priority_flag + size += uint32(len(p.schedule_delivery_time) * 1) + size += uint32(len(p.validity_period) * 1) + size += 1 // registered_delivery + size += 1 // replace_if_present + size += 1 // data_coding + size += 1 // sm_default_msg_id + size += 1 // sm_length + size += uint32(len(p.short_message) * 1) + return size }