version 1.56, 2008/10/22 08:11:24
|
version 1.68, 2012/10/22 11:18:18
|
|
|
//%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. |
|
// | // |
//============================================================================== |
////////////////////////////////////////////////////////////////////////// |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
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", |
|
|
"IndicationReceipt", | "IndicationReceipt", |
"CMPIProviderInterface", | "CMPIProviderInterface", |
"WsmServer", | "WsmServer", |
"LogMessages" |
"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, |
|
|
// 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; |
| |
|
|
_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]); |
|
|
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; |
} | } |
| |
|
|
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 |
// | // |