// SMsgDirG2ExplicitSetDataObjects::Pack // Virtual method from SmallMessage. Packs data into message buffer. void* SMsgDirG2ExplicitSetDataObjects::Pack(void) { WTRACE("SMsgDirG2ExplicitSetDataObjects::Pack"); SetServiceType(WONMsg::SmallDirServerG2); SetMessageType(mKeyType == KT_SERVICE ? WONMsg::DirG2ServiceExplicitSetDataObjects : WONMsg::DirG2DirectoryExplicitSetDataObjects); SMsgDirG2UpdateBase::Pack(); PackKey(*this); AppendShort(mObjects.size()); ExplicitDOInfoList::iterator anItr(mObjects.begin()); for (; anItr != mObjects.end(); anItr++) { AppendByte(static_cast<unsigned char>(anItr->mSetMode)); unsigned char aTypeLen = anItr->mData.GetDataType().size(); AppendByte(aTypeLen); if (aTypeLen > 0) AppendBytes(aTypeLen, anItr->mData.GetDataType().data()); unsigned short aDataLen = anItr->mData.GetData().size(); AppendShort(aDataLen); if (aDataLen > 0) AppendBytes(aDataLen, anItr->mData.GetData().data()); } PackPeerData(); return GetDataPtr(); }
void* MMsgRoutingModifyDataObject::Pack(void) { WTRACE("MMsgRoutingModifyDataObject::Pack"); SetServiceType(WONMsg::MiniRoutingServer); SetMessageType(WONMsg::RoutingModifyDataObject); RoutingServerMessage::Pack(); WDBG_LL("MMsgRoutingModifyDataObject::Pack Appending message data"); // append the client/group id AppendClientOrGroupId(mLinkId); // append the datatype, preceded by datatype length AppendByte(mDataType.size()); AppendBytes(mDataType.size(), mDataType.data()); // append the offset AppendShort(mOffset); // append the IsInsert flag AppendBool(mIsInsert); // append the data length followed by the data itself AppendShort(mData.size()); AppendBytes(mData.size(), mData.data()); return GetDataPtr(); }
// SMsgDirG2ModifyService::Pack // Virtual method from SmallMessage. Packs data into message buffer. void* SMsgDirG2ModifyService::Pack(void) { WTRACE("SMsgDirG2ModifyService::Pack"); SetKeyType(KT_SERVICE); SetServiceType(WONMsg::SmallDirServerG2); if (IsExtended()) { SetMessageType(WONMsg::DirG2ModifyServiceEx); SetExtended(true, true); } else SetMessageType(WONMsg::DirG2ModifyService); SMsgDirG2UpdateExtendBase::Pack(); AppendByte(mEntityFlags); PackKey(*this); Append_PW_STRING(mNewName); unsigned char aLen = mNewNetAddress.size(); AppendByte(aLen); if (aLen > 0) AppendBytes(aLen, mNewNetAddress.data()); Append_PW_STRING(mNewDisplayName); AppendLong(mNewLifespan); PackExtended(); PackPeerData(); return GetDataPtr(); }
void* MMsgRoutingSendData::Pack(void) { WTRACE("MMsgRoutingSendData::Pack"); SetServiceType(WONMsg::MiniRoutingServer); SetMessageType(WONMsg::RoutingSendData); RoutingServerMessage::Pack(); WDBG_LL("MMsgRoutingSendData::Pack Appending message data"); // append the flags unsigned char aFlags = 0; if (mShouldSendReply) aFlags |= 0x01; if (mIncludeExcludeFlag) aFlags |= 0x02; AppendByte(aFlags); // append the message length and data _ASSERT(mData.size() <= USHRT_MAX); AppendShort(mData.size()); AppendBytes(mData.size(), mData.data()); // append the addressee list AppendAddresseeList(this); return GetDataPtr(); }
// TMsgAuthLastRawBufferBase::PackRawBuf // Packs 2 byte length of raw buffer and raw buffer. void TMsgAuthLastRawBufferBase::PackRawBuf() { WTRACE("TMsgAuthLastRawBufferBase::PackRawBuf"); WDBG_LL("TMsgAuthLastRawBufferBase::Pack Appending RawBuf"); if (mRawLen > 0) AppendBytes(mRawLen, mRawP); }
void* MMsgRoutingUnsubscribeDataObject::Pack(void) { WTRACE("MMsgRoutingUnsubscribeDataObject::Pack"); SetServiceType(WONMsg::MiniRoutingServer); SetMessageType(WONMsg::RoutingUnsubscribeDataObject); RoutingServerMessage::Pack(); WDBG_LL("MMsgRoutingUnsubscribeDataObject::Pack Appending message data"); // append the client/group id AppendClientOrGroupId(mLinkId); // append the datatype length followed by the datatype itself AppendByte(mDataType.size()); AppendBytes(mDataType.size(), mDataType.data()); // append the flags unsigned char aFlags = 0; if (mExactOrRecursiveFlag) aFlags |= 0x01; if (mGroupOrMembersFlag) aFlags |= 0x02; AppendByte(aFlags); return GetDataPtr(); }
// TMsgDirFindServiceReply::Pack // Virtual method from TMessage. Packs data into message buffer and // sets the new message length. void* TMsgDirFindServiceReply::Pack(void) { WTRACE("TMsgDirFindServiceReply::Pack"); SetServiceType(WONMsg::DirServer); SetMessageType(WONMsg::DirFindServiceReply); TMessage::Pack(); WDBG_LL("TMsgDirFindServiceReply::Pack Appending message data"); AppendShort(static_cast<short>(mStatus)); // Service info only sent if status is ok if (mStatus == WONMsg::StatusCommon_Success) { Append_PW_STRING(mService.mPath); Append_PW_STRING(mService.mName); Append_PW_STRING(mService.mDisplayName); Append_PW_STRING(mService.mVersion); Append_PW_STRING(mService.mProtoName); Append_PW_STRING(mService.mProtoVersion); Append_PW_STRING(mService.mNetAddress); AppendLong(mService.mLifespan); AppendLong(mService.mCreated); AppendShort(mService.mBlobLen); AppendBytes(mService.mBlobLen, mService.mBlob); } return GetDataPtr(); }
void TMsgDirGetDirContentsReply::PackEntry(const DirServerEntry& theEntry) { WTRACE("TMsgDirGetDirContentsReply::PackEntry"); WDBG_LL("TMsgDirGetDirContentsReply::PackEntry Packing entry"); AppendByte(theEntry.mType); Append_PW_STRING(theEntry.mPath); Append_PW_STRING(theEntry.mName); Append_PW_STRING(theEntry.mDisplayName); AppendLong(theEntry.mLifespan); AppendLong(theEntry.mCreated); if (theEntry.mType == DirServerEntry::EntryTypeDirectory) { AppendByte(theEntry.mVisible ? 1 : 0); } else if (theEntry.mType == DirServerEntry::EntryTypeService) { Append_PW_STRING(theEntry.mVersion); Append_PW_STRING(theEntry.mProtoName); Append_PW_STRING(theEntry.mProtoVersion); Append_PW_STRING(theEntry.mNetAddress); AppendShort(theEntry.mBlobLen); AppendBytes(theEntry.mBlobLen, theEntry.mBlob); } }
void SMsgDirG2UpdateExtendBase::PackExtended(void) { WTRACE("SMsgDirG2UpdateExtendBase::PackExtended"); WDBG_LL("SMsgDirG2UpdateExtendBase::PackExtended enableDataObjects=" << mEnableDataObjects << " enableACLs=" << mEnableACLs); if (mEnableDataObjects) { WDBG_LL("SMsgDirG2UpdateExtendBase::PackExtended Writing " << mDataObjects.size() << " data objects."); AppendShort(mDataObjects.size()); DataObjectTypeSet::iterator anItr(mDataObjects.begin()); for (; anItr != mDataObjects.end(); anItr++) { unsigned char aTypeLen = anItr->GetDataType().size(); AppendByte(aTypeLen); if (aTypeLen > 0) AppendBytes(aTypeLen, anItr->GetDataType().data()); unsigned short aDataLen = anItr->GetData().size(); AppendShort(aDataLen); if (aDataLen > 0) AppendBytes(aDataLen, anItr->GetData().data()); } } if (mEnableACLs) { WDBG_LL("SMsgDirG2UpdateExtendBase::PackExtended Writing " << mACLs.size() << " ACLs."); AppendShort(mACLs.size()); DirACLList::const_iterator anACLItr(mACLs.begin()); for (; anACLItr != mACLs.end(); anACLItr++) { AppendByte(anACLItr->mType); AppendShort(anACLItr->mACL.size()); PermissionACL::const_iterator aPermItr(anACLItr->mACL.begin()); for (; aPermItr != anACLItr->mACL.end(); aPermItr++) { AppendLong(aPermItr->mUserId); AppendLong(aPermItr->mCommunityId); AppendShort(aPermItr->mTrustLevel); } } } }
Bool CRealSister::GenerateTail() { UInt32 mod = GenerateSeed() % 3; switch (mod) { case 0: { Byte bytes[] = { 0xBE }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { UInt32 v = (UInt32)m_EncryptBlock; if (AppendBytes(sizeof(v), &v) == False) return False; } { Byte bytes[] = { 0x8B, 0x86 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { UInt32 v = (GenerateSeed() & 0x3FF) << 2; if (AppendBytes(sizeof(v), &v) == False) return False; } break; case 1: { Byte bytes[] = { 0xB8 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { UInt32 v = GenerateSeed(); if (AppendBytes(sizeof(v), &v) == False) return False; } break; case 2: { Byte bytes[] = { 0x8B, 0xC7 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; } return True; }
void* MMsgRoutingReplaceDataObject::Pack(void) { WTRACE("MMsgRoutingReplaceDataObject::Pack"); SetServiceType(WONMsg::MiniRoutingServer); SetMessageType(WONMsg::RoutingReplaceDataObject); RoutingServerMessage::Pack(); WDBG_LL("MMsgRoutingReplaceDataObject::Pack Appending message data"); // append the client/group id AppendClientOrGroupId(mLinkId); // append the datatype, preceded by datatype length AppendByte(mDataType.size()); AppendBytes(mDataType.size(), mDataType.data()); // append the data, preceded by the data length AppendShort(mData.size()); AppendBytes(mData.size(), mData.data()); return GetDataPtr(); }
OP_STATUS ByteBuffer::Append2( UINT16 n ) { union { UINT16 n; char ns[2]; } u; u.n = n; #ifndef OPERA_BIG_ENDIAN char tmp; tmp = u.ns[0]; u.ns[0] = u.ns[1]; u.ns[1] = tmp; #endif return AppendBytes( u.ns, 2 ); }
// TMsgAuth1Challenge1::Pack // Virtual method from TMessage. Packs data into message buffer and // sets the new message length. void* TMsgAuth1Challenge1::Pack(void) { WTRACE("TMsgAuth1Challenge1::Pack"); SetServiceType(WONMsg::Auth1PeerToPeer); SetMessageType(WONMsg::Auth1Challenge1); TMsgAuthRawBufferBase::Pack(); WDBG_LL("TMsgAuth1Challenge1::Pack Appending message data"); AppendShort(mSecretBLen); if (mSecretBLen > 0) AppendBytes(mSecretBLen, mSecretBP); PackRawBuf(); return GetDataPtr(); }
void SMsgDirG2QueryExtendBase::PackExtended(void) { WTRACE("SMsgDirG2QueryExtendBase::PackExtended"); WDBG_LL("SMsgDirG2QueryExtendBase::PackExtended Extended=" << mExtended << " GetTypes size=" << mGetTypes.size()); if (! mExtended) return; AppendShort(mGetTypes.size()); DataObjectTypeSet::iterator anItr(mGetTypes.begin()); for (; anItr != mGetTypes.end(); anItr++) { unsigned char aLen = anItr->GetDataType().size(); AppendByte(aLen); if (aLen > 0) AppendBytes(aLen, anItr->GetDataType().data()); } }
OP_STATUS ByteBuffer::GetNewChunk( char **bytes, unsigned int *nbytes ) { /* This is perhaps not pretty, but it does ensure that there is a valid chunk numbered 'current' and that there are non-zero bytes available in it. */ RETURN_IF_ERROR( AppendBytes( "", 0 ) ); *nbytes = BYTEBUFFER_CHUNKSIZE - length % BYTEBUFFER_CHUNKSIZE; *bytes = chunks[current]; if (*nbytes == 0) *nbytes = BYTEBUFFER_CHUNKSIZE; else *bytes += BYTEBUFFER_CHUNKSIZE - *nbytes; return OpStatus::OK; }
void* MMsgRoutingPeerData::Pack(void) { WTRACE("MMsgRoutingPeerData::Pack"); SetServiceType(WONMsg::MiniRoutingServer); SetMessageType(WONMsg::RoutingPeerData); RoutingServerMessage::Pack(); WDBG_LL("MMsgRoutingPeerData::Pack Appending message data"); // append the client id AppendClientId(mClientId); // append the data AppendBytes(mData.size(), mData.data()); return GetDataPtr(); }
void* MMsgRoutingSendDataBroadcast::Pack(void) { WTRACE("MMsgRoutingSendDataBroadcast::Pack"); SetServiceType(WONMsg::MiniRoutingServer); SetMessageType(WONMsg::RoutingSendDataBroadcast); RoutingServerMessage::Pack(); WDBG_LL("MMsgRoutingSendDataBroadcast::Pack Appending message data"); // append the flags unsigned char aFlags = 0; if (mShouldSendReply) aFlags |= 0x01; AppendByte(aFlags); // append the data AppendBytes(mData.size(), mData.data()); return GetDataPtr(); }
// MMsgObsSubscribeReply::Pack // Virtual method from MiniMessage. Packs data into message buffer and // sets the new message length. void* MMsgObsSubscribeReply::Pack(void) { WTRACE("MMsgObsSubscribeReply::Pack"); SetServiceType(WONMsg::MiniObsServer); SetMessageType(WONMsg::ObsMsg_SubscribeReply); MiniMessage::Pack(); WDBG_LL("MMsgObsSubscribeReply::Pack Appending message data"); AppendShort((short)(mStatus)); AppendLong(mPublicationId); AppendLong(mSubscriberId); AppendShort(mDataLength); if (mDataLength > 0) { AppendBytes(mDataLength, mDataP); } Append_PA_STRING(mPeerRedirection); return GetDataPtr(); }
// MMsgObsGetDataPoolReply::Pack // Virtual method from MiniMessage. Packs data into message buffer and // sets the new message length. void* MMsgObsGetDataPoolReply::Pack(void) { WTRACE("MMsgObsGetDataPoolReply::Pack"); SetServiceType(WONMsg::MiniObsServer); SetMessageType(WONMsg::ObsMsg_GetDataPoolReply); MiniMessage::Pack(); WDBG_LL("MMsgObsGetDataPoolReply::Pack Appending message data"); AppendShort((short)mStatus); AppendLong(mDataPoolId); AppendShort(mDataLength); if (mDataLength > 0) { AppendBytes(mDataLength, mDataP); } return GetDataPtr(); }
// SMsgDirG2ClearDataObjects::Pack // Virtual method from SmallMessage. Packs data into message buffer. void* SMsgDirG2ClearDataObjects::Pack(void) { WTRACE("SMsgDirG2ClearDataObjects::Pack"); SetServiceType(WONMsg::SmallDirServerG2); SetMessageType(mKeyType == KT_SERVICE ? WONMsg::DirG2ServiceClearDataObjects : WONMsg::DirG2DirectoryClearDataObjects); SMsgDirG2UpdateBase::Pack(); PackKey(*this); AppendShort(mClearTypes.size()); DataObjectTypeSet::iterator anItr(mClearTypes.begin()); for (; anItr != mClearTypes.end(); anItr++) { unsigned char aLen = anItr->GetDataType().size(); AppendByte(aLen); if (aLen > 0) AppendBytes(aLen, anItr->GetDataType().data()); } PackPeerData(); return GetDataPtr(); }
// MMsgObsPublishDataPool::Pack // Virtual method from MiniMessage. Packs data into message buffer and // sets the new message length. void* MMsgObsPublishDataPool::Pack(void) { WTRACE("MMsgObsPublishDataPool::Pack"); SetServiceType(WONMsg::MiniObsServer); SetMessageType(WONMsg::ObsMsg_PublishDataPool); MiniMessage::Pack(); WDBG_LL("MMsgObsPublishDataPool::Pack Appending message data"); AppendLong(mPublisherId); Append_PA_STRING(mPublicationName); Append_PW_STRING(mPublicationDescription); AppendByte((char)mSubscriptionNotification); AppendShort(mDataLength); if (mDataLength > 0) { AppendBytes(mDataLength, mDataP); } return GetDataPtr(); }
Bool CRealSister::GenerateBody(UInt32 uLoop) { if (--uLoop == 0) { return GenerateTail(); } { Byte bytes[] = { 0x53 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } if (GenerateSeed() & 1) { if (GenerateBody(uLoop) == False) return False; } else if (GenerateBody2(uLoop) == False) return False; { Byte bytes[] = { 0x89, 0xC3 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } if (GenerateSeed() & 1) { if (GenerateBody(uLoop) == False) return False; } else if (GenerateBody2(uLoop) == False) return False; UInt32 mod = GenerateSeed() % 6; switch (mod) { case 0: { Byte bytes[] = { 0x29, 0xD8 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 1: case 2: { Byte bytes[] = { 0x51 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0x89, 0xD9 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0x83, 0xE1, 0x0F }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0xD3, mod == 2 ? 0xE0 : 0xE8 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0x59 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 3: { Byte bytes[] = { 0x0F, 0xAF, 0xC3 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 4: { Byte bytes[] = { 0xF7, 0xD8 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } case 5: { Byte bytes[] = { 0x01, 0xD8 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; } Byte bytes[] = { 0x5B }; return AppendBytes(sizeof(bytes), bytes); }
Bool CRealSister::GenerateBody2(UInt32 uLoop) { if (--uLoop == 0) return GenerateTail(); if (GenerateSeed() & 1) { if (GenerateBody(uLoop) == False) return False; } else if (GenerateBody2(uLoop) == False) return False; switch (GenerateSeed() & 7) { case 0: { Byte bytes[] = { 0xF7, 0xD8 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 1: { Byte bytes[] = { 0xBE }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { UInt32 v = (UInt32)m_EncryptBlock; if (AppendBytes(sizeof(v), &v) == False) return False; } { Byte bytes[] = { 0x25 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { UInt32 v = 0x3FF; if (AppendBytes(sizeof(v), &v) == False) return False; } { Byte bytes[] = { 0x8B, 0x04, 0x86 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 2: { Byte bytes[] = { 0x40 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 3: { Byte bytes[] = { 0xF7, 0xD0 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 4: { Byte bytes[] = { 0x48 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 5: { Byte bytes[] = { 0x53 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0x89, 0xC3 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0x81, 0xE3, 0xAA, 0xAA, 0xAA, 0xAA }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0x25, 0x55, 0x55, 0x55, 0x55 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0xD1, 0xEB }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0xD1, 0xE0 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0x09, 0xD8 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } { Byte bytes[] = { 0x5B }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; } break; case 6: { Byte bytes[] = { 0x35 }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; UInt32 v = GenerateSeed(); if (AppendBytes(sizeof(v), &v) == False) return False; } break; case 7: { Byte bytes[] = { (GenerateSeed() & 1) ? 0x05 : 0x2D }; if (AppendBytes(sizeof(bytes), bytes) == False) return False; UInt32 v = GenerateSeed(); if (AppendBytes(sizeof(v), &v) == False) return False; } break; } return True; }