RioSession Class Reference

#include <SessionManager.h>

Private Member Functions

 RioSession (CSessionManager *mgr)
 RioSession (CSessionManager *mgr, SOCKADDR_IN remoteAddress)
 ~RioSession ()
void * checkid (int id, idtype type)
void ** newid (int *id, idtype type)
int ObjectToPath (char *ObjectName, char *RioPath, int PathSize)
int Open (char *Username, char *Password)
int ChangeDir (char *Dir)
int GetCurrentDir (int size, char *Dir)
int Close ()
int CreateObject (char *ObjectName, short Type)
int DeleteObject (char *ObjectName)
int RenameObject (char *CurrentName, char *NewName)
int GetObjectInfo (char *ObjectName, ObjectInfo *ObjectInfo)
int GetBlockSize (unsigned int *BlockSize)
int GetRemoteAddress (SOCKADDR_IN *Address)
int GetNumberOfDisks (unsigned int *NumberOfDisks)
int GetNumberOfStorageNodes (unsigned int *NumberOfStorageNodes)
int GetStorageNodeInfo (unsigned int StorageNodeIndex, RioStorageNodeInfo *StorageNodeInfo)
int GetNumberOfActiveAndMaxSessions (unsigned int *NumberOfActiveSessions, unsigned int *NumberOfMaxSessions)
int RemoveIdEntryFromTable (int ObjectId, idtype type)
int SaveMeasures ()
int GetMonitorTable (vector< ClientData > &clientTable, vector< StorageData > &storageTable)
int FirstObject (char *DirectoryName, int *dirid, int *IsDirectory, int BufferSize, char *ObjectName)
int OpenStream (RioStreamTraffic *Traffic, int *StreamId)
int StreamOpenObject (int StreamId, char *ObjectName, RioAccess Access, int *StreamObjId)
int StreamOpenObject (int StreamId, char *ObjectName, struct timeval RTT_average, int BufferSize, RioAccess Access, int *StreamObjId)
int ClientCanStart (int StreamId)
int CloseStream (int StreamId)
int StreamMaxRequests (int StreamId)
int NextObject (int DirectoryId, int *IsDirectory, int BufferSize, char *ObjectName)
int GetSize (int ObjectId, RioObjectSize *ObjectSize)
int SetSize (int ObjectId, RioObjectSize ObjectSize, char *md5sum, unsigned long long int ExcludeStorages)
int GetType (int ObjectId, short *Type)
int GetnBlocks (int ObjectId, RioBlock *nBlocks)
int CloseObject (int ObjectId)
 Funcao CloseObject: fecha um objeto que foi anteriormente aberto pelo cliente conectado nesta sessao do Servidor RIO dada pela classe.
int DataRequest (u32 reqid, u32 ipaddr, u32 objid, u32 block, u32 repbits, u16 port, u16 operation)
int ExecuteCall (unsigned int Class, unsigned int Method, char *Parameter, unsigned int ParameterSize, char **Result, unsigned int *ResultSize)
int ExecuteSessionManager (unsigned int Method, char *Parameter, unsigned int ParameterSize, char **Result, unsigned int *ResultSize)
int ExecuteStreamManager (unsigned int Method, char *Parameter, unsigned int ParameterSize, char **Result, unsigned int *ResultSize)
int ExecuteObjectManager (unsigned int Method, char *Parameter, unsigned int ParameterSize, char **Result, unsigned int *ResultSize)
int ExecuteRouter (unsigned int Method, char *Parameter, unsigned int ParameterSize, char **Result, unsigned int *ResultSize)
int ExecuteUserManager (unsigned int Method, char *Parameter, unsigned int ParameterSize, char **Result, unsigned int *ResultSize)
int GetVideoRate (int ObjectId, unsigned int *VideoRate)
 GetVideoRate funcao usada pela implementacao controle de fluxo para obter a taxa de transmissao do video (esta funcao sera usada pelo novo metodo remoto da Object Manager, que sera usado pelo riosh para ler a taxa de transmissao do video).
int SetVideoRate (int ObjectId, unsigned int VideoRate)
 SetVideoRate funcao usada pela implementacao controle de fluxo para alterar a taxa de transmissao do video (esta funcao sera usada pelo novo metodo remoto da Object Manager, que sera usado pelo riosh para alterar a taxa de transmissao do video).
int ReallocBlocks (int ObjectId, unsigned int Block, unsigned long long int ExcludeStorages)
 Funcao usada para realocar os blocos fisicos associados ao bloco logico de um objeto.
int SaveLogLine (const char *StrInfo, const char *ObjectName)
 Funcao usada para armazenar uma linha no log do servidor de despacho.
int SearchLogsRequest (u32 searchtype, time_t starttime, time_t endtime, u32 serveripaddr, u16 serverport, u32 clientipaddr, u16 clientport, u32 reqid)
 Nova funcao para solicitar uma busca em um conjunto de logs de um dos servidores.
int SearchResultDataRequest (u32 serveripaddr, u16 serverport, u32 clientipaddr, u16 clientport, u64 resultfileid, u32 block, u32 reqid)
 Nova funcao para ler um bloco do arquivo com os resultados da busca.
int RemoveSearchResultFile (u32 serveripaddr, u16 serverport, u64 resultfileid)
 Nova funcao para informar ao servidor que o arquivo com o resultado da busca pode ser removido.
int CreateUser (char *UserName, char *Password)
 Nova funcao para criar um novo usuario.
int RemoveUser (char *UserName)
 Nova funcao para remover um dos usuarios do RIO.
int ChangePassword (char *UserName, char *Password)
 Nova funcao para alterar a senha de um dos usuarios do RIO.
int GetUserList (vector< string > &UserList)
 Nova funcao para obter a lista com todos os usuarios.

Private Attributes

CSessionManagers_mgr
RioUsers_user
int s_id
identry s_idtable [s_idmax]
char s_CurrentDir [MaxPathSize+100]
bool m_alreadyClosed
SOCKADDR_IN s_remoteAddress
NATData s_ServerNat

Static Private Attributes

static const unsigned int s_idmax = 50

Friends

class CSessionManager

Detailed Description

Definition at line 92 of file server/SessionManager.h.


Constructor & Destructor Documentation

RioSession::RioSession ( CSessionManager mgr  )  [private]

Definition at line 1019 of file server/SessionManager.cpp.

01020 {
01021     unsigned int i;
01022 
01023     s_CurrentDir[ 0 ] = '\0';
01024     m_alreadyClosed = false;
01025     memset( (char *)&s_remoteAddress, 0, sizeof( SOCKADDR_IN ) );
01026     s_mgr  = mgr;
01027     s_user = NULL;  // set by logon
01028     s_id   = -1;
01029 
01030     for( i = 0; i < s_idmax; i++ )
01031     {
01032         s_idtable[i].id_type   = idt_invalid;
01033         s_idtable[i].id_object = 0;
01034     }
01035     
01036     // Inicializa o endereco de envio de informacoes de estado e dados de busca
01037     // nos logs do cliente para o servidor de gerenciamento.
01038     s_ServerNat.nat_addr = 0;
01039     s_ServerNat.nat_port = 0;
01040 }

RioSession::RioSession ( CSessionManager mgr,
SOCKADDR_IN  remoteAddress 
) [private]

Definition at line 1044 of file server/SessionManager.cpp.

01045 {
01046     unsigned int i;
01047 
01048     s_CurrentDir[ 0 ] = '\0';
01049     m_alreadyClosed = false;
01050     s_remoteAddress = remoteAddress;
01051     s_mgr  = mgr;
01052     s_user = NULL;  // set by logon
01053     s_id   = -1;
01054 
01055     for( i = 0; i < s_idmax; i++ )
01056     {
01057         s_idtable[i].id_type   = idt_invalid;
01058         s_idtable[i].id_object = 0;
01059     }
01060 }

RioSession::~RioSession (  )  [private]

Definition at line 1063 of file server/SessionManager.cpp.

01064 {
01065     Close();
01066 }


Member Function Documentation

int RioSession::ChangeDir ( char *  Dir  )  [private]

Definition at line 5109 of file server/SessionManager.cpp.

05110 {
05111     int rc;
05112     char newdir[MaxPathSize + 1];
05113 
05114     // convert input to full RIO path name
05115     rc = ObjectToPath( Dir, newdir, sizeof( newdir ));
05116     if( rc )
05117         return rc;
05118 
05119     rc = s_user->CheckAccess( newdir );
05120     if( rc == 0 )
05121     {
05122         rc = s_mgr->m_ObjectManager->ExistDirectory( newdir );
05123         if( rc )
05124             return rc;
05125     }
05126     else
05127         return rc;
05128 
05129     strcpy( s_CurrentDir, newdir );
05130     return S_OK;
05131 }

int RioSession::ChangePassword ( char *  UserName,
char *  Password 
) [private]

Nova funcao para alterar a senha de um dos usuarios do RIO.

Parameters:
UserName ponteiro para o nome do usuario.
Password pontrito para a senha do usuario.
Returns:
S_OK se o a senha fou alterada com sucesso ou o codigo de erro caso nao tenha sido possivel alterar a senha do usuario.

Definition at line 4743 of file server/SessionManager.cpp.

04744 {
04745     // Armazena o ponteiro o nome do usuario associado a sessao, que atualmente
04746     // e igual ao diretorio padrao do usuario. Se depois mudarmos isso,
04747     // precisamos criar em RioUser um novo campo com o nome do usuario.
04748     char *SessionUserName;
04749 
04750     // Obtem o "nome" do usuario.
04751     s_user->GetUser( &SessionUserName );
04752 
04753     // O usuario root podera alterar qualquer senha de qualquer usuario, mas um
04754     // usuario somente podera alterar a sua propria senha.
04755     if( ( strcmp( SessionUserName, "root" ) != 0 ) &&
04756         ( strcmp( UserName, SessionUserName ) != 0 ) )
04757     {
04758         return ERROR_RIOSESSION + ERROR_PERMISSION_DENIED;
04759     }
04760 
04761     // Verifica se o usuario que desejamos mudar a senha e o guest. Neste caso,
04762     // temos um erro porque este usuario nao tem uma senha.
04763     if( strcmp( UserName, "guest" ) == 0 )
04764     {
04765         return ERROR_RIOSESSION + ERROR_INVALID_USER;
04766     }
04767 
04768     // Primeiramente verifica se a senha e muito grande (maior do que
04769     // MAXPASSWORDSIZE caracteres).
04770     if( strlen( Password ) > MAXPASSWORDSIZE )
04771     {
04772         return ERROR_RIOSESSION + ERROR_INVALID_PARAM;
04773     }
04774 
04775     return s_mgr->m_UserManager->ChangePassword( UserName, Password );
04776 }

void * RioSession::checkid ( int  id,
idtype  type 
) [private]

Definition at line 1207 of file server/SessionManager.cpp.

01208 {
01209     if( ( unsigned ) id > ( unsigned ) s_idmax )
01210     {
01211         RioErr << " Session " << this << " Error: id (" << id
01212                << ") > s_idmax (" << s_idmax << ")"
01213                << endl;
01214         return 0;
01215     }
01216     if( s_idtable[id].id_type != type )
01217     {
01218         return 0;
01219     }
01220     return s_idtable[id].id_object;
01221 }

int RioSession::ClientCanStart ( int  StreamId  )  [private]

Definition at line 3269 of file server/SessionManager.cpp.

03270 {
03271     RioStream *sp = ( RioStream * )checkid( StreamId, idt_stream );
03272     if( sp == 0 )
03273     {
03274         return ERROR_SESSIONMANAGER + ERROR_INVALID_STREAM;
03275     }
03276 
03277     return ( sp->ClientCanStart() );
03278 }

int RioSession::Close ( void   )  [private]

Definition at line 1099 of file server/SessionManager.cpp.

01100 {
01101     unsigned int i;
01102 
01103     if( m_alreadyClosed == false )
01104     {
01105         m_alreadyClosed = true;
01106     }
01107     else
01108     {
01109         return S_OK;
01110     }
01111     // ------------------------------------------------------------------------
01112 
01113     #ifdef RIO_DEBUG2
01114     struct in_addr clientip;
01115     clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01116     s_mgr->m_log    << " ip: " << inet_ntoa(clientip)
01117                     << " port: " <<  htons( s_remoteAddress.sin_port )
01118                     << " Closing Session." << endl;
01119     #endif
01120     // ------------------------------------------------------------------------
01121 
01122     #ifdef RIO_DEBUG2
01123     // Imprime os mapeamentos.
01124     s_mgr->m_Router->PrintNATMapping();
01125     #endif
01126 
01127     // Remove os pares IP, porta do mapa com os mapeamentos do NAT.
01128     if( s_ServerNat.nat_addr != 0 )
01129     {
01130         // Note que o numero e o numero de servidores de armazanemento mais 1, 
01131         // pois tambem armazenamos o mapeamento para o servidor de 
01132         // gerenciamento.
01133         for( unsigned int i = 0; i <= s_mgr->m_NumberOfStorageNodes; i++ )
01134             s_mgr->m_Router->RemoveNATMapping( s_ServerNat, i );
01135         // Verifica se precisamos remover as novas entradas associadas aos novos
01136         // mapeamentos. Note que somente os clientes conectados que usam a nova
01137         // implementacao tem estas entradas, por isso, precisamos verificar a
01138         // existencia de uma (no caso, a primeira) das entradas.
01139         if( s_mgr->m_Router->FindNATMapping( s_ServerNat,
01140             s_mgr->m_NumberOfStorageNodes + 1 ) )
01141         {
01142             for( unsigned int i = s_mgr->m_NumberOfStorageNodes + 1;
01143                  i <= ( 2 * s_mgr->m_NumberOfStorageNodes + 1); i++ )
01144                 s_mgr->m_Router->RemoveNATMapping( s_ServerNat, i );
01145 
01146         }
01147     }
01148     
01149     #ifdef RIO_DEBUG2
01150     // Imprime os mapeamentos.
01151     s_mgr->m_Router->PrintNATMapping();
01152     #endif
01153 
01154     // close all directories
01155     for( i = 0; i < s_idmax; i++ )
01156     {
01157         if( s_idtable[i].id_type == idt_directory )
01158         {
01159             CloseObject(i);
01160         }
01161     }
01162     // close all streamobj
01163     for( i = 0; i < s_idmax; i++ )
01164     {
01165         if( s_idtable[i].id_type == idt_streamobj )
01166         {
01167             CloseObject(i);
01168         }
01169     }
01170 
01171     // close all streams
01172     for( i = 0; i < s_idmax; i++ )
01173     {
01174         if( s_idtable[i].id_type == idt_stream )
01175         {
01176             CloseStream(i);
01177         }
01178     }
01179 
01180     if( s_user != 0 )
01181     {
01182         delete s_user;// free RioUser
01183         s_user = 0;
01184     }
01185 
01186     // release global sesison id now
01187     if( s_id != -1 )
01188     {
01189         pthread_mutex_lock( &s_mgr->m_mutex );
01190         s_mgr->m_used--;
01191         // Salva uma linha no log, para informar que o cliente fechou a sessao.
01192         SaveLogLine( "Disconnected", "<<close session>>" );
01193         s_mgr->m_SessionTable[s_id].Session.Index = -1;
01194         s_mgr->m_SessionTable[s_id].Session.Version = 0;
01195         s_mgr->m_SessionTable[s_id].s_ptr = 0;
01196         s_id = -1;
01197         pthread_mutex_unlock(&s_mgr->m_mutex);
01198     }
01199 
01200     return S_OK;
01201 }

int RioSession::CloseObject ( int  ObjectId  )  [private]

Funcao CloseObject: fecha um objeto que foi anteriormente aberto pelo cliente conectado nesta sessao do Servidor RIO dada pela classe.

Parameters:
ObjectId Valor identificando o objeto dentre todos os objetos abertos na sessao.
Returns:
Erro se o valor for diferente de S_OK.

Definition at line 5196 of file server/SessionManager.cpp.

05197 {
05198     RioStreamObj *op = (RioStreamObj *) checkid( ObjectId, idt_streamobj);
05199 
05200     #ifdef USE_GRID
05201     // Vari�veis usadas pela implementa��o da cache.
05202     // String que armazenar� o nome do arquivo (com o caminho completo)
05203     // associado ao objeto RioObject de um objeto RioStreamObj que desejamos
05204     // fechar.
05205     char         ObjectName[ 2*MaxPathSize+1 ];
05206     // Ponteiro usado para obter, internamente no caminho do arquivo dado por
05207     // ObjectName, o caminho no sistema de arquivos do Servidor RIO (basta
05208     // desconsiderarmos o primeiro componente do caminho).
05209     char        *RioObjectName;
05210     // Vari�vel usada para armazenar o retorno das fun��es.
05211     int          status;
05212     // Estrutura usada para obter os atributos do arquivo a ser fechado.
05213     struct stat  FileStat;
05214     // Variavel usasa para verificar se precisamos deletar o objeto.
05215     bool DeleteStreamObj;
05216     #else
05217     char         ObjectName[ 2*MaxPathSize+1 ];
05218     char        *RioObjectName;
05219     // Variavel usasa para verificar se precisamos deletar o objeto.
05220     bool DeleteStreamObj;
05221     #endif
05222 
05223     if( op == 0 )
05224     {
05225         // Perhaps it's a Directory, not a StreamObj. 
05226         RioDirectory *dp = (RioDirectory *) checkid( ObjectId, idt_directory );
05227         if( dp == 0 )
05228         {
05229             return ERROR_SESSIONMANAGER + ERROR_INVALID_OBJECT_HANDLE;
05230         }
05231         dp->Close();
05232         delete dp;
05233         s_idtable[ ObjectId ].id_type = idt_invalid;
05234         s_idtable[ ObjectId ].id_object = 0;
05235         return S_OK;
05236     }
05237 
05238     #ifdef USE_GRID
05239     // Obt�m o nome do arquivo associado ao objeto do objeto da classe
05240     // RioStreamObj apontado por op (usamos a nova fun��o GetObjectName da
05241     // classe RioStreamObj para obter este nome).
05242     op->GetObjectName( ObjectName );
05243     // Remove a parte inicial do caminho (deve ser igual a m_FileRoot) mais a "/"
05244     // ao final.
05245     RioObjectName = &ObjectName[ strlen( s_mgr->m_FileRoot ) + 1 ];
05246     if( RioObjectName == NULL )
05247         // Este erro n�o derevia ocorrer, pois o caminho deve ter pelo menos
05248         // dois componentes.
05249         return ERROR_SESSIONMANAGER + ERROR_UNEXPECTED;
05250 
05251     // Preenche a estrutura FileStat com os atributos do arquivo cujo nome do
05252     // caminho, relativo ao diret�rio do Servidor RIO, desejamos fechar.
05253     status = stat( ObjectName, &FileStat );
05254 
05255     if( status )
05256         // Como n�o foi poss�vel obter os atributos do arquivo, deveremos
05257         // retornar um erro.
05258         return ERROR_SESSIONMANAGER + ERROR_UNEXPECTED;
05259 
05260     // Atualiza o tempo do �ltimo acesso do objeto na lista com os arquivos que
05261     // est�o na cache, ordenada pelo tempo de �ltimo acesso.
05262     status = s_mgr->m_ObjectManager->ChangeLastAccess( RioObjectName,
05263                                                        FileStat.st_atime );
05264 
05265     if( status )
05266         // Como n�o foi poss�vel atualizar o tempo de �ltimo acesso do arquivo,
05267         // e nem decrementar o seu contador de refer�ncias, deveremos retornar
05268         // um erro.
05269         return status;
05270 
05271     // Imprime a altera��o do tempo de �ltimo acesso do arquivo no log
05272     // RIOSessionManager.log da classe RioSession, se este estiver habilitado.
05273     if( s_mgr->m_log.is_open() ) 
05274         s_mgr->m_log << "RioSession::CloseObject Object " << ObjectName  
05275                      << ", FileName = /" << RioObjectName << " closed. "
05276                      << "Last Access Time = " <<  FileStat.st_atime << endl;
05277 
05278     // Usada para depurar o c�digo (mostra a lista com todos os arquivos que
05279     // est�o na cache).
05280     s_mgr->m_ObjectManager->PrintFileList();
05281 #else
05282     // Obt�m o nome do arquivo associado ao objeto do objeto da classe
05283     // RioStreamObj apontado por op (usamos a nova fun��o GetObjectName da
05284     // classe RioStreamObj para obter este nome).
05285     op->GetObjectName( ObjectName );
05286     // Remove a parte inicial do caminho (deve ser igual a m_FileRoot) mais a "/"
05287     // ao final.
05288     RioObjectName = &ObjectName[ strlen( s_mgr->m_FileRoot ) + 1 ];
05289     #endif
05290 
05291     op->Close( &DeleteStreamObj );
05292     s_idtable[ ObjectId ].id_type   = idt_invalid;
05293     s_idtable[ ObjectId ].id_object = 0;
05294 
05295     // O objeto do tipo RioStreamObj deve ser deletado aqui somente se todas as
05296     // mensagens de termino das requisicoes executadas sobre o stream ja foram
05297     // processadas. Caso isso nao tenha ocorrido, o objeto somente devera ser
05298     // deletado quando a ultima mensagem for recebida.
05299     if( DeleteStreamObj )
05300     {
05301         //RioErr << "RioSession::CloseObject deletando o objeto RioStreamObj "
05302         //     << "cujo ponteiro e igual a 0x " << hex << ( unsigned long ) op
05303         //     << dec << "." << endl;
05304         delete op;
05305     }
05306 
05307     struct in_addr clientip;
05308     clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
05309 
05310     DisconnectEvent *it_event = new DisconnectEvent( inet_ntoa(clientip),
05311             htons( s_remoteAddress.sin_port ), RioObjectName );
05312     s_mgr->PostITEvent( (MonitorEvent *)it_event );
05313 
05314     // Gera o log do objeto fechado pelo cliente. Devemos fazer isso no final, 
05315     // isto e, somente se a abertura tiver sucesso?
05316 
05317     SaveLogLine( "Close", &ObjectName[ strlen( s_mgr->m_FileRoot ) ] );
05318 
05319     return S_OK;
05320 }

