示例#1
0
void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute)
{
	LLPointer<LLSpeaker> speakerp = findSpeaker(avatar_id);
	if (!speakerp) return;

	// *NOTE: mantipov: probably this condition will be incorrect when avatar will be blocked for
	// text chat via moderation (LLSpeaker::mModeratorMutedText == TRUE)
	bool is_in_voice = speakerp->mStatus <= LLSpeaker::STATUS_VOICE_ACTIVE || speakerp->mStatus == LLSpeaker::STATUS_MUTED;

	// do not send voice moderation changes for avatars not in voice channel
	if (!is_in_voice) return;

	std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest");
	LLSD data;
	data["method"] = "mute update";
	data["session-id"] = getSessionID();
	data["params"] = LLSD::emptyMap();
	data["params"]["agent_id"] = avatar_id;
	data["params"]["mute_info"] = LLSD::emptyMap();
	data["params"]["mute_info"]["voice"] = !unmute;

	LLHTTPClient::post(
		url,
		data,
		new ModerationResponder(getSessionID()));
}
示例#2
0
/**
 Sets volume of sessionId. If sessionId=-1, sets Master Volume
 */
bool setSessionVolume(const int sessionId, const float volume){
	int sessionCount = getSessionID();
	if (sessionId == -1)
		return setMasterVolume(volume);
	if (sessionId >= sessionCount || sessionId < 0) {
		//printf("session: %d / %d\n", sessionId, sessionCount);  
		errorMessage = ERRMSG_UNDEFINEDSESSIONID;
		return false;
	}
	CComPtr<IAudioSessionControl> pSessionControl;
	CComPtr<ISimpleAudioVolume> pSAV;
	// Get SessionControl
	if (FAILED(pAudioSessionEnumerator->GetSession(sessionId, &pSessionControl))){
		errorMessage = ERRMSG_SESSIONCONTROL_INIT_FAILED;
		return false;
	}
	// Ask for SimpleAudioVolume
	if (FAILED(pSessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (VOID**)&pSAV))){
		errorMessage = ERRMSG_AUDIOVOLUME_INIT_FAILED;
		return false;
	}
	//LPWSTR name;
	//pSessionControl->GetDisplayName(&name);
	//_tprintf(name);
	// adjust session volume
	errorMessage = ERRMSG_OK;
	return S_OK == pSAV->SetMasterVolume(volume, NULL);
}
示例#3
0
/**
 Returns volume of sessionId. If sessionId=-1, returns Master Volume
 */
float getSessionVolume(const int sessionId){
	CComPtr<IAudioSessionControl> pSessionControl;
	CComPtr<ISimpleAudioVolume> pSAV;
	int sessionCount = getSessionID();
	float vol; 
	if (sessionId == -1)
		return getMasterVolume();
	if (sessionId >= sessionCount || sessionId < 0) {
		//printf("session: %d / %d\n", sessionId, sessionCount);  
		errorMessage = ERRMSG_UNDEFINEDSESSIONID;
		return -1;
	}

	// Get SessionControl
	if (FAILED(pAudioSessionEnumerator->GetSession(sessionId, &pSessionControl))){
		errorMessage = ERRMSG_AUIDOSESSIONENUMERATOR_INIT_FAILED;
		return -1;
	}
	// Ask for SimpleAudioVolume
	if (FAILED(pSessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (VOID**)&pSAV))){
		errorMessage = ERRMSG_SESSIONCONTROL_INIT_FAILED;
		return -1;
	}
	//LPWSTR name;
	//pSessionControl->GetDisplayName(&name);
	//_tprintf(name);
	// adjust session volume
	pSAV->GetMasterVolume(&vol);
	
	errorMessage = ERRMSG_OK;
	return vol;
}
示例#4
0
QNetworkRequest createNetworkRequest() {

    QNetworkRequest request;

    QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL();
    requestURL.setPath(USER_ACTIVITY_URL);

    request.setUrl(requestURL);

    auto accountManager = DependencyManager::get<AccountManager>();

    if (accountManager->hasValidAccessToken()) {
        request.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER,
                             accountManager->getAccountInfo().getAccessToken().authorizationHeaderValue());
    }

    request.setRawHeader(METAVERSE_SESSION_ID_HEADER,
                         uuidStringWithoutCurlyBraces(accountManager->getSessionID()).toLocal8Bit());

    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

    request.setPriority(QNetworkRequest::HighPriority);

    return request;
}
示例#5
0
/**
 * @param outPattern only set if success is returned; points to referenced open file, so it does
 * not need to be free'd/deleted.
 */
FhgfsOpsErr LookupIntentMsgEx::open(EntryInfo* entryInfo, std::string* outFileHandleID,
   StripePattern** outPattern, PathInfo* outPathInfo)
{
   App* app = Program::getApp();
   SessionStore* sessions = app->getSessions();

   FileInode* inode;

   bool useQuota = isMsgHeaderFeatureFlagSet(LOOKUPINTENTMSG_FLAG_USE_QUOTA);

   FhgfsOpsErr openRes = MsgHelperOpen::openFile(
      entryInfo, getAccessFlags(), useQuota, getMsgHeaderUserID(), &inode);

   if(openRes != FhgfsOpsErr_SUCCESS)
      return openRes; // error occurred

   // open successful => insert session

   SessionFile* sessionFile = new SessionFile(inode, getAccessFlags(), entryInfo);

   Session* session = sessions->referenceSession(getSessionID(), true);

   *outPattern = inode->getStripePattern();
   inode->getPathInfo(outPathInfo);

   unsigned ownerFD = session->getFiles()->addSession(sessionFile);

   sessions->releaseSession(session);

   *outFileHandleID = SessionTk::generateFileHandleID(ownerFD, entryInfo->getEntryID() );

   return openRes;
}
示例#6
0
/**
 * Find out if a session is muted. -1 -> Master
 */
