105 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package pdu
 | |
| 
 | |
| import "fmt"
 | |
| 
 | |
| type (
 | |
| 	SUBMIT_SM struct {
 | |
| 		header                 PDU_HEADER
 | |
| 		service_type           string
 | |
| 		source_addr_ton        uint8
 | |
| 		source_addr_npi        uint8
 | |
| 		source_addr            string
 | |
| 		dest_addr_ton          uint8
 | |
| 		dest_addr_npi          uint8
 | |
| 		destination_addr       string
 | |
| 		esm_class              uint8
 | |
| 		protocol_id            uint8
 | |
| 		priority_flag          uint8
 | |
| 		schedule_delivery_time string
 | |
| 		validity_period        string
 | |
| 		registered_delivery    uint8
 | |
| 		replace_if_present     uint8
 | |
| 		data_coding            uint8
 | |
| 		sm_default_msg_id      uint8
 | |
| 		sm_length              uint8
 | |
| 		short_message          string
 | |
| 		// user_message_reference uint16
 | |
| 		// source_port               uint16
 | |
| 		// source_addr_subunit       uint8
 | |
| 		// destination_port          uint16
 | |
| 		// dest_addr_subunit         uint8
 | |
| 		// sar_msg_ref_num           uint16
 | |
| 		// sar_total_segments        uint8
 | |
| 		// sar_segment_seqnum        uint8
 | |
| 		// more_messages_to_send     uint8
 | |
| 		// payload_type              uint8
 | |
| 		// message_payload           string
 | |
| 		// privacy_indicator         uint8
 | |
| 		// callback_num              string
 | |
| 		// callback_num_pres         uint8
 | |
| 		// callback_num_atag         string
 | |
| 		// source_subaddress         string
 | |
| 		// dest_subaddress           string
 | |
| 		// user_response_code        uint8
 | |
| 		// display_time              uint8
 | |
| 		// sms_signal                uint8
 | |
| 		// ms_validity               uint8
 | |
| 		// ms_msg_wait_facilities    uint8
 | |
| 		// number_of_messages        uint8
 | |
| 		// alert_on_message_delivery uint8
 | |
| 		// language_indicator        uint8
 | |
| 		// its_reply_type            uint8
 | |
| 		// its_session_info          uint8
 | |
| 		// ussd_service_op           uint8
 | |
| 	}
 | |
| 	SUBMIT_SM_RESP struct {
 | |
| 		header     PDU_HEADER
 | |
| 		message_id string
 | |
| 	}
 | |
| 	SUBMIT_MULTI      struct{}
 | |
| 	SUBMIT_MULTI_RESP struct{}
 | |
| )
 | |
| 
 | |
| func (p *SUBMIT_SM) Encode() ([]byte, error) {
 | |
| 	buf := make([]byte, p.Size())
 | |
| 	err := p.EncodeInto(&buf)
 | |
| 	return buf, err
 | |
| }
 | |
| func (p *SUBMIT_SM) EncodeInto(buf *[]byte) error {
 | |
| 	if buf == nil {
 | |
| 		return fmt.Errorf("cannot encode SUBMIT_SM, buffer is nil")
 | |
| 	}
 | |
| 	if len(*buf) < int(p.Size()) {
 | |
| 		return fmt.Errorf("cannot encode SUBMIT_SM, buffer too small (%d, required %d)", len(*buf), p.Size())
 | |
| 	}
 | |
| 
 | |
| 	p.header.EncodeInto(buf)
 | |
| 
 | |
| 	return nil
 | |
| }
 | |
| func (p *SUBMIT_SM) Decode(data []byte) {
 | |
| }
 | |
| func (p *SUBMIT_SM) Size() uint32 {
 | |
| 	var size uint32
 | |
| 	size += p.header.Size()
 | |
| 	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
 | |
| }
 | 