int RioSession::CloseStream ( int  StreamId  )  [private]

Definition at line 3227 of file server/SessionManager.cpp.

03228 {
03229     RioStream *sp = ( RioStream * )checkid( StreamId, idt_stream );
03230     if( sp == 0 )
03231     {
03232         return ERROR_SESSIONMANAGER + ERROR_INVALID_STREAM;
03233     }
03234 
03235     RioStream *stream;
03236 
03237     // Close any open object in stream
03238     // Search in table for objects beinting to this stream
03239     for( unsigned int i = 0; i < s_idmax; i++ )
03240     {
03241         if( s_idtable[i].id_type == idt_streamobj )
03242         {
03243             stream = ((RioStreamObj *)(s_idtable[i].id_object))->Stream();
03244             if( stream == sp )
03245                 CloseObject(i);
03246         }
03247     }
03248     sp->Close();
03249     s_idtable[StreamId].id_type = idt_invalid;
03250     s_idtable[StreamId].id_object = 0;
03251 
03252     return S_OK;
03253 }

int RioSession::CreateObject ( char *  ObjectName,
short  Type 
) [private]

Definition at line 4858 of file server/SessionManager.cpp.

04859 {
04860     int rc;
04861     char Path[MaxPathSize + 1];
04862 
04863     // convert object name to Rio Path
04864     rc = ObjectToPath( ObjectName, Path, sizeof( Path ));
04865     if( rc )
04866         return rc;
04867 
04868     rc = s_user->CheckAccess( Path, 1 );
04869     if( rc == 0 )
04870         rc = s_mgr->m_ObjectManager->Create( Path, Type );
04871 
04872     return rc;
04873 }

int RioSession::CreateUser ( char *  UserName,
char *  Password 
) [private]

Nova funcao para criar um novo usuario.

Parameters:
UserName ponteiro para o nome do usuario.
Password pontrito para a senha do usuario.
Returns:
S_OK se o usuario foi criado com sucesso ou o codigo de erro caso o usuario nao tenha sido criado com sucesso.

Definition at line 4674 of file server/SessionManager.cpp.

04675 {
04676     // Armazena o ponteiro o nome do usuario associado a sessao, que atualmente
04677     // e igual ao diretorio padrao do usuario. Se depois mudarmos isso,
04678     // precisamos criar em RioUser um novo campo com o nome do usuario.
04679     char *SessionUserName;
04680 
04681     // Obtem o "nome" do usuario.
04682     s_user->GetUser( &SessionUserName );
04683 
04684     // Verifica se o usuario associado a sessao e o root, pois somente ele pode
04685     // criar um novo usuario no RIO
04686     if( strcmp( SessionUserName, "root" ) != 0 )
04687     {
04688         return ERROR_RIOSESSION + ERROR_PERMISSION_DENIED;
04689     }
04690 
04691     // Verifica se o usuario a ser criado e o usuario guest. Este usuario nao
04692     // pode ser criado.
04693     if( ( strcmp( UserName, "guest" ) == 0 ) ||
04694         ( strcmp( UserName, "root" ) == 0 ) ||
04695         ( strcmp( UserName, "var" ) == 0 ) ||
04696         ( strcmp( UserName, "etc" ) == 0 ) )
04697     {
04698         return ERROR_RIOSESSION + ERROR_INVALID_USER;
04699     }
04700 
04701     // Primeiramente verifica se a senha e muito grande (maior do que
04702     // MAXPASSWORDSIZE caracteres).
04703     if( strlen( Password ) > MAXPASSWORDSIZE )
04704     {
04705         return ERROR_RIOSESSION + ERROR_INVALID_PARAM;
04706     }
04707 
04708     return s_mgr->m_UserManager->CreateUser( UserName, Password );
04709 }

int RioSession::DataRequest ( u32  reqid,
u32  ipaddr,
u32  objid,
u32  block,
u32  repbits,
u16  port,
u16  operation 
) [private]

Definition at line 1247 of file server/SessionManager.cpp.

01249 {
01250     RioStreamObj *op;
01251 
01252     #ifdef RIO_DEBUG2
01253     unsigned long long int      curTime;/* actual time in miliseconds */
01254     struct timeval          arriv_time; /* current time           */
01255     struct in_addr          LocalIPaddress;
01256     LocalIPaddress.s_addr = ipaddr;
01257     gettimeofday( &arriv_time, NULL );
01258     curTime = arriv_time.tv_sec * 1000000 + arriv_time.tv_usec;
01259 
01260     RioErr << "RioSession.DataRequest: "
01261            << " ipaddr "    << inet_ntoa(LocalIPaddress )
01262            << " port "      << ntohs( port )
01263            << " reqid "     << reqid
01264            << " objid "     << objid
01265            << " block "     << block
01266            << " operation " << operation
01267            << " curTime "   << curTime << endl;
01268     #endif
01269 
01270     // ### the following code duplicates the code in checkid.
01271     // also at entry to checkid need to somehow lock
01272     // the idt table so it can't change (perhaps it's
01273     // currently locked as all changes happen on the
01274     // thread for this session?)
01275     // ### once have found correct RioStreamObj need
01276     //     to get a "bind" (a non-thread type lock)
01277     //     on it so it can't go away until this I/O is
01278     //     complete (either worked or failed).
01279 
01280     if( objid > RioSession::s_idmax )
01281     {
01282         return ERROR_SESSIONMANAGER + 0xfa;
01283     }
01284     if( s_idtable[objid].id_type != idt_streamobj )
01285     {
01286         return ERROR_SESSIONMANAGER + 0xfb;
01287     }
01288 
01289     op = ( RioStreamObj * )s_idtable[objid].id_object;
01290 
01291     return( op->DataRequest( reqid, operation, ipaddr, port, block, repbits ));
01292 }

int RioSession::DeleteObject ( char *  ObjectName  )  [private]

Definition at line 4876 of file server/SessionManager.cpp.

04877 {
04878     int rc;
04879     char Path[MaxPathSize + 1];
04880 
04881     // convert object name to Rio Path.
04882     rc = ObjectToPath( ObjectName, Path, sizeof( Path ));
04883     if( rc )
04884         return rc;
04885 
04886     #ifdef RIO_DEBUG2
04887     RioErr << "Caminho original " << ObjectName << ", caminho convertido "
04888            << Path << endl;
04889 
04890     RioErr << "Tentando removendo objeto no caminho " << Path << endl;
04891     #endif
04892 
04893     rc = s_user->CheckAccess( Path, 1 );
04894 
04895     if( rc == 0 )
04896     {
04897         // Verifica se podemos remover o objeto.
04898         char *UserName;
04899 
04900         s_user->GetUser( &UserName );
04901 
04902         // O usuario nao pode remover o seu proprio diretorio e nem o "/". A
04903         // funcao ObjectToPath recusa qualquer caminho com diversas "/"
04904         // concecutivas, ou que termine com uma "/", caso no qual se inclui o
04905         // "/". Como a "/" inicial e removida de Path, o caminho "/" tera
04906         // tamanho igual a 0.
04907         if( ( strcmp( Path, UserName ) == 0 ) ||
04908             ( strlen( Path ) == 0 ) )
04909         {
04910             #ifdef RIO_DEBUG2
04911             RioErr << "Permissao negada do remover o objeto no caminho "
04912                    << Path << endl;
04913             #endif
04914 
04915             return ERROR_RIOSESSION + ERROR_PERMISSION_DENIED;
04916         }
04917 
04918         #ifdef RIO_DEBUG2
04919         RioErr << "Removendo objeto no caminho " << Path << endl;
04920         #endif
04921 
04922         rc = s_mgr->m_ObjectManager->Delete( Path );
04923     }
04924     #ifdef RIO_DEBUG2
04925     else
04926         RioErr << "Permissao negada do remover o objeto no caminho " << Path
04927                << endl;
04928     #endif
04929 
04930     return rc;
04931 }

int RioSession::ExecuteCall ( unsigned int  Class,
unsigned int  Method,
char *  Parameter,
unsigned int  ParameterSize,
char **  Result,
unsigned int *  ResultSize 
) [private]

Definition at line 1309 of file server/SessionManager.cpp.

01315 {
01316     #ifdef RIO_DEBUG2
01317     RioErr << "RioSession::ExecuteCall executando chamada da classe com id "
01318            << "igual a " << Class << ", e o metodo com id " << Method 
01319            << " desta classe." << endl;
01320     #endif
01321            
01322     switch(Class)
01323     {
01324         case RioClassSessionManager:
01325         {
01326             return ExecuteSessionManager( Method, Parameter, ParameterSize,
01327                                           Result, ResultSize );
01328         }
01329         case RioClassStreamManager:
01330         {
01331             return ExecuteStreamManager ( Method, Parameter, ParameterSize,
01332                                           Result, ResultSize );
01333         }
01334         case RioClassObjectManager:
01335         {
01336             return ExecuteObjectManager ( Method, Parameter, ParameterSize,
01337                                           Result, ResultSize );
01338         }
01339         case RioClassRouter:
01340         {
01341             return ExecuteRouter( Method, Parameter, ParameterSize,
01342                                   Result, ResultSize );
01343         }
01344         // Nova funcao para executar as chamadas remotas para a UserManager.
01345         case RioClassUserManager:
01346         {
01347             return ExecuteUserManager( Method, Parameter, ParameterSize,
01348                                        Result, ResultSize );
01349         }
01350         // should never execute default case
01351         default:
01352         {
01353             RioErr << "Executecall: invalid class " << endl;
01354             return ERROR_CONNECTIONMANAGER + ERROR_INVALID_CLASS;
01355         }
01356     }
01357 
01358     return S_OK;
01359 }

int RioSession::ExecuteObjectManager ( unsigned int  Method,
char *  Parameter,
unsigned int  ParameterSize,
char **  Result,
unsigned int *  ResultSize 
) [private]

Definition at line 3281 of file server/SessionManager.cpp.

03286 {
03287     int offset = 0;
03288     unsigned int Size;
03289 
03290     switch( Method )
03291     {
03292         case RioMethodObjectManagerClose:
03293         {
03294             ObjectHandle Handle;
03295             offset = 0;
03296 
03297             #ifdef RIO_DEBUG2
03298             struct in_addr clientip;
03299             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03300            if( s_mgr->m_log.is_open() )
03301                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03302                             << " port: " <<  htons( s_remoteAddress.sin_port )
03303                             << " closing object " << endl;
03304             #endif
03305             // ----------------------------------------------------------------
03306 
03307             // Get method parameters from ascii buffer
03308 
03309             // Get Object handle
03310             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03311                 &offset ) )
03312             {
03313                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03314             }
03315             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03316             {
03317                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03318             }
03319 
03320             // Call method
03321             HRESULT hresult = CloseObject( Handle.Index );
03322 
03323             // Check if Result Size is less than Result buffer
03324             Size = MAX_LONG_STRING_SIZE;
03325             if( Size > *ResultSize )
03326             {
03327                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03328             }
03329             offset = 0;
03330 
03331             // Set return result
03332             SetLong( *Result, hresult, &offset );
03333 
03334             // Update output result size
03335             *ResultSize = offset;
03336 
03337             return S_OK;
03338         }
03339         //////////////////////////////////////////
03340         case RioMethodObjectManagerGetSize:
03341         {
03342             ObjectHandle Handle;
03343             RioObjectSize ObjectSize;
03344             offset = 0;
03345 
03346             #ifdef RIO_DEBUG2
03347             struct in_addr clientip;
03348             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03349            if( s_mgr->m_log.is_open() )
03350                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03351                             << " port: " <<  htons( s_remoteAddress.sin_port )
03352                             << " getting object size " << endl;
03353             #endif
03354             // ----------------------------------------------------------------
03355 
03356             // Get method parameters from ascii buffer
03357 
03358             // Get Object handle
03359             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03360                 &offset ) )
03361             {
03362                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03363             }
03364             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03365             {
03366                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03367             }
03368 
03369             // Call method
03370             HRESULT hresult = GetSize( Handle.Index, &ObjectSize );
03371 
03372             // Check if Result Size is less than Result buffer
03373             Size = MAX_LONG_STRING_SIZE + 2 * MAX_ULONG_STRING_SIZE;
03374             if( Size > *ResultSize )
03375             {
03376                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03377             }
03378             offset = 0;
03379 
03380             // Set return result
03381             SetLong( *Result, hresult, &offset );
03382             // Set Object Size
03383             unsigned int highpart = ( unsigned int )(( ObjectSize >> 32 )
03384                                        & 0xffffffff);
03385             unsigned int lowpart =  ( unsigned int )( ObjectSize
03386                                        & 0xffffffff);
03387             SetULong( *Result, highpart, &offset );
03388             SetULong( *Result, lowpart, &offset );
03389 
03390             // Update output result size
03391             *ResultSize = offset;
03392 
03393             return S_OK;
03394         }
03395         //////////////////////////////////////////
03396         case RioMethodObjectManagerSetSize:
03397         {
03398             ObjectHandle Handle;
03399             RioObjectSize ObjectSize;
03400             unsigned long long int ExcludeStorages;
03401 
03402             char* md5sum;
03403 
03404             offset = 0;
03405 
03406             #ifdef RIO_DEBUG2
03407             struct in_addr clientip;
03408             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03409            if( s_mgr->m_log.is_open() )
03410                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03411                              << " port: " <<  htons( s_remoteAddress.sin_port )
03412                              << " setting object size " << endl;
03413             #endif
03414             // ----------------------------------------------------------------
03415 
03416             // Get method parameters from ascii buffer
03417 
03418             // Get Object handle
03419             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03420                 &offset ) )
03421             {
03422                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03423             }
03424             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03425             {
03426                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03427             }
03428 
03429             // Get Object Size
03430             unsigned int highpart;
03431             unsigned int lowpart;
03432             if( !GetULong( Parameter, ParameterSize, &highpart, &offset ) )
03433             {
03434                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03435             }
03436             if( !GetULong( Parameter, ParameterSize, &lowpart, &offset ) )
03437             {
03438                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03439             }
03440             ObjectSize = ( ((RioObjectSize) highpart) << 32 ) | lowpart ;
03441 
03442             // Get md5sum
03443             if( Handle.Version != 0 ) //if it's the new version (1)
03444             {
03445                 if( !GetString(Parameter, ParameterSize, &md5sum, &offset ) )
03446                 {
03447                     return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03448                 }
03449             }
03450             else //if it's the old version (0)
03451             {
03452                 //use a dummy md5sum
03453                 md5sum = strdup("0123456789abcdef0123456789abcdef");
03454             } 
03455 
03456             // null MD5 checksums, which represent directories, are
03457             // received as a single 0
03458             if( strcmp( md5sum, "0" ) == 0 ) 
03459                 md5sum = NULL;
03460                 
03461             // Obtem o vetor com os servidores que nao podem ser usados para
03462             // este cliente.
03463             ExcludeStorages = s_mgr->m_Router->GetInvalidStorages( 
03464                                                                   s_ServerNat );     
03465 
03466             // Call method
03467             HRESULT hresult = SetSize( Handle.Index, ObjectSize, md5sum,
03468                                        ExcludeStorages );     
03469             if( Handle.Version == 0 ) // Neste caso, desalocamos uma string 
03470                                       // dummy que foi alocada anteriormente 
03471                                       // (como pode ser visto pelo if apos o 
03472                                       // comentario Get md5sum).
03473                 free( md5sum );          
03474 
03475             // Check if Result Size is less than Result buffer
03476             Size = MAX_LONG_STRING_SIZE;
03477             if( Size > *ResultSize )
03478             {
03479                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03480             }
03481             offset = 0;
03482 
03483             // Set return result
03484             SetLong( *Result, hresult, &offset );
03485 
03486             // Update output result size
03487             *ResultSize = offset;
03488             return S_OK;
03489 
03490         }
03491         //////////////////////////////////////////
03492         case RioMethodObjectManagerGetType:
03493         {
03494             ObjectHandle Handle;
03495             short Type;
03496 
03497             #ifdef RIO_DEBUG2
03498             struct in_addr clientip;
03499             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03500            if( s_mgr->m_log.is_open() )
03501                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03502                              << " port: " <<  htons( s_remoteAddress.sin_port )
03503                              << " get object type " << endl;
03504             #endif
03505             // ----------------------------------------------------------------
03506 
03507             offset = 0;
03508 
03509             // Get method parameters from ascii buffer
03510 
03511             // Get Object handle
03512             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03513                 &offset ) )
03514             {
03515                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03516             }
03517             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03518             {
03519                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03520             }
03521 
03522             // Call method
03523             HRESULT hresult = GetType( Handle.Index, &Type );
03524 
03525             // Check if Result Size is less than Result buffer
03526             Size = MAX_LONG_STRING_SIZE + MAX_SHORT_STRING_SIZE;
03527             if( Size > *ResultSize )
03528             {
03529                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03530             }
03531             offset = 0;
03532 
03533             // Set return result
03534             SetLong( *Result, hresult, &offset );
03535             // Set Type
03536             SetShort( *Result, (short) Type, &offset );
03537 
03538             // Update output result size
03539             *ResultSize = offset;
03540             return S_OK;
03541         }
03542         //////////////////////////////////////////
03543         // I think it is not used (riosh)
03544         case RioMethodObjectManagerGetnBlocks:
03545         {
03546             ObjectHandle Handle;
03547             RioBlock nBlocks;
03548 
03549             #ifdef RIO_DEBUG2
03550             struct in_addr clientip;
03551             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03552            if( s_mgr->m_log.is_open() )
03553                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03554                              << " port: " <<  htons( s_remoteAddress.sin_port )
03555                              << " get n blocks " << endl;
03556             #endif
03557             // ----------------------------------------------------------------
03558 
03559             offset = 0;
03560 
03561             // Get method parameters from ascii buffer
03562 
03563             // Get Object handle
03564             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03565                 &offset ) )
03566             {
03567                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03568             }
03569             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03570             {
03571                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03572             }
03573 
03574             // Call method
03575             HRESULT hresult = GetnBlocks( Handle.Index, &nBlocks );
03576 
03577             // Check if Result Size is less than Result buffer
03578             Size = MAX_LONG_STRING_SIZE + MAX_ULONG_STRING_SIZE;
03579             if( Size > *ResultSize )
03580             {
03581                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03582             }
03583             offset = 0;
03584 
03585             // Set return result
03586             SetLong( *Result, hresult, &offset );
03587             // Set Type
03588             SetULong( *Result, nBlocks, &offset );
03589 
03590             // Update output result size
03591             *ResultSize = offset;
03592 
03593             return S_OK;
03594         }
03595         //////////////////////////////////////////
03596 /*
03597         #if 0
03598         case RioMethodObjectManagerGetBlockMap:
03599         {
03600             ObjectHandle Handle;
03601             RioBlock First;
03602             RioBlock nBlocks;
03603 
03604             offset = 0;
03605 
03606             // Get method parameters from ascii buffer
03607 
03608             // Get Object handle
03609             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03610                 &offset ) )
03611             {
03612                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03613             }
03614             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03615             {
03616                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03617             }
03618 
03619             // Get First Block number
03620             if( !GetULong(Parameter, ParameterSize, &First, &offset ) )
03621             {
03622                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03623             }
03624             // Get number of Blocks
03625             if( !GetULong(Parameter, ParameterSize, &nBlocks, &offset ) )
03626             {
03627                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03628             }
03629 
03630             // Allocate space for block map
03631             RioPhysicalBlock BlockMap[MaxBlockMapSize];
03632 
03633             // Call method
03634             HRESULT hresult = s_mgr->m_ObjectManager->GetBlockMap( Handle,
03635                                                                    First,
03636                                                                    nBlocks,
03637                                                                    BlockMap );
03638 
03639             // Check if Result Size is less than Result buffer
03640             Size = MAX_LONG_STRING_SIZE + nBlocks * 2 *
03641                    ( MAX_SHORT_STRING_SIZE + MAX_ULONG_STRING_SIZE );
03642             if( Size > *ResultSize )
03643             {
03644                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03645             }
03646             offset = 0;
03647 
03648             // Set return result
03649             SetLong( *Result, hresult, &offset );
03650             // Set BlockMap
03651             for(( unsigned int ) i = 0; i < nBlocks; i++ )
03652             {
03653                 SetShort( *Result, BlockMap[i].copy1.disk, &offset );
03654                 SetULong( *Result, BlockMap[i].copy1.block, &offset );
03655                 SetShort( *Result, BlockMap[i].copy2.disk, &offset );
03656                 SetULong( *Result, BlockMap[i].copy2.block, &offset );
03657             }
03658 
03659             // Update output result size
03660             *ResultSize = offset;
03661 
03662             return S_OK;
03663         }
03664         #endif
03665 */
03666         //////////////////////////////////////////
03667         case RioMethodObjectManagerNextObject:
03668         {
03669             ObjectHandle Handle;
03670             int BufferSize;
03671             int IsDirectory;
03672 
03673             #ifdef RIO_DEBUG2
03674             struct in_addr clientip;
03675             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03676            if( s_mgr->m_log.is_open() )
03677                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03678                              << " port: " <<  htons( s_remoteAddress.sin_port )
03679                              << " get next object " << endl;
03680             #endif
03681             // ----------------------------------------------------------------
03682 
03683             offset = 0;
03684 
03685             // Get method parameters from ascii buffer
03686 
03687             // Get Object handle
03688             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03689                 &offset ) )
03690             {
03691                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03692             }
03693             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03694             {
03695                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03696             }
03697 
03698             // Get Buffer size
03699             if( !GetLong( Parameter, ParameterSize, &BufferSize, &offset ) )
03700             {
03701                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03702             }
03703 
03704             char *ObjectName = new char [BufferSize];
03705 
03706             // Call method
03707 
03708             HRESULT hresult = NextObject( Handle.Index, &IsDirectory,
03709                                           BufferSize, ObjectName );
03710 
03711             // Check if Result Size is less than Result buffer
03712             Size = MAX_LONG_STRING_SIZE + BufferSize + 1;
03713             if( Size > *ResultSize )
03714             {
03715                 delete[] ObjectName;
03716                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03717             }
03718             offset = 0;
03719 
03720             // Set return result
03721             SetLong( *Result, hresult, &offset );
03722 
03723             //Set Directory flag
03724             SetLong( *Result, IsDirectory, &offset );
03725 
03726             // Set Object Name
03727             SetString( *Result, ObjectName, &offset );
03728 
03729             // Update output result size
03730             *ResultSize = offset;
03731 
03732             delete[] ObjectName;
03733 
03734             return S_OK;
03735 
03736         }
03737         //////////////////////////////////////////
03738         // Novos metodos para o controle de     //
03739         // fluxo                                //
03740         //////////////////////////////////////////
03741         // Metodo para ler a taxa de transferencia
03742         case RioMethodObjectManagerGetVideoRate:
03743         {
03744             // Observacao: este metodo foi baseado no metodo
03745             // RioMethodObjectManagerGetSize 
03746             unsigned int VideoRate;
03747             ObjectHandle Handle;
03748             offset = 0;
03749 
03750             #ifdef RIO_DEBUG2
03751             struct in_addr clientip;
03752             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03753             if( s_mgr->m_log.is_open() )
03754                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03755                             << " port: " <<  htons( s_remoteAddress.sin_port )
03756                             << " getting object video rate " << endl;
03757             #endif
03758             // ----------------------------------------------------------------
03759 
03760             // Get method parameters from ascii buffer
03761 
03762             // Get Object handle
03763             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03764                 &offset ) )
03765             {
03766                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03767             }
03768             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03769             {
03770                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03771             }
03772 
03773             // Call method
03774             HRESULT hresult = GetVideoRate( Handle.Index, &VideoRate );
03775 
03776             // Check if Result Size is less than Result buffer
03777             Size = MAX_LONG_STRING_SIZE + MAX_ULONG_STRING_SIZE;
03778             if( Size > *ResultSize )
03779             {
03780                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03781             }
03782             offset = 0;
03783 
03784             // Set return result
03785             SetLong( *Result, hresult, &offset );
03786             // Set Object VideoRate
03787             SetULong( *Result, VideoRate, &offset );
03788 
03789             // Update output result size
03790             *ResultSize = offset;
03791 
03792             return S_OK;
03793         }
03794         // Metodo para alterar a taxa de transferencia
03795         //////////////////////////////////////////
03796         case RioMethodObjectManagerSetVideoRate:
03797         {
03798             // Observacao: este metodo foi baseado no metodo
03799             // RioMethodObjectManagerSetSize 
03800             unsigned int VideoRate;
03801             ObjectHandle Handle;
03802             offset = 0;
03803 
03804             #ifdef RIO_DEBUG2
03805             struct in_addr clientip;
03806             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03807             if( s_mgr->m_log.is_open() )
03808                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03809                              << " port: " <<  htons( s_remoteAddress.sin_port )
03810                              << " setting object video rate " << endl;
03811             #endif
03812             // ----------------------------------------------------------------
03813 
03814             // Get method parameters from ascii buffer
03815 
03816             // Get Object handle
03817             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03818                 &offset ) )
03819             {
03820                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03821             }
03822             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03823             {
03824                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03825             }
03826 
03827             // Get Object Video Rate
03828             if( !GetULong( Parameter, ParameterSize, &VideoRate, &offset ) )
03829             {
03830                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03831             }
03832             // Call method
03833             HRESULT hresult = SetVideoRate( Handle.Index, VideoRate );
03834 
03835             // Check if Result Size is less than Result buffer
03836             Size = MAX_LONG_STRING_SIZE;
03837             if( Size > *ResultSize )
03838             {
03839                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03840             }
03841             offset = 0;
03842 
03843             // Set return result
03844             SetLong( *Result, hresult, &offset );
03845 
03846             // Update output result size
03847             *ResultSize = offset;
03848             return S_OK;
03849         }
03850         //////////////////////////////////////////
03851         // Novo metodo usado pela implementacao //
03852         // que permite o reinicio dos servidores//
03853         //////////////////////////////////////////
03854         // Metodo para realocar os blocos fisicos de um dado bloco logico.
03855         case RioMethodObjectManagerReallocBlocks:
03856         {
03857             // Observacao: este metodo foi baseado no metodo
03858             // RioMethodObjectManagerSetSize 
03859             unsigned int Block;
03860             ObjectHandle Handle;
03861             unsigned long long int ExcludeStorages;
03862 
03863             offset = 0;
03864 
03865             #ifdef RIO_DEBUG2
03866             struct in_addr clientip;
03867             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03868             if( s_mgr->m_log.is_open() )
03869                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03870                              << " port: " <<  htons( s_remoteAddress.sin_port )
03871                              << " changing fisical blocks " << endl;
03872             #endif
03873             // ----------------------------------------------------------------
03874 
03875             // Get method parameters from ascii buffer
03876 
03877             // Get Object handle
03878             if( !GetLong( Parameter, ParameterSize, &(Handle.Version),
03879                 &offset ) )
03880             {
03881                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03882             }
03883             if( !GetLong( Parameter, ParameterSize, &(Handle.Index), &offset ) )
03884             {
03885                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03886             }
03887 
03888             // Get Block
03889             if( !GetULong( Parameter, ParameterSize, &Block, &offset ) )
03890             {
03891                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03892             }
03893 
03894             // Obtem o vetor com os servidores que nao podem ser usados para
03895             // este cliente.
03896             ExcludeStorages = s_mgr->m_Router->GetInvalidStorages( 
03897                                                                   s_ServerNat );     
03898 
03899             // Call method
03900             HRESULT hresult = ReallocBlocks( Handle.Index, Block,
03901                                              ExcludeStorages );
03902 
03903             // Check if Result Size is less than Result buffer
03904             Size = MAX_LONG_STRING_SIZE;
03905             if( Size > *ResultSize )
03906             {
03907                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03908             }
03909             offset = 0;
03910 
03911             // Set return result
03912             SetLong( *Result, hresult, &offset );
03913 
03914             // Update output result size
03915             *ResultSize = offset;
03916             return S_OK;
03917         }
03918         //////////////////////////////////////////
03919         // should never execute default case
03920         default:
03921         {
03922             return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD;
03923         };
03924     }
03925 
03926 }