bool getSessionMute(const int sessionId){
	int sessionCount = getSessionID();
	if (sessionId == -1)
		return getMasterMute();
	if (sessionId >= sessionCount || sessionId < 0) {
		errorMessage = ERRMSG_UNDEFINEDSESSIONID;
		return false;
	}
	CComPtr<IAudioSessionControl> pSessionControl;
	CComPtr<ISimpleAudioVolume> pSAV;
	// Get SessionControl
	if (FAILED(pAudioSessionEnumerator->GetSession(sessionId, &pSessionControl))){
		errorMessage = ERRMSG_SESSIONCONTROL_INIT_FAILED;
		return false;
	}
	// Ask for SimpleAudioVolume
	if (FAILED(pSessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (VOID**)&pSAV))){
		errorMessage = ERRMSG_AUDIOVOLUME_INIT_FAILED;
		return false;
	}
	BOOL mute;
	pSAV->GetMute(&mute);
	errorMessage = ERRMSG_OK;
	return mute != 0; // BOOL(is int, so int->bool via not null)
}
示例#7
0
void LLIMSpeakerMgr::toggleAllowTextChat(const LLUUID& speaker_id)
{
	LLPointer<LLSpeaker> speakerp = findSpeaker(speaker_id);
	if (!speakerp) return;

	std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest");
	LLSD data;
	data["method"] = "mute update";
	data["session-id"] = getSessionID();
	data["params"] = LLSD::emptyMap();
	data["params"]["agent_id"] = speaker_id;
	data["params"]["mute_info"] = LLSD::emptyMap();
	//current value represents ability to type, so invert
	data["params"]["mute_info"]["text"] = !speakerp->mModeratorMutedText;

	LLHTTPClient::post(url, data, new ModerationResponder(getSessionID()));
}
示例#8
0
void CGoldenBetState::onStateDuringTimeUp() 
{
	// time out 
	stMsgGoldenPlayerAct act ;
	act.nPlayerAct = (uint8_t)eRoomPeerAction_GiveUp ;
	act.nValue = 0 ;
	auto pp = m_pRoom->getPlayerByIdx(m_pRoom->getCurActIdx()) ;
	assert(pp && "why current act player is null ?" );
	LOGFMTD("player not act so give up idx = %u",m_pRoom->getCurActIdx()) ;
	onMessage(&act,ID_MSG_PORT_CLIENT,pp->getSessionID());
}
示例#9
0
void LLIMSpeakerMgr::moderateVoiceAllParticipants( bool unmute_everyone )
{
	if (mVoiceModerated == !unmute_everyone)
	{
		// session already in requested state. Just force participants which do not match it.
		forceVoiceModeratedMode(mVoiceModerated);
	}
	else
	{
		// otherwise set moderated mode for a whole session.
		moderateVoiceSession(getSessionID(), !unmute_everyone);
	}
}
示例#10
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
void xDistributedSession::onGhostRemove()
{
	xNetInterface *netInterface  = getNetInterface();

	if (getNetInterface())
	{

		if(!getNetInterface()->IsServer())
		{
			xDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();
			xDistObjectIt begin = distObjects->begin();
			xDistObjectIt end = distObjects->end();

			while (begin!=end)
			{
				xDistributedObject *distObject  = *begin;
				if (distObject)
				{
					xDistributedClass *_class = distObject->getDistributedClass();
					if (_class)
					{
						if (_class->getEnitityType() == E_DC_BTYPE_CLIENT )
						{
							xDistributedClient *distClient  = static_cast<xDistributedClient*>(distObject);
							if (distClient && distClient->getSessionID() == getSessionID() )
							{
								distClient->setSessionID(-1);
								disableFlag(distClient->getClientFlags(),E_CF_SESSION_JOINED);
								enableFlag(distClient->getClientFlags(),E_CF_DELETING);
								enableFlag(distClient->getClientFlags(),E_CF_SESSION_DESTROYED);

							}
						}
					}
				}
				begin++;
			}
		}
		
		if(getNetInterface()->IsServer())
		{
			xLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION,"Server : Session is going to be deleted : %s",this->GetName().getString());
		}
		
		getNetInterface()->getDistObjectInterface()->removeObject(this);
		
	}
}
示例#11
0
void printAudioInfo(){
	int sessionCount = getSessionID();
	printf("\n\n\n\n\n\n\n\n");
	printf("################################################################################");
	printf("     Audio Sessions \n");
	printf("################################################################################");
	printf("[id] PID  - %-10s - %-50s\n","process","Main-Window Title");
	printf("--------------------------------------------------------------------------------");
	for (int sessionID(0); sessionID < sessionCount; sessionID++){
		CComPtr<IAudioSessionControl> pSessionControl;
		CComPtr<ISimpleAudioVolume> pSAV;
		CComPtr<IAudioSessionControl2> pSC2;
		// Get SessionControl
		if (FAILED(pAudioSessionEnumerator->GetSession(sessionID, &pSessionControl)))
			continue;
		// Ask for SimpleAudioVolume
		if (FAILED(pSessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (VOID**)&pSAV)))
			continue;
		// audio session 2 for extended name info
		if (FAILED(pSessionControl->QueryInterface(__uuidof(IAudioSessionControl2), (VOID**)&pSC2)))
			continue;
		LPWSTR name1,name2,icon;
		DWORD procid(0);
		float vol = 0;
		
		pSessionControl->GetDisplayName(&name1);
		pSessionControl->GetIconPath(&icon);
		pSC2->GetSessionIdentifier(&name2);
		pSC2->GetProcessId(&procid);
		
		procid = getSessionPID(sessionID);
		getPIDName(procid);
		getPIDTitle(procid);

		pSAV->GetMasterVolume(&vol);
//		printf("Session[%d] Vol[%.2f]\nDisplayName: %ls\nSessionIdentifier: %ls\nProcessId: %d\nMainWindowTitle: %s\nProcessName: %s\nIconPath: %s\n\n", i, vol, name1, name2, procid, title, procname, icon);
//		printf("Session[%d] Vol[%.2f]\nDisplayName: %ls\nProcessId: %d\nMainWindowTitle: %s\nProcessName: %s\nIconPath: %s\n\n", i, vol, name1, procid, title, procname, icon);

		//18+name+laststring
		printf("[% 2d]% 5d - %-10.10s - %-50.50s\n", sessionID, procid, g_pidName, g_pidTitle);

		CoTaskMemFree(name1); // TODO: to be done better :/
		CoTaskMemFree(name2);
		CoTaskMemFree(icon);
	}
	printf("--------------------------------------------------------------------------------");
}
示例#12
0
DWORD getSessionPID(const int sessionId){
	CComPtr<IAudioSessionControl> pSessionControl;
	CComPtr<IAudioSessionControl2> pSC2;
	int sessionCount = getSessionID();
	if (sessionId >= sessionCount || sessionId < 0) { 
		errorMessage = ERRMSG_UNDEFINEDSESSIONID;
		return NULL;
	}
	// Get SessionControl
	if (FAILED(pAudioSessionEnumerator->GetSession(sessionId, &pSessionControl))){
		errorMessage = ERRMSG_AUIDOSESSIONENUMERATOR_INIT_FAILED;
		return NULL;
	}
	// audio session 2 for extended name info
	if (FAILED(pSessionControl->QueryInterface(__uuidof(IAudioSessionControl2), (VOID**)&pSC2))){
		errorMessage = ERRMSG_SESSIONCONTROL2_INIT_FAILED;
		return NULL;
	}
	
	DWORD procid;
	pSC2->GetProcessId(&procid);
	return procid;
}
示例#13
0
void LLIMSpeakerMgr::moderateVoiceOtherParticipants(const LLUUID& excluded_avatar_id, bool unmute_everyone_else)
{
    // *TODO: mantipov: add more intellectual processing of several following requests if it is needed.
    /*
    	Such situation should be tested:
    	 "Moderator sends the same second request before first response is come"
    	Moderator sends "mute everyone else" for A and then for B
    		two requests to disallow voice chat are sent
    		UUID of B is stored.
    	Then first response (to disallow voice chat) is come
    		request to allow voice for stored avatar (B)
    	Then second response (to disallow voice chat) is come
    		have nothing to do, the latest selected speaker is already enabled

    		What can happen?
    	If request to allow voice for stored avatar (B) is processed on server BEFORE
    	second request to disallow voice chat all speakers will be disabled on voice.
    	But I'm not sure such situation is possible.
    	See EXT-3431.
    */

    mReverseVoiceModeratedAvatarID = excluded_avatar_id;
    moderateVoiceSession(getSessionID(), !unmute_everyone_else);
}
示例#14
0
/**
 Mutes/Unmutes a session. If sessionId=-1, info about master
 */
bool setSessionMute(const int sessionId, const bool mute){
	int sessionCount = getSessionID();
	if (sessionId == -1)
		return setMasterMute(mute);
	if (sessionId >= sessionCount || sessionId < 0) {
		errorMessage = ERRMSG_UNDEFINEDSESSIONID;
		return false;
	}
	CComPtr<IAudioSessionControl> pSessionControl;
	CComPtr<ISimpleAudioVolume> pSAV;
	// Get SessionControl
	if (FAILED(pAudioSessionEnumerator->GetSession(sessionId, &pSessionControl))){
		errorMessage = ERRMSG_SESSIONCONTROL_INIT_FAILED;
		return false;
	}
	// Ask for SimpleAudioVolume
	if (FAILED(pSessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (VOID**)&pSAV))){
		errorMessage = ERRMSG_AUDIOVOLUME_INIT_FAILED;
		return false;
	}

	errorMessage = ERRMSG_OK;
	return S_OK == pSAV->SetMute(mute, NULL);
}
示例#15
0
/**
 * The rest after MsgHelperClose::closeSessionFile(), i.e. MsgHelperClose::closeChunkFile()
 * and metaStore->closeFile().
 *
 * @param inode inode for closed file (as returned by MsgHelperClose::closeSessionFile() )
 * @param maxUsedNodeIndex zero-based index, -1 means "none"
 * @param outFileWasUnlinked true if the hardlink count of the file was 0
 */
