📄 h323parser.cpp
字号:
wsprintf( pFollowEntry->szProtocol, "TCP" ); // TPKT pFollowEntry = &(pFollowSet->Entry[1]); wsprintf( pFollowEntry->szProtocol, "TPKT" ); // the outgoing HandOff set ----------------------------------------------- // allocate NumHandoffs = 1; pHandoffSet = (PPF_HANDOFFSET) HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( PF_HANDOFFSET ) + NumHandoffs * sizeof( PF_HANDOFFENTRY) ); if( pHandoffSet == NULL ) { // just return early return FALSE; } // fill in outgoing HandOff set pParserInfo->pWhoDoIHandOffTo = pHandoffSet; pFollowSet->nEntries = NumHandoffs; // TPKT pHandoffEntry = &(pHandoffSet->Entry[0]); wsprintf( pHandoffEntry->szProtocol, "TPKT" ); return TRUE;}BOOL TPKT_AutoInstall(PPF_PARSERINFO pParserInfo){ DWORD NumFollows; PPF_FOLLOWSET pFollowSet; PPF_FOLLOWENTRY pFollowEntry; wsprintf( pParserInfo->szProtocolName, "TPKT" ); wsprintf( pParserInfo->szComment, "RFC 1001 TPKT Protocol" ); wsprintf( pParserInfo->szHelpFile, ""); // the incoming follow set ----------------------------------------------- // allocate NumFollows = 3; pFollowSet = (PPF_FOLLOWSET)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( PF_FOLLOWSET ) + NumFollows * sizeof( PF_FOLLOWENTRY) ); if( pFollowSet == NULL ) { // just return early return FALSE; } // fill in the incoming follow set pParserInfo->pWhoCanPrecedeMe = pFollowSet; pFollowSet->nEntries = NumFollows; // TCP pFollowEntry = &(pFollowSet->Entry[0]); wsprintf( pFollowEntry->szProtocol, "TCP" ); // Q.931 pFollowEntry = &(pFollowSet->Entry[1]); wsprintf( pFollowEntry->szProtocol, "Q.931" ); // H.245 pFollowEntry = &(pFollowSet->Entry[2]); wsprintf( pFollowEntry->szProtocol, "H.245" ); // the outgoing follow set ----------------------------------------------- // allocate NumFollows = 2; pFollowSet = (PPF_FOLLOWSET)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( PF_FOLLOWSET ) + NumFollows * sizeof( PF_FOLLOWENTRY) ); if( pFollowSet == NULL ) { // just return early return FALSE; } // fill in outgoing follow set pParserInfo->pWhoCanFollowMe = pFollowSet; pFollowSet->nEntries = NumFollows; // Q.931 pFollowEntry = &(pFollowSet->Entry[0]); wsprintf( pFollowEntry->szProtocol, "Q.931" ); // H.245 pFollowEntry = &(pFollowSet->Entry[1]); wsprintf( pFollowEntry->szProtocol, "H.245" ); return TRUE;}//============================================================================// // AutoInstall - return all of the information neede to install us//// Modification history:// //============================================================================PPF_PARSERDLLINFO WINAPI ParserAutoInstallInfo() { PPF_PARSERDLLINFO pParserDllInfo; DWORD NumProtocols; // Base structure ======================================================== // Allocate memory for parser info: NumProtocols = 4; pParserDllInfo = (PPF_PARSERDLLINFO)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( PF_PARSERDLLINFO ) + NumProtocols * sizeof( PF_PARSERINFO) ); if( pParserDllInfo == NULL) { return NULL; } // fill in the parser DLL info pParserDllInfo->nParsers = NumProtocols; // fill in the individual parser infos... RAS_AutoInstall(&(pParserDllInfo->ParserInfo[0])); Q931_AutoInstall(&(pParserDllInfo->ParserInfo[1])); H245_AutoInstall(&(pParserDllInfo->ParserInfo[2])); TPKT_AutoInstall(&(pParserDllInfo->ParserInfo[3])); return pParserDllInfo;}ASN1::CoderEnv* env;H4501_Supplementary_ServiceAPDU_Structure::Module* h4501Module;H4501_General_Error_List::Module* errListModule;Call_Transfer_Operations::Module* h4502Module;Call_Diversion_Operations::Module* h4503Module;Call_Hold_Operations::Module* h4504Module;Call_Park_Pickup_Operations::Module* h4505Module;Call_Waiting_Operations::Module* h4506Module;Message_Waiting_Indication_Operations::Module* h4507Module;Name_Operations::Module* h4508Module;Call_Completion_Operations::Module* h4509Module;Call_Offer_Operations::Module* h45010Module;BOOL APIENTRY DllMain( HANDLE hModule, DWORD Command, LPVOID lpReserved ){ // what type of call is this switch( Command ) { case DLL_PROCESS_ATTACH: // are we loading for the first time? if( Attached == 0 ) { // the first time in we need to tell t kernel // about ourselves hRAS = CreateProtocol( "RAS", &RASEntryPoints, ENTRYPOINTS_SIZE); hQ931 = CreateProtocol( "Q.931", &Q931EntryPoints, ENTRYPOINTS_SIZE); hH245 = CreateProtocol( "H.245", &H245EntryPoints, ENTRYPOINTS_SIZE); hTPKT = CreateProtocol( "TPKT", &TPKTEntryPoints, ENTRYPOINTS_SIZE); env = new ASN1::CoderEnv; h4501Module = new H4501_Supplementary_ServiceAPDU_Structure::Module; errListModule = new H4501_General_Error_List::Module; h4502Module = new Call_Transfer_Operations::Module(errListModule); h4503Module = new Call_Diversion_Operations::Module(errListModule); h4504Module = new Call_Hold_Operations::Module(errListModule); h4505Module = new Call_Park_Pickup_Operations::Module(errListModule); h4506Module = new Call_Waiting_Operations::Module; h4507Module = new Message_Waiting_Indication_Operations::Module(errListModule); h4508Module = new Name_Operations::Module; h4509Module = new Call_Completion_Operations::Module(h4504Module, errListModule); h45010Module = new Call_Offer_Operations::Module(h4506Module); Remote_Operations_Information_Objects::OPERATION& operations = h4501Module->get_OperationSet(); operations.insert(h4502Module->get_H323CallTransferOperations().begin(), h4502Module->get_H323CallTransferOperations().end()); operations.insert(h4503Module->get_H323CallDiversionOperations().begin(), h4503Module->get_H323CallDiversionOperations().end()); operations.insert(h4504Module->get_CallHoldOperations().begin(), h4504Module->get_CallHoldOperations().end()); operations.insert(h4505Module->get_CallParkPickupOperations().begin(), h4505Module->get_CallParkPickupOperations().end()); operations.insert(h4506Module->get_CallWaitingOperations().begin(), h4506Module->get_CallWaitingOperations().end()); operations.insert(h4507Module->get_H323_MWI_Operations().begin(), h4507Module->get_H323_MWI_Operations().end()); operations.insert(h4508Module->get_NameOperations().begin(), h4508Module->get_NameOperations().end()); operations.insert(h4509Module->get_H323CallCompletionOperations().begin(), h4509Module->get_H323CallCompletionOperations().end()); operations.insert(h45010Module->get_H323CallOfferOperations().begin(), h45010Module->get_H323CallOfferOperations().end()); env->set_per_Basic_Aligned(); env->insert(h4501Module); } Attached++; break; case DLL_PROCESS_DETACH: // are we detaching our last instance? Attached--; if( Attached == 0 ) { // last guy out needs to clean up DestroyProtocol(hTPKT); DestroyProtocol(hH245); DestroyProtocol(hQ931); DestroyProtocol( hRAS); delete env; delete h45010Module; delete h4509Module; delete h4508Module; delete h4507Module; delete h4506Module; delete h4505Module; delete h4504Module; delete h4503Module; delete h4502Module; delete errListModule; delete h4501Module; } break; } // Netmon parsers ALWAYS return TRUE. return TRUE;}//============================================================================// Function: H323_Deregister// // Description: Destroy our property database and handoff set//// Modification History//// Huang-Ming Huang 08/11/2000 Created//============================================================================VOID WINAPI H323_Deregister( HPROTOCOL hH323){ // tell the kernel that it may now free our database DestroyPropertyDatabase( hH323);}//============================================================================// Function: H323_FormatProperties// // Description: Format the given properties on the given frame.//// Modification History//// Huang-Ming Huang 08/11/2000 Created//============================================================================DWORD BHAPI H323_FormatProperties( HFRAME hFrame, LPBYTE pMacFrame, LPBYTE pBLRPLATEFrame, DWORD nPropertyInsts, LPPROPERTYINST p){ // loop through the property instances while( nPropertyInsts-- > 0) { // and call the formatter for each ( (FORMAT)(p->lpPropertyInfo->InstanceData) )( p); p++; } return NMERR_SUCCESS;}//============================================================================// Function: Custom_Format// // Description: The custom formatter for the summary property//// Modification History//// Huang-Ming Huang 08/11/2000 Created//============================================================================VOID WINAPIV Custom_Format( LPPROPERTYINST pPropertyInst){ char* pReturnedString = pPropertyInst->szPropertyText; strcpy(pReturnedString,(const char*)pPropertyInst->lpPropertyInstEx->Byte);}//============================================================================// Function: RAS_Register// // Description: Create our property database and handoff sets.//// Modification History//// Huang-Ming Huang 08/11/2000 Created//============================================================================void BHAPI RAS_Register( HPROTOCOL hRAS){ // tell the kernel to make reserve some space for our property table CreatePropertyDatabase( hRAS, 1); // add our properties to the kernel's database AddProperty( hRAS, &RasPropertyInfo);}//============================================================================// Function: RAS_RecognizeFrame// // Description: Determine whether we exist in the frame at the spot // indicated. We also indicate who (if anyone) follows us// and how much of the frame we claim.//// Modification History//// Huang-Ming Huang 08/11/2000 Created//============================================================================LPBYTE BHAPI RAS_RecognizeFrame( HFRAME hFrame, LPBYTE pMacFrame, LPBYTE pFrame, DWORD MacType, DWORD BytesLeft, HPROTOCOL hPrevProtocol, DWORD nPrevProtOffset, LPDWORD pProtocolStatus, LPHPROTOCOL phNextProtocol, LPDWORD InstData) { *pProtocolStatus = PROTOCOL_STATUS_NOT_RECOGNIZED; try { H323_MESSAGES::RasMessage msg; ASN1::PERDecoder decoder((char*)pFrame, (char*)pFrame+BytesLeft); if (msg.accept(decoder)) *pProtocolStatus = PROTOCOL_STATUS_CLAIMED; } catch (...) { } return NULL;}//============================================================================// Function: RAS_AttachProperties// // Description: Indicate where in the frame each of our properties live.//// Modification History//// Huang-Ming Huang 08/11/2000 Created//============================================================================LPBYTE BHAPI RAS_AttachProperties( HFRAME hFrame, LPBYTE pMacFrame, LPBYTE pFrame, DWORD MacType, DWORD BytesLeft, HPROTOCOL hPrevProtocol, DWORD nPrevProtOffset, DWORD InstData) { // Decode the first byte to determine the type of the message int tag; if ((pFrame[0] & 0x80) == 0) tag = pFrame[0] >> 2; else tag = pFrame[0] & 0x3F + 25; // Attach the summery std::ostringstream strm; strm << "RAS " << RAS_String[tag] << " (Length = " << BytesLeft << ")";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -