Implement size in submit_pdu

This commit is contained in:
PhatPhuckDave
2024-07-22 22:43:48 +02:00
parent 9b86dfc2ef
commit 1b904b69fd
2 changed files with 22 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ type (
EncodeInto(*[]uint8)
Encode() []uint8
Decode([]uint8)
// Size in bytes
Size() uint32
}

View File

@@ -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
}