int RioSession::ExecuteRouter ( unsigned int  Method,
char *  Parameter,
unsigned int  ParameterSize,
char **  Result,
unsigned int *  ResultSize 
) [private]

Definition at line 3929 of file server/SessionManager.cpp.

03934 {
03935     int offset = 0;
03936     unsigned int Size;
03937     switch( Method )
03938     {
03939         //////////////////////////////////////////
03940         case RioMethodRouterDataRequest:
03941         {
03942             #if defined(RIO_DEBUG2) || defined(RIO_DEBUG_EMUL)
03943             struct in_addr clientip;
03944             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03945             #endif
03946             #ifdef RIO_DEBUG2
03947             if( s_mgr->m_log.is_open() )
03948                 s_mgr->m_log << "SessionManager - ExecuteRouter "
03949                              << " ip: " << inet_ntoa(clientip)
03950                              << " port: " <<  htons( s_remoteAddress.sin_port )
03951                              << " data request " <<  endl;
03952             #endif       
03953 
03954             // Esta impressao foi comentada porque estes logs ainda nao sao 
03955             // necessarios. Se for necessario usar estes logs, esta linha do 
03956             // codigo pode ser descomentada (ja existe um script para processar 
03957             // estes logs).
03958             //#ifdef RIO_DEBUG_EMUL                 
03959             //RioErr << "DATAREQUEST " << ( int ) time( NULL ) << " "
03960             //       <<  inet_ntoa( clientip ) << " "
03961             //       <<  htons( s_remoteAddress.sin_port ) << endl; 
03962             //#endif
03963             // ----------------------------------------------------------------
03964 
03965             offset = 0;
03966             u32 reqid, ipaddr, objid, block, repbits, PL;
03967             u16 port, operation;
03968             HRESULT hresult;
03969             bool CanRead, CanWrite;
03970 
03971             const int ERR = ERROR_CONNECTIONMANAGER +
03972                             ERROR_INVALID_METHOD_PARAM;
03973 
03974             if( !GetULong( Parameter, ParameterSize, &reqid, &offset ) )
03975             {
03976                 return ERR;
03977             }
03978             if( !GetULong( Parameter, ParameterSize, &ipaddr, &offset ) )
03979             {
03980                 return ERR;
03981             }
03982             if( !GetULong( Parameter, ParameterSize, &objid, &offset ) )
03983             {
03984                 return ERR;
03985             }
03986             if( !GetULong( Parameter, ParameterSize, &block, &offset ) )
03987             {
03988                 return ERR;
03989             }
03990             if( !GetULong( Parameter, ParameterSize, &repbits, &offset ) )
03991             {
03992                 return ERR;
03993             }
03994             if( !GetUShort(Parameter, ParameterSize, &port, &offset ) )
03995             {
03996                 return ERR;
03997             }
03998             if( !GetUShort( Parameter, ParameterSize, &operation, &offset ) )
03999             {
04000                 return ERR;
04001             }
04002             if( !GetULong( Parameter, ParameterSize, &PL, &offset ) )
04003             {
04004                 return ERR;
04005             }
04006             
04007             // Obtem o numero de servidores ativos e inativos.
04008             s_mgr->m_Router->GetStorageInfo( s_ServerNat, &CanRead, &CanWrite );
04009 
04010             // Verifica, caso desejemos abrir o arquivo para escrita, se a 
04011             // solicitacao de blocos pode ser feita. 
04012             //
04013             // Obs: a leitura nao e verificada porque isso precisa sera feito 
04014             // quando processarmos o pedido do bloco na classe Router: se nao
04015             // existirem discos disponiveis, isto e, se todos os servidores de
04016             // armazenamento cujos discos possuem uma copia do bloco logico a 
04017             // ser acessado estao indisponiveies, a classe Router retornara, ao
04018             // cliente, que o pedido nao foi finalizado corretamente, usando o
04019             // erro ERROR_INVALID_DISK (que agora nao siginicara mais, 
04020             // necessariamente, um bug no RIO).
04021             if( ( operation == READ ) || ( ( operation == WRITE ) &&
04022                                            ( CanWrite ) ) )
04023             {
04024                 if( !PL )
04025                 {
04026                     hresult = DataRequest( htonl( reqid ),
04027                                            s_remoteAddress.sin_addr.s_addr,
04028                                            objid, block, repbits,
04029                                            htons( port ), operation );
04030                 }
04031                 else
04032                 {
04033                     //PL has called a client's block, send directly to client
04034                     hresult = DataRequest( htonl( reqid ),
04035                                            htonl( ipaddr ),
04036                                            objid, block, repbits,
04037                                            htons( port ), operation );
04038                 }
04039             } 
04040             else
04041                   hresult = ERROR_SESSIONMANAGER + 
04042                             ERROR_SERVICE_TEMPORARY_UNAVAILABLE;
04043             // ----------------------------------------------------------------
04044 
04045             if( FAILED( hresult ) )
04046             {
04047                 #ifdef RIO_DEBUG2
04048                if( s_mgr->m_log.is_open() )
04049                     s_mgr->m_log << "SessionManager - ExecuteRouter "
04050                                  << " Failed to call datarequest: "
04051                                  << GetErrorDescription( hresult ) << endl;
04052                #endif
04053                 RioErr << " Failed DataRequest"
04054                        << GetErrorDescription( hresult ) << endl;
04055             }
04056 
04057             // Check if Result Size is less than Result buffer
04058             Size = MAX_LONG_STRING_SIZE + 2 * MAX_SHORT_STRING_SIZE;
04059             if( Size > *ResultSize )
04060             {
04061                 #ifdef RIO_DEBUG2
04062                if( s_mgr->m_log.is_open() )
04063                     s_mgr->m_log << "SessionManager - ExecuteRouter "
04064                                  << " Error on size "
04065                                  <<  endl;
04066                 #endif
04067                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
04068             }
04069             offset = 0;
04070 
04071             // Set return result
04072             SetLong( *Result, hresult, &offset );
04073 
04074             // Update output result size
04075             *ResultSize = offset;
04076 
04077             return S_OK;
04078         }
04079         //////////////////////////////////////////
04080         // set NAT mapping for a client
04081         case RioMethodRouterSetNATMappings:
04082         {
04083             unsigned int NumberOfNodes, PosError;
04084             GetNumberOfStorageNodes( &NumberOfNodes ); //get number of storages
04085             // Armazena a unica posicao que pode ter um erro (isso ocorrera se
04086             // o cliente for o antigo).
04087             PosError = NumberOfNodes + 1; // OS storages + o dispatcher, contado
04088                                           // depois em NumberOfNodes.
04089             // Adiciona o servidor de despacho.
04090             NumberOfNodes++; //adding server to count: increment
04091             // Ajusta para possibilitar recebermos novas informacoes para os
04092             // storages
04093             NumberOfNodes = 2 * NumberOfNodes;
04094 
04095             bool ServerNatfilled = false; // whether these variables are filled
04096             unsigned int id;
04097             
04098             #ifdef RIO_DEBUG2
04099             RioErr << "NumberOfNodes = " << NumberOfNodes << endl;
04100             #endif
04101 
04102             for( id = 0; id < NumberOfNodes; id++ )
04103             {
04104                 NATData currNAT; //current mapping
04105                 int curr_addr, curr_port;
04106                 if( !GetLong( Parameter, ParameterSize, &curr_addr, &offset ) )
04107                 {
04108                     if( id == PosError )
04109                         break;
04110                     else
04111                         return ERROR_CONNECTIONMANAGER +  
04112                                ERROR_INVALID_METHOD_PARAM;
04113                 }
04114                 if( !GetLong( Parameter, ParameterSize, &curr_port, &offset ) )
04115                 {
04116                     if( id == PosError )
04117                         break;
04118                     else
04119                         return ERROR_CONNECTIONMANAGER +  
04120                                ERROR_INVALID_METHOD_PARAM;
04121                 }
04122                 #ifdef RIO_DEBUG2
04123                 in_addr ipr;
04124                 
04125                 ipr.s_addr = curr_addr;
04126                 
04127                 RioErr << "SessionManager::ExecuteRouter Recebendo o par de "
04128                        << "enderecos numero " << id << ": IP = " 
04129                        << inet_ntoa( ipr ) << ", Porta = " 
04130                        << ntohs( curr_port ) << "." << endl;
04131                 #endif
04132                 currNAT.nat_addr = curr_addr;
04133                 currNAT.nat_port = curr_port;
04134                 if( !ServerNatfilled )
04135                 {
04136                     // Inicializa o endereco do cliente para o servidor de 
04137                     // armazenamento (este sera o primeiro endereco da lista)
04138                     s_ServerNat.nat_addr = currNAT.nat_addr;
04139                     s_ServerNat.nat_port = currNAT.nat_port;
04140                     ServerNatfilled = true;
04141                 }
04142                 s_mgr->SetNATMapping( s_ServerNat, id, currNAT );
04143             }
04144 
04145             #ifdef RIO_DEBUG2
04146             // Imprime os mapeamentos.
04147             s_mgr->m_Router->PrintNATMapping();
04148             #endif
04149             
04150             offset = 0;
04151             // Set return result
04152             SetLong( *Result, S_OK, &offset );
04153 
04154             return S_OK;
04155         }
04156         //////////////////////////////////////////
04157         // Novas chamadas relacionadas a obtencao 
04158         // dos logs dos servidores
04159         /////////////////////////////////////////
04160         // Novo Metodo para iniciar uma busca em um dos logs de um servidores.
04161         case RioMethodRouterSearchLogsRequest:
04162         {
04163             #ifdef RIO_DEBUG2
04164             struct in_addr clientip;
04165             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
04166             if( s_mgr->m_log.is_open() )
04167                 s_mgr->m_log << "SessionManager - ExecuteRouter "
04168                              << " ip: " << inet_ntoa(clientip)
04169                              << " port: " <<  htons( s_remoteAddress.sin_port )
04170                              << " search logs request " <<  endl;
04171             #endif
04172             // ----------------------------------------------------------------
04173 
04174             offset = 0;
04175             u32 reqid, serveripaddr, clientipaddr, searchtype;
04176             u16 serverport, clientport;
04177             time_t starttime, endtime;
04178             HRESULT hresult;
04179             unsigned int AuxInt;
04180 
04181             // Obtem o tipo da busca na mensagem.
04182             if( !GetULong( Parameter, ParameterSize, &searchtype, &offset ) )
04183                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04184             // Obtem o tempo inicial da busca.
04185             if( !GetULong( Parameter, ParameterSize, &AuxInt, &offset ) )
04186                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04187             starttime = AuxInt;    
04188             // Obtem o tempo final da busca.
04189             if( !GetULong( Parameter, ParameterSize, &AuxInt, &offset ) )
04190                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04191             endtime = AuxInt;
04192             // Obtem o IP do servidor.
04193             if( !GetULong( Parameter, ParameterSize, &serveripaddr, &offset ) )
04194                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04195             // Obtem a porta do servidor.
04196             if( !GetUShort( Parameter, ParameterSize, &serverport, &offset ) )
04197                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04198             // Obtem o IP do cliente.
04199             if( !GetULong( Parameter, ParameterSize, &clientipaddr, &offset ) )
04200                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04201             // Obtem a porta do cliente.
04202             if( !GetUShort( Parameter, ParameterSize, &clientport, &offset ) )
04203                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04204             // Obtem o identificador para a resposta da solicitacao de busca.
04205             if( !GetULong( Parameter, ParameterSize, &reqid, &offset ) )
04206                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04207                 
04208             // Garante que o tempo inicial nao e maior do que o tempo final.
04209             
04210             if( endtime < starttime )
04211                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04212 
04213             // Chama a funcao que inicializa a busca.
04214             hresult = SearchLogsRequest( searchtype, starttime, endtime, 
04215                                          serveripaddr, serverport, clientipaddr, 
04216                                          clientport, reqid );
04217 
04218             if( FAILED( hresult ) )
04219             {
04220                 #ifdef RIO_DEBUG2
04221                 if( s_mgr->m_log.is_open() )
04222                      s_mgr->m_log << "SessionManager - ExecuteRouter "
04223                                   << " Failed to call SearchLogsRequest: "
04224                                   << GetErrorDescription( hresult ) << endl;
04225                 #endif
04226                 RioErr << " Failed SearchLogsRequest: "
04227                        << GetErrorDescription( hresult ) << endl;
04228             }
04229 
04230             // Check if Result Size is less than Result buffer
04231             Size = MAX_LONG_STRING_SIZE;
04232             if( Size > *ResultSize )
04233             {
04234                 #ifdef RIO_DEBUG2
04235                 if( s_mgr->m_log.is_open() )
04236                      s_mgr->m_log << "SessionManager - ExecuteRouter "
04237                                   << " Error on size "
04238                                   <<  endl;
04239                 #endif
04240                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
04241             }
04242             offset = 0;
04243 
04244             // Set return result
04245             SetLong( *Result, hresult, &offset );
04246 
04247             // Update output result size
04248             *ResultSize = offset;
04249 
04250             return S_OK;
04251         }
04252         // Novo metodo para pedir os blocos do resultado de uma busca iniciada 
04253         // pelo metodo acima
04254         case RioMethodRouterSearchResultDataRequest:
04255         {
04256             #ifdef RIO_DEBUG2
04257             struct in_addr clientip;
04258             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
04259             if( s_mgr->m_log.is_open() )
04260                 s_mgr->m_log << "SessionManager - ExecuteRouter "
04261                              << " ip: " << inet_ntoa(clientip)
04262                              << " port: " <<  htons( s_remoteAddress.sin_port )
04263                              << " search result data request " <<  endl;
04264             #endif
04265             // ----------------------------------------------------------------
04266 
04267             offset = 0;
04268             u64 resultfileid;
04269             u32 reqid, serveripaddr, clientipaddr, block, highid, lowid;
04270             u16 serverport, clientport;
04271             HRESULT hresult;
04272 
04273             // Obtem o IP do servidor.
04274             if( !GetULong( Parameter, ParameterSize, &serveripaddr, &offset ) )
04275                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04276             // Obtem a porta do servidor.
04277             if( !GetUShort( Parameter, ParameterSize, &serverport, &offset ) )
04278                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04279             // Obtem o IP do cliente.
04280             if( !GetULong( Parameter, ParameterSize, &clientipaddr, &offset ) )
04281                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04282             // Obtem a porta do cliente.
04283             if( !GetUShort( Parameter, ParameterSize, &clientport, &offset ) )
04284                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04285             // Obtem a parte inferior do identificador do arquivo.
04286             if( !GetULong( Parameter, ParameterSize, &lowid, &offset ) )
04287                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04288             // Obtem a parte superior do identificador do arquivo.
04289             if( !GetULong( Parameter, ParameterSize, &highid, &offset ) )
04290                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04291             // Obtem o numero do bloco a ser requisitado.
04292             if( !GetULong( Parameter, ParameterSize, &block, &offset ) )
04293                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04294             // Obtem o identificador para a resposta da solicitacao de busca.
04295             if( !GetULong( Parameter, ParameterSize, &reqid, &offset ) )
04296                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04297                 
04298             // Compoe o identificador do arquivo.
04299             resultfileid = highid;
04300             resultfileid = ( resultfileid << 32 ) | lowid;    
04301 
04302             // Chama a funcao que le um bloco do arquivo com o resultado da
04303             // busca.
04304             hresult = SearchResultDataRequest( serveripaddr, serverport, 
04305                                                clientipaddr, clientport, 
04306                                                resultfileid, block, reqid );
04307 
04308             if( FAILED( hresult ) )
04309             {
04310                 #ifdef RIO_DEBUG2
04311                 if( s_mgr->m_log.is_open() )
04312                      s_mgr->m_log << "SessionManager - ExecuteRouter "
04313                                   << " Failed to call SearchResultDataRequest: "
04314                                   << GetErrorDescription( hresult ) << endl;
04315                 #endif
04316                 RioErr << " Failed SearchResultDataRequest: "
04317                        << GetErrorDescription( hresult ) << endl;
04318             }
04319 
04320             // Check if Result Size is less than Result buffer
04321             Size = MAX_LONG_STRING_SIZE;
04322             if( Size > *ResultSize )
04323             {
04324                 #ifdef RIO_DEBUG2
04325                 if( s_mgr->m_log.is_open() )
04326                      s_mgr->m_log << "SessionManager - ExecuteRouter "
04327                                   << " Error on size "
04328                                   <<  endl;
04329                 #endif
04330                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
04331             }
04332             offset = 0;
04333 
04334             // Set return result
04335             SetLong( *Result, hresult, &offset );
04336 
04337             // Update output result size
04338             *ResultSize = offset;
04339 
04340             return S_OK;
04341         }
04342         // Novo metodo para informar ao servidor que um arquivo com um resultado 
04343         // da busca pelos logs pode ser removido.
04344         case RioMethodRouterRemoveSearchResultFile:
04345         {
04346             #ifdef RIO_DEBUG2
04347             struct in_addr clientip;
04348             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
04349             if( s_mgr->m_log.is_open() )
04350                 s_mgr->m_log << "SessionManager - ExecuteRouter "
04351                              << " ip: " << inet_ntoa(clientip)
04352                              << " port: " <<  htons( s_remoteAddress.sin_port )
04353                              << " remove search result file " <<  endl;
04354             #endif
04355             // ----------------------------------------------------------------
04356 
04357             offset = 0;
04358             u64 resultfileid;
04359             u32 ipaddr, highid, lowid;
04360             u16 port;
04361             HRESULT hresult;
04362 
04363             // Obtem o IP do servidor.
04364             if( !GetULong( Parameter, ParameterSize, &ipaddr, &offset ) )
04365                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04366             // Obtem a porta do servidor.
04367             if( !GetUShort( Parameter, ParameterSize, &port, &offset ) )
04368                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04369             // Obtem a parte inferior do identificador do arquivo.
04370             if( !GetULong( Parameter, ParameterSize, &lowid, &offset ) )
04371                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04372             // Obtem a parte superior do identificador do arquivo.
04373             if( !GetULong( Parameter, ParameterSize, &highid, &offset ) )
04374                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04375 
04376             // Compoe o identificador do arquivo.
04377             resultfileid = highid;
04378             resultfileid = ( resultfileid << 32 ) | lowid;    
04379 
04380             // Chama a funcao que remove o arquivo com a busca.
04381             hresult = RemoveSearchResultFile( ipaddr, port, resultfileid );
04382 
04383             if( FAILED( hresult ) )
04384             {
04385                 #ifdef RIO_DEBUG2
04386                 if( s_mgr->m_log.is_open() )
04387                      s_mgr->m_log << "SessionManager - ExecuteRouter "
04388                                   << " Failed to call RemoveSearchResultFile: "
04389                                   << GetErrorDescription( hresult ) << endl;
04390                 #endif
04391                 RioErr << " Failed RemoveSearchResultFile: "
04392                        << GetErrorDescription( hresult ) << endl;
04393             }
04394 
04395             // Check if Result Size is less than Result buffer
04396             Size = MAX_LONG_STRING_SIZE;
04397             if( Size > *ResultSize )
04398             {
04399                 #ifdef RIO_DEBUG2
04400                 if( s_mgr->m_log.is_open() )
04401                      s_mgr->m_log << "SessionManager - ExecuteRouter "
04402                                   << " Error on size "
04403                                   <<  endl;
04404                 #endif
04405                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
04406             }
04407             offset = 0;
04408 
04409             // Set return result
04410             SetLong( *Result, hresult, &offset );
04411 
04412             // Update output result size
04413             *ResultSize = offset;
04414 
04415             return S_OK;
04416         }
04417         //////////////////////////////////////////
04418         // should never execute default case
04419         default:
04420         {
04421             return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD;
04422         };
04423     }
04424 }

