Example #1
0
        /// <summary>
        /// Gets the optional parameter string associated with
        /// the given tag.
        /// </summary>
        /// <param name="tag">The tag in TLV.</param>
        /// <returns>The optional parameter string, or null if not found.</returns>
        public string GetOptionalParamString(Tag tag)
        {
            var tlv = vTlv.GetTlvByTag(tag);

            if (tlv == null)
            {
                return(null);
            }

            return(vSmppEncodingService.GetCStringFromBytes(tlv.RawValue));
        }
Example #2
0
        private static string BytesToString(byte[] value, SmppEncodingService encodingService)
        {
            try
            {
                if (encodingService != null)
                {
                    return(encodingService.GetCStringFromBytes(value));
                }

                return(BytesToStringHex(value));
            }
            catch (Exception)
            {
                return(BytesToStringHex(value));
            }
        }
Example #3
0
        internal static string DecodeCString(ByteBuffer buffer, SmppEncodingService smppEncodingService)
        {
            //Get next terminating null value
            int pos = buffer.Find(0x00);

            if (pos < 0)
            {
                throw new PDUFormatException("CString type field could not be read. The terminating charactor is missing");
            }
            try { string value = smppEncodingService.GetCStringFromBytes(buffer.Remove(pos + 1)); return(value); }
            catch (ArgumentException ex)
            {
                //ByteBuffer.Remove(int count) throw ArgumentException if the buffer length is less than count
                //This is the indication that the amount of bytes required could not be met
                //We wrap this exception as NotEnoughtBytesException exception
                throw new NotEnoughBytesException("PDU requires more bytes than supplied", ex);
            }
        }