您现在的位置: 软界网软界问答软件开发C++Build > 问题显示
我要提问    
提示:提问和回答别人的问题均可赢得积分
加入收藏我要投诉 我来回答
此问题已经被浏览43次,收藏:0次. 所属类别:[C++Build]
问题:谁有pdu编码解码的列子"?
谢谢
提问时间:2007-4-9 20:33:38 回答次数:(6) 提问人:软界网友 我来回答
回答(1)
RadiusPDU::RadiusPDU()
:
code( 0 ),
id( 0 )
{
// memset(authenticator,0,sizeof(authenticator));
}

RadiusPDU::RadiusPDU(
const RadiusPDU& pdu
)
:
code( pdu.code ),
id( pdu.id )
{
memcpy(authenticator,pdu.authenticator,sizeof(authenticator));
attributes = pdu.attributes;
attributes.MakeUnique();
}

RadiusPDU::RadiusPDU(
unsigned char packetCode, /// code - see #Codes enum#
unsigned char packetId /// packet id (sequence number)
)
:
code( packetCode ),
id( packetId )
{
// memset(authenticator,0,sizeof(authenticator));
}

RadiusPDU::RadiusPDU(
unsigned char packetCode, /// code - see #Codes enum#
const RadiusAttr::List& attrs, /// attributes
unsigned char packetId /// packet id (sequence number)
)
:
code( packetCode ),
id( packetId )
{
attributes = attrs;
attributes.MakeUnique();
}

RadiusPDU::RadiusPDU(
const void* rawData, /// raw data buffer
PINDEX rawLength /// raw data length
)
:
code( 0 ),
id( 0 )
{
if( !Read(rawData,rawLength) ) {
attributes.RemoveAll();
code = id = 0;
}
}

RadiusPDU::~RadiusPDU()
{
}

PINDEX RadiusPDU::GetLength() const
{
PINDEX len = FixedHeaderLength;
const PINDEX numAttrs = attributes.GetSize();

for( PINDEX i = 0; i < numAttrs; i++ ) {
const RadiusAttr* const attr = (RadiusAttr*)(attributes.GetAt(i));
if( attr && attr-> IsValid() )
len += attr-> GetLength();
else
return 0;
}

return len;
}

void RadiusPDU::PrintOn(
ostream& strm /// Stream to print the object into.
) const
{
const int indent = strm.precision() + 2;

strm < < ((!IsValid())? "(Invalid) {\n ": "{\n ");

#if PTRACING
strm < < setw(indent+7) < < "code = " < < (unsigned)code
< < " ( " < < PMAP_CODE_TO_NAME(code) < < ")\n ";
#else
strm < < setw(indent+7) < < "code = " < < (unsigned)code < < '\n ';
#endif
strm < < setw(indent+5) < < "id = " < < (unsigned)id < < '\n ';
strm < < setw(indent+9) < < "length = " < < GetLength() < < " octets\n ";

const _Ios_Fmtflags flags = strm.flags();
const PBYTEArray value( (const BYTE*)authenticator, AuthenticatorLength, FALSE );

strm < < setw(indent+28) < < "authenticator = 16 octets {\n ";
strm < < hex < < setfill( '0 ') < < resetiosflags(ios::floatfield)
< < setprecision(indent+2) < < setw(16);
strm < < value < < '\n ';
strm < < dec < < setfill( ' ') < < setprecision(indent);
strm.flags(flags);
strm < < setw(indent+2) < < "}\n ";

if( attributes.GetSize() == 0 )
strm < < setw(indent+22) < < "attributes = < <null> > \n ";
else {
strm < < setw(indent+13) < < "attributes = " < < attributes.GetSize() < < " elements {\n ";

const int aindent = indent + 2;

for( PINDEX i = 0; i < attributes.GetSize(); i++ ) {
const RadiusAttr* const attr = (RadiusAttr*)(attributes.GetAt(i));
if( attr )
strm < < setw(aindent+1) < < "[ " < < i < < "]= "
< < setprecision(aindent) < < *attr
< < setprecision(indent);
}
strm < < setw(aindent) < < "}\n ";
}

strm < < setw(indent-1) < < "}\n " < < setprecision(indent-2);
}

BOOL RadiusPDU::IsValid() const
{
if( code == Invalid )
return FALSE;

PINDEX len = FixedHeaderLength;
const PINDEX numAttrs = attributes.GetSi
回答人:软界网友 我来回答
回答(2)
刚好我做过
^_^
你可以参考Gnugk得例子
它在解析pdu得时候有一个专门得类

我开发得由于是商业得 所以不方便透露
而且我其实和gnugk得差不多
回答人:软界网友 我来回答
回答(3)
刚好我做过
^_^
你可以参考Gnugk得例子
它在解析pdu得时候有一个专门得类

我开发得由于是商业得 所以不方便透露
而且我其实和gnugk得差不多
回答人:软界网友 我来回答
回答(4)
学习
好贴子
关注
回答人:软界网友 我来回答
回答(5)
http://faq.csdn.net/read/212510.html
回答人:软界网友 我来回答
回答(6)
我以前的回答
http://topic.csdn.net/t/20060227/21/4581697.html
回答人:软界网友 我来回答
相关问题
关键字: lt,RadiusPDU,setw,39,authenticator, code,setprecision, attributes, id,amp,GetSize,aindent, strm,GetLength,IsValid,sizeof
我来回答
验证码