int RioSession::ExecuteSessionManager ( unsigned int  Method,
char *  Parameter,
unsigned int  ParameterSize,
char **  Result,
unsigned int *  ResultSize 
) [private]

Definition at line 1362 of file server/SessionManager.cpp.

01367 {
01368     int offset = 0;
01369     unsigned int Size;
01370 
01371     switch( Method )
01372     {
01373         //////////////////////////////////////////
01374         case RioMethodSessionManagerOpen:
01375         {
01376             char* UserName;
01377             char* Password;
01378             bool CanRead, CanWrite;
01379             HRESULT hresult;
01380 
01381             offset = 0;
01382 
01383             #ifdef RIO_DEBUG2
01384             struct in_addr clientip;
01385             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01386             if( s_mgr->m_log.is_open() ) 
01387                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01388                              << " port: " <<  htons( s_remoteAddress.sin_port )
01389                              << " opening session " << endl;
01390             #endif
01391             // ----------------------------------------------------------------
01392 
01393 
01394             // Get method parameters from ascii buffer
01395             // Get UserName
01396             if(!GetString( Parameter, ParameterSize, &UserName, &offset ))
01397             {
01398                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01399             }
01400             // Get Password
01401             if(!GetString( Parameter, ParameterSize, &Password, &offset ))
01402             {
01403                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01404             }
01405             
01406             // Verifica se podemos abrir uma nova sessao (isso somente podera
01407             // ser feito se o numero de servidores de armazenamento que cairam
01408             // for menor do que o numero de replicacoes).
01409             
01410             s_mgr->m_Router->GetStorageInfo( s_ServerNat, &CanRead, &CanWrite );
01411             
01412             if( ( CanRead ) && ( CanWrite ) ) 
01413             {
01414                 // Call method
01415                 hresult = Open( UserName, Password );
01416             } 
01417             else
01418                 hresult = ERROR_SESSIONMANAGER + 
01419                           ERROR_SERVICE_TEMPORARY_UNAVAILABLE;
01420 
01421             // Check if Result Size is less than Result buffer
01422             Size = 3 * MAX_LONG_STRING_SIZE;
01423             if( Size > *ResultSize )
01424             {
01425                 Close();
01426                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01427             }
01428             offset = 0;
01429 
01430             // Set return result
01431             SetLong( *Result, hresult, &offset );
01432             // Set Session Id {just send him some dummy version & index}
01433             SetLong( *Result, 2000, &offset );
01434             SetLong( *Result, 1, &offset );
01435 
01436             unsigned int BlockSize;
01437 
01438             GetBlockSize( &BlockSize );
01439 
01440             // to reduce 1 RTT
01441             SetULong( *Result, BlockSize, &offset );
01442             // ----------------------------------------------------------------
01443 
01444             // Update output result size
01445             *ResultSize = offset;
01446             return S_OK;
01447         }
01448         //////////////////////////////////////////
01449         case RioMethodSessionManagerClose:
01450         {
01451             RioSessionId Session;
01452             offset = 0;
01453 
01454             #ifdef RIO_DEBUG2
01455             struct in_addr clientip;
01456             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01457             if( s_mgr->m_log.is_open() ) 
01458                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01459                              << " port: " <<  htons( s_remoteAddress.sin_port )
01460                              << " closing session " << endl;
01461             #endif
01462             // ----------------------------------------------------------------
01463 
01464             // Get method parameters from ascii buffer
01465 
01466             // Get Session Id
01467             if(!GetLong( Parameter, ParameterSize, 
01468                          &(Session.Version), &offset )
01469               )
01470             {
01471                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01472             }
01473             if(!GetLong( Parameter, ParameterSize, &(Session.Index), &offset ))
01474             {
01475                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01476             }
01477 
01478             // Call method
01479             HRESULT hresult = Close();
01480 
01481             // Check if Result Size is less than Result buffer
01482             Size = MAX_LONG_STRING_SIZE;
01483             if( Size > *ResultSize )
01484             {
01485                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01486             }
01487             offset = 0;
01488 
01489             // Set return result
01490             SetLong( *Result, hresult, &offset );
01491 
01492             // Update output result size
01493             *ResultSize = offset;
01494 
01495             return S_OK;
01496         }
01497         //////////////////////////////////////////
01498         case RioMethodSessionManagerOpenStream:
01499         {
01500             RioSessionId Session;
01501             RioStreamTraffic Traffic;
01502             RioStreamId Stream;
01503             offset = 0;
01504 
01505             #ifdef RIO_DEBUG2
01506             struct in_addr clientip;
01507             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01508             if( s_mgr->m_log.is_open() )
01509                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01510                              << " port: " <<  htons( s_remoteAddress.sin_port )
01511                              << " opening stream " << endl;
01512             #endif
01513             // ----------------------------------------------------------------
01514 
01515             // Get method parameters from ascii buffer
01516 
01517             // Get Session Id
01518             if(!GetLong( Parameter, ParameterSize,
01519                          &(Session.Version), &offset )
01520               )
01521             {
01522                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01523             }
01524             if(!GetLong( Parameter, ParameterSize, &(Session.Index), &offset ))
01525             {
01526                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01527             }
01528 
01529             // Get Traffic
01530             short shortvalue;
01531             if(!GetShort( Parameter, ParameterSize, &shortvalue, &offset ))
01532             {
01533                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01534             }
01535             Traffic.Type = ( RioTrafficType ) shortvalue;
01536 
01537             if(!GetShort( Parameter, ParameterSize, &shortvalue, &offset ))
01538             {
01539                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01540             }
01541             Traffic.Direction = ( RioStreamDirection ) shortvalue;
01542 
01543             if( !GetULong( Parameter, ParameterSize,
01544                            &(Traffic.LogicalBlockSize), &offset )
01545               )
01546             {
01547                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01548             }
01549             if( !GetLong( Parameter, ParameterSize, &(Traffic.MaxRequests),
01550                           &offset ))
01551             {
01552                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01553             }
01554 
01555             if( Traffic.Type == RIO_TRAFFIC_CBR )
01556             {
01557                 if( !GetDouble( Parameter, ParameterSize,
01558                                 &(Traffic.TrafficCBR.Rate), &offset ))
01559                 {
01560                     return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01561                 }
01562             }
01563             if( Traffic.Type == RIO_TRAFFIC_VBR )
01564             {
01565                 if( !GetDouble( Parameter, ParameterSize,
01566                                 &(Traffic.TrafficVBR.Rate), &offset ))
01567                 {
01568                     return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01569                 }
01570             }
01571             if( Traffic.Type == RIO_TRAFFIC_NRT )
01572             {
01573                 if( !GetULong( Parameter, ParameterSize,
01574                                &(Traffic.TrafficNRT.Reserved), &offset ))
01575                 {
01576                     return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01577                 }
01578             }
01579 
01580             // Call method
01581             HRESULT hresult = OpenStream( &Traffic, &Stream.Index );
01582 
01583             // Check if Result Size is less than Result buffer
01584             Size = 3 * MAX_LONG_STRING_SIZE;
01585             if( Size > *ResultSize )
01586             {
01587                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01588             }
01589             offset = 0;
01590 
01591             // Set return result
01592             SetLong( *Result, hresult, &offset );
01593 
01594             // Set Stream Id
01595             SetLong( *Result, Stream.Version, &offset );
01596             SetLong( *Result, Stream.Index, &offset );
01597 
01598             // to reduce 1 RTT
01599             hresult = StreamMaxRequests( Stream.Index );
01600             SetLong( *Result, hresult, &offset );
01601             // ----------------------------------------------------------------
01602 
01603             // Update output result size
01604             *ResultSize = offset;
01605             return S_OK;
01606 
01607         }
01608         //////////////////////////////////////////
01609         case RioMethodSessionManagerCreateObject:
01610         {
01611             RioSessionId Session;
01612             char* ObjectName;
01613             short Type;
01614 
01615             offset = 0;
01616 
01617             #ifdef RIO_DEBUG2
01618             struct in_addr clientip;
01619             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01620             if( s_mgr->m_log.is_open() )
01621                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01622                              << " port: " <<  htons( s_remoteAddress.sin_port )
01623                              << " creating object " << endl;
01624             #endif
01625             // ----------------------------------------------------------------
01626 
01627             // Get method parameters from ascii buffer
01628             // Get Session Id
01629             if( !GetLong( Parameter, ParameterSize,
01630                           &(Session.Version), &offset )
01631               )
01632             {
01633                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01634             }
01635             if( !GetLong( Parameter, ParameterSize,
01636                           &(Session.Index), &offset )
01637               )
01638             {
01639                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01640             }
01641 
01642             // Get ObjectName
01643             if( !GetString(Parameter, ParameterSize, &ObjectName, &offset ) )
01644             {
01645                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01646             }
01647 
01648             short shortvalue;
01649             if( !GetShort(Parameter, ParameterSize, &shortvalue, &offset ) )
01650             {
01651                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01652             }
01653             Type = shortvalue;
01654 
01655             // Call method
01656             HRESULT hresult = CreateObject( ObjectName, Type );
01657 
01658             // Check if Result Size is less than Result buffer
01659             Size = MAX_LONG_STRING_SIZE;
01660             if( Size > *ResultSize )
01661             {
01662                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01663             }
01664             offset = 0;
01665 
01666             // Set return result
01667             SetLong( *Result, hresult, &offset );
01668 
01669             // Update output result size
01670             *ResultSize = offset;
01671 
01672             return S_OK;
01673 
01674         }
01675         //////////////////////////////////////////
01676         case RioMethodSessionManagerDeleteObject:
01677         {
01678             RioSessionId Session;
01679             char* ObjectName;
01680 
01681             #ifdef RIO_DEBUG2
01682             struct in_addr clientip;
01683             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01684             if( s_mgr->m_log.is_open() )
01685                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01686                              << " port: " <<  htons( s_remoteAddress.sin_port )
01687                              << " deleting object " << endl;
01688             #endif
01689             // ----------------------------------------------------------------
01690 
01691             offset = 0;
01692 
01693             // Get method parameters from ascii buffer
01694             // Get Session Id
01695             if( !GetLong( Parameter, ParameterSize,
01696                           &(Session.Version), &offset )
01697               )
01698             {
01699                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01700             }
01701             if( !GetLong( Parameter, ParameterSize,
01702                           &(Session.Index), &offset )
01703               )
01704             {
01705                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01706             }
01707 
01708             // Get ObjectName
01709             if( !GetString(Parameter, ParameterSize, &ObjectName, &offset ) )
01710             {
01711                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01712             }
01713 
01714             // Call method
01715             HRESULT hresult = DeleteObject( ObjectName );
01716 
01717             // Check if Result Size is less than Result buffer
01718             Size = MAX_LONG_STRING_SIZE;
01719             if( Size > *ResultSize )
01720             {
01721                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01722             }
01723             offset = 0;
01724 
01725             // Set return result
01726             SetLong( *Result, hresult, &offset );
01727 
01728             // Update output result size
01729             *ResultSize = offset;
01730 
01731             return S_OK;
01732 
01733         }
01734         //////////////////////////////////////////
01735         case RioMethodSessionManagerRenameObject:
01736         {
01737             RioSessionId Session;
01738             char* CurrentName;
01739             char* NewName;
01740 
01741             #ifdef RIO_DEBUG2
01742             struct in_addr clientip;
01743             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01744             if( s_mgr->m_log.is_open() )
01745                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01746                              << " port: " <<  htons( s_remoteAddress.sin_port )
01747                              << " rename object " << endl;
01748             #endif
01749             // ----------------------------------------------------------------
01750             offset = 0;
01751 
01752             // Get method parameters from ascii buffer
01753             // Get Session Id
01754             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
01755                 &offset ) )
01756             {
01757                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01758             }
01759             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
01760                 &offset ) )
01761             {
01762                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01763             }
01764 
01765             // Get CurrentName
01766             if( !GetString( Parameter, ParameterSize, &CurrentName, &offset ) )
01767             {
01768                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01769             }
01770 
01771             // Get NewName
01772             if( !GetString( Parameter, ParameterSize, &NewName, &offset ) )
01773             {
01774                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01775             }
01776 
01777             // Call method
01778             HRESULT hresult = RenameObject( CurrentName, NewName );
01779 
01780             // Check if Result Size is less than Result buffer
01781             Size = MAX_LONG_STRING_SIZE;
01782             if( Size > *ResultSize )
01783             {
01784                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01785             }
01786             offset = 0;
01787 
01788             // Set return result
01789             SetLong( *Result, hresult, &offset );
01790 
01791             // Update output result size
01792             *ResultSize = offset;
01793 
01794             return S_OK;
01795 
01796         }
01797         //////////////////////////////////////////
01798         case RioMethodSessionManagerGetBlockSize:
01799         {
01800             RioSessionId Session;
01801             unsigned int BlockSize;
01802 
01803             #ifdef RIO_DEBUG2
01804             struct in_addr clientip;
01805             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01806            if( s_mgr->m_log.is_open() )
01807                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01808                              << " port: " <<  htons( s_remoteAddress.sin_port )
01809                              << " getting block size " << endl;
01810             #endif
01811             // ----------------------------------------------------------------
01812 
01813             offset = 0;
01814 
01815             // Get method parameters from ascii buffer
01816             // Get Session Id
01817             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
01818                 &offset ) )
01819             {
01820                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01821             }
01822             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
01823                 &offset ) )
01824             {
01825                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01826             }
01827 
01828             // Call method
01829             HRESULT hresult = GetBlockSize( &BlockSize );
01830 
01831             // Check if Result Size is less than Result buffer
01832             Size = MAX_LONG_STRING_SIZE + MAX_ULONG_STRING_SIZE;
01833             if( Size > *ResultSize )
01834             {
01835                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01836             }
01837             offset = 0;
01838 
01839             // Set return result
01840             SetLong( *Result, hresult, &offset );
01841             // Set BlockSize
01842             SetULong( *Result, BlockSize, &offset );
01843 
01844             // Update output result size
01845             *ResultSize = offset;
01846             return S_OK;
01847 
01848         }
01849         //////////////////////////////////////////
01850         case RioMethodSessionManagerFirstObject:
01851         {
01852             RioSessionId Session;
01853             char* DirectoryName;
01854             int BufferSize;
01855             ObjectHandle Handle;
01856             int IsDirectory;
01857 
01858             #ifdef RIO_DEBUG2
01859             struct in_addr clientip;
01860             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01861            if( s_mgr->m_log.is_open() )
01862                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01863                              << " port: " <<  htons( s_remoteAddress.sin_port )
01864                              << " first object " << endl;
01865             #endif
01866             // ----------------------------------------------------------------
01867 
01868             offset = 0;
01869 
01870             // Get method parameters from ascii buffer
01871             // Get Session Id
01872             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
01873                 &offset ) )
01874             {
01875                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01876             }
01877             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
01878                 &offset ) )
01879             {
01880                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01881             }
01882 
01883             // Get DirectoryName
01884             if( !GetString(Parameter, ParameterSize, &DirectoryName, &offset ) )
01885             {
01886                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01887             }
01888 
01889             // Get Buffer size
01890             if( !GetLong(Parameter, ParameterSize, &BufferSize, &offset ) )
01891             {
01892                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01893             }
01894 
01895             char *ObjectName = new char [BufferSize];
01896 
01897             // Call method
01898             HRESULT hresult = FirstObject( DirectoryName, &Handle.Index,
01899                                            &IsDirectory, BufferSize,
01900                                            ObjectName );
01901 
01902             // Check if Result Size is less than Result buffer
01903             Size = 4 * MAX_LONG_STRING_SIZE + BufferSize + 1;
01904             if( Size > *ResultSize )
01905             {
01906                 delete[] ObjectName;
01907                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01908             }
01909             offset = 0;
01910 
01911             // Set return result
01912             SetLong( *Result, hresult, &offset );
01913             // Set Object Handle
01914             SetLong( *Result, Handle.Version, &offset );
01915             SetLong( *Result, Handle.Index, &offset );
01916 
01917             //Set Directory flag
01918             SetLong( *Result, IsDirectory, &offset );
01919 
01920             // Set Object Handle
01921             SetString( *Result, ObjectName, &offset );
01922 
01923             // Update output result size
01924             *ResultSize = offset;
01925 
01926             delete[] ObjectName;
01927 
01928             return S_OK;
01929         }
01930 
01931         //////////////////////////////////////////
01932         case RioMethodSessionManagerChangeDir:
01933         {
01934             RioSessionId Session;
01935             char* DirectoryName;
01936 
01937             #ifdef RIO_DEBUG2
01938             struct in_addr clientip;
01939             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01940            if( s_mgr->m_log.is_open() ) s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01941                          << " port: " <<  htons( s_remoteAddress.sin_port )
01942                          << " change Dir " << endl;
01943             #endif
01944             // ----------------------------------------------------------------
01945 
01946             offset = 0;
01947 
01948             // Get method parameters from ascii buffer
01949             // Get Session Id
01950             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
01951                 &offset ) )
01952             {
01953                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01954             }
01955             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
01956                 &offset ) )
01957             {
01958                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01959             }
01960 
01961             // Get DirectoryName
01962             if( !GetString(Parameter, ParameterSize, &DirectoryName, &offset ) )
01963             {
01964                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
01965             }
01966 
01967             // Call method
01968             HRESULT hresult = ChangeDir( DirectoryName );
01969 
01970             // Check if Result Size is less than Result buffer
01971             Size = MAX_LONG_STRING_SIZE + 1;
01972             if( Size > *ResultSize )
01973             {
01974                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
01975             }
01976             offset = 0;
01977 
01978             // Set return result
01979             SetLong( *Result, hresult, &offset );
01980 
01981             // Update output result size
01982             *ResultSize = offset;
01983 
01984             return S_OK;
01985         }
01986 
01987         //////////////////////////////////////////
01988         case RioMethodSessionManagerGetCurrentDir:
01989         {
01990             RioSessionId Session;
01991             int BufferSize;
01992 
01993             #ifdef RIO_DEBUG2
01994             struct in_addr clientip;
01995             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
01996            if( s_mgr->m_log.is_open() )
01997                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
01998                              << " port: " <<  htons( s_remoteAddress.sin_port )
01999                              << " get current Dir " << endl;
02000             #endif
02001             // ----------------------------------------------------------------
02002 
02003             offset = 0;
02004 
02005             // Get method parameters from ascii buffer
02006             // Get Session Id
02007             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
02008                 &offset ) )
02009             {
02010                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02011             }
02012             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
02013                 &offset ) )
02014             {
02015                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02016             }
02017 
02018             // Get directory    name buffer size
02019             if( !GetLong( Parameter, ParameterSize, &BufferSize, &offset ) )
02020             {
02021                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02022             }
02023 
02024             char *DirName = new char [BufferSize];
02025 
02026 
02027             // Call method
02028             HRESULT hresult = GetCurrentDir( BufferSize, DirName );
02029 
02030             // Check if Result Size is less than Result buffer
02031             Size = MAX_LONG_STRING_SIZE + BufferSize + 1;
02032             if( Size > *ResultSize )
02033             {
02034                 delete[] DirName;
02035                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02036             }
02037             offset = 0;
02038 
02039             // Set return result
02040             SetLong( *Result, hresult, &offset );
02041 
02042             // Set Directory name
02043             SetString( *Result, DirName, &offset );
02044 
02045             // Update output result size
02046             *ResultSize = offset;
02047 
02048             delete[] DirName;
02049 
02050             return S_OK;
02051         }
02052         //////////////////////////////////////////
02053         case RioMethodSessionManagerGetObjectInfo:
02054         {
02055             RioSessionId Session;
02056             char* ObjectName;
02057 
02058             char md5sum[33];
02059 
02060             ObjectInfo ObjectInfo;
02061 
02062             #ifdef RIO_DEBUG2
02063             struct in_addr clientip;
02064             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02065            if( s_mgr->m_log.is_open() )
02066                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02067                              << " port: " <<  htons( s_remoteAddress.sin_port )
02068                              << " get object info" << endl;
02069             #endif
02070             // ----------------------------------------------------------------
02071 
02072             offset = 0;
02073 
02074             // Get method parameters from ascii buffer
02075             // Get Session Id
02076             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
02077                 &offset ) )
02078             {
02079                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02080             }
02081             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
02082                 &offset ) )
02083             {
02084                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02085             }
02086 
02087             // Get Object name
02088             if( !GetString( Parameter, ParameterSize, &ObjectName, &offset ) )
02089             {
02090                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02091             }
02092 
02093             // Call method
02094             HRESULT hresult = GetObjectInfo( ObjectName, &ObjectInfo );
02095 
02096             // Check if Result Size is less than Result buffer
02097             ObjectInfo.getMd5sum( md5sum );
02098 
02099             Size = MAX_LONG_STRING_SIZE +
02100                    MAX_SHORT_STRING_SIZE +
02101                    MAX_SHORT_STRING_SIZE +
02102                    3 * MAX_ULONG_STRING_SIZE + // Alteracao para colocar a 
02103                                                // taxa de transferencia: de
02104                                                // 2 * MAX_ULONG_STRING_SIZE
02105                                                // para 
02106                                                // 3 * MAX_ULONG_STRING_SIZE
02107                    6 * MAX_SHORT_STRING_SIZE +
02108                    strlen( ( char * ) ObjectInfo.getOwner().c_str() ) + 1 +
02109                    strlen( ( char * ) ObjectInfo.getGroup().c_str() ) + 1 +
02110                    MD5SIZE + 1 +
02111                    1;
02112             if( Size > *ResultSize )
02113             {
02114                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02115             }
02116             offset = 0;
02117 
02118             // Set return result
02119             SetLong( *Result, hresult, &offset );
02120 
02121             // Set Object Info
02122 
02123             // Set Object Type
02124             SetShort( *Result, ObjectInfo.getType(), &offset );
02125 
02126             // Set Permission
02127             SetShort( *Result, ObjectInfo.getPermission(), &offset );
02128 
02129             // Set Object Size;
02130             unsigned int highpart =
02131                                 ( unsigned int )(( ObjectInfo.getSize() >> 32 )
02132                                 & 0xffffffff );
02133             unsigned int lowpart = ( unsigned int )( ObjectInfo.getSize()
02134                                       & 0xffffffff );
02135             SetULong( *Result, highpart, &offset );
02136             SetULong( *Result, lowpart, &offset );
02137 
02138             // Set Last Modification Time
02139             // year
02140             SetShort( *Result, ObjectInfo.getTime().Year, &offset );
02141             // month
02142             SetShort( *Result, ObjectInfo.getTime().Month, &offset );
02143             // dayofweek
02144             SetShort( *Result, ObjectInfo.getTime().DayOfWeek, &offset );
02145             // day
02146             SetShort( *Result, ObjectInfo.getTime().Day, &offset );
02147             // Hour
02148             SetShort( *Result, ObjectInfo.getTime().Hour, &offset );
02149             // Minute
02150             SetShort( *Result, ObjectInfo.getTime().Minute, &offset );
02151 
02152             // Set Owner User Name
02153             SetString( *Result, (char*)ObjectInfo.getOwner().c_str(), &offset );
02154             // Set Owner Group Name
02155             SetString( *Result, (char*)ObjectInfo.getGroup().c_str(), &offset );
02156 
02157             // Adiciona a taxa de transmissao na mensagem (usada pela
02158             // implemententacao com controle de fluxo).
02159             SetULong( *Result, ObjectInfo.getVideoRate(), &offset );
02160 
02161             // Set MD5Sum
02162             SetString( *Result, md5sum, &offset );
02163 
02164             // Update output result size
02165             *ResultSize = offset;
02166 
02167             return S_OK;
02168         }
02169 
02170         // added to support df command -----------------------------
02171         case RioMethodSessionManagerGetNumberOfDisks:
02172         {
02173             RioSessionId Session;
02174             unsigned int NumberOfDisks;
02175 
02176             #ifdef RIO_DEBUG2
02177             struct in_addr clientip;
02178             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02179            if( s_mgr->m_log.is_open() )
02180                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02181                              << " port: " <<  htons( s_remoteAddress.sin_port )
02182                              << " get number of disks " << endl;
02183             #endif
02184 
02185             offset = 0;
02186 
02187             // Get method parameters from ascii buffer
02188             // Get Session Id
02189             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
02190                 &offset ) )
02191             {
02192                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02193             }
02194             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
02195                 &offset ) )
02196             {
02197                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02198             }
02199 
02200             // Call method
02201             HRESULT hresult = GetNumberOfDisks( &NumberOfDisks );
02202 
02203             // Check if Result Size is less than Result buffer
02204             Size = MAX_LONG_STRING_SIZE + MAX_ULONG_STRING_SIZE;
02205             if( Size > *ResultSize )
02206             {
02207                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02208             }
02209             offset = 0;
02210 
02211             // Set return result
02212             SetLong( *Result, hresult, &offset );
02213             // Set Number of disks
02214             SetULong( *Result, NumberOfDisks, &offset );
02215 
02216             // Update output result size
02217             *ResultSize = offset;
02218 
02219             return S_OK;
02220         }
02221         // --------------------------------------------------------------------
02222         // added to support df command -----------------------------
02223         case RioMethodSessionManagerGetNumberOfStorageNodes:
02224         {
02225             RioSessionId Session;
02226             unsigned int NumberOfStorageNodes;
02227 
02228             #ifdef RIO_DEBUG2
02229             struct in_addr clientip;
02230             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02231            if( s_mgr->m_log.is_open() )
02232                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02233                              << " port: " <<  htons( s_remoteAddress.sin_port )
02234                              << " get number of storage nodes " << endl;
02235             #endif
02236 
02237             offset = 0;
02238 
02239             // Get method parameters from ascii buffer
02240             // Get Session Id
02241             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
02242                 &offset ) )
02243             {
02244                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02245             }
02246             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
02247                 &offset ) )
02248             {
02249                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02250             }
02251 
02252             // Call method
02253             HRESULT hresult = GetNumberOfStorageNodes( &NumberOfStorageNodes );
02254 
02255             // Check if Result Size is less than Result buffer
02256             Size = MAX_LONG_STRING_SIZE + MAX_ULONG_STRING_SIZE;
02257             if( Size > *ResultSize )
02258             {
02259                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02260             }
02261             offset = 0;
02262 
02263             // Set return result
02264             SetLong( *Result, hresult, &offset );
02265             // Set Number of storage nodes
02266             SetULong( *Result, NumberOfStorageNodes, &offset );
02267 
02268             // Update output result size
02269             *ResultSize = offset;
02270 
02271             return S_OK;
02272         }
02273         // --------------------------------------------------------------------
02274         // added to support df command -----------------------------
02275         case RioMethodSessionManagerGetStorageNodeInfo:
02276         {
02277             RioSessionId Session;
02278             unsigned int StorageNodeIndex;
02279             RioStorageNodeInfo StorageNodeInfo;
02280 
02281             #ifdef RIO_DEBUG2
02282             struct in_addr clientip;
02283             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02284            if( s_mgr->m_log.is_open() )
02285                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02286                              << " port: " <<  htons( s_remoteAddress.sin_port )
02287                              << " get storage node info " << endl;
02288             #endif
02289 
02290             offset = 0;
02291 
02292             // Get method parameters from ascii buffer
02293             // Get Session Id
02294             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
02295                 &offset ) )
02296             {
02297                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02298             }
02299             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
02300                 &offset ) )
02301             {
02302                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02303             }
02304 
02305             if( !GetULong( Parameter, ParameterSize, &StorageNodeIndex,
02306                 &offset ) )
02307             {
02308                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02309             }
02310 
02311             // Call method
02312             HRESULT hresult = GetStorageNodeInfo( StorageNodeIndex,
02313                                                   &StorageNodeInfo );
02314 
02315             // Check if Result Size is less than Result buffer
02316             Size = MAX_LONG_STRING_SIZE +
02317                    60 + MAX_SHORT_STRING_SIZE +
02318                    4* ( 60 + ( 3 * MAX_ULONG_STRING_SIZE )) + 1;
02319 
02320             if( Size > *ResultSize )
02321             {
02322                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02323             }
02324             offset = 0;
02325 
02326             // Set return result
02327             SetLong( *Result, hresult, &offset );
02328 
02329             // Set StorageNodeInfo
02330 
02331             // Set Hostname Type
02332             SetString( *Result, (char*)StorageNodeInfo.Hostname, &offset );
02333             // Set NumberOfdisks
02334             SetShort( *Result, StorageNodeInfo.NumberOfDisks, &offset );
02335             //for each disk set name, size, freeblocks
02336             int i;
02337 
02338             for( i = 0; i < (int) StorageNodeInfo.NumberOfDisks; i++ )
02339             {
02340                  // Set DiskName
02341                  SetString( *Result, ( char* )StorageNodeInfo.Disks[i].DiskName,
02342                             &offset );
02343                  // Set Disk Size
02344                  unsigned int highpart = ( unsigned int )
02345                        (( StorageNodeInfo.Disks[i].Size >> 32 ) & 0xffffffff );
02346                  unsigned int lowpart = ( unsigned int )
02347                                 ( StorageNodeInfo.Disks[i].Size & 0xffffffff );
02348                  SetULong( *Result, highpart, &offset );
02349                  SetULong( *Result, lowpart, &offset );
02350                  // Set Number of free blocks
02351                  SetULong( *Result, StorageNodeInfo.Disks[i].NumberOfFreeBlocks,
02352                            &offset );
02353             }
02354             // Update output result size
02355             *ResultSize = offset;
02356 
02357             return S_OK;
02358         }
02359         // --------------------------------------------------------------------
02360         // added to get number of active sessions ------------------
02361         case RioMethodSessionManagerGetNumberOfActiveAndMaxSessions:
02362         {
02363             RioSessionId Session;
02364             unsigned int NumberOfActiveSessions;
02365             unsigned int NumberOfMaxSessions;
02366 
02367             #ifdef RIO_DEBUG2
02368             struct in_addr clientip;
02369             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02370            if( s_mgr->m_log.is_open() )
02371                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02372                              << " port: " <<  htons( s_remoteAddress.sin_port )
02373                              << " get number of active and max sessions "
02374                              << endl;
02375             #endif
02376 
02377             offset = 0;
02378 
02379             // Get method parameters from ascii buffer
02380             // Get Session Id
02381             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
02382                 &offset ) )
02383             {
02384                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02385             }
02386             if( !GetLong( Parameter, ParameterSize, &(Session.Index),
02387                 &offset ) )
02388             {
02389                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02390             }
02391 
02392             // Call method
02393             HRESULT hresult = GetNumberOfActiveAndMaxSessions(
02394                                                        &NumberOfActiveSessions,
02395                                                        &NumberOfMaxSessions );
02396 
02397             // Check if Result Size is less than Result buffer
02398             Size = MAX_LONG_STRING_SIZE + 2 * MAX_ULONG_STRING_SIZE;
02399             if( Size > *ResultSize )
02400             {
02401                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02402             }
02403             offset = 0;
02404 
02405             // Set return result
02406             SetLong( *Result, hresult, &offset );
02407             // Set Number of active sessions
02408             SetULong( *Result, NumberOfActiveSessions, &offset );
02409             // Set Number of max sessions
02410             SetULong( *Result, NumberOfMaxSessions, &offset );
02411 
02412             // Update output result size
02413             *ResultSize = offset;
02414 
02415             return S_OK;
02416         }
02417         // --------------------------------------------------------------------
02418         // added to save measures from storagenodes, cac, etc ------
02419         case RioMethodSessionManagerSaveMeasures:
02420         {
02421             RioSessionId Session;
02422 
02423             #ifdef RIO_DEBUG2
02424             struct in_addr clientip;
02425             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02426            if( s_mgr->m_log.is_open() )
02427                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02428                              << " port: " <<  htons( s_remoteAddress.sin_port )
02429                              << " save measures " << endl;
02430             #endif
02431 
02432             offset = 0;
02433 
02434             // Get Session Id
02435             if( !GetLong( Parameter, ParameterSize, &(Session.Version),
02436                 &offset ) )
02437             {
02438                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02439             }
02440             if(!GetLong( Parameter, ParameterSize, &(Session.Index), &offset ))
02441             {
02442                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02443             }
02444 
02445             // Call method
02446             HRESULT hresult = SaveMeasures();
02447 
02448             Size = 3 * MAX_LONG_STRING_SIZE;
02449             if( Size > *ResultSize )
02450             {
02451                 Close();
02452                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02453             }
02454             offset = 0;
02455 
02456             // Set return result
02457             SetLong( *Result, hresult, &offset );
02458 
02459             // Update output result size
02460             *ResultSize = offset;
02461             return S_OK;
02462         }
02463         // --------------------------------------------------------------------
02464         // getting IPs and ports of RioServer and Storage Servers
02465         case RioMethodSessionManagerGetServerAddress:
02466         {
02467             // Temos que enviar m_ServerAddressSize valores do tipo 
02468             // unsigned short e m_ServerAddressSize + 1 valores do 
02469             // tipo unsigned int: um valor unsigned int com o valor
02470             // m_ServerAddressSize, e m_ServerAddressSize pares de 
02471             // unsigned int, unsigned short, com os IPs e as portas
02472             // do RIO Server e dos Storage Servers.
02473             Size = s_mgr->m_ServerAddressSize * MAX_USHORT_STRING_SIZE + 
02474                    (s_mgr->m_ServerAddressSize + 1) * MAX_ULONG_STRING_SIZE;
02475             if( Size > *ResultSize )
02476             {
02477                 RioErr << "Error: Message too int." << endl;
02478                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02479             }
02480             offset = 0;
02481             // O numero de pares IP, porta e igual ao numero de Storage Servers
02482             // (um par IP, porta UDP para cada Storage Server) mais 1 (um par
02483             // IP, porta UDP para o RIO Server).
02484             SetULong( *Result, s_mgr->m_ServerAddressSize, &offset );
02485             // Adiciona cada par IP,porta a resposta.
02486             for( unsigned int i = 0; i < s_mgr->m_ServerAddressSize; i++ )
02487             {
02488                 // Adiciona cada um dos pares IP,porta a resposta.
02489                 SetULong( *Result, 
02490                           ntohl( s_mgr->m_ServerAddress[ i ].sin_addr.s_addr ),
02491                           &offset );
02492                 SetUShort( *Result, ntohs ( s_mgr->m_ServerAddress[ i ].sin_port ),
02493                            &offset );
02494             }
02495             // Atualiza o tamanho da resposta da chamada.
02496             *ResultSize = offset;
02497             return S_OK;
02498         }
02499         // --------------------------------------------------------------------
02500         // added to get current state of the monitor table
02501         case RioMethodSessionManagerGetMonitorTable:
02502         {
02503             char *UserName;
02504             if( !GetString(Parameter, ParameterSize, &UserName, &offset ) )
02505             {
02506                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02507             }
02508             
02509             if( strcmp( UserName, "root") != 0 )
02510             {
02511                 return ERROR_CONNECTIONMANAGER + ERROR_PERMISSION_DENIED;
02512             }
02513             
02514             vector<ClientData> clientTable;
02515             vector<StorageData> storageTable;
02516             GetMonitorTable( clientTable, storageTable );
02517 
02518             time_t currentTime;
02519             time( &currentTime );
02520 
02521             // Computa o tamanho da mensagem, para ver se e necessario aumentar
02522             // o espaco alocado (igual a MaxTCPDataSize).
02523             unsigned int MessageSize;
02524             // Tamamnho do maior inteiro (20 bytes) mais o sinal (1 byte) e o 
02525             // terminador (1 byte).
02526             char BufferAux[ 22 ]; 
02527             // Tamanho das tabelas.
02528             sprintf( BufferAux, "%hu", (unsigned short) clientTable.size() );
02529             MessageSize = strlen( BufferAux ) + 1;
02530             sprintf( BufferAux, "%hu", (unsigned short) storageTable.size() );
02531             MessageSize += strlen( BufferAux ) + 1;
02532             // Computa o tamanho gasto pela tabela com as informacoes dos 
02533             // clientes.
02534             for( vector<ClientData>::iterator c_it = clientTable.begin();
02535                  c_it != clientTable.end(); c_it++ )
02536             {
02537                 // Espaco gasto pelo ndereco IP.
02538                 MessageSize += strlen( (*c_it).m_ip.c_str() ) + 1; 
02539                 // Espaco gasto pela porta.
02540                 sprintf( BufferAux, "%hu", (unsigned short) (*c_it).m_port );
02541                 MessageSize += strlen( BufferAux ) + 1;
02542                 // Espaco gasto pelo nome do video.
02543                 MessageSize += strlen( (*c_it).m_video.c_str() ) + 1; 
02544                 // Espaco gasto pelo tempo de conexao.
02545                 double connection_time = difftime( currentTime, (*c_it).m_time );                
02546                 sprintf( BufferAux, "%hu", (unsigned short) connection_time );
02547                 MessageSize += strlen( BufferAux ) + 1;
02548                 // Espaco gasto pelo tempo de conexao pelo tamanho da fila.
02549                 sprintf( BufferAux, "%hu", (unsigned short) (*c_it).m_queue );
02550                 MessageSize += strlen( BufferAux ) + 1;
02551             }            
02552             // Computa o tamanho gasto pel tabela com as informacoes dos discos.
02553             for( vector<StorageData>::iterator s_it = storageTable.begin();
02554                  s_it != storageTable.end(); s_it++ )
02555             {
02556                 // Espaco gasto pelo endereo IP do servidor de armazenamento.
02557                 MessageSize += strlen( (*s_it).m_ip.c_str() ) + 1;
02558                 // Espaco gasto pelo nome da maquina do servidor de 
02559                 // armazenamento.
02560                 MessageSize += strlen( (*s_it).m_hostname.c_str() ) + 1;
02561                 // Espaco gasto pelo nome do disco do servidor de armazenamento.
02562                 MessageSize += strlen( (*s_it).m_diskname.c_str() ) + 1;
02563                 // Espaco gasto pelo tamanho da fila.
02564                 sprintf( BufferAux, "%hu", (unsigned short) (*s_it).m_queue );
02565                 MessageSize += strlen( BufferAux ) + 1;
02566             }
02567             // Verifica se e necessario realocar o espaco
02568             #ifdef RIO_DEBUG2
02569             RioErr << "RioSession::ExecuteSessionManager tamanho computado para"
02570                    << " a mensagem foi de " << " bytes." << endl;
02571             #endif       
02572             if( MessageSize > *ResultSize )
02573             {
02574                 // Tenta aumentar o espaco alocado.
02575                 #ifdef RIO_DEBUG2
02576                 RioErr << "RioSession::ExecuteSessionManager realocando a"
02577                        << " memoria de " << *ResultSize << " bytes para "
02578                        << MessageSize << " bytes." << endl;
02579                 #endif       
02580                 char *NewResult = ( char * ) realloc( *Result, MessageSize );
02581                 if( NewResult == NULL )
02582                 {
02583                     return ERROR_CONNECTIONMANAGER + 
02584                            ERROR_RESULT_MESSAGE_OVERFLOW;
02585                 }
02586                 *Result = NewResult;
02587             }
02588             
02589             offset = 0;
02590 
02591             // Set return result
02592             SetUShort( *Result, (unsigned short)  clientTable.size(), &offset );
02593             SetUShort( *Result, (unsigned short) storageTable.size(), &offset );
02594             for( vector<ClientData>::iterator c_it = clientTable.begin();
02595                  c_it != clientTable.end(); c_it++ )
02596             {
02597                 double connection_time = difftime( currentTime, (*c_it).m_time );                
02598                 SetString( *Result,                 (*c_it).m_ip.c_str(), &offset );
02599                 SetUShort( *Result, (unsigned short)(*c_it).m_port,       &offset );
02600                 SetString( *Result, (*c_it).m_video.c_str(),              &offset );
02601                 SetUShort( *Result, (unsigned short) connection_time,     &offset );
02602                 SetUShort( *Result, (unsigned short)(*c_it).m_queue,      &offset );
02603             }
02604             for( vector<StorageData>::iterator s_it = storageTable.begin();
02605                  s_it != storageTable.end(); s_it++ )
02606             {
02607                 SetString( *Result,                 (*s_it).m_ip.c_str(),       &offset );
02608                 SetString( *Result,                 (*s_it).m_hostname.c_str(), &offset );
02609                 SetString( *Result,                 (*s_it).m_diskname.c_str(), &offset );
02610                 SetUShort( *Result, (unsigned short)(*s_it).m_queue,            &offset );
02611             }
02612 
02613             // Update output result size
02614             *ResultSize = offset;
02615             
02616             #ifdef RIO_DEBUG2
02617             RioErr << "CSessionManager::ExecuteSessionMananger o tamanho da " 
02618                    << "mensagem e de " << offset << " bytes." << endl;
02619 
02620             struct in_addr clientip;
02621             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02622             if( s_mgr->m_log.is_open() )
02623                  s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02624                               << " port: " <<  htons( s_remoteAddress.sin_port )
02625                               << " set interface " << endl;
02626             #endif
02627  
02628             return S_OK;
02629         }
02630         // --------------------------------------------------------------------
02631         // this method is used to detect stream control implementation.
02632         case RioMethodSessionManagerCheckStreamControl:
02633         {
02634             offset = 0;
02635 
02636             Size = MAX_LONG_STRING_SIZE;
02637             if( Size > *ResultSize )
02638             {
02639                 Close();
02640                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02641             }
02642 
02643             // Set return result
02644             SetLong( *Result, S_OK, &offset );
02645 
02646             // Update output result size
02647             *ResultSize = offset;
02648             return S_OK;
02649             break;
02650         }
02651         // --------------------------------------------------------------------
02652         //////////////////////////////////////////
02653         // should never execute default case
02654         default:
02655         {
02656             #ifdef RIO_DEBUG2
02657             RioErr << "[CRioSession] Trying to execute invalid method"
02658                    << endl;
02659             #endif
02660             return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD;
02661         };
02662     }
02663 }

