文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > 中国移动 CMPP v3.0 ISMG SP 收发短信的 SP 客户端
侵权投诉

中国移动 CMPP v3.0 ISMG SP 收发短信的 SP 客户端

3.0的版本,高4bit为3,低4位为0
private uint _Timestamp; // 4 Unsigned Integer 时间戳的明文,由客户端产生,格式为MMDDHHMMSS,即月日时分秒,10位数字的整型,右对齐 。
private MessageHeader _Header;
public MessageHeader Header
{
get
{
return _Header;
}
}
public byte[] AuthenticatorSource
{
get
{
return _AuthenticatorSource;
}
}
public CMPP_CONNECT
(
string Source_Addr
, string Password
, DateTime Timestamp
, uint Version
, uint Sequence_Id
)
{
_Header = new MessageHeader
(
MessageHeader.Length + BodyLength
, CMPP_Command_Id.CMPP_CONNECT
, Sequence_Id
);
_Source_Addr = Source_Addr;
_Password = Password;
string s = Utility.Get_MMDDHHMMSS_String(Timestamp);
_Timestamp = UInt32.Parse(s);
byte[] buffer = new byte[6 + 9 + _Password.Length + 10];
Encoding.ASCII.GetBytes(_Source_Addr).CopyTo(buffer, 0);
Encoding.ASCII.GetBytes(_Password).CopyTo(buffer, 6 + 9);
Encoding.ASCII.GetBytes(s).CopyTo(buffer, 6 + 9 + _Password.Length);
_AuthenticatorSource = new MD5CryptoServiceProvider().ComputeHash(buffer, 0, buffer.Length);
_Version = Version;
}
public byte[] ToBytes()
{
int i = 0;
byte[] bytes = new byte[MessageHeader.Length + BodyLength];
//header 12
byte[] buffer = _Header.ToBytes();
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length);
//Source_Addr 6
i += MessageHeader.Length;
buffer = Encoding.ASCII.GetBytes(_Source_Addr);
Buffer.BlockCopy(buffer, 0, bytes, i, 6);
//AuthenticatorSource 16
i += 6;
buffer = _AuthenticatorSource;
Buffer.BlockCopy(buffer, 0, bytes, i, buffer.Length); //16
//version 1
i += 16;
bytes[i++] = (byte) _Version; //版本
//Timestamp
buffer = BitConverter.GetBytes(_Timestamp);
Array.Reverse(buffer);
buffer.CopyTo(bytes, i);
return (bytes);
}
public override string ToString()
{
return "[\r\n"
+ _Header.ToString() + "\r\n"
+ "\t"
+ string.Format
(
"MessageBody:"
+ "{0}AuthenticatorSource: {1}"
+ "{0}Password: {2}"
+ "{0}Source_Addr: {3}"
+ "{0}Version: {4}"
, "\r\n\t\t"
, Utility.BytesArrayToHexString(_AuthenticatorSource)
, _Password
, _Source_Addr
, _Timestamp
, _Version
)
+ "\r\n]";
}
}
public class CMPP_CONNECT_RESP //: CMPP_Response
{
private MessageHeader _Header;
public const int BodyLength = 4 + 16 + 1;
private uint _Status; // 4 Unsigned Integer 状态
// 0:正确
// 1:消息结构错
// 2:非法源地址
// 3:认证错
// 4:版本太高
// 5~:其他错误
private byte[] _AuthenticatorISMG; // 16 Octet Strin

上一页第4页

你可能喜欢

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email