(file) Return to Tracer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Tracer.cpp between version 1.56 and 1.72

version 1.56, 2008/10/22 08:11:24 version 1.72, 2013/12/16 09:37:27
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  //
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  // Permission is hereby granted, free of charge, to any person obtaining a
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  // copy of this software and associated documentation files (the "Software"),
 // EMC Corporation; Symantec Corporation; The Open Group.  // to deal in the Software without restriction, including without limitation
 //  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // and/or sell copies of the Software, and to permit persons to whom the
 // of this software and associated documentation files (the "Software"), to  // Software is furnished to do so, subject to the following conditions:
 // deal in the Software without restriction, including without limitation the  //
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // The above copyright notice and this permission notice shall be included
 // sell copies of the Software, and to permit persons to whom the Software is  // in all copies or substantial portions of the Software.
 // furnished to do so, subject to the following conditions:  //
 //  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 // //
 //==============================================================================  //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 65 
Line 63 
  
        Tracer::setTraceComponents("Config,Repository");        Tracer::setTraceComponents("Config,Repository");
 */ */
 static char const* TRACE_COMPONENT_LIST[] =  char const* Tracer::TRACE_COMPONENT_LIST[] =
 { {
     "XmlParser",      "Xml",
     "XmlWriter",  
     "XmlReader",  
     "XmlIO",     "XmlIO",
     "Http",     "Http",
     "CimData",  
     "Repository",     "Repository",
     "Dispatcher",     "Dispatcher",
     "OsAbstraction",     "OsAbstraction",
     "Config",     "Config",
     "IndHandler",      "IndicationHandler",
     "Authentication",     "Authentication",
     "Authorization",     "Authorization",
     "UserManager",     "UserManager",
     "Registration",  
     "Shutdown",     "Shutdown",
     "Server",     "Server",
     "IndicationService",     "IndicationService",
     "IndicationServiceInternal",  
     "MessageQueueService",     "MessageQueueService",
     "ProviderManager",     "ProviderManager",
     "ObjectResolution",     "ObjectResolution",
     "WQL",     "WQL",
     "CQL",     "CQL",
     "Thread",     "Thread",
     "IPC",  
     "IndicationHandlerService",  
     "CIMExportRequestDispatcher",     "CIMExportRequestDispatcher",
     "SSL",     "SSL",
     "ControlProvider",     "ControlProvider",
     "CIMOMHandle",     "CIMOMHandle",
     "BinaryMessageHandler",  
     "L10N",     "L10N",
     "ExportClient",     "ExportClient",
     "Listener",     "Listener",
Line 111 
Line 101 
     "IndicationReceipt",     "IndicationReceipt",
     "CMPIProviderInterface",     "CMPIProviderInterface",
     "WsmServer",     "WsmServer",
     "LogMessages"      "RsServer",
   #ifdef PEGASUS_ENABLE_PROTOCOL_WEB
       "WebServer",
   #endif
       "LogMessages",
       "WMIMapperConsumer",
       "InternalProvider"
 }; };
  
   // Set the number of defined components
   const Uint32 Tracer::_NUM_COMPONENTS =
       sizeof(TRACE_COMPONENT_LIST)/sizeof(TRACE_COMPONENT_LIST[0]);
   
  
 // Defines the value values for trace facilities // Defines the value values for trace facilities
 // Keep the TRACE_FACILITY_LIST in sync with the TRACE_FACILITY_INDEX, // Keep the TRACE_FACILITY_LIST in sync with the TRACE_FACILITY_INDEX,
Line 148 
Line 148 
 // Set component separator // Set component separator
 const char Tracer::_COMPONENT_SEPARATOR = ','; const char Tracer::_COMPONENT_SEPARATOR = ',';
  
 // Set the number of defined components  
 const Uint32 Tracer::_NUM_COMPONENTS =  
     sizeof(TRACE_COMPONENT_LIST)/sizeof(TRACE_COMPONENT_LIST[0]);  
   
 // Set the line maximum // Set the line maximum
 const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21; const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21;
  