int RioSession::ExecuteStreamManager ( unsigned int  Method,
char *  Parameter,
unsigned int  ParameterSize,
char **  Result,
unsigned int *  ResultSize 
) [private]

Definition at line 2666 of file server/SessionManager.cpp.

02671 {
02672     int offset = 0;
02673     unsigned int Size;
02674 
02675     switch( Method )
02676     {
02677         //////////////////////////////////////////
02678         case RioMethodStreamManagerClose:
02679         {
02680             RioStreamId Stream;
02681             offset = 0;
02682 
02683             #ifdef RIO_DEBUG2
02684             struct in_addr clientip;
02685             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02686            if( s_mgr->m_log.is_open() )
02687                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02688                              << " port: " <<  htons( s_remoteAddress.sin_port )
02689                              << " closing stream " << endl;
02690             #endif
02691             // ----------------------------------------------------------------
02692 
02693             // Get method parameters from ascii buffer
02694 
02695             // Get Stream Id
02696             if( !GetLong( Parameter, ParameterSize, &(Stream.Version),
02697                 &offset ) )
02698             {
02699                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02700             }
02701             if( !GetLong( Parameter, ParameterSize, &(Stream.Index), &offset ) )
02702             {
02703                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02704             }
02705 
02706             // Call method
02707             HRESULT hresult = CloseStream( Stream.Index );
02708 
02709             // Check if Result Size is less than Result buffer
02710             Size = MAX_LONG_STRING_SIZE;
02711             if( Size > *ResultSize )
02712             {
02713                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02714             }
02715             offset = 0;
02716 
02717             // Set return result
02718             SetLong( *Result, hresult, &offset );
02719 
02720             // Update output result size
02721             *ResultSize = offset;
02722 
02723             return S_OK;
02724 
02725         }
02726         //////////////////////////////////////////
02727         case RioMethodStreamManagerOpenObject:
02728         {
02729             RioStreamId Stream;
02730             char* ObjectName;
02731             RioAccess Access;
02732             ObjectHandle Handle;
02733             int hresult;
02734             bool AccessGranted;
02735             bool CanRead, CanWrite;
02736 
02737             #ifdef RIO_DEBUG2
02738             struct in_addr clientip;
02739             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02740             if( s_mgr->m_log.is_open() )
02741                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02742                              << " port: " <<  htons( s_remoteAddress.sin_port )
02743                              << " opening object " << endl;
02744             #endif
02745             // ----------------------------------------------------------------
02746 
02747             offset = 0;
02748 
02749             // Get method parameters from ascii buffer
02750 
02751             // Get Stream Id
02752             if( !GetLong( Parameter, ParameterSize, &(Stream.Version),
02753                 &offset ) )
02754             {
02755                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02756             }
02757             if( !GetLong( Parameter, ParameterSize, &(Stream.Index), &offset ) )
02758             {
02759                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02760             }
02761 
02762             // Get Object name
02763             if( !GetString( Parameter, ParameterSize, &ObjectName, &offset ) )
02764             {
02765                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02766             }
02767 
02768             // Get Access type
02769             if( !GetULong( Parameter, ParameterSize, &Access, &offset ) )
02770             {
02771                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02772             }
02773 
02774             // Obtem o numero de servidores ativos e inativos.
02775 
02776             s_mgr->m_Router->GetStorageInfo( s_ServerNat, &CanRead, &CanWrite );
02777 
02778             // Verifica, caso desejemos abrir o arquivo para escrita, se a 
02779             // solicitacao de blocos pode ser feita. 
02780             //
02781             // Obs: a leitura nao e verificada porque isso precisa sera feito 
02782             // quando processarmos o pedido do bloco na classe Router: se nao
02783             // existirem discos disponiveis, isto e, se todos os servidores de
02784             // armazenamento cujos discos possuem uma copia do bloco logico a 
02785             // ser acessado estao indisponiveies, a classe Router retornara, ao
02786             // cliente, que o pedido nao foi finalizado corretamente, usando o
02787             // erro ERROR_INVALID_DISK (que agora nao siginicara mais, 
02788             // necessariamente, um bug no RIO).
02789             AccessGranted = true;
02790             if( ( Access & RIO_WRITE_MASK ) != 0 )
02791             {
02792                 AccessGranted = CanWrite;
02793             } 
02794             if( AccessGranted )
02795             {
02796                 // Call method
02797                 hresult = StreamOpenObject( Stream.Index, ObjectName, Access, 
02798                                             &Handle.Index );
02799                 // It was a bug when the name of the object was
02800                 // wrong. It tried to remove the object but it was not opened.
02801                 // With the test below it is corrected.
02802                 if( FAILED( hresult ) )
02803                 {
02804                     int rc;
02805                     rc = RemoveIdEntryFromTable( Handle.Index, idt_streamobj );
02806                     if( rc )
02807                         RioErr << "Error: Object does not exist. Could not "
02808                                   "remove. Did not find id on ta ble." << endl;
02809                 }
02810             }
02811             else
02812                 hresult = ERROR_SESSIONMANAGER + 
02813                           ERROR_SERVICE_TEMPORARY_UNAVAILABLE;
02814 
02815             // ----------------------------------------------------------------
02816 
02817             // Check if Result Size is less than Result buffer
02818             Size = 3 * MAX_LONG_STRING_SIZE;
02819             if( Size > *ResultSize )
02820             {
02821                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02822             }
02823             offset = 0;
02824 
02825             // Set return result
02826             SetLong( *Result, hresult, &offset );
02827             // Set Object Handle
02828             SetLong( *Result, Handle.Version, &offset );
02829             SetLong( *Result, Handle.Index, &offset );
02830 
02831             // Update output result size
02832             *ResultSize = offset;
02833             
02834             return S_OK;
02835         }
02836 
02837         //added to get RTT and buffersize from client --------------
02838         case RioMethodStreamManagerOpenObjectSubmitToCAC:
02839         {
02840             RioStreamId Stream;
02841             char* ObjectName;
02842             RioAccess Access;
02843             ObjectHandle Handle;
02844             struct timeval average_RTT;
02845             int BufferSize;
02846             RioObjectSize ObjectSize;
02847             int hresult;
02848             bool AccessGranted;
02849             bool CanRead, CanWrite;
02850             unsigned int highpart = 0;
02851             unsigned int lowpart = 0;
02852             int m_FlagRequests;
02853             int AuxInt;
02854 
02855             /* --------------------------- */
02856 
02857 
02858             #ifdef RIO_DEBUG2
02859             struct in_addr clientip;
02860             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
02861             if( s_mgr->m_log.is_open() )
02862                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
02863                              << " port: " <<  htons( s_remoteAddress.sin_port )
02864                              << " opening object (submit to cac) ";
02865             #endif
02866 
02867             offset = 0;
02868 
02869             // Get method parameters from ascii buffer
02870 
02871             // Get Stream Id
02872             if( !GetLong( Parameter, ParameterSize, &(Stream.Version),
02873                 &offset ) )
02874             {
02875                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02876             }
02877             if( !GetLong( Parameter, ParameterSize, &(Stream.Index), &offset ) )
02878             {
02879                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02880             }
02881 
02882             // Get Object name
02883             if( !GetString( Parameter, ParameterSize, &ObjectName, &offset ) )
02884             {
02885                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02886             }
02887 
02888             // Get Access type
02889             if( !GetULong( Parameter, ParameterSize, &Access, &offset ) )
02890             {
02891                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02892             }
02893 
02894 
02895             // Get average RTT
02896             if( !GetLong( Parameter, ParameterSize, &AuxInt, &offset ) )
02897             {
02898                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02899             }
02900             average_RTT.tv_sec = AuxInt;
02901             if( !GetLong( Parameter, ParameterSize, &AuxInt, &offset ) )
02902             {
02903                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02904             }
02905             average_RTT.tv_usec = AuxInt;
02906             // Get buffer size
02907             if( !GetLong( Parameter, ParameterSize, &(BufferSize), &offset ) )
02908             {
02909                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
02910             }
02911 
02912             #ifdef RIO_DEBUG2
02913             if( s_mgr->m_log.is_open() )
02914                 s_mgr->m_log << " get from client  RTT: "
02915                              << average_RTT.tv_sec << " : "
02916                              << average_RTT.tv_usec
02917                              << " BufferSize : " << BufferSize << endl;
02918             #endif
02919 
02920             // Obtem o numero de servidores ativos e inativos.
02921             s_mgr->m_Router->GetStorageInfo( s_ServerNat, &CanRead, &CanWrite );
02922             
02923             // Verifica, caso desejemos abrir o arquivo para escrita, se a 
02924             // solicitacao de blocos pode ser feita. 
02925             //
02926             // Obs: a leitura nao e verificada porque isso precisa sera feito 
02927             // quando processarmos o pedido do bloco na classe Router: se nao
02928             // existirem discos disponiveis, isto e, se todos os servidores de
02929             // armazenamento cujos discos possuem uma copia do bloco logico a 
02930             // ser acessado estao indisponiveies, a classe Router retornara, ao
02931             // cliente, que o pedido nao foi finalizado corretamente, usando o
02932             // erro ERROR_INVALID_DISK (que agora nao siginicara mais, 
02933             // necessariamente, um bug no RIO).
02934             AccessGranted = true;
02935             if( ( Access & RIO_WRITE_MASK ) != 0 )
02936             {
02937                 AccessGranted = CanWrite;
02938                                 
02939             } 
02940             if( AccessGranted )
02941             {
02942                 hresult = StreamOpenObject( Stream.Index, ObjectName,
02943                                             average_RTT, BufferSize,
02944                                             Access, &Handle.Index );
02945 
02946                 if( FAILED( hresult ) )
02947                 {
02948                     int rc;
02949                     rc = RemoveIdEntryFromTable( Handle.Index, idt_streamobj );
02950                     if( rc )
02951                         RioErr << "Error: Object does not exist. Could not "
02952                                   " remove. Did not find id on table." << endl;
02953                 }
02954                 else
02955                 {
02956                     // Call method
02957                     hresult = GetSize( Handle.Index, &ObjectSize );
02958 
02959                     // Set Object Size
02960                     highpart = ( unsigned int ) ( ( ObjectSize >> 32 ) & 
02961                                                    0xffffffff );
02962                     lowpart =  ( unsigned int ) ( ObjectSize & 0xffffffff);
02963 
02964                     if( FAILED( hresult ) )
02965                     {
02966                         RioErr << "Error: Could not get size of Object " 
02967                                << ObjectName << " Index " << Handle.Index 
02968                                << endl;
02969                     }
02970                 }
02971             }
02972             else
02973                 hresult = ERROR_SESSIONMANAGER + 
02974                           ERROR_SERVICE_TEMPORARY_UNAVAILABLE;
02975 
02976             // Check if Result Size is less than Result buffer
02977             // Size = 3 * MAX_LONG_STRING_SIZE + MAX_LONG_STRING_SIZE +
02978             /* ----------------------------------------------------- */
02979             Size = 4 * MAX_LONG_STRING_SIZE + MAX_LONG_STRING_SIZE +
02980                    2 * MAX_ULONG_STRING_SIZE;
02981             if( Size > *ResultSize )
02982             {
02983                 RioErr << "Error: Message too int." << endl;
02984                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
02985             }
02986             offset = 0;
02987 
02988             // Set return result
02989             SetLong( *Result, hresult, &offset );
02990 
02991             // Set Object Handle
02992             SetLong( *Result, Handle.Version, &offset );
02993             SetLong( *Result, Handle.Index, &offset );
02994 
02995             // to reduce 1 RTT send object size
02996             SetULong( *Result, highpart, &offset );
02997             SetULong( *Result, lowpart, &offset );
02998 
02999             m_FlagRequests = 2;
03000 
03001             SetLong( *Result, m_FlagRequests, &offset );
03002 
03003             /* ---------------------------------------- */
03004 
03005             // Update output result size
03006             *ResultSize = offset;
03007 
03008             return S_OK;
03009         }
03010         // --------------------------------------------------------------------
03011         //////////////////////////////////////////
03012         case RioMethodStreamManagerMaxRequests:
03013         {
03014             RioStreamId Stream;
03015 
03016             #ifdef RIO_DEBUG2
03017             struct in_addr clientip;
03018             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03019            if( s_mgr->m_log.is_open() )
03020                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03021                              << " port: " <<  htons( s_remoteAddress.sin_port )
03022                              << " get max requests " << endl;
03023             #endif
03024             // ----------------------------------------------------------------
03025 
03026             offset = 0;
03027 
03028             // Get method parameters from ascii buffer
03029 
03030             // Get Stream Id
03031             if( !GetLong( Parameter, ParameterSize, &(Stream.Version),
03032                 &offset ) )
03033             {
03034                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03035             }
03036             if( !GetLong( Parameter, ParameterSize, &(Stream.Index), &offset ) )
03037             {
03038                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03039             }
03040             int hresult = StreamMaxRequests( Stream.Index );
03041 
03042             // Check if Result Size is less than Result buffer
03043             Size = MAX_LONG_STRING_SIZE;
03044             if( Size > *ResultSize )
03045             {
03046                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03047             }
03048             offset = 0;
03049 
03050             // Set return result
03051             SetLong( *Result, hresult, &offset );
03052 
03053             // Update output result size
03054             *ResultSize = offset;
03055             return S_OK;
03056         }
03057         // to be used to warn when the client can start the visualization
03058         case RioMethodStreamManagerClientCanStart:
03059         {
03060             RioStreamId Stream;
03061 
03062             #ifdef RIO_DEBUG2
03063             struct in_addr clientip;
03064             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03065            if( s_mgr->m_log.is_open() )
03066                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
03067                              << " port: " <<  htons( s_remoteAddress.sin_port )
03068                              << " can start? " << endl;
03069             #endif
03070 
03071             offset = 0;
03072 
03073             // Get method parameters from ascii buffer
03074 
03075             // Get Stream Id
03076             if( !GetLong( Parameter, ParameterSize, &(Stream.Version),
03077                 &offset ) )
03078             {
03079                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03080             }
03081             if( !GetLong( Parameter, ParameterSize, &(Stream.Index), &offset ) )
03082             {
03083                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
03084             }
03085 
03086             int hresult = ClientCanStart( Stream.Index );
03087 
03088             // Check if Result Size is less than Result buffer
03089             Size = MAX_LONG_STRING_SIZE;
03090             if( Size > *ResultSize )
03091             {
03092                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
03093             }
03094             offset = 0;
03095 
03096             // Set return result
03097             SetLong( *Result, hresult, &offset );
03098 
03099             // Update output result size
03100             *ResultSize = offset;
03101 
03102             return S_OK;
03103         }
03104         // --------------------------------------------------------------------
03105         //////////////////////////////////////////
03106         // should never execute default case
03107         default:
03108         {
03109             return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD;
03110         }
03111     }
03112 }

