// 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* 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();
}
// 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
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);
	}
}
// TMsgDirFindService::Pack
// Virtual method from TMessage.  Packs data into message buffer and
// sets the new message length.
void*
TMsgDirFindService::Pack(void)
{
	WTRACE("TMsgDirFindService::Pack");
	SetServiceType(WONMsg::DirServer);
	SetMessageType(WONMsg::DirFindService);
	TMsgDirServiceBase::Pack();

	WDBG_LL("TMsgDirFindService::Pack Appending message data");
	AppendByte(mFindMask);
	AppendByte(mRecursive ? 1 : 0);

	return GetDataPtr();
}
// TMsgAuth1Request::Pack
// Virtual method from TMessage.  Packs data into message buffer and
// sets the new message length.
void*
TMsgAuth1Request::Pack(void)
{
	WTRACE("TMsgAuth1Request::Pack");
	SetServiceType(WONMsg::Auth1PeerToPeer);
	SetMessageType(WONMsg::Auth1Request);
	TMsgAuthRawBufferBase::Pack();

	WDBG_LL("TMsgAuth1Request::Pack Appending message data");
	AppendByte(static_cast<unsigned char>(mAuthMode));
	AppendByte(static_cast<unsigned char>(mEncryptMode));
	AppendShort(mEncryptFlags);
	PackRawBuf();

	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();
}
void* MMsgRoutingCreateGroup::Pack(void)
{
	WTRACE("MMsgRoutingCreateGroup::Pack");

	SetServiceType(WONMsg::MiniRoutingServer);
	SetMessageType(WONMsg::RoutingCreateGroup);
	RoutingServerMessage::Pack();

	WDBG_LL("MMsgRoutingCreateGroup::Pack Appending message data");

	// append group name
	AppendGroupName(mGroupName);

	// append flags
	unsigned char aFlags = 0;
	if (mIsPublic)             aFlags |= 0x01;
	if (mAnnounceGroupChanges) aFlags |= 0x02;
	AppendByte(aFlags);

	// append client count
	_ASSERT(mClientList.size() <= USHRT_MAX);
	AppendShort(mClientList.size());

	// append client list
	std::list<unsigned short>::iterator itr = mClientList.begin();
	while (itr != mClientList.end())
		AppendClientId(*(itr++));

	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();
}
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);
			}
		}
	}
}
// MMsgObsAddPublisher::Pack
// Virtual method from MiniMessage.  Packs data into message buffer and
// sets the new message length.
void*
MMsgObsAddPublisher::Pack(void)
{
	WTRACE("MMsgObsAddPublisher::Pack");

	SetServiceType(WONMsg::MiniObsServer);
	SetMessageType(WONMsg::ObsMsg_AddPublisher);
	MiniMessage::Pack();

	WDBG_LL("MMsgObsAddPublisher::Pack Appending message data");
	Append_PA_STRING(mPublisherName);
	Append_PW_STRING(mPublisherDescription);
	AppendShort((short)mConnectionType);
	Append_PA_STRING(mNetAddress);
	AppendByte((char)mAccessPubsByName);
	AppendByte((char)mOnDemandPublishing);
	
	return GetDataPtr();
}
Exemple #12
0
void CBC_QRCoderBitVector::AppendBit(int32_t bit) {
  ASSERT(bit == 0 || bit == 1);
  int32_t numBitsInLastByte = m_sizeInBits & 0x7;
  if (numBitsInLastByte == 0) {
    AppendByte(0);
    m_sizeInBits -= 8;
  }
  m_array[m_sizeInBits >> 3] |= (bit << (7 - numBitsInLastByte));
  ++m_sizeInBits;
}
Exemple #13
0
void *TMsgCommProtocolReject::Pack()
{
    WTRACE("TMsgCommProtocolReject::Pack");

    TMessage::Pack();

    WDBG_LL("TMsgCommProtocolReject::Pack Appending message data");
    AppendByte( mProtocolType );

    return GetDataPtr();
}
void* MMsgRoutingGetUserList::Pack(void)
{
	WTRACE("MMsgRoutingGetUserList::Pack");

	SetServiceType(WONMsg::MiniRoutingServer);
	SetMessageType(WONMsg::RoutingGetUserList);
	RoutingServerMessage::Pack();

	AppendByte(mUserListType);

	return GetDataPtr();
}
void CBC_QRCoderBitVector::AppendBit(int32_t bit, int32_t& e) {
  if (!(bit == 0 || bit == 1)) {
    e = BCExceptionBadValueException;
    BC_EXCEPTION_CHECK_ReturnVoid(e);
  }
  int32_t numBitsInLastByte = m_sizeInBits & 0x7;
  if (numBitsInLastByte == 0) {
    AppendByte(0);
    m_sizeInBits -= 8;
  }
  m_array[m_sizeInBits >> 3] |= (bit << (7 - numBitsInLastByte));
  ++m_sizeInBits;
}
// TMsgDirGetDirContents::Pack
// Virtual method from TMessage.  Packs data into message buffer and
// sets the new message length.
void*
TMsgDirGetDirContents::Pack(void)
{
	WTRACE("TMsgDirGetDirContents::Pack");
	SetServiceType(WONMsg::DirServer);
	SetMessageType(WONMsg::DirGetDirContents);
	TMessage::Pack();

	WDBG_LL("TMsgDirGetDirContents::Pack Appending message data");
	Append_PW_STRING(mDirectoryPath);
	AppendByte(mRecursive ? 1 : 0);

	return GetDataPtr();
}
void CBC_QRCoderBitVector::AppendBits(int32_t value,
                                      int32_t numBits,
                                      int32_t& e) {
  if (numBits < 0 || numBits > 32) {
    e = BCExceptionBadNumBitsException;
    BC_EXCEPTION_CHECK_ReturnVoid(e);
  }
  int32_t numBitsLeft = numBits;
  while (numBitsLeft > 0) {
    if ((m_sizeInBits & 0x7) == 0 && numBitsLeft >= 8) {
      int32_t newByte = (value >> (numBitsLeft - 8)) & 0xff;
      AppendByte(newByte);
      numBitsLeft -= 8;
    } else {
void* MMsgRoutingAddSuccessor::Pack(void)
{
	WTRACE("MMsgRoutingAddSuccessor::Pack");

	SetServiceType(WONMsg::MiniRoutingServer);
	SetMessageType(WONMsg::RoutingAddSuccessor);
	RoutingServerMessage::Pack();

	WDBG_LL("MMsgRoutingAddSuccessor::Pack Appending message data");

	AppendClientId(mClientId);
	AppendByte(mRanking);

	return GetDataPtr();
}
void* SMsgFactRunProcess::Pack(void)
{
	WTRACE("SMsgFactRunProcess::Pack");

	SetServiceType(WONMsg::SmallFactoryServer);
	SetMessageType(WONMsg::FactRunProcess);
	SmallMessage::Pack();

	WDBG_LL("SMsgFactRunProcess::Pack Appending message data");

	Append_PA_STRING(mCommandLine);
	Append_PA_STRING(mWorkingDirectory);
	AppendByte(mRunDetached?1:0);

	return GetDataPtr();
}
void* SMsgFactStreamFile::Pack(void)
{
	WTRACE("SMsgFactStreamFile::Pack");

	SetServiceType(WONMsg::SmallFactoryServer);
	SetMessageType(WONMsg::FactStreamFile);
	SmallMessage::Pack();

	WDBG_LL("SMsgFactStreamFile::Pack Appending message data");

	Append_PA_STRING(mFilePath);
	AppendByte(mCompress?1:0);
	AppendLong(mModifyTime.dwHighDateTime);
	AppendLong(mModifyTime.dwLowDateTime);
	return GetDataPtr();
}
// SMsgDirG2SetDataObjects::Pack
// Virtual method from SmallMessage.  Packs data into message buffer.
void*
SMsgDirG2SetDataObjects::Pack(void)
{
	WTRACE("SMsgDirG2SetDataObjects::Pack");
	SetExtended(true, false);
	SetServiceType(WONMsg::SmallDirServerG2);
	SetMessageType(mKeyType == KT_SERVICE ? WONMsg::DirG2ServiceSetDataObjects : WONMsg::DirG2DirectorySetDataObjects);
	SMsgDirG2UpdateExtendBase::Pack();

	AppendByte(static_cast<unsigned char>(mSetMode));
	PackKey(*this);
	PackExtended();
	PackPeerData();

	return GetDataPtr();
}
// TMsgAuth1LoginBase::Pack
// Virtual method from TMessage.  Packs data into message buffer and
// sets the new message length.
void*
TMsgAuth1LoginBase::Pack(void)
{
	WTRACE("TMsgAuth1LoginBase::Pack");
//	SetServiceType(WONMsg::Auth1Login);
//	SetMessageType(WONMsg::Auth1LoginRequest);
	TMsgAuthRawBufferBase::Pack();

	WDBG_LL("TMsgAuth1LoginBase::Pack Appending message data");
	AppendShort(mKeyBlockId);
	AppendByte(mNeedKey ? 1 : 0);
	Append_PW_STRING(mLoginName);
	Append_PW_STRING(mCommunityName);
	Append_PW_STRING(mNicknameKey);

	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());
	}
}
// MMsgObsPublishStream::Pack
// Virtual method from MiniMessage.  Packs data into message buffer and
// sets the new message length.
void*
MMsgObsPublishStream::Pack(void)
{
	WTRACE("MMsgObsPublishStream::Pack");

	SetServiceType(WONMsg::MiniObsServer);
	SetMessageType(WONMsg::ObsMsg_PublishStream);
	MiniMessage::Pack();

	WDBG_LL("MMsgObsPublishStream::Pack Appending message data");

	AppendLong(mPublisherId);
	Append_PA_STRING(mPublicationName);
	Append_PW_STRING(mPublicationDescription);
	AppendByte((char)mSubscriptionNotification);

	return GetDataPtr();
}
Exemple #25
0
void DataSerializer::AppendBits(u32 value, int amount)
{
	const u8 *bytes = reinterpret_cast<const u8*>(&value);
	while(amount >= 8)
	{
		AppendByte(*bytes);
		++bytes;
		amount -= 8;
	}

	u8 remainder = *bytes & LSB(amount);

	data[elemOfs] = (data[elemOfs] & LSB(bitOfs)) | ((remainder & LSB(8-bitOfs)) << bitOfs);
	if (bitOfs + amount >= 8)
		data[++elemOfs] = remainder >> (8-bitOfs);

	bitOfs = (bitOfs + amount) & 7;
}
void* MMsgRoutingDeleteDataObject::Pack(void)
{
	WTRACE("MMsgRoutingDeleteDataObject::Pack");

	SetServiceType(WONMsg::MiniRoutingServer);
	SetMessageType(WONMsg::RoutingDeleteDataObject);
	RoutingServerMessage::Pack();

	WDBG_LL("MMsgRoutingDeleteDataObject::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());

	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();
}
void* RoutingServerGenericFlagMessage::Pack(void)
{
	WTRACE("RoutingServerGenericFlagMessage::Pack");
	RoutingServerFlagMessage::Pack();

	WDBG_LL("RoutingServerGenericFlagMessage::Pack Appending message data");

	AppendByte(mContentType);
	switch (mContentType)
	{
		case CONTENTTYPE_CLIENTID:
			AppendClientId(mClientId); break;
		case CONTENTTYPE_CLIENTNAME:
			AppendClientName(mClientName); break;
		case CONTENTTYPE_WONUSERID:
			AppendLong(mWONUserId); break;
	}

	return GetDataPtr();
}
void* TMsgFactStatusReply::Pack(void){

	WTRACE("TMsgFactStatusReply::Pack");

	SetServiceType(WONMsg::FactoryServer);
	SetMessageType(WONMsg::FactStatusReply);
	TMessage::Pack();

	WDBG_LL("TMsgFactStatusReply::Pack Appending message data");
	AppendShort(mProcessStatus);

	AppendByte(mProcessPortIDSet.size());
	for(FACT_SERV_PORT_RANGE_SET::iterator aPortIterator(mProcessPortIDSet.begin());
		aPortIterator != mProcessPortIDSet.end(); aPortIterator++){

		AppendShort(*aPortIterator);

	}

	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();
}