Line 311 
Line 307 
     _traceCString(traceComponent, "", (const char*) traceMsg);     _traceCString(traceComponent, "", (const char*) traceMsg);
 } }
  
   char* Tracer::_formatHexDump(
       char* targetBuffer,
       const char * data,
       Uint32 size)
   {
       unsigned char* p = (unsigned char*)data;
       unsigned char buf[16];
       size_t n = 0;
       int len;
   
       for (size_t i = 0, col = 0; i < size; i++)
       {
           unsigned char c = p[i];
           buf[n++] = c;
   
           if (col == 0)
           {
               len = sprintf(targetBuffer, "%06X ", (unsigned int)i);
               targetBuffer+=len;
           }
   
           len = sprintf(targetBuffer, "%02X", c);
           targetBuffer+=len;
   
           if ( ((col+1) & 3) == 0 )
           {
               *targetBuffer = ' ';
               targetBuffer++;
           }
           if (col + 1 == sizeof(buf) || i + 1 == size)
           {
               for (size_t j = col + 1; j < sizeof(buf); j++)
               {
                   targetBuffer[0]=' ';
                   targetBuffer[1]=' ';
                   targetBuffer[2]=' ';
                   targetBuffer += 3;
               }
               for (size_t j = 0; j < n; j++)
               {
                   c = buf[j];
   
                   if (c >= ' ' && c <= '~')
                   {
                       *targetBuffer = c;
                   }
                   else
                   {
                       *targetBuffer = '.';
                   }
                   targetBuffer++;
               }
               *targetBuffer = '\n';
               targetBuffer++;
               n = 0;
           }
           if (col + 1 == sizeof(buf))
           {
               col = 0;
           }
           else
           {
               col++;
           }
       }
       *targetBuffer = '\n';
       targetBuffer++;
       return targetBuffer;
   }
   
   SharedArrayPtr<char> Tracer::traceFormatChars(
       const Buffer& data,
       bool binary)
   {
       static char start[]="\n### Begin of binary data\n";
       static char end[]="\n### End of binary data\n";
       static char msg[] ="\n### Parts of data omitted. Only first 768 bytes and "\
           "last 256 bytes shown. For complete information, use traceLevel 5.\n\n";
   
       SharedArrayPtr<char> outputBuffer(
           new char[(10*data.size()+sizeof(start)+sizeof(end)+sizeof(msg))]);
   
       char* target = outputBuffer.get();
       size_t size = data.size();
   
       if (0 == size)
       {
           target[0] = 0;
           return outputBuffer;
       }
       if (binary)
       {
           memcpy(target,&(start[0]),sizeof(start)-1);
           target+=sizeof(start)-1;
           // If there are more then 1024 bytes of binary data and the trace level
           // is not at highest level(5), we only trace part of the data and not
           // everything
           if ((_traceLevelMask & Tracer::LEVEL5) || (size <= 1024))
           {
               target=_formatHexDump(target, data.getData(), size);
   
           }
           else
           {
               target=_formatHexDump(target, data.getData(), 768);
   
               memcpy(target, &(msg[0]), sizeof(msg)-1);
               target+=sizeof(msg)-1;
   
               target=_formatHexDump(target, &(data.getData()[size-256]), 256);
           }
           memcpy(target,&(end[0]),sizeof(end));
       }
       else
       {
           memcpy(target, data.getData(), size);
           target[size] = 0;
       }
       return outputBuffer;
   }
   
 SharedArrayPtr<char> Tracer::getHTTPRequestMessage( SharedArrayPtr<char> Tracer::getHTTPRequestMessage(
     const Buffer& requestMessage)     const Buffer& requestMessage)
 { {
     const Uint32 requestSize = requestMessage.size();     const Uint32 requestSize = requestMessage.size();
  
       // Check if requestMessage contains "application/x-openpegasus"
       // and if true format the the requestBuf as HexDump for tracing
       //
       // Binary is only possible on localConnect and doesn't have Basic
       // authorization for that reason
       if (strstr(requestMessage.getData(),"application/x-openpegasus"))
       {
           return traceFormatChars(requestMessage,true);
       }
   
     // Make a copy of the request message.     // Make a copy of the request message.
     SharedArrayPtr<char>     SharedArrayPtr<char>
         requestBuf(new char [requestSize + 1]);         requestBuf(new char [requestSize + 1]);
Line 329 
Line 456 
     char* sep;     char* sep;
     const char* line = requestBuf.get();     const char* line = requestBuf.get();
  
     while ((sep = HTTPMessage::findSeparator(      while ((sep = HTTPMessage::findSeparator(line)) && (line != sep))
         line, (Uint32)(requestSize - (line - requestBuf.get())))) &&  
         (line != sep))  
     {     {
         if (HTTPMessage::expectHeaderToken(line, "Authorization") &&         if (HTTPMessage::expectHeaderToken(line, "Authorization") &&
              HTTPMessage::expectHeaderToken(line, ":") &&              HTTPMessage::expectHeaderToken(line, ":") &&
Line 341 
Line 466 
             HTTPMessage::skipHeaderWhitespace(line);             HTTPMessage::skipHeaderWhitespace(line);
             for ( char* userpass = (char*)line ;             for ( char* userpass = (char*)line ;
                 userpass < sep;                 userpass < sep;
                 *userpass = 'X', userpass++);                  *userpass = 'X', userpass++)
               {
               }
             break;             break;
         }         }
  
         line = sep + ((*sep == '\r') ? 2 : 1);         line = sep + ((*sep == '\r') ? 2 : 1);
     }     }
   
     return requestBuf;     return requestBuf;
 } }
  