FhgfsOpsErr CloseFileMsgEx::closeFileAfterEarlyResponse(FileInode* inode, unsigned accessFlags,
   bool* outUnlinkDisposalFile)
{
   MetaStore* metaStore = Program::getApp()->getMetaStore();

   unsigned numHardlinks;
   unsigned numInodeRefs;

   *outUnlinkDisposalFile = false;


   FhgfsOpsErr chunksRes = MsgHelperClose::closeChunkFile(
      getSessionID(), getFileHandleID(), getMaxUsedNodeIndex(), inode, getEntryInfo(),
      getMsgHeaderUserID() );


   metaStore->closeFile(getEntryInfo(), inode, accessFlags, &numHardlinks, &numInodeRefs);


   if (!numHardlinks && !numInodeRefs)
      *outUnlinkDisposalFile = true;

   return chunksRes;
}
示例#16
0
bool CloseFileMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock,
   char* respBuf, size_t bufLen, HighResolutionStats* stats)
{
   #ifdef BEEGFS_DEBUG
      const char* logContext = "CloseFileMsg incoming";

      std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername();
      LOG_DEBUG(logContext, Log_DEBUG, std::string("Received a CloseFileMsg from: ") + peer);
   #endif // BEEGFS_DEBUG

   App* app = Program::getApp();

   FhgfsOpsErr closeRes;
   bool unlinkDisposalFile = false;

   EntryInfo* entryInfo = getEntryInfo();

   // update operation counters (here on top because we have an early sock release in this msg)
   app->getNodeOpStats()->updateNodeOp(sock->getPeerIP(), MetaOpCounter_CLOSE,
      getMsgHeaderUserID() );


   if(isMsgHeaderFeatureFlagSet(CLOSEFILEMSG_FLAG_CANCELAPPENDLOCKS) )
   { // client requests cleanup of granted or pending locks for this handle

      unsigned ownerFD = SessionTk::ownerFDFromHandleID(getFileHandleID() );
      EntryLockDetails lockDetails(getSessionID(), 0, 0, "", ENTRYLOCKTYPE_CANCEL);

      MsgHelperLocking::flockAppend(entryInfo, ownerFD, lockDetails);
   }


   /* two alternatives:
         1) early response before chunk file close (if client isn't interested in chunks result).
         2) normal response after chunk file close. */

   if(isMsgHeaderFeatureFlagSet(CLOSEFILEMSG_FLAG_EARLYRESPONSE) )
   { // alternative 1: client requests an early response

      /* note: linux won't even return the vfs release() result to userspace apps, so there's
         usually no point in waiting for the chunk file close result before sending the response */

      unsigned accessFlags;
      FileInode* inode;

      closeRes = MsgHelperClose::closeSessionFile(
         getSessionID(), getFileHandleID(), entryInfo, &accessFlags, &inode);

      // send response
      CloseFileRespMsg respMsg(closeRes);
      respMsg.serialize(respBuf, bufLen);
      sock->sendto(respBuf, respMsg.getMsgLength(), 0,
         (struct sockaddr*)fromAddr, sizeof(struct sockaddr_in) );

      IncomingPreprocessedMsgWork::releaseSocket(app, &sock, this);

      if(likely(closeRes == FhgfsOpsErr_SUCCESS) )
         closeRes = closeFileAfterEarlyResponse(inode, accessFlags, &unlinkDisposalFile);
   }
   else
   { // alternative 2: normal response (after chunk file close)

      closeRes = MsgHelperClose::closeFile(getSessionID(), getFileHandleID(),
         entryInfo, getMaxUsedNodeIndex(), getMsgHeaderUserID(), &unlinkDisposalFile);

      // send response
      // (caller won't be interested in the unlink result below, so no reason to wait for that)

      if(unlikely(closeRes == FhgfsOpsErr_COMMUNICATION) )
      { // forward comm error as indirect communication error to client
         GenericResponseMsg respMsg(GenericRespMsgCode_INDIRECTCOMMERR,
            "Communication with storage target failed");
         respMsg.serialize(respBuf, bufLen);
         sock->sendto(respBuf, respMsg.getMsgLength(), 0,
            (struct sockaddr*)fromAddr, sizeof(struct sockaddr_in) );
      }
      else
      { // normal response
         CloseFileRespMsg respMsg(closeRes);
         respMsg.serialize(respBuf, bufLen);
         sock->sendto(respBuf, respMsg.getMsgLength(), 0,
            (struct sockaddr*)fromAddr, sizeof(struct sockaddr_in) );
      }
   }


   // unlink if file marked as disposable
   if( (closeRes == FhgfsOpsErr_SUCCESS) && unlinkDisposalFile)
   { // check whether file has been unlinked (and perform the unlink operation on last close)

      /* note: we do this only if also the chunk file close succeeded, because if storage servers
         are down, unlinkDisposableFile() will keep the file in the disposal store anyways */
      
      MsgHelperClose::unlinkDisposableFile(entryInfo->getEntryID(), getMsgHeaderUserID() );
   }
   

   return true;
}
示例#17
0
文件: opaswquery.c 项目: 01org/opa-ff
int main(int argc, char *argv[])
{
	char				*cmdName;
	const char			*opts="Dvqt:l:h:o:m:Q:i:";
	char				parameter[100];
	char				*p;
	EUI64				destPortGuid = -1;
	int					c;
	int					i;
	uint8				hfi = 0;
	uint8				port = 0;
	IB_PATH_RECORD		path;
	uint16				sessionID;
	uint32				regValue;
	uint32				fanSpeed[OPASW_PSOC_FAN_CTRL_TACHS];
	char				tempStrs[I2C_OPASW_TEMP_SENSOR_COUNT][TEMP_STR_LENGTH];
	uint32				psStatus;
	uint8				fwVersion[40];
	vpd_fruInfo_rec_t	vpdInfo;
	char				mfgID[10];
	char				mfgDate[20];
	char				mfgTime[10];
	uint8				nodeDesc[80];
	opasw_ini_descriptor_get_t tableDescriptors;
	table_parsed_data_t	*portParsedDataTable=NULL;
	uint32				numPorts;
	uint32				portEntrySize;
	uint8				memoryData[200];
	uint8				boardID;
	VENDOR_MAD			mad;
	FSTATUS				status = FSUCCESS;
	uint32				asicVersion;
	uint8				chipStep;
	uint8				chipRev;



	table_parsed_data_t	*portPtrs=NULL;
	uint32				portLinkWidthSupportedIndex;
	uint32				portLinkSpeedSupportedIndex;
	uint32				portFMEnabledIndex;
	uint32				portLinkCRCModeIndex;
	uint32				portvCUIndex;
	uint32				portExternalLoopbackAllowedIndex;
	char				portLinkCRCModeValue[35];
	char				portLinkWidthSupportedText[20];
	char				portLinkSpeedSupportedText[20];
	struct              oib_port *oib_port_session = NULL;

	// determine how we've been invoked
	cmdName = strrchr(argv[0], '/');			// Find last '/' in path
	if (cmdName != NULL) {
		cmdName++;								// Skip over last '/'
	} else {
		cmdName = argv[0];
	}

	// Initialize


	// parse options and parameters
	while (-1 != (c = getopt(argc, argv, opts))) {
		switch (c) {
			case 'D':
				g_debugMode = 1;
				oib_set_dbg(stderr);
				break;

			case 't':
				errno = 0;
				strncpy(parameter, optarg, sizeof(parameter)-1);
				parameter[sizeof(parameter)-1] = 0;
				if ((p = strchr(parameter, ',')) != NULL) {
					*p = '\0';
				}
				if (FSUCCESS != StringToUint64(&destPortGuid, parameter, NULL, 0, TRUE)) {
					fprintf(stderr, "%s: Error: Invalid GUID: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				break;

			case 'l':
#if !LIST_FILE_SUPPORTED
				fprintf(stderr, "Error: l option is not supported at this time\n");
				exit(1);
#endif
				break;

			case 'v':
				oib_set_dbg(stderr);
				g_verbose = 1;
				break;

			case 'q':
				g_quiet = 1;
				break;

			case 'h':
				if (FSUCCESS != StringToUint8(&hfi, optarg, NULL, 0, TRUE)) {
					fprintf(stderr, "%s: Error: Invalid HFI Number: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				g_gotHfi = 1;
				break;

			case 'o':
				if (FSUCCESS != StringToUint8(&port, optarg, NULL, 0, TRUE)) {
					fprintf(stderr, "%s: Error: Invalid Port Number: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				g_gotPort = 1;
				break;

			case 'Q':
				if (FSUCCESS != StringToUint8(&g_queryNum, optarg, NULL, 0, TRUE)) {
					fprintf(stderr, "%s: Error: Invalid Query Number: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				break;

			case 'i':
				if (FSUCCESS != StringToInt8(&g_intParam, optarg, NULL, 0, TRUE)
					|| g_intParam < 0) {
					fprintf(stderr, "%s: Error: Invalid integer parameter: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				break;

			default:
				usage(cmdName);
				break;

		}
	}

	// user has requested display of help
	if (argc == 1) {
		usage(cmdName);
		exit(0);
	}

	if (-1 == destPortGuid) {
		fprintf(stderr, "%s: Error: Must specify a target GUID\n", cmdName);
		exit(1);
	}

	if (g_queryNum == 0) {
		fprintf(stderr, "%s: Error: must enter a query number\n", cmdName);
		exit(1);
	}

	if ((g_queryNum == 8) && ((g_intParam > MAX_PS) || (g_intParam < MIN_PS))) {
		fprintf(stderr, "%s: Error: Query number 8 - must use -i for valid Power Supply number %d - %d\n", cmdName, MIN_PS, MAX_PS);
		usage(cmdName);
	}

	if (g_quiet && (g_debugMode || g_verbose)) {
		fprintf(stderr, "%s: Error: Can not specify both -q and -D|-v\n", cmdName);
		exit(1);
	}

	// Get the path

	status = oib_open_port_by_num(&oib_port_session, hfi, port);
	if (status != 0) {
		fprintf(stderr, "%s: Error: Unable to open fabric interface.\n", cmdName);
		exit(1);
	}

	if (getDestPath(oib_port_session, destPortGuid, cmdName, &path) != FSUCCESS) {
		fprintf(stderr, "%s: Error: Failed to get destination path\n", cmdName);
		goto err_exit;
	}

	// Send a ClassPortInfo to see if the switch is responding

	status = sendClassPortInfoMad(oib_port_session, &path, &mad);
	if (status != FSUCCESS) {
		fprintf(stderr, "%s: Error: Failed to send/rcv ClassPortInfo\n", cmdName);
		goto err_exit;
	}

	// Get a session ID

	sessionID = getSessionID(oib_port_session, &path);
	if (sessionID == (uint16)-1) {
		fprintf(stderr, "%s: Error: Failed to obtain sessionID\n", cmdName);
		status = FERROR;
		goto err_exit;
	}

	// Send the test mad

	switch (g_queryNum) {
		case 1:
			fprintf(stderr, "Error: Module type query no longer supported.\n");
			status = FERROR;
			break;

		case 2:
			status = sendRegisterAccessMad(oib_port_session, &path, &mad, sessionID, 
										   (uint8)0x6f, &regValue, 1);
			if (status != FSUCCESS) {
				fprintf(stderr, "Error: Failed to access register - status %d\n", status);
				break;
			}
			printf("Switch has booted from %s firmware image\n", (regValue & EEPROM_MASK) ? "failsafe" : "primary");
			break;

		case 3:
			status = getFwVersion(oib_port_session, &path, &mad, sessionID, fwVersion);
			if (status != FSUCCESS) {
				fprintf(stderr, "Error: Failed to acquire fw version - status %d\n", status);
				break;
			}
			printf("FW Version is %s\n", fwVersion);
			break;

		case 4:
			status = getVPDInfo(oib_port_session, &path, &mad, sessionID, OPASW_MODULE, &vpdInfo);
			if (status != FSUCCESS) {
				fprintf(stderr, "Error: Failed to access vpd info - status %d\n", status);
				break;
			}
			snprintf(mfgID, sizeof(mfgID), "%02x%02x%02x", vpdInfo.mfgID[0] & 0xff, vpdInfo.mfgID[1] & 0xff, vpdInfo.mfgID[2] & 0xff);
			snprintf(mfgDate, sizeof(mfgDate), "%d-%02d-%d", vpdInfo.mfgMonth, vpdInfo.mfgDay, vpdInfo.mfgYear + 2000);
			snprintf(mfgTime, sizeof(mfgTime), "%02d:%02d", vpdInfo.mfgHours, vpdInfo.mfgMins);
			printf("VPD \"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n",
				vpdInfo.serialNum,
				vpdInfo.partNum,
				vpdInfo.model,
				vpdInfo.version,
				vpdInfo.mfgName,
				vpdInfo.productName,
				mfgID,
				mfgDate,
				mfgTime);
			break;

		case 5:
			status = getNodeDescription(oib_port_session, &path, sessionID, nodeDesc);
			if (status != FSUCCESS) {
				fprintf(stderr, "Error: Failed to acquire node description - status %d\n", status);
				break;
			}
			printf("Node description is %s\n", nodeDesc);
			break;
		case 6:
			status = getTempReadings(oib_port_session, &path, &mad, sessionID, tempStrs);

			for (i=0; i<I2C_OPASW_TEMP_SENSOR_COUNT; i++) {
				printf("SENSOR %d: %s ", i, tempStrs[i]);
			}
			printf("\n");
			if (status != FSUCCESS) {
				fprintf(stderr, "Error: Failed to get one or more temperature readings - status %s\n",
					iba_fstatus_msg(status & 0xFF));
			}
			break;
		case 7:
			for (i = 0; i < OPASW_PSOC_FAN_CTRL_TACHS; i++) {
				status = getFanSpeed(oib_port_session, &path, &mad, sessionID,
									 (uint32)i, &fanSpeed[i]);
				if (status != FSUCCESS) {
					fprintf(stderr, "Error: Failed to get fan speed for fan %d - status %d\n", i, status);
					break;
				}
				if (g_verbose) {
					printf("Fan speed is %d\n", fanSpeed[i]);
				}
				// TODO: stl1baseboard.c only reports the speed itself, not FAST/SLOW/NORMAL, so I can't confirm that this matches
				if (fanSpeed[i] > MAX_FAN_SPEED) 
					printf("FAN %d:FAST ", i);
				else if (fanSpeed[i] < MIN_FAN_SPEED)
					printf("FAN %d:SLOW ", i);
				else
					printf("FAN %d:NORMAL ", i);
			}
			printf("\n");
			break;

		case 8:
			status = getPowerSupplyStatus(oib_port_session, &path, &mad, sessionID, g_intParam, 
										  &psStatus);
			if (status != FSUCCESS) {
				fprintf(stderr, "Error: Failed to get power supply status for ps %d - status %d\n", g_intParam, status);
				break;
			}
			switch (psStatus) {
				case PS_ONLINE:
					printf("PS %d: ONLINE\n", g_intParam);
					break;
				case PS_OFFLINE:
					printf("PS %d: OFFLINE\n", g_intParam);
					break;
				case PS_NOT_PRESENT:
					printf("PS %d: NOT PRESENT\n", g_intParam);
					break;
				case PS_INVALID:
					printf("PS %d: INVALID\n", g_intParam);
					break;
				default:  
					fprintf(stderr, "Error: Failed to get power supply status for ps %d\n", g_intParam); 
					break;
			}
			break;

		case 9:
			status = getAsicVersion(oib_port_session, &path, &mad, sessionID, &asicVersion);
			if (status != FSUCCESS) {
				fprintf(stderr, "Error: Failed to get ASIC version - status %d\n", status);
				break;
			}

			chipStep = (asicVersion & ASIC_CHIP_STEP_MASK) >> ASIC_CHIP_STEP_SHFT;
			chipRev = (asicVersion & ASIC_CHIP_REV_MASK) >> ASIC_CHIP_REV_SHFT;
			printf("ASIC Version: V");
			if (chipRev == 0) {
				switch (chipStep) {
					case ASIC_CHIP_STEP_A:
						printf("1\n");
						break;
					case ASIC_CHIP_STEP_B:
						printf("2\n");
						break;
					case ASIC_CHIP_STEP_C:
						printf("3\n");
						break;
					default:
						printf("0\n");
						break;
				}
			} else {
				printf("0\n");
			}
			break;

		case 10:
			printf("Session ID: %d\n", sessionID);
			break;
		case 11:
			{
				/* query port 2 */
				int dest_port_query=1;
				printf("Switch configuration values\n");
				status = sendIniDescriptorGetMad(oib_port_session, &path, &mad, sessionID, &tableDescriptors);
				if (status != FSUCCESS) {
					fprintf(stderr, "%s: Error: Failed to get ini descriptors - status %d\n", cmdName, status);
					goto retErr;
				}
				numPorts = getNumPorts(oib_port_session, &path, sessionID);

				if( numPorts <= 0){
					fprintf(stderr,"error in fetching port records\n");
					goto retErr;
				}
				portEntrySize = tableDescriptors.portDataLen / numPorts;
				status = sendMemAccessGetMad(oib_port_session, &path, &mad, sessionID, tableDescriptors.portDataAddr + (dest_port_query * portEntrySize), portEntrySize*4, memoryData);
				if (status != FSUCCESS) {
					printf("Mem Access MAD Failed \n");
					goto retErr;
				}

				if (g_verbose) {
					printf("MemoryData dump:\n");
					opaswDisplayBuffer((char *)memoryData, portEntrySize * 4);
				}
				portParsedDataTable = malloc(tableDescriptors.portMetaDataLen * sizeof(table_parsed_data_t));
				if(portParsedDataTable == NULL)
				{
					fprintf(stderr,"Not enough memory \n");
					goto retErr;
				}
				status = parseDataTable(&portMetaData[0], memoryData, portMetaDataSize, portParsedDataTable, 0);
				if(status != FSUCCESS) {
					fprintf(stderr," failed: parseDataTable \n");
					goto retErr;
				}
				portPtrs = portParsedDataTable;
				portLinkWidthSupportedIndex = getMetaDataIndexByField(&portMetaData[0], tableDescriptors.portMetaDataLen, "LINK_WIDTH_SUPPORTED");
				portLinkSpeedSupportedIndex = getMetaDataIndexByField(&portMetaData[0], tableDescriptors.portMetaDataLen, "LINK_SPEED_SUPPORTED");
				portFMEnabledIndex = getMetaDataIndexByField(&portMetaData[0], tableDescriptors.portMetaDataLen, "FM_ENABLED");
				portLinkCRCModeIndex = getMetaDataIndexByField(&portMetaData[0], tableDescriptors.portMetaDataLen, "LTP_CRC_MODE_SUPPORTED");
				portvCUIndex = getMetaDataIndexByField(&portMetaData[0], tableDescriptors.portMetaDataLen, "VCU");
				portExternalLoopbackAllowedIndex = getMetaDataIndexByField(&portMetaData[0], tableDescriptors.portMetaDataLen, "EXTERNAL_LOOPBACK_ALLOWED");

				status = getNodeDescription(oib_port_session, &path, sessionID, nodeDesc);
				if (status != FSUCCESS) {
					fprintf(stderr, "Error: Failed to acquire node description - status %d\n", status);
					goto retErr;
				}
#define PRINT_REC(str,fmt,arg...)  printf("        %-*s : "fmt,35,str,arg);

				StlLinkWidthToText(portPtrs[portLinkWidthSupportedIndex].val.intVal, portLinkWidthSupportedText, 20);
				StlLinkSpeedToText(portPtrs[portLinkSpeedSupportedIndex].val.intVal, portLinkSpeedSupportedText, 20);

				PRINT_REC("Link Width"," %s\n", portLinkWidthSupportedText);
				PRINT_REC("Link Speed"," %s\n", portLinkSpeedSupportedText);
				PRINT_REC("FM Enabled"," %s\n", portPtrs[portFMEnabledIndex].val.intVal ? "Yes" : "No");
				PRINT_REC("Link CRC Mode"," %s\n", StlPortLtpCrcModeVMAToText(portPtrs[portLinkCRCModeIndex].val.intVal,portLinkCRCModeValue,sizeof(portLinkCRCModeValue)));
				PRINT_REC("vCU"," %d\n", portPtrs[portvCUIndex].val.intVal);
				PRINT_REC("External Loopback Allowed"," %s\n", portPtrs[portExternalLoopbackAllowedIndex].val.intVal ? "Yes" : "No");
				PRINT_REC("Node Description"," %s\n", strlen((const char *)nodeDesc)==0?(const char *)"no description":(char *)nodeDesc);
retErr:
				if(portParsedDataTable)
					free(portParsedDataTable);
				break;
			}
		case 12:
			status = getBoardID(oib_port_session, &path, &mad, sessionID, &boardID);
			if (status != FSUCCESS) {
				fprintf(stderr, "Error: Failed to get board id - status %d\n", status);
				break;
			}
			printf("BoardID: 0x%02x\n", boardID);
			break;

		default:
			fprintf(stderr, "Error: Invalid query number %d\n", g_queryNum);
			releaseSession(oib_port_session, &path, sessionID);
			usage(cmdName);
			break;
	}

	releaseSession(oib_port_session, &path, sessionID);

	printf("opaswquery completed\n");

err_exit:
	if (oib_port_session != NULL) {
		oib_close_port(oib_port_session);
	}

	if (status == FSUCCESS)
		exit(0);
	else
		exit(1);

}
示例#18
0
bool ISitableRoom::onMessage( stMsg* prealMsg , eMsgPort eSenderPort , uint32_t nPlayerSessionID )
{
	if ( IRoom::onMessage(prealMsg,eSenderPort,nPlayerSessionID) )
	{
		return true ;
	}

	switch ( prealMsg->usMsgType )
	{
	case MSG_REQ_CUR_GAME_OFFSET:
		{
			auto pPlayer = getSitdownPlayerBySessionID(nPlayerSessionID) ;
			if ( pPlayer )
			{
				stMsgReqRobotCurGameOffsetRet msgback ;
				msgback.nCurGameOffset = pPlayer->getTotalGameOffset();
				sendMsgToPlayer(&msgback,sizeof(msgback),nPlayerSessionID) ;
				LOGFMTD("robot req cur offset = %d , uid = %u",msgback.nCurGameOffset,pPlayer->getUserUID());
			}
		}
		break;
	case MSG_ADD_TEMP_HALO:
		{
			auto pPlayer = getPlayerBySessionID(nPlayerSessionID) ;
			if ( pPlayer == nullptr )
			{
				LOGFMTE("not in room player add temp halo session id = %u",nPlayerSessionID);
				break;
			}

			//if ( pPlayer->nPlayerType == ePlayer_Normal )
			//{
			//	LOGFMTE("normal can not add temp halo");
			//	break;
			//}

			stMsgAddTempHalo* pRet = (stMsgAddTempHalo*)prealMsg ;
			if ( 0 == pRet->nTargetUID )
			{
				pRet->nTargetUID = pPlayer->nUserUID ;
			}

			auto psitpp = getSitdownPlayerByUID(pRet->nTargetUID) ;
			if ( psitpp )
			{
				psitpp->setTempHaloWeight(pRet->nTempHalo);
				LOGFMTD("uid = %u add temp halo = %u",pRet->nTargetUID,pRet->nTempHalo) ;
			}
			else
			{
				LOGFMTE("uid = %u not sit down why add temp halo",pPlayer->nUserUID);
			}
		}
		break;
	case MSG_PLAYER_SITDOWN:
		{
			stMsgPlayerSitDownRet msgBack ;
			msgBack.nRet = 0 ;

			stStandPlayer* pPlayer = getPlayerBySessionID(nPlayerSessionID) ;
			if ( !pPlayer )
			{
				LOGFMTE("palyer session id = %d ,not in this room so , can not sit down",nPlayerSessionID) ;
				msgBack.nRet = 3 ;
				sendMsgToPlayer(&msgBack,sizeof(msgBack),nPlayerSessionID) ;
				break; 
			}

			auto pp = getSitdownPlayerByUID(pPlayer->nUserUID);
			if ( pp )
			{
				LOGFMTE("session id = %d , already sit down , don't sit down again",nPlayerSessionID ) ;
				msgBack.nRet = 4 ;
				sendMsgToPlayer(&msgBack,sizeof(msgBack),nPlayerSessionID) ;
				break;
			}

			stMsgPlayerSitDown* pRet = (stMsgPlayerSitDown*)prealMsg ;
			if ( pRet->nTakeInCoin == 0 || pRet->nTakeInCoin > pPlayer->nCoin)
			{
				pRet->nTakeInCoin = pPlayer->nCoin ;
			}

			if ( pRet->nTakeInCoin < coinNeededToSitDown() )
			{
				msgBack.nRet = 1 ;
				sendMsgToPlayer(&msgBack,sizeof(msgBack),nPlayerSessionID) ;
				break; 
			}

			if ( isSeatIdxEmpty(pRet->nIdx) == false )
			{
				msgBack.nRet = 2 ;
				sendMsgToPlayer(&msgBack,sizeof(msgBack),nPlayerSessionID) ;
				break; 
			}

			auto sitDownPlayer = getReuseSitableRoomPlayerObject() ;
			sitDownPlayer->reset(pPlayer) ;
			pPlayer->nCoin -= pRet->nTakeInCoin ;
			sitDownPlayer->setCoin(pRet->nTakeInCoin) ;
			sitDownPlayer->doSitdown(pRet->nIdx) ;
			sitDownPlayer->setIdx(pRet->nIdx);
			sitDownPlayer->setState(eRoomPeer_WaitNextGame );
			m_vSitdownPlayers[pRet->nIdx] = sitDownPlayer ;

			// tell others ;
			stMsgRoomSitDown msgSitDown ;
			msgSitDown.nIdx = sitDownPlayer->getIdx() ;
			msgSitDown.nSitDownPlayerUserUID = sitDownPlayer->getUserUID() ;
			msgSitDown.nTakeInCoin = sitDownPlayer->getCoin() ;
			sendRoomMsg(&msgSitDown,sizeof(msgSitDown));

			onPlayerSitDown(sitDownPlayer) ;

			if ( pPlayer->nPlayerType == ePlayer_Robot )
			{
				LOGFMTD("robot uid = %d enter room",sitDownPlayer->getUserUID()) ;
				m_pRobotDispatchStrage->onRobotJoin(sitDownPlayer->getSessionID());
			}
		}
		break;
	case MSG_PLAYER_STANDUP:
		{
			stMsgPlayerStandUpRet msgBack ;
			msgBack.nRet = 0 ;
			auto player = getSitdownPlayerBySessionID(nPlayerSessionID) ;
			if ( player == nullptr )
			{
				msgBack.nRet = 1 ;
				sendMsgToPlayer(&msgBack,sizeof(msgBack),nPlayerSessionID) ;
				break; 
			}
			onPlayerWillStandUp(player);
		}
		break;
	default:
		return false;
	}
	return true ;
}
示例#19
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
TNL::U32 xDistributedSession::packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream)
{
	xNetInterface *netInterface  = (xNetInterface*) connection->getInterface();
	if (netInterface)
	{
		//the first time  ? : we write out all necessary attributes for the client : 
		if(stream->writeFlag(updateMask & InitialMask))
		{

			if(stream->writeFlag(true))
			{
				//write out name :
				stream->writeString(GetName().getString(),strlen(GetName().getString()));

				//retrieve its class : 
				xDistributedClass *distClass = getDistributedClass();
				if (distClass)
				{
					//write out the class name : 
					stream->writeString(distClass->getClassName().getString(),strlen(distClass->getClassName().getString()));

					//write out the class base type : 
					stream->writeInt(distClass->getEnitityType(),32);

					//write out users id :
					vtConnection *con  = (vtConnection*)connection;
					int uid = getUserID();
					stream->writeInt(getUserID(),32);

					//write out server side id  : 
					int serverID = connection->getGhostIndex(this);
					stream->writeInt(connection->getGhostIndex(this),32);
					setServerID(connection->getGhostIndex(this));

					float time = getCreationTime();
					//write out creation time
					stream->write(getCreationTime());
				//	xLogger::xLog(ELOGINFO,XL_START,"server:init pack update of %s: %f , %d , ",GetName().getString(),time,uid);
					stream->writeInt(getSessionID(),32);
					stream->writeInt(getMaxUsers(),32);
					stream->writeString(getPassword().getString(),strlen(getPassword().getString()));

					//netInterface->deploySessionClasses(connection);

				}
				setNetInterface(netInterface);
			}
		}
		/************************************************************************/
		/*																			                                                                   */
		/************************************************************************/
		stream->writeSignedInt(getUpdateBits().getMask(),32);
		//xLogger::xLog(ELOGINFO,XL_START,"server is updating ghosts %d", getUpdateBits().getMask() );
		xDistributedPropertyArrayType &props = *getDistributedPorperties();
		for (unsigned int i = 0  ;  i < props.size() ; i++ )
		{
			xDistributedProperty *prop  = props[i];
			xDistributedPropertyInfo*propInfo  = prop->getPropertyInfo();
			int blockIndex = prop->getBlockIndex();
			if (propInfo)
			{
				if (getUpdateBits().testStrict(1<<blockIndex))
				{
					prop->updateGhostValue(stream);
					//xLogger::xLog(ELOGINFO,XL_START,"server is updating ghosts %d",blockIndex);
				}
			}
		}
		//getUpdateBits().clear();
	}
	return 0;
}
示例#20
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
void xDistributedSession::removeUser(xDistributedClient *client)
{
	xNetInterface *nInterface = getNetInterface();
	if (!nInterface)
	{
		return;
	}


	xDistributedClient *myClient  = nInterface->getMyClient();
	if (client && myClient && client->getUserID() == myClient->getUserID())
	{
		myClient->setSessionID(-1);
	}

	if (client)
	{
		if (isClientJoined(client->getUserID()))
		{

			//////////////////////////////////////////////////////////////////////////
			if (client->getUserID() == getUserID())
			{
				xLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION,"Session master %d left session %d",client->getUserID(),getSessionID());
				
				if (nInterface)
				{

					//////////////////////////////////////////////////////////////////////////
					//we tag all existing users as new : 
					
					IDistributedObjects *doInterface  = nInterface->getDistObjectInterface();
					xDistributedObjectsArrayType *distObjects = nInterface->getDistributedObjects();
					xDistObjectIt begin = distObjects->begin();
					xDistObjectIt end = distObjects->end();

					while (begin!=end)
					{
						xDistributedObject *distObject  = *begin;
						if (distObject)
						{
							xDistributedClass *_class = distObject->getDistributedClass();
							if (_class)
							{
								if (_class->getEnitityType() == E_DC_BTYPE_CLIENT )
								{
									xDistributedClient *distClient  = static_cast<xDistributedClient*>(distObject);
									if (distClient && isClientJoined(distClient->getUserID()))
									{
										if (isFlagOn(distClient->getClientFlags(),E_CF_SESSION_JOINED))
										{

											//distClient->setSessionID(-1);
											disableFlag(distClient->getClientFlags(),E_CF_SESSION_JOINED);
											enableFlag(distClient->getClientFlags(),E_CF_DELETING);
											enableFlag(distClient->getClientFlags(),E_CF_SESSION_DESTROYED);
											xLogger::xLogExtro(0,"\tRemoving user %d from session",distClient->getUserID(),getSessionID());
										}
									}
								}
							}
						}
						begin++;
					}

					getClientTable().clear();
					goto ENDUPDATE;
					return;
				}
			}
		}
		if (client->getUserID() != getUserID())
		{
			enableFlag(client->getClientFlags(),E_CF_REMOVED);
			client->setSessionID(-1);
		}
		//////////////////////////////////////////////////////////////////////////
		for(int i = 0 ; i < getClientTable().size() ; i++)
		{

			std::vector<xDistributedClient*>::iterator begin = getClientTable().begin();
			std::vector<xDistributedClient*>::iterator end = getClientTable().end();
			while (begin !=end)
			{
				xDistributedClient *current = *begin;
				if (current && current->getUserID()  == client->getUserID() )
				{
                    getClientTable().erase(begin);						
				}
				begin++;
			}
		}

		goto ENDUPDATE;

		ENDUPDATE :
		xDistributedInteger *numUser= (xDistributedInteger *)getProperty(E_DC_S_NP_NUM_USERS);
		numUser->updateValue(getClientTable().size(),0);
		setNumUsers(getClientTable().size());
		int blockIndex = numUser->getBlockIndex();
		getUpdateBits().set(1<<blockIndex,true);
		setMaskBits(1<<blockIndex);
	}else
		xLogger::xLog(XL_START,ELOGERROR,E_LI_SESSION,"couldn't find client object");

	
	
}
示例#21
0
int main(int argc, char *argv[])
{
	char				*cmdName;
	const char			*opts="DvqSt:l:h:o:m:C:i:s:";
	char				parameter[100];
	char				strParameter[100];
	int32				integerParameter = 0;
	char				*p;
	EUI64				destPortGuid = -1;
	int					c;
	int					i;
	uint8				hfi = 1;
	uint8				port = -1;
	IB_PATH_RECORD		path;
	uint16				sessionID = 0;
	int32				metaIndex = -1;
	uint32				numPorts;
	uint32				linkWidth;
	uint32				linkSpeed;
	uint32				port1LinkWidth;
	uint32				fmEnabled;
	uint32				linkCRCMode;
	uint32				vCU;
	uint32				extLoopbackAllowed;
	VENDOR_MAD			mad;
	FSTATUS				status = FSUCCESS;
	uint8				nodeDescription[NODE_DESC_SIZE];
	struct              oib_port *oib_port_session = NULL;

	// determine how we've been invoked
	cmdName = strrchr(argv[0], '/');			// Find last '/' in path
	if (cmdName != NULL) {
		cmdName++;								// Skip over last '/'
	} else {
		cmdName = argv[0];
	}

	// Initialize

	strParameter[0] = '\0';


	// parse options and parameters
	while (-1 != (c = getopt(argc, argv, opts))) {
		switch (c) {
			case 'D':
				g_debugMode = 1;
				oib_set_dbg(stderr);
				break;

			case 't':
				errno = 0;
				strncpy(parameter, optarg, sizeof(parameter)-1);
				parameter[sizeof(parameter)-1] = 0;
				if ((p = strchr(parameter, ',')) != NULL) {
					*p = '\0';
				}
				if (FSUCCESS != StringToUint64(&destPortGuid, parameter, NULL, 0, TRUE)) {
					fprintf(stderr, "%s: Error: Invalid GUID: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				break;

			case 'l':
#if !LIST_FILE_SUPPORTED
				fprintf(stderr, "Error: l option is not supported at this time\n");
				exit(1);
#endif
				break;

			case 'v':
				oib_set_dbg(stderr);
				g_verbose = 1;
				break;

			case 'q':
				g_quiet = 1;
				break;

			case 'h':
				if (FSUCCESS != StringToUint8(&hfi, optarg, NULL, 0, TRUE)) {
					fprintf(stderr, "%s: Error: Invalid HFI Number: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				g_gotHfi = 1;
				break;

			case 'o':
				if (FSUCCESS != StringToUint8(&port, optarg, NULL, 0, TRUE)) {
					fprintf(stderr, "%s: Error: Invalid Port Number: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				g_gotPort = 1;
				break;

			case 'C':
				if (!g_configNum) {
					if (FSUCCESS != StringToUint8(&g_configNum, optarg, NULL, 0, TRUE)) {
						fprintf(stderr, "%s: Error: Invalid Config-option Number: %s\n", cmdName, optarg);
						usage(cmdName);
					}
				} else {
					fprintf(stderr, "%s: Error: Only one instance of -C allowed\n\n", cmdName);
					usage(cmdName);
				}
				break;

			case 's':
				g_gotStrParam = 1;
				strcpy(strParameter, optarg);
				break;

			case 'i':
				g_gotIntParam = 1;
				if (FSUCCESS != StringToInt32(&integerParameter, optarg, NULL, 0, TRUE)) {
					fprintf(stderr, "%s: Error: Invalid integer parameter: %s\n", cmdName, optarg);
					usage(cmdName);
				}
				break;

			case 'S':
				g_gotSave = 1;
				break;

			default:
				usage(cmdName);
				break;

		}
	}

	// user has requested display of help
	if (argc == 1) {
		usage(cmdName);
		exit(0);
	}

	if (-1 == destPortGuid) {
		fprintf(stderr, "%s: Error: Must specify a target GUID\n", cmdName);
		exit(1);
	}

	if (g_configNum == 0) {
		fprintf(stderr, "%s: Error: must enter a configuration option number\n", cmdName);
		exit(1);
	}

	if (g_quiet && (g_debugMode || g_verbose)) {
		fprintf(stderr, "%s: Error: Can not specify both -q and -D|-v\n", cmdName);
		exit(1);
	}

	if (!port) {
		fprintf(stderr, "%s: Error: Invalid port number, First Port is 1\n", cmdName);
		exit(1);
	}
	if (port == (uint8)-1)
		port = 0;			// first active port

	// Get the LID

	status = oib_open_port_by_num(&oib_port_session, hfi, port);
	if (status != FSUCCESS) {
		fprintf(stderr, "%s: Error: Unable to open fabric interface.\n", cmdName);
		exit(1);
	}

	if (getDestPath(oib_port_session, destPortGuid, cmdName, &path) != FSUCCESS) {
		fprintf(stderr, "%s: Error finding destination path\n", cmdName);
		status = FERROR;
		goto err_exit;
	}

	// Send a ClassPortInfo to see if the switch is responding

	status = sendClassPortInfoMad(oib_port_session, &path, &mad);
	if (status != FSUCCESS) {
		fprintf(stderr, "%s: Error: Failed to send/rcv ClassPortInfo\n", cmdName);
		goto err_exit;
	}

	// Get a session ID

	sessionID = getSessionID(oib_port_session, &path);
	if (sessionID == (uint16)-1) {
		fprintf(stderr, "%s: Error: Failed to obtain sessionID\n", cmdName);
		status = FERROR;
		goto err_exit;
	}

	// Perform the config option

	switch (g_configNum) {
		case 1:
			if (!g_gotStrParam) {
				fprintf(stderr, "%s: Error: must enter a string parameter (-s) with configuration option 1\n", cmdName);
				status = FERROR;
			} else if (strlen(strParameter) > 63) {
				fprintf(stderr, "%s: Error: Invalid node description: %s\n", cmdName, strParameter);
				status = FERROR;
			} else {
				metaIndex = getMetaDataIndexByField(systemMetaData, systemMetaDataSize, "NODE_STRING");
			}
			if (metaIndex < 0) {
				fprintf(stderr, "%s: Error: can not find NODE_STRING in metaData table\n", cmdName);
				status = FERROR;
			}
			if (status == FSUCCESS) {
				strncpy((char*)nodeDescription, strParameter, NODE_DESC_SIZE);
				nodeDescription[NODE_DESC_SIZE-1]=0;
				status = sendSysTableAccessSetMad(oib_port_session, &path, &mad, sessionID, (uint8)metaIndex, 
												  (uint8)NODE_DESC_SIZE, nodeDescription);
				if (status != FSUCCESS) {
					fprintf(stderr, "%s: Error: Failed to send/rcv SysTableAccessSet MAD\n", cmdName);
					status = FERROR;
				}
			}
			break;

		case 2:
			fprintf(stderr, "%s: Error: vendor key no longer supported\n", cmdName);
			status = FERROR;
			break;

		case 3:
			fprintf(stderr, "%s: Error: MTU Capability no longer supported\n", cmdName);
			status = FERROR;
			break;

		case 4:
			fprintf(stderr, "%s: Error: VL Capability no longer supported\n", cmdName);
			status = FERROR;
			break;

		case 5:
			if (!g_gotIntParam) {
				fprintf(stderr, "%s: Error: must enter a integer parameter (-i) with configuration option 5\n", cmdName);
				status = FERROR;
			} else if ((integerParameter < 1) || (integerParameter > 15)) {
				fprintf(stderr, "%s: Error: bad integer value %d; must be 1-1X, 2-2X, 3-2X_1X, 4-3X, 5-3_1X, 6-3X_2X, 7-3X_2X_1X, 8-4X, 9-4X_1X, 10-4X_2X, 11-4X_2X_1X, 12-4X_3X, 13-4X_3X_1X, 14-4X_3X_2X, 15-4X_3X_2X_1X\n", cmdName, integerParameter);
				status = FERROR;
			} else {
				metaIndex = getMetaDataIndexByField(&portMetaData[0], portMetaDataSize, "LINK_WIDTH_SUPPORTED");
				if (metaIndex < 0) {
					fprintf(stderr, "%s: Error: can not find LINK WIDTH SUPPORTED in metaData table\n", cmdName);
					status = FERROR;
				}
			}
			if (status == FSUCCESS) {
				numPorts = getNumPorts(oib_port_session, &path, sessionID);
				linkWidth = integerParameter;
				// make sure that port1 always has 4x enabled
				port1LinkWidth = linkWidth | 0x8;

				linkWidth = ntoh32(linkWidth);
				port1LinkWidth = ntoh32(port1LinkWidth);

				// first set port 1
				status = sendPortTableAccessSetMad(oib_port_session, &path, &mad, sessionID, 
												   (uint8)metaIndex, 1, 4, (uint8 *)&port1LinkWidth);
				if (status != FSUCCESS) {
					fprintf(stderr, "%s: Error: Failed to send/rcv PortTableAccessSet MAD for port %d\n", cmdName, 1);
					status = FERROR;
				}

				// now set ports 2 through numPorts
				for (i = 2; i <= numPorts; i++) {
					status = sendPortTableAccessSetMad(oib_port_session, &path, &mad, sessionID, 
													   (uint8)metaIndex, i, 4, (uint8 *)&linkWidth);
					if (status != FSUCCESS) {
						fprintf(stderr, "%s: Error: Failed to send/rcv PortTableAccessSet MAD for port %d\n", cmdName, i);
						status = FERROR;
					}
				}
			}
			break;

		case 7:
			if (!g_gotIntParam) {
				fprintf(stderr, "%s: Error: must enter a integer parameter (-i) with configuration option 7\n", cmdName);
				status = FERROR;
			} else if ((integerParameter < 1) || (integerParameter > 3)) {
				fprintf(stderr, "%s: Error: bad integer value %d; must be 1 for 12G, 2 for 25G, 3 for 12G/25G\n", cmdName, integerParameter);
				status = FERROR;
			} else {
				metaIndex = getMetaDataIndexByField(&portMetaData[0], portMetaDataSize, "LINK_SPEED_SUPPORTED");
				if (metaIndex < 0) {
					fprintf(stderr, "%s: Error: can not find LINK SPEED SUPPORTED in metaData table\n", cmdName);
					status = FERROR;
				}
			}
			if (status == FSUCCESS) {
				numPorts = getNumPorts(oib_port_session, &path, sessionID);
				linkSpeed = integerParameter;

				linkSpeed = ntoh32(linkSpeed);
				// set ports 1 through numPorts
				for (i = 1; i <= numPorts; i++) {
					status = sendPortTableAccessSetMad(oib_port_session, &path, &mad, sessionID, 
													   (uint8)metaIndex, i, 4, (uint8 *)&linkSpeed);
					if (status != FSUCCESS) {
						fprintf(stderr, "%s: Error: Failed to send/rcv PortTableAccessSet MAD for port %d\n", cmdName, i);
						status = FERROR;
					}
				}
			}
			break;
		case 8:
			if (!g_gotIntParam) {
				fprintf(stderr, "%s: Error: must enter an integer paramemter (-i) with configuration option 8\n", cmdName);
				status = FERROR;
			} else if ((integerParameter < 0) || (integerParameter > 1)) {
				fprintf(stderr, "%s: Error: bad integer value %d; must be 0 for disable or 1 for enable\n", cmdName, integerParameter);
				status = FERROR;
			} else {
				metaIndex = getMetaDataIndexByField(&portMetaData[0], portMetaDataSize, "FM_ENABLED");
				if (metaIndex < 0) {
					fprintf(stderr, "%s: Error: can not find FM ENABLED in metaData table\n", cmdName);
					status = FERROR;
				}
			}
			if (status == FSUCCESS) {
				numPorts = getNumPorts(oib_port_session, &path, sessionID);
				fmEnabled = integerParameter;

				fmEnabled = ntoh32(fmEnabled);
				// set ports 1 through numPorts
				for (i = 1; i <= numPorts; i++) {
					status = sendPortTableAccessSetMad(oib_port_session, &path, &mad, sessionID,
													   (uint8)metaIndex, i, 4, (uint8 *)&fmEnabled);
					if (status != FSUCCESS) {
						fprintf(stderr, "%s: Error: Failed to send/rcv PortTableAccessSet MAD for port %d\n", cmdName, i);
						status = FERROR;
					}
				}
			}
			break;
		case 9:	
			if (!g_gotIntParam) {
				fprintf(stderr, "%s: Error: must enter an integer paramemter (-i) with configuration option 9\n", cmdName);
				status = FERROR;
			} else if ((integerParameter < 0) || (integerParameter > 7)) {
				fprintf(stderr, "%s: Error: bad integer value %d; must be 0-16b, 1-14b/16b, 2-48b/16b, 3-48b/14b/16b, 4-per lane/16b, 5-per lane/14b/16b, 6-per lane/48b/16b, 7-per lane/48b/14b/16b\n", cmdName, integerParameter);
				status = FERROR;
			} else {
				metaIndex = getMetaDataIndexByField(&portMetaData[0], portMetaDataSize, "LTP_CRC_MODE_SUPPORTED");
				if (metaIndex < 0) {
					fprintf(stderr, "%s: Error: can not find CRC in metaData table\n", cmdName);
					status = FERROR;
				}
			}
			if (status == FSUCCESS) {
				numPorts = getNumPorts(oib_port_session, &path, sessionID);
				linkCRCMode = integerParameter;

				linkCRCMode = ntoh32(linkCRCMode);
				// set ports 1 through numPorts
				for (i = 1; i <= numPorts; i++) {
					status = sendPortTableAccessSetMad(oib_port_session, &path, &mad, sessionID,
													   (uint8)metaIndex, i, 4, (uint8 *)&linkCRCMode);
					if (status != FSUCCESS) {
						fprintf(stderr, "%s: Error: Failed to send/rcv PortTableAccessSet MAD for port %d\n", cmdName, i);
						status = FERROR;
					}
				}
			}
			break;
		case 10:
			if (!g_gotIntParam) {
				fprintf(stderr, "%s: Error: must enter an integer paramemter (-i) with configuration option 10\n", cmdName);
				status = FERROR;
			} else if (integerParameter < 0 || integerParameter > 7) { 
				fprintf(stderr, "%s: Error: bad integer value %d; Must be 0-7", cmdName, integerParameter);
				status = FERROR;
			} else {
				metaIndex = getMetaDataIndexByField(&portMetaData[0], portMetaDataSize, "VCU");
				if (metaIndex < 0) {
					fprintf(stderr, "%s: Error: can not find vCU in metaData table\n", cmdName);
					status = FERROR;
				}
			}
			if (status == FSUCCESS) {
				numPorts = getNumPorts(oib_port_session, &path, sessionID);
				vCU = integerParameter;

				vCU = ntoh32(vCU);
				// set ports 1 through numPorts
				for (i = 1; i <= numPorts; i++) {
					status = sendPortTableAccessSetMad(oib_port_session, &path, &mad, sessionID,
													   (uint8)metaIndex, i, 4, (uint8 *)&vCU);
					if (status != FSUCCESS) {
						fprintf(stderr, "%s: Error: Failed to send/rcv PortTableAccessSet MAD for port %d\n", cmdName, i);
						status = FERROR;
					}
				}
			}
			break;
		case 11:
			if (!g_gotIntParam) {
				fprintf(stderr, "%s: Error: must enter an integer paramemter (-i) with configuration option 11\n", cmdName);
				status = FERROR;
			} else if (integerParameter < 0 || integerParameter > 1) {
				fprintf(stderr, "%s: Error: bad integer value %d; must be 0 for disable or 1 for enable\n", cmdName, integerParameter);
				status = FERROR;
			} else {
				metaIndex = getMetaDataIndexByField(&portMetaData[0], portMetaDataSize, "EXTERNAL_LOOPBACK_ALLOWED");
				if (metaIndex < 0) {
					fprintf(stderr, "%s: Error: can not find EXTERNAL LOOPBACK ALLOWED in metaData table\n", cmdName);
					status = FERROR;
				}
			}
			if (status == FSUCCESS) {
				numPorts = getNumPorts(oib_port_session, &path, sessionID);
				extLoopbackAllowed = integerParameter;

				extLoopbackAllowed = ntoh32(extLoopbackAllowed);
				// set ports 1 through numPorts
				for (i = 1; i <= numPorts; i++) {
					status = sendPortTableAccessSetMad(oib_port_session, &path, &mad, sessionID,
													   (uint8)metaIndex, i, 4, (uint8 *)&extLoopbackAllowed);
					if (status != FSUCCESS) {
						fprintf(stderr, "%s: Error: Failed to send/rcv PortTableAccessSet MAD for port %d\n", cmdName, i);
						status = FERROR;
					}
				}
			}
			break;
		default:
			if (sessionID>0) releaseSession(oib_port_session, &path, sessionID);
			fprintf(stderr, "Error: Invalid configuration option number %d\n", g_configNum);
			usage(cmdName);
			break;
	}

	if (g_gotSave) {
		// save configuration to make change permanent
		status = sendSaveConfigMad(oib_port_session, &path, &mad, sessionID);
		if (status != FSUCCESS) {
			fprintf(stderr, "%s: Error: Failed to send/rcv SaveConfig MAD\n", cmdName);
			status = FERROR;
		}
	}

	if (sessionID>0) releaseSession(oib_port_session, &path, sessionID);

	printf("opaswconfigure completed\n");

err_exit:
	if (oib_port_session != NULL) {
		oib_close_port(oib_port_session);
	}

	if (status == FSUCCESS)
		exit(0);
	else
		exit(1);

}