int RioSession::ExecuteUserManager ( unsigned int  Method,
char *  Parameter,
unsigned int  ParameterSize,
char **  Result,
unsigned int *  ResultSize 
) [private]

Definition at line 4427 of file server/SessionManager.cpp.

04432 {
04433     int offset = 0;
04434     unsigned int Size;
04435     switch( Method )
04436     {
04437         // Metodo para criar um novo usuario.
04438         //////////////////////////////////////////
04439         case RioMethodUserManagerCreateUser:
04440         {
04441             char* UserName;
04442             char* Password;
04443             HRESULT hResult;
04444 
04445             offset = 0;
04446 
04447             #ifdef RIO_DEBUG2
04448             struct in_addr clientip;
04449             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
04450             if( s_mgr->m_log.is_open() )
04451                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
04452                              << " port: " <<  htons( s_remoteAddress.sin_port )
04453                              << " creating user " << endl;
04454             #endif
04455             // ----------------------------------------------------------------
04456 
04457             // Get method parameters from ascii buffer
04458 
04459             // Get UserName
04460             if( !GetString( Parameter, ParameterSize, &UserName, &offset ) )
04461             {
04462                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04463             }
04464 
04465             // Get Password
04466             if( !GetString( Parameter, ParameterSize, &Password, &offset ) )
04467             {
04468                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04469             }
04470 
04471             // Tenta criar o usuario
04472             hResult = CreateUser( UserName, Password );
04473 
04474             // Check if Result Size is less than Result buffer
04475             Size = MAX_LONG_STRING_SIZE;
04476             if( Size > *ResultSize )
04477             {
04478                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
04479             }
04480             offset = 0;
04481 
04482             // Set return result
04483             SetLong( *Result, hResult, &offset );
04484 
04485             // ----------------------------------------------------------------
04486 
04487             // Update output result size
04488             *ResultSize = offset;
04489             return S_OK;
04490         }
04491 
04492         // Metodo para remover um usuario existente.
04493         //////////////////////////////////////////
04494         case RioMethodUserManagerRemoveUser:
04495         {
04496             char* UserName;
04497             HRESULT hResult;
04498 
04499             offset = 0;
04500 
04501             #ifdef RIO_DEBUG2
04502             struct in_addr clientip;
04503             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
04504             if( s_mgr->m_log.is_open() )
04505                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
04506                              << " port: " <<  htons( s_remoteAddress.sin_port )
04507                              << " remove user " << endl;
04508             #endif
04509             // ----------------------------------------------------------------
04510 
04511 
04512             // Get method parameters from ascii buffer
04513 
04514             // Get UserName
04515             if( !GetString( Parameter, ParameterSize, &UserName, &offset ) )
04516             {
04517                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04518             }
04519 
04520             // Tenta remover o usuario
04521             hResult = RemoveUser( UserName );
04522 
04523             // Check if Result Size is less than Result buffer
04524             Size = MAX_LONG_STRING_SIZE;
04525             if( Size > *ResultSize )
04526             {
04527                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
04528             }
04529             offset = 0;
04530 
04531             // Set return result
04532             SetLong( *Result, hResult, &offset );
04533 
04534             // ----------------------------------------------------------------
04535 
04536             // Update output result size
04537             *ResultSize = offset;
04538             return S_OK;
04539         }
04540 
04541         // Metodo para alterar a senha de um usuario existente.
04542         //////////////////////////////////////////
04543         case RioMethodUserManagerChangePassword:
04544         {
04545             char* UserName;
04546             char* Password;
04547             HRESULT hResult;
04548 
04549             offset = 0;
04550 
04551             #ifdef RIO_DEBUG2
04552             struct in_addr clientip;
04553             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
04554             if( s_mgr->m_log.is_open() )
04555                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
04556                              << " port: " <<  htons( s_remoteAddress.sin_port )
04557                              << " change password " << endl;
04558             #endif
04559             // ----------------------------------------------------------------
04560 
04561 
04562             // Get method parameters from ascii buffer
04563 
04564             // Get UserName
04565             if( !GetString( Parameter, ParameterSize, &UserName, &offset ) )
04566             {
04567                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04568             }
04569 
04570             // Get Password
04571             if( !GetString( Parameter, ParameterSize, &Password, &offset ) )
04572             {
04573                 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM;
04574             }
04575 
04576             // Tenta criar o usuario
04577             hResult = ChangePassword( UserName, Password );
04578 
04579             // Check if Result Size is less than Result buffer
04580             Size = MAX_LONG_STRING_SIZE;
04581             if( Size > *ResultSize )
04582             {
04583                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
04584             }
04585             offset = 0;
04586 
04587             // Set return result
04588             SetLong( *Result, hResult, &offset );
04589 
04590             // ----------------------------------------------------------------
04591 
04592             // Update output result size
04593             *ResultSize = offset;
04594             return S_OK;
04595         }
04596 
04597         // Metodo para retornar a lista de usuarios.
04598         //////////////////////////////////////////
04599         case RioMethodUserManagerUserList:
04600         {
04601             HRESULT hResult;
04602             vector< string > UserList;
04603 
04604             #ifdef RIO_DEBUG2
04605             struct in_addr clientip;
04606             clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
04607             if( s_mgr->m_log.is_open() )
04608                 s_mgr->m_log << " ip: " << inet_ntoa(clientip )
04609                              << " port: " <<  htons( s_remoteAddress.sin_port )
04610                              << " user list " << endl;
04611             #endif
04612             // ----------------------------------------------------------------
04613 
04614             // Tenta criar o usuario
04615             hResult = GetUserList( UserList );
04616 
04617             if( FAILED( hResult ) )
04618                 Size = MAX_LONG_STRING_SIZE;
04619             else
04620             {
04621                 Size = MAX_LONG_STRING_SIZE + MAX_ULONG_STRING_SIZE;
04622                 for( unsigned int i = 0; i < UserList.size(); i++ )
04623                     Size = Size + strlen( UserList[ i ].c_str() ) + 1;
04624 
04625                 #ifdef RIO_DEBUG2
04626                 // Mostra a lista a ser enviada
04627                 RioErr << "RioSession::ExecuteUserManager lista de usuarios a "
04628                        << "ser enviada, com " << UserList.size()
04629                        << " usuarios: ";
04630                 for( unsigned int i = 0; i < UserList.size(); i++ )
04631                 {
04632                     RioErr << UserList[ i ];
04633                     if( i != ( UserList.size() - 1 ) )
04634                         RioErr << ",";
04635                 }
04636                 RioErr << endl;
04637                 #endif
04638 
04639             }
04640 
04641             // Check if Result Size is less than Result buffer
04642             if( Size > *ResultSize )
04643             {
04644                 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
04645             }
04646             offset = 0;
04647 
04648             // Set return result
04649             SetLong( *Result, hResult, &offset );
04650 
04651             // Se nao ocorreu nenhum erro, adiciona os usuarios a mensagem.
04652             if( !FAILED( hResult ) )
04653             {
04654                 SetULong( *Result, UserList.size(), &offset );
04655                 for( unsigned int i = 0; i < UserList.size(); i++ )
04656                     SetString( *Result, UserList[ i ].c_str(), &offset );
04657             }
04658 
04659             // Update output result size
04660             *ResultSize = offset;
04661 
04662             return S_OK;
04663         }
04664         //////////////////////////////////////////
04665         // should never execute default case
04666         default:
04667         {
04668             return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD;
04669         };
04670     }
04671 }

int RioSession::FirstObject ( char *  DirectoryName,
int *  dirid,
int *  IsDirectory,
int  BufferSize,
char *  ObjectName 
) [private]

Definition at line 5052 of file server/SessionManager.cpp.

05055 {
05056     int rc;
05057     char Path[MaxPathSize + 1];
05058 
05059     // convert input to full RIO path name
05060     rc = ObjectToPath( DirectoryName, Path, sizeof( Path ));
05061     if( rc )
05062         return rc;
05063 
05064     RioDirectory **idp = (RioDirectory **) newid( dirid, idt_directory );
05065     if( idp == 0 )
05066     {
05067         return ERROR_SESSIONMANAGER + ERROR_MAX_OPENED_OBJECTS;
05068     }
05069 
05070     rc = s_user->CheckAccess( Path );
05071 
05072     if( rc == 0 )
05073         rc = s_mgr->m_ObjectManager->FirstObject( Path, idp,
05074                                                   IsDirectory, BufferSize,
05075                                                   ObjectName );
05076     return rc;
05077 }

int RioSession::GetBlockSize ( unsigned int *  BlockSize  )  [private]

Definition at line 4987 of file server/SessionManager.cpp.

04988 {
04989     *BlockSize = s_mgr->m_BlockSize;
04990     return S_OK;
04991 }

int RioSession::GetCurrentDir ( int  size,
char *  Dir 
) [private]

Definition at line 5133 of file server/SessionManager.cpp.

05134 {
05135     if( (( signed ) strlen( s_CurrentDir ) + 1 ) >= size )
05136     {
05137         return ERROR_SESSIONMANAGER + ERROR_NAMEBUFFER_OVERFLOW;
05138     }
05139 
05140     strcpy( Dir, "/" );
05141     strcpy( Dir + 1, s_CurrentDir );
05142     return S_OK;
05143 }

int RioSession::GetMonitorTable ( vector< ClientData > &  clientTable,
vector< StorageData > &  storageTable 
) [private]

Definition at line 1301 of file server/SessionManager.cpp.

01303 {
01304     s_mgr->GetMonitorTable( clientTable, storageTable );
01305     return 0;
01306 }

int RioSession::GetnBlocks ( int  ObjectId,
RioBlock nBlocks 
) [private]

Definition at line 5181 of file server/SessionManager.cpp.

05182 {
05183     RioStreamObj *op = ( RioStreamObj * ) checkid( ObjectId, idt_streamobj );
05184     if( op == 0 )
05185     {
05186         return ERROR_SESSIONMANAGER + ERROR_INVALID_OBJECT_HANDLE;
05187     }
05188 
05189     return op->GetnBlocks( nBlocks );
05190 }

int RioSession::GetNumberOfActiveAndMaxSessions ( unsigned int *  NumberOfActiveSessions,
unsigned int *  NumberOfMaxSessions 
) [private]

Definition at line 5043 of file server/SessionManager.cpp.

05046 {
05047     *NumberOfActiveSessions = s_mgr->m_used;
05048     *NumberOfMaxSessions = s_mgr->m_MaxSessions;
05049     return S_OK;
05050 }

int RioSession::GetNumberOfDisks ( unsigned int *  NumberOfDisks  )  [private]

Definition at line 5017 of file server/SessionManager.cpp.

05018 {
05019     *NumberOfDisks = s_mgr->m_NumberOfDisks;
05020     return S_OK;
05021 }

int RioSession::GetNumberOfStorageNodes ( unsigned int *  NumberOfStorageNodes  )  [private]

Definition at line 5024 of file server/SessionManager.cpp.

05025 {
05026     *NumberOfStorageNodes = s_mgr->m_NumberOfStorageNodes;
05027     return S_OK;
05028 }

int RioSession::GetObjectInfo ( char *  ObjectName,
ObjectInfo ObjectInfo 
) [private]

Definition at line 5096 of file server/SessionManager.cpp.

05097 {
05098     int rc;
05099     char Path[MaxPathSize + 1];
05100 
05101     // convert input to full RIO path name
05102     rc = ObjectToPath( ObjectName, Path, sizeof( Path ) );
05103     if( rc )
05104         return rc;
05105 
05106     return s_mgr->m_ObjectManager->GetObjectInfo( Path, ObjectInfo );
05107 }

int RioSession::GetRemoteAddress ( SOCKADDR_IN Address  )  [private]

Definition at line 4994 of file server/SessionManager.cpp.

04995 {
04996     *Address = s_remoteAddress;
04997     return S_OK;
04998 }

int RioSession::GetSize ( int  ObjectId,
RioObjectSize ObjectSize 
) [private]

Definition at line 5145 of file server/SessionManager.cpp.

05146 {
05147     RioStreamObj *op = ( RioStreamObj * ) checkid( ObjectId, idt_streamobj );
05148     if( op == 0 )
05149     {
05150         RioErr << "Invalid Object Handle "<< ObjectId << endl;
05151         return ERROR_SESSIONMANAGER + ERROR_INVALID_OBJECT_HANDLE;
05152     }
05153     return op->GetSize( ObjectSize );
05154 }

int RioSession::GetStorageNodeInfo ( unsigned int  StorageNodeIndex,
RioStorageNodeInfo StorageNodeInfo 
) [private]

Definition at line 5032 of file server/SessionManager.cpp.

05034 {
05035     int rc = 0;
05036     rc =  s_mgr->m_DiskMgr->GetStorageNodeInfo( StorageNodeIndex,
05037                                                 StorageNodeInfo );
05038     return rc;
05039 }

int RioSession::GetType ( int  ObjectId,
short *  Type 
) [private]

Definition at line 5170 of file server/SessionManager.cpp.

05171 {
05172     RioStreamObj *op = ( RioStreamObj * ) checkid( ObjectId, idt_streamobj );
05173     if( op == 0 )
05174     {
05175         return ERROR_SESSIONMANAGER + ERROR_INVALID_OBJECT_HANDLE;
05176     }
05177 
05178     return op->GetType( Type );
05179 }

int RioSession::GetUserList ( vector< string > &  UserList  )  [private]

Nova funcao para obter a lista com todos os usuarios.

Parameters:
USerList vetor de strings (STL) no qual a lista de usuarios sera armazenada.
Returns:
S_OK caso a lista tenha sido gerada com sucesso ou o codigo de erro caso nao tenha sido possivel gerar a lista.

Definition at line 4778 of file server/SessionManager.cpp.

04779 {
04780     // Armazena o ponteiro o nome do usuario associado a sessao, que atualmente
04781     // e igual ao diretorio padrao do usuario. Se depois mudarmos isso,
04782     // precisamos criar em RioUser um novo campo com o nome do usuario.
04783     char *SessionUserName;
04784 
04785     // Obtem o "nome" do usuario.
04786     s_user->GetUser( &SessionUserName );
04787 
04788     // O usuario root podera alterar qualquer senha de qualquer usuario, mas um
04789     // usuario somente podera alterar a sua propria senha.
04790     if( strcmp( SessionUserName, "root" ) != 0 )
04791     {
04792         return ERROR_RIOSESSION + ERROR_PERMISSION_DENIED;
04793     }
04794 
04795     return s_mgr->m_UserManager->GetUserList( UserList );
04796 }

int RioSession::GetVideoRate ( int  ObjectId,
unsigned int *  VideoRate 
) [private]

GetVideoRate funcao usada pela implementacao controle de fluxo para obter a taxa de transmissao do video (esta funcao sera usada pelo novo metodo remoto da Object Manager, que sera usado pelo riosh para ler a taxa de transmissao do video).

Parameters:
ObjectId identificador do objeto.
VideoRate ponteiro para o inteiro nao sinalizado que armazenara a taxa de transmissao do video.
Returns:
diferente de S_OK se algum erro ocorreu ao obter a taxa.

Definition at line 5369 of file server/SessionManager.cpp.

05370 {
05371     RioStreamObj *op = ( RioStreamObj * ) checkid( ObjectId, idt_streamobj );
05372     if( op == 0 )
05373     {
05374         return ERROR_SESSIONMANAGER + ERROR_INVALID_OBJECT_HANDLE;
05375     }
05376 
05377     return op->GetVideoRate( VideoRate );
05378 }

void ** RioSession::newid ( int *  id,
idtype  type 
) [private]

Definition at line 1226 of file server/SessionManager.cpp.

01227 {
01228     unsigned int i;
01229 
01230     // for now a linear search for available id
01231     for( i = 0; i < s_idmax; i++ )
01232     {
01233         if( s_idtable[i].id_type == idt_invalid )
01234         {
01235             s_idtable[i].id_type = type;
01236             *id = i;
01237             return &s_idtable[i].id_object;
01238         }
01239     }
01240     RioErr << "Error: Could not create id " << -1 << endl;
01241     *id = -1;
01242     return 0;
01243 }

int RioSession::NextObject ( int  DirectoryId,
int *  IsDirectory,
int  BufferSize,
char *  ObjectName 
) [private]

Definition at line 5079 of file server/SessionManager.cpp.

05081 {
05082     RioDirectory *dp = (RioDirectory *) checkid( DirectoryId, idt_directory );
05083 
05084     // Inicializa as variaveis IsDirectory e ObjetcName.
05085     *IsDirectory = false;
05086     ObjectName[ 0 ] = 0;
05087 
05088     if( dp == 0 )
05089     {
05090         return ERROR_SESSIONMANAGER + ERROR_OBJECT_NOT_DIRECTORY;
05091     }
05092 
05093     return dp->NextObject( IsDirectory, BufferSize, ObjectName );
05094 }

int RioSession::ObjectToPath ( char *  ObjectName,
char *  RioPath,
int  PathSize 
) [private]

Definition at line 5326 of file server/SessionManager.cpp.

05327 {
05328     // check for absolute path (leading slash)
05329     if( ObjectName[0] == '/' )
05330     {
05331         // Verifica se o caminho e igual a somente "/"
05332         //if( strcmp( ObjectName, "/" ) == 0 )
05333         //  return ERROR_RIOSESSION + ERROR_PERMISSION_DENIED;
05334         // remove leading slash and deal with embeded "." and ".."
05335         return s_mgr->m_ObjectManager->StrToPath( ObjectName + 1,
05336                                                 RioPath, PathSize );
05337     }
05338 
05339     // Name is under current directory
05340     int DirSize = strlen(s_CurrentDir);
05341     if( ( DirSize + 1 + strlen( ObjectName )) > MaxPathSize )
05342     {
05343         return ERROR_SESSIONMANAGER + ERROR_PATHNAME_TOOLARGE;
05344     }
05345 
05346     char ObjectPath[MaxPathSize + 1];
05347     *ObjectPath = '\0';
05348 
05349     if( DirSize != 0 )// non-null current directory (root )
05350     {
05351         strcpy( ObjectPath, s_CurrentDir );
05352         // only add slash after directory if more follows
05353         if( strlen( ObjectName ) != 0 )
05354             strcat ( ObjectPath, "/" );
05355     }
05356     strcat( ObjectPath, ObjectName );
05357     return s_mgr->m_ObjectManager->StrToPath( ObjectPath, RioPath, PathSize );
05358 }

int RioSession::Open ( char *  Username,
char *  Password 
) [private]

Definition at line 4799 of file server/SessionManager.cpp.

04800 {
04801     int rc;
04802 
04803     // Primeiramente verifica se a senha e muito grande (maior do que
04804     // MAXPASSWORDSIZE caracteres).
04805     if( strlen( Password ) > MAXPASSWORDSIZE )
04806     {
04807         return ERROR_RIOSESSION + ERROR_INVALID_PARAM;
04808     }
04809 
04810     // first clean up any previous logon on same session
04811     if( s_user )
04812     {
04813         delete s_user;
04814         s_user = 0;
04815     }
04816     s_CurrentDir[0] = '\0';
04817 
04818 
04819     rc = s_mgr->m_UserManager->Logon( Username, Password, &s_user );
04820     if( rc )
04821         return rc;
04822 
04823     // set current directory to home
04824     char *s;
04825     rc = s_user->GetUserHome( &s );
04826     if( rc )
04827     {
04828         delete s_user;
04829         s_user = 0;
04830         return rc;
04831     }
04832     strcpy( s_CurrentDir, s );
04833     return rc;
04834 }

int RioSession::OpenStream ( RioStreamTraffic Traffic,
int *  StreamId 
) [private]

Definition at line 4839 of file server/SessionManager.cpp.

04840 {
04841     // ### check accesses???
04842     int rc;
04843 
04844     RioStream **idp = ( RioStream ** ) newid( StreamId, idt_stream );
04845     if( idp == 0 )
04846     {
04847         return ERROR_SESSIONMANAGER + ERROR_MAX_OPENED_OBJECTS;
04848     }
04849 
04850     rc = s_mgr->m_StreamManager->Open( Traffic, idp, s_remoteAddress );
04851     if( rc )
04852         return rc;
04853 
04854     return S_OK;
04855 }

int RioSession::ReallocBlocks ( int  ObjectId,
unsigned int  Block,
unsigned long long int  ExcludeStorages 
) [private]

Funcao usada para realocar os blocos fisicos associados ao bloco logico de um objeto.

Parameters:
ObjectId identificador do objeto.
Block bloco logico do objeto para o qual desejamos realocar os blocos fisicos.
ExcludeStorages vetor de bits que indica quais servidores de armazenamento nao podem ser usados (cada bit esta associado a um servidor e um valor 1 neste bit indica que o servidor nao pode ser usado) ao alocarmos os blocos.
Returns:
diferente de S_OK se algum erro ocorreu ao realocar os blocos.

Definition at line 5401 of file server/SessionManager.cpp.

05403 {
05404     RioStreamObj *op = ( RioStreamObj * ) checkid( ObjectId, idt_streamobj );
05405     if( op == 0 )
05406     {
05407         return ERROR_SESSIONMANAGER + ERROR_INVALID_OBJECT_HANDLE;
05408     }
05409 
05410     return op->ReallocBlocks( Block, ExcludeStorages );
05411 }

int RioSession::RemoveIdEntryFromTable ( int  ObjectId,
idtype  type 
) [private]

Definition at line 5003 of file server/SessionManager.cpp.

05004 {
05005     if( ( unsigned ) ObjectId > ( unsigned ) s_idmax )
05006         return -1;
05007     if( s_idtable[ObjectId].id_type != type )
05008         return -1;
05009 
05010     s_idtable[ObjectId].id_type = idt_invalid;
05011     s_idtable[ObjectId].id_object = 0;
05012     return S_OK;
05013 }

int RioSession::RemoveSearchResultFile ( u32  serveripaddr,
u16  serverport,
u64  resultfileid 
) [private]

Nova funcao para informar ao servidor que o arquivo com o resultado da busca pode ser removido.

Parameters:
serveripaddr endereco IP do servidor.
serverport porta (a UDP) usada por este servidor.
resultfileid valor usado para identificar o arquivo com o resultado da busca no servidor, retornado quando recebemos a informacao de que a busca foi feita com sucesso.
Returns:
S_OK se o pedido de remocao do arquivo foi feito com sucesso, ou um valor diferente de S_OK se algum erro ocorreu.

Definition at line 5611 of file server/SessionManager.cpp.

05613 {
05614     // O processamento do pedido de remocao do arquivo de log no servidor de 
05615     // despacho sera imediato, mas o processamento do pedido de remocao no 
05616     // servidor de armazenamento ira gera um evento para o router, que devera 
05617     // repassar a solicitacao de remocao ao servidor de armazenamento adequado.
05618     if( ( serveripaddr == s_mgr->m_ServerAddress[ 0 ].sin_addr.s_addr ) &&
05619          ( serverport == s_mgr->m_ServerAddress[ 0 ].sin_port ) ) 
05620     {
05621         #ifdef RIO_DEBUG2
05622         RioErr << "RioSession::RemoveSearchResultFile Pedido de remocao do "  
05623                << " do arquivo com o identificador " << resultfileid << endl;
05624         #endif
05625         // Tenta executar a remocao do arquivo de busca, usando a classe que
05626         // executa as buscas, e retorna o resultado desta funcao.
05627         return s_mgr->m_SearchLogs->RemoveSearchResultFile( resultfileid );
05628     }
05629     else
05630     {
05631         // O que podemos fazer em relacao ao servidor de armazenamento? O pedido
05632         // de remocao do arquivo, se falhar, nao podera retornar um estado.
05633         #ifdef RIO_DEBUG2
05634         in_addr ip;    
05635         ip.s_addr = serveripaddr;
05636         RioErr << "RioSession::RemoveSearchResultFile Pedido de remocao do "  
05637                << " do arquivo com o identificador " << resultfileid
05638                << ", para o servidor de armazenamento com o IP " 
05639                << inet_ntoa( ip ) << " e a porta " << ntohs( serverport ) 
05640                << endl;  
05641         #endif
05642         
05643         // Repassa o pedido do bloco de um arquivo com o resultado da busca ao
05644         // servidor de armazenamento.
05645         EventStorageRequest *event;
05646         event = ( EventStorageRequest* ) EventManager.
05647                                                  New( EventTypeStorageRequest );        
05648         if( event == NULL )
05649             return ERROR_CONNECTIONMANAGER + ERROR_MEMORY;
05650             
05651         event->StorageRequest.Header.Type = MSG_RSS_REMOVE_SEARCH_FILE_REQ;    
05652         event->StorageRequest.Header.Size  = SizeMsgRSSRemoveSearchFileReq;
05653         event->StorageRequest.Header.Token = RSS_TOKEN_ROUTER;
05654         
05655         // Inicializa a mensagem com os dados do pedido de remocao de um arquivo
05656         // com o resultado de uma busca.
05657         MsgRSSRemoveSearchFileReq *Msg = & ( event->StorageRequest. 
05658                                              RemoveSearchFile );
05659                                              
05660         Msg->FileId = resultfileid;
05661    
05662         // Send request to storage
05663         s_mgr->m_DiskMgr->SendStorageNodeByIP( event, serveripaddr );
05664 
05665         return S_OK;
05666     }
05667 }

int RioSession::RemoveUser ( char *  UserName  )  [private]

Nova funcao para remover um dos usuarios do RIO.

Parameters:
UserName ponteiro para o nome do usuario.
Returns:
S_OK se o usuario foi removido com sucesso ou o codigo de erro caso nao tenha sido possivel remover o usuario.

Definition at line 4712 of file server/SessionManager.cpp.

04713 {
04714     // Armazena o ponteiro o nome do usuario associado a sessao, que atualmente
04715     // e igual ao diretorio padrao do usuario. Se depois mudarmos isso,
04716     // precisamos criar em RioUser um novo campo com o nome do usuario.
04717     char *SessionUserName;
04718 
04719     // Obtem o "nome" do usuario.
04720     s_user->GetUser( &SessionUserName );
04721 
04722     // Verifica se o usuario associado a sessao e o root, pois somente ele pode
04723     // remover um usuario do sistema.
04724     if( strcmp( SessionUserName, "root" ) != 0 )
04725     {
04726         return ERROR_RIOSESSION + ERROR_PERMISSION_DENIED;
04727     }
04728 
04729     // Verifica se o usuario a ser removido e o usuario guest. Este usuario
04730     // nao pode ser removido (na verdade, nem deveria existir no arquivo).
04731     if( ( strcmp( UserName, "guest" ) == 0 ) ||
04732         ( strcmp( UserName, "root" ) == 0 ) ||
04733         ( strcmp( UserName, "var" ) == 0 ) ||
04734         ( strcmp( UserName, "etc" ) == 0 ) )
04735     {
04736         return ERROR_RIOSESSION + ERROR_INVALID_USER;
04737     }
04738 
04739     return s_mgr->m_UserManager->RemoveUser( UserName );
04740 }

int RioSession::RenameObject ( char *  CurrentName,
char *  NewName 
) [private]

Definition at line 4933 of file server/SessionManager.cpp.

04934 {
04935     int rc;
04936     char CurPath[MaxPathSize + 1];
04937     char NewPath[MaxPathSize + 1];
04938 
04939     // convert object name to Rio Path
04940     rc = ObjectToPath( CurrentName, CurPath, sizeof( CurPath ));
04941     if( rc )
04942         return rc;
04943     rc = ObjectToPath( NewName, NewPath, sizeof( NewPath ));
04944     if( rc )
04945         return rc;
04946 
04947     rc = s_user->CheckAccess( CurPath, 1 );
04948     if( rc != 0 )
04949         return rc;
04950 
04951     rc = s_user->CheckAccess( NewPath, 1 );
04952 
04953     if( rc == 0 )
04954     {
04955         // Verifica se podemos remover o objeto.
04956         char *UserName;
04957 
04958         s_user->GetUser( &UserName );
04959 
04960         // O usuario nao pode renomear o seu proprio diretorio e nem o "/". A
04961         // funcao ObjectToPath recusa qualquer caminho com diversas "/"
04962         // concecutivas, ou que termine com uma "/", caso no qual se inclui o
04963         // "/". Como a "/" inicial e removida de Path, o caminho "/" tera
04964         // tamanho igual a 0.
04965         if( ( strcmp( CurPath, UserName ) == 0 ) ||
04966             ( strlen( CurPath ) == 0 ) )
04967         {
04968             #ifdef RIO_DEBUG2
04969             RioErr << "Permissao negada do renomear o objeto no caminho "
04970                    << CurPath << endl;
04971             #endif
04972 
04973             return ERROR_RIOSESSION + ERROR_PERMISSION_DENIED;
04974         }
04975 
04976         #ifdef RIO_DEBUG2
04977         RioErr << "Renomeando objeto no caminho " << CurPath << " para "
04978                << NewPath << endl;
04979         #endif
04980 
04981         rc = s_mgr->m_ObjectManager->Rename( CurPath, NewPath );
04982     }
04983 
04984     return rc;
04985 }

int RioSession::SaveLogLine ( const char *  StrInfo,
const char *  ObjectName 
) [private]

Funcao usada para armazenar uma linha no log do servidor de despacho.

A linha a ser impressa contera, nesta ordem, o tempo atual (colocado pela classe CLogRotation), StrInfo, ObjectName, o IP do cliente e a porta do cliente.

Parameters:
StrInfo cadeia com a informacao especifica a ser colocada no log.
ObjectName nome do objeto (o caminho completo do arquivo do sistema de arquivos do RIO) a ser colocado no log.
Returns:
S_OK se a linha foi inserida no log com sucesso, ou um valor diferente de S_OK se algum erro ocorreu.

Definition at line 5418 of file server/SessionManager.cpp.

05419 {
05420     int status;
05421     char LogLine[ MAXLOGLINESIZE ];
05422     sprintf( LogLine, "%u %s %s %s %u", s_mgr->m_used, StrInfo, ObjectName,
05423              inet_ntoa( s_remoteAddress.sin_addr ), 
05424              ntohs( s_remoteAddress.sin_port ) );
05425     status = s_mgr->m_LogRotation->NewLogLine( time( NULL ), LogLine );        
05426     #ifdef RIO_DEBUG2 
05427     if( status != S_OK )
05428         RioErr << "RioSession::SaveLogLine erro ao salvar uma linha no "
05429                << "log com o comportamento dos clientes" << endl;
05430     #endif           
05431     return status;    
05432 }

int RioSession::SaveMeasures (  )  [private]

Definition at line 1296 of file server/SessionManager.cpp.

01297 {
01298     return( s_mgr->SaveMeasures());
01299 }

int RioSession::SearchLogsRequest ( u32  searchtype,
time_t  starttime,
time_t  endtime,
u32  serveripaddr,
u16  serverport,
u32  clientipaddr,
u16  clientport,
u32  reqid 
) [private]

Nova funcao para solicitar uma busca em um conjunto de logs de um dos servidores.

Parameters:
searchtype tipo da busca, que por enquanto, pode ser SEARCHINTRAFFICLOGS para fazer busca nos logs com os trafegos de um dos servidores de armazenamento, ou SEARCHINCLIENTSLOGS para fazer uma busca nos logs com os comportamentos dos clientes do servidor de despacho.
starttime Tempo inicial da busca (baseado no mesmo principio da funcao time da biblioteca do C, isto e, o tempo em segundos desde a Epoch (00:00:00 UTC, Janeiro 1 de 1970).
endtime Tempo Final da busca (o mesmo princio do tempo inicial dado acima).
serveripaddr endereco IP do servidor.
serverport porta (a UDP) usada por este servidor.
clientipaddr endereco IP do cliente que fez a busca.
clientport porta (a UDP) usada por este cliente.
reqid identificador que deve ser usado pelo servidor ao enviar o resultado da busca.
Returns:
S_OK se a solicitacao de busca foi inicializada com sucesso, ou um valor diferente de S_OK se a solicitacao nao foi iniciada com sucesso. No caso do fracasso, se o erro e ERROR_INVALID_METHOD, isso naoindicara um erro e sim, que o servidor nao possui suporte para fazer as buscas.

Definition at line 5435 of file server/SessionManager.cpp.

05439 {
05440     // O processamento do inicio da busca do servidor de despacho sera imediato, 
05441     // mas o processamento do inicio da busca do servidor de armazenamento ira
05442     // gera um evento para o router, que devera repassar a solicitacao de busca
05443     // ao servidor de armazenamento adequado.
05444     if( ( serveripaddr == s_mgr->m_ServerAddress[ 0 ].sin_addr.s_addr ) &&
05445          ( serverport == s_mgr->m_ServerAddress[ 0 ].sin_port ) ) 
05446     {
05447         // O cliente fez uma requisicao de busca ao servidor de despacho. 
05448         // Inicialmente vamos verificar se a busca e do tipo
05449         // SEARCHINCLIENTSLOGS pois esta e a unica busca que o servidor de 
05450         // despacho aceita fazer. Se a busca nao for esta, retornaremos entao 
05451         // o erro ERROR_INVALID_METHOD_PARAM.
05452         if( searchtype != SEARCHINCLIENTSLOGS )
05453            return ERROR_CONNECTIONMANAGER + ERROR_SEARCHLOGS_SEARCH_TYPE;
05454            
05455         #ifdef RIO_DEBUG2
05456         in_addr ip;    
05457         ip.s_addr = clientipaddr;
05458         RioErr << "RioSession::SearchLogsRequest Executando uma busca do tipo "
05459                << searchtype << " a partir do tempo " << starttime 
05460                << " ate o tempo " << endtime << " nos logs do comportamento "
05461                << "dos clientes para o cliente com o IP " << inet_ntoa( ip ) 
05462                << " e porta " << ntohs( clientport ) << ", usando a id "
05463                << reqid << endl;  
05464         #endif
05465         // Executar uma busca usando o objeto de busca nos logs, e retorna o
05466         // resultado, que sera um erro caso a busca nao possa ser inicializada.
05467         
05468         //return s_mgr->m_SearchLogs->SearchLogsRequest( starttime, endtime, 
05469         //                                              clientipaddr, clientport,
05470         //                                               reqid );
05471         s_mgr->m_SearchLogs->SearchLogsRequestSendError( starttime, endtime, 
05472                                                    clientipaddr, clientport,
05473                                                    reqid );
05474         return S_OK;                                           
05475     }
05476     else
05477     {
05478         // O cliente fez uma requisicao de busca ao servidor de armazenamento. 
05479         // Inicialmente vamos verificar se a busca e do tipo
05480         // SEARCHINTRAFFICLOGS pois esta e a unica busca que o servidor de 
05481         // armazenamento aceita fazer. Se a busca nao for esta, retornaremos 
05482         // entao o erro ERROR_INVALID_METHOD_PARAM.
05483         if( searchtype != SEARCHINTRAFFICLOGS )
05484            return ERROR_CONNECTIONMANAGER + ERROR_SEARCHLOGS_SEARCH_TYPE;
05485 
05486         #ifdef RIO_DEBUG2
05487         in_addr ip;    
05488         ip.s_addr = clientipaddr;
05489         RioErr << "RioSession::SearchLogsRequest Executando uma busca do tipo "
05490                << searchtype << " a partir do tempo " << starttime 
05491                << " ate o tempo " << endtime << " nos logs do comportamento "
05492                << "dos clientes para o cliente com o IP " << inet_ntoa( ip ) 
05493                << " e porta " << ntohs( clientport ) << ", usando a id "
05494                << reqid;  
05495         ip.s_addr = serveripaddr;
05496         RioErr << ", para o servidor de armazenamento com o IP " 
05497                << inet_ntoa( ip ) << " e a porta " << ntohs( serverport ) 
05498                << endl;  
05499         #endif
05500 
05501         // Repassa o pedido de busca nos logs ao servidor de armazenamento.
05502         EventStorageRequest *event;
05503         event = ( EventStorageRequest* ) EventManager.
05504                                                  New( EventTypeStorageRequest );        
05505         if( event == NULL )
05506             return ERROR_CONNECTIONMANAGER + ERROR_MEMORY;
05507         event->StorageRequest.Header.Type = MSG_RSS_START_SEARCH_IN_LOGS_REQ;    
05508         event->StorageRequest.Header.Size  = SizeMsgRSSStartSearchInLogsReq;
05509         event->StorageRequest.Header.Token = RSS_TOKEN_ROUTER;
05510         
05511         // Inicializa a mensagem com os dados do pedido de busca.
05512         MsgRSSStartSearchInLogsReq *Msg = & ( event->StorageRequest.
05513                                               StartSearchInLogs );
05514         Msg->SearchType = searchtype;
05515         Msg->StartTime = starttime;
05516         Msg->EndTime = endtime; 
05517         Msg->IPaddr = clientipaddr;
05518         Msg->Port = clientport;
05519         Msg->ClientId = reqid;
05520    
05521         // Send request to storage
05522         s_mgr->m_DiskMgr->SendStorageNodeByIP( event, serveripaddr );
05523                                        
05524         return S_OK;
05525     }
05526 
05527 }

int RioSession::SearchResultDataRequest ( u32  serveripaddr,
u16  serverport,
u32  clientipaddr,
u16  clientport,
u64  resultfileid,
u32  block,
u32  reqid 
) [private]

Nova funcao para ler um bloco do arquivo com os resultados da busca.

Parameters:
serveripaddr endereco IP do servidor.
serverport porta (a UDP) usada por este servidor.
clientipaddr endereco IP do cliente que fez a busca.
clientport porta (a UDP) usada por este cliente.
resultfileid valor usado para identificar o arquivo com o resultado da busca no servidor, retornado quando recebemos a informacao de que a busca foi feita com sucesso.
block numero do bloco que desejamos obter.
reqid identificador que deve ser usado pelo servidor ao enviar o bloco do arquivo ao cliente.
Returns:
S_OK se o pedido do bloco foi feito com sucesso, ou um valor diferente de S_OK se o pedido nao foi feito com sucesso.

Definition at line 5531 of file server/SessionManager.cpp.

05535 {
05536     // O processamento do pedido de um bloco do servidor de despacho sera 
05537     // imediato, mas o processamento do pedido de um bloco do servidor de 
05538     // armazenamento ira gera um evento para o router, que devera repassar a 
05539     // solicitacao de pedido ao servidor de armazenamento adequado.
05540     if( ( serveripaddr == s_mgr->m_ServerAddress[ 0 ].sin_addr.s_addr ) &&
05541          ( serverport == s_mgr->m_ServerAddress[ 0 ].sin_port ) ) 
05542     {
05543         #ifdef RIO_DEBUG2
05544         in_addr ip;    
05545         ip.s_addr = clientipaddr;
05546         RioErr << "RioSession::SearchResultDataRequest Pedido do bloco " 
05547                << block << " do arquivo com o identificador " << resultfileid 
05548                << " a partir do cliente com o IP " << inet_ntoa( ip ) 
05549                << " e porta " << ntohs( clientport ) << ", usando a id "
05550                << reqid << endl;  
05551         #endif
05552         // Tenta executar o pedido de bloco, usando a classe de busca, e 
05553         // retorna o resultado deste pedido.
05554         //return s_mgr->m_SearchLogs->SearchResultDataRequest( clientipaddr,
05555         //                                                     clientport, 
05556         //                                                     resultfileid,
05557         //                                                     block, reqid );
05558         s_mgr->m_SearchLogs->SearchResultDataRequestSendError( clientipaddr,
05559                                                                clientport, 
05560                                                                resultfileid,
05561                                                                block, reqid );
05562         return S_OK;                                                 
05563     }
05564     else
05565     {
05566         #ifdef RIO_DEBUG2
05567         in_addr ip;    
05568         ip.s_addr = clientipaddr;
05569         RioErr << "RioSession::SearchResultDataRequest Pedido do bloco " 
05570                << block << " do arquivo com o identificador " << resultfileid 
05571                << " a partir do cliente com o IP " << inet_ntoa( ip ) 
05572                << " e porta " << ntohs( clientport ) << ", usando a id "
05573                << reqid;
05574         ip.s_addr = serveripaddr;
05575         RioErr << ", para o servidor de armazenamento com o IP " 
05576                << inet_ntoa( ip ) << " e a porta " << ntohs( serverport ) 
05577                << endl;  
05578         #endif
05579         
05580         // Repassa o pedido do bloco de um arquivo com o resultado da busca ao
05581         // servidor de armazenamento.
05582         EventStorageRequest *event;
05583         event = ( EventStorageRequest* ) EventManager.
05584                                                  New( EventTypeStorageRequest );        
05585         if( event == NULL )
05586             return ERROR_CONNECTIONMANAGER + ERROR_MEMORY;
05587             
05588         event->StorageRequest.Header.Type = MSG_RSS_BLOCK_SEARCH_FILE_REQ;    
05589         event->StorageRequest.Header.Size  = SizeMsgRSSBlockSearchFileReq;
05590         event->StorageRequest.Header.Token = RSS_TOKEN_ROUTER;
05591         
05592         // Inicializa a mensagem com os dados do pedido de um bloco.
05593         MsgRSSBlockSearchFileReq *Msg = & ( event->StorageRequest. 
05594                                             BlockSearchFile );
05595         Msg->IPaddr = clientipaddr;
05596         Msg->Port = clientport;
05597         Msg->FileId = resultfileid;
05598         Msg->Block = block;
05599         Msg->ClientId = reqid;
05600    
05601         // Send request to storage
05602         s_mgr->m_DiskMgr->SendStorageNodeByIP( event, serveripaddr );
05603 
05604         return S_OK;
05605     }
05606 }

int RioSession::SetSize ( int  ObjectId,
RioObjectSize  ObjectSize,
char *  md5sum,
unsigned long long int  ExcludeStorages 
) [private]

Definition at line 5156 of file server/SessionManager.cpp.

05158 {
05159     int rc;
05160 
05161     RioStreamObj *op = ( RioStreamObj * ) checkid( ObjectId, idt_streamobj );
05162     if( op == 0 )
05163     {
05164         return ERROR_SESSIONMANAGER + ERROR_INVALID_OBJECT_HANDLE;
05165     }
05166     rc = op->SetSize( ObjectSize, md5sum, ExcludeStorages );
05167     return rc;
05168 }

int RioSession::SetVideoRate ( int  ObjectId,
unsigned int  VideoRate 
) [private]

SetVideoRate funcao usada pela implementacao controle de fluxo para alterar a taxa de transmissao do video (esta funcao sera usada pelo novo metodo remoto da Object Manager, que sera usado pelo riosh para alterar a taxa de transmissao do video).

Parameters:
ObjectId identificador do objeto.
VideoRate inteiro nao sinalizado com a nova taxa de transmissao do video.
Returns:
diferente de S_OK se algum erro ocorreu ao alterar a taxa.

Definition at line 5384 of file server/SessionManager.cpp.

05385 {
05386     RioStreamObj *op = ( RioStreamObj * ) checkid( ObjectId, idt_streamobj );
05387     if( op == 0 )
05388     {
05389         return ERROR_SESSIONMANAGER + ERROR_INVALID_OBJECT_HANDLE;
05390     }
05391 
05392     return op->SetVideoRate( VideoRate );
05393 }

int RioSession::StreamMaxRequests ( int  StreamId  )  [private]

Definition at line 3256 of file server/SessionManager.cpp.

03257 {
03258     RioStream *sp = ( RioStream * )checkid( StreamId, idt_stream );
03259     if( sp == 0 )
03260     {
03261         return ERROR_SESSIONMANAGER + ERROR_INVALID_STREAM;
03262     }
03263 
03264     return ( sp->MaxRequests() );
03265 }

int RioSession::StreamOpenObject ( int  StreamId,
char *  ObjectName,
struct timeval  RTT_average,
int  BufferSize,
RioAccess  Access,
int *  StreamObjId 
) [private]

Definition at line 3176 of file server/SessionManager.cpp.

03180 {
03181     int rc;
03182     char Path[MaxPathSize + 1];
03183 
03184     // convert input to full RIO path name
03185     rc = ObjectToPath( ObjectName, Path, sizeof( Path ));
03186     if( rc )
03187     {
03188         RioErr << "Error: Invalid Path " << Path << endl;
03189         return rc;
03190     }
03191 
03192     // map stream index to RioStream *
03193     RioStream *sp = ( RioStream * )checkid( StreamId, idt_stream );
03194     if( sp == 0 )
03195     {
03196         RioErr << "Error: Invalid Stream " << endl;
03197         return ERROR_SESSIONMANAGER + ERROR_INVALID_STREAM;
03198     }
03199 
03200     RioStreamObj **idp = (RioStreamObj **) newid( StreamObjId, idt_streamobj );
03201     if( idp == 0 )
03202     {
03203         RioErr << "Error: Max Opened Objects " << endl;
03204         return ERROR_SESSIONMANAGER + ERROR_MAX_OPENED_OBJECTS;
03205     }
03206 
03207     rc = sp->OpenObject( Path, Access, average_RTT, BufferSize, idp );
03208 
03209     if( rc )
03210         return rc;
03211 
03212     struct in_addr clientip;
03213     clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03214 
03215     ConnectEvent *it_event = new ConnectEvent( inet_ntoa(clientip),
03216         htons( s_remoteAddress.sin_port ), Path );
03217     s_mgr->PostITEvent( (MonitorEvent *)it_event );
03218 
03219     // Gera o log do objeto aberto pelo cliente. Devemos fazer isso no final, 
03220     // isto e, somente se a abertura tiver sucesso?
03221 
03222     SaveLogLine( "OpenCAC", ObjectName );
03223 
03224     return S_OK;
03225 }

int RioSession::StreamOpenObject ( int  StreamId,
char *  ObjectName,
RioAccess  Access,
int *  StreamObjId 
) [private]

Definition at line 3114 of file server/SessionManager.cpp.

03116 {
03117     int rc;
03118     char Path[MaxPathSize + 1];
03119 
03120     // convert input to full RIO path name
03121     rc = ObjectToPath( ObjectName, Path, sizeof( Path ));
03122     if( rc )
03123     {
03124         RioErr << "Error: Invalid Path " << Path << endl;
03125         return rc;
03126     }
03127 
03128     // map stream index to RioStream *
03129     RioStream *sp = ( RioStream * )checkid( StreamId, idt_stream );
03130     if( sp == 0 )
03131     {
03132         RioErr << "Error: Invalid Stream " << endl;
03133         return ERROR_SESSIONMANAGER + ERROR_INVALID_STREAM;
03134     }
03135 
03136     RioStreamObj **idp = (RioStreamObj **) newid( StreamObjId, idt_streamobj );
03137     if( idp == 0 )
03138     {
03139         RioErr << "Error: Max Opened Objects " << endl;
03140         return ERROR_SESSIONMANAGER + ERROR_MAX_OPENED_OBJECTS;
03141     }
03142 
03143     // Check Access
03144     if( sp->getDirection() == RioStreamDirectionRead )
03145     {
03146         rc = s_user->CheckAccess( Path );
03147     }
03148     else
03149     {
03150         rc = s_user->CheckAccess( Path, 1 );
03151     }
03152 
03153     if( rc )
03154         return rc;
03155 
03156     rc = sp->OpenObject( Path, Access, idp );
03157     if( rc )
03158         return rc;
03159 
03160     struct in_addr clientip;
03161     clientip.s_addr = s_remoteAddress.sin_addr.s_addr;
03162 
03163     ConnectEvent *it_event = new ConnectEvent( inet_ntoa(clientip),
03164         htons( s_remoteAddress.sin_port ), Path );
03165     s_mgr->PostITEvent( (MonitorEvent *)it_event );
03166 
03167     // Gera o log do objeto aberto pelo cliente. Devemos fazer isso no final, 
03168     // isto e, somente se a abertura tiver sucesso?
03169 
03170     SaveLogLine( "Open", ObjectName );
03171 
03172     return S_OK;
03173 }


Friends And Related Function Documentation

friend class CSessionManager [friend]

Definition at line 388 of file server/SessionManager.h.


Field Documentation

Definition at line 102 of file server/SessionManager.h.

char RioSession::s_CurrentDir[MaxPathSize+100] [private]

Definition at line 101 of file server/SessionManager.h.

int RioSession::s_id [private]

Definition at line 97 of file server/SessionManager.h.

const unsigned int RioSession::s_idmax = 50 [static, private]

Definition at line 99 of file server/SessionManager.h.

Definition at line 100 of file server/SessionManager.h.

Definition at line 95 of file server/SessionManager.h.

Definition at line 103 of file server/SessionManager.h.

Definition at line 104 of file server/SessionManager.h.

Definition at line 96 of file server/SessionManager.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 4 16:03:37 2012 for RIO by  doxygen 1.6.3