Line 486 
Line 611 
     else     else
     {     {
         //         //
         // Since the message is blank, form a string using the pid and tid  
         //  
         char* tmpBuffer;  
   
         //  
         // Allocate messageHeader.         // Allocate messageHeader.
         // Needs to be updated if additional info is added         // Needs to be updated if additional info is added
         //         //
Line 982 
Line 1102 
  
 #endif /* !PEGASUS_REMOVE_TRACE */ #endif /* !PEGASUS_REMOVE_TRACE */
  
   //set the trace file size only when the tracing is on a file
   void Tracer::setMaxTraceFileSize(const String &size)
   {
       Tracer *inst = _getInstance();
       if ( inst->getTraceFacility() == TRACE_FACILITY_FILE )
       {
           Uint32 traceFileSizeKBytes = 0;
           tracePropertyToUint32(size, traceFileSizeKBytes);
   
           //Safe to typecast here as we know that handler is of type file
           TraceFileHandler *hdlr = (TraceFileHandler*) (inst->_traceHandler);
   
           hdlr->setMaxTraceFileSize(traceFileSizeKBytes*1024);
   
       }
   }
   
   //set the trace file number for rolling only when the tracing is on a file
   void Tracer::setMaxTraceFileNumber(const String &maxTraceFileNumber)
   {
       Tracer *inst = _getInstance();
   
       if ( inst->getTraceFacility() == TRACE_FACILITY_FILE )
       {
           Uint32 numberOfTraceFiles = 0;
           tracePropertyToUint32(maxTraceFileNumber, numberOfTraceFiles);
   
           //Safe to typecast here as we know that handler is of type file
           TraceFileHandler *hdlr = (TraceFileHandler*) (inst->_traceHandler);
   
           hdlr->setMaxTraceFileNumber(numberOfTraceFiles);
        }
   }
   
   //
   // Converts the quantifiable trace  proprties string into a Uint32 value.
   // It returns false and the bufferSize is set to 0 if the string was not valid.
   //
   Boolean Tracer::tracePropertyToUint32(
       const String& traceProperty, Uint32& valueInUint32 )
   {
       Boolean retCode = false;
       Uint64 uInt64BufferSize;
   
       valueInUint32 = 0;
       CString stringBufferSize = traceProperty.getCString();
   
   
       retCode = StringConversion::decimalStringToUint64(stringBufferSize,
                                                         uInt64BufferSize);
   
       if (retCode )
       {
           retCode = StringConversion::checkUintBounds(uInt64BufferSize,
                                                       CIMTYPE_UINT32);
       }
   
       if (retCode )
       {
           valueInUint32 = (Uint32)uInt64BufferSize;
       }
   
       return retCode;
   }
   
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.56  
changed lines
  Added in v.1.72

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2