Пример #1
0
int8 dealPacket( pgcontext pgc, ppacket pTxBuf )
{
    GAgent_Printf(GAGENT_DEBUG,"\r\n");
    GAgent_Printf(GAGENT_DEBUG,"IN %s packet type : %04x",__FUNCTION__ ,pTxBuf->type );
    if( ((pTxBuf->type)&(LOCAL_DATA_OUT)) == LOCAL_DATA_OUT )
    {
        GAgent_Printf( GAGENT_DEBUG,"packet Type : LOCAL_DATA_OUT ");
        copyPacket(pTxBuf, pgc->mcu.Txbuf);
        GAgent_LocalDataWriteP0( pgc,pgc->rtinfo.local.uart_fd, pgc->mcu.Txbuf,MCU_CTRL_CMD );
        GAgent_Printf( GAGENT_DEBUG,"ReSetpacket Type : LOCAL_DATA_OUT ");
        pTxBuf->type = SetPacketType(pTxBuf->type, LOCAL_DATA_OUT, 0);

    }
    if( ((pTxBuf->type)&(CLOUD_DATA_OUT)) == CLOUD_DATA_OUT )
    {
        if( ((pgc->rtinfo.GAgentStatus)&WIFI_CLOUD_CONNECTED)  == WIFI_CLOUD_CONNECTED )
        {
            GAgent_Printf( GAGENT_DEBUG,"packet Type : CLOUD_DATA_OUT ");
            GAgent_Cloud_SendData(  pgc,pTxBuf,(pTxBuf->pend)-(pTxBuf->ppayload) );
            GAgent_Printf( GAGENT_DEBUG,"ReSetpacket Type : CLOUD_DATA_OUT ");
        }
        pTxBuf->type = SetPacketType(pTxBuf->type, CLOUD_DATA_OUT, 0);
    }
    if( ((pTxBuf->type)&(LAN_TCP_DATA_OUT)) == LAN_TCP_DATA_OUT )
    {
        GAgent_Lan_SendTcpData(pgc, pTxBuf);
        pTxBuf->type = SetPacketType(pTxBuf->type, LAN_TCP_DATA_OUT, 0);
    }
    GAgent_Printf( GAGENT_DEBUG,"OUT packet type : %04X\r\n",pTxBuf->type );
    return 0;
}
Пример #2
0
int H264::handlePacket(AVPacket* packet)
{
	int gotFrame;
	int bytes;
	H264Context* h = (H264Context*)stream()->codec->priv_data;
	
	// Transform timestamps to relative timestamps
	packet->dts = pts_rel(packet->dts);
	packet->pts = pts_rel(packet->pts);
	
	if(m_decoding && !m_syncing)
		parseNAL(packet->data, packet->size);
	
	if(!m_decoding)
	{
		if(m_nc && m_nc->time - packet->pts < m_startDecodeOffset)
		{
			log_debug("Switching decoder on at PTS %'10lld (m_nc: %'10lld)",
				packet->pts, m_nc->time);
			m_decoding = true;
			
			avcodec_flush_buffers(stream()->codec);
		}
	}
	
	if(m_decoding)
	{
		if(avcodec_decode_video2(stream()->codec, &m_frame, &gotFrame, packet) < 0)
			return error("Could not decode packet");
	}
	
	if(!m_encoding && m_nc)
	{
		if(m_nc->direction == CutPoint::OUT && m_nc->time < packet->dts)
		{
			m_decoding = false;
			m_isCutout = true;
			
			int64_t current_time = m_nc->time;
			m_nc = cutList().nextCutPoint(packet->dts);
			
			if(m_nc)
				setTotalCutout(m_nc->time - (current_time - totalCutout()));
			else
				setActive(false); // last cutpoint reached
		}
		else if(m_nc->direction == CutPoint::IN && m_nc->time <= packet->dts)
		{
			m_encoding = true;
			m_encFrameCount = 0;
			
			log_debug("Opening encoder for frame with PTS %'10lld", packet->dts);

			AVDictionary* opts = 0;
			av_dict_set(&opts, "profile", "main", 0);
			av_dict_set(&opts, "preset", "ultrafast", 0);
			
			if(avcodec_open2(outputStream()->codec, m_codec, &opts) != 0)
				return error("Could not open encoder");
		}
	}
	
	if(m_encoding && m_encFrameCount > 20 && packet->flags & AV_PKT_FLAG_KEY && h->s.current_picture_ptr)
	{
		m_syncing = true;
		m_syncPoint = packet->pts;
		
		log_debug("SYNC: start with keyframe packet PTS %'10lld", m_syncPoint);
// 		log_debug("SYNC: frame_num of first original frame is %d",
// 				h->s.current_picture_ptr->frame_num
// 		);
	}

	if(m_syncing)
	{
		log_debug("decode=%d, gotFrame=%d, keyframe=%d, t=%d", m_decoding, gotFrame, m_frame.key_frame, m_frame.pict_type);
	}
	
	if(m_syncing && gotFrame && m_frame.pict_type == 1)
	{
		// Flush out encoder
		while(1)
		{
			log_debug("SYNC: Flushing out encoder");
			bytes = avcodec_encode_video(
				outputStream()->codec,
				m_encodeBuffer, ENCODE_BUFSIZE,
				NULL
			);
			outputStream()->codec->has_b_frames = 6;
			
			if(!bytes)
				break;
			
			int64_t pts = av_rescale_q(outputStream()->codec->coded_frame->pts,
					outputStream()->codec->time_base, outputStream()->time_base
				);
			
			if(pts + totalCutout() >= m_syncPoint)
			{
				log_debug("SYNC: (encoder) Skipping PTS %'10lld >= sync point %'10lld",
					pts + totalCutout(), m_syncPoint
				);
				continue;
			}
			
			if(writeOutputPacket(m_encodeBuffer, bytes, pts) != 0)
				return error("SYNC: (encoder) Could not write packet");
		}
		log_debug("SYNC: closing encoder");
		avcodec_close(outputStream()->codec);
		
		// Flush out sync buffer
		for(int i = 0; i < m_syncBuffer.size(); ++i)
		{
			log_debug("SYNC: writing packet from buffer");

			AVPacket* packet = &m_syncBuffer[i];
			if(packet->pts < m_syncPoint)
			{
				log_debug("SYNC: (buffer) Skipping PTS %'10lld < sync point %'10lld",
					packet->pts, m_syncPoint
				);
				continue;
			}
			
			if(writeInputPacket(packet) != 0)
				return error("SYNC: (buffer) Could not write packet");
		}
		m_syncBuffer.clear();
		
		m_encoding = false;
		m_isCutout = false;
		m_decoding = false;
		m_syncing = false;
		
		log_debug("SYNC: finished, got keyframe from decoder with PTS %'10lld", packet->dts);
		
		m_nc = cutList().nextCutPoint(packet->dts);
	}
	
	if(m_syncing)
	{
		m_syncBuffer.push_back(copyPacket(*packet));
	}
	
	if(m_encoding && gotFrame)
	{
		setFrameFields(&m_frame, packet->dts - totalCutout());
		
		bytes = avcodec_encode_video(
			outputStream()->codec,
			m_encodeBuffer, ENCODE_BUFSIZE,
			&m_frame
		);
		outputStream()->codec->has_b_frames = 6;
		
		if(bytes)
		{
			writeOutputPacket(
				m_encodeBuffer, bytes,
				av_rescale_q(outputStream()->codec->coded_frame->pts,
					outputStream()->codec->time_base, outputStream()->time_base
				)
			);
			m_encFrameCount++;
		}
	}
	
	if(!m_isCutout && !m_encoding)
	{
		if(m_syncPoint > 0 && packet->pts < m_syncPoint)
		{
			log_debug("COPY: Skipping packet with PTS %'10lld", packet->pts);
			return 0;
		}
		
		if(m_sps.data || m_pps.data)
		{
			int size = packet->size + m_sps.size + m_pps.size;
			uint8_t* buf = (uint8_t*)malloc(size);
			int off = 0;
			
			memcpy(buf + off, m_sps.data, m_sps.size);
			off += m_sps.size;
			memcpy(buf + off, m_pps.data, m_pps.size);
			off += m_pps.size;
			
			memcpy(buf + off, packet->data, packet->size);
			
			writeOutputPacket(buf, size, packet->pts - totalCutout());
			
			free(m_sps.data); m_sps.data = 0;
			free(m_pps.data); m_pps.data = 0;
			free(buf);
			return 0;
		}
		
// 		log_debug("COPY: packet with PTS %'10lld", packet->pts);
		outputStream()->codec->has_b_frames = 6;
		if(writeInputPacket(packet) != 0)
		{
			log_debug("PTS buffer:");
			
			for(int i = 0; i < outputStream()->codec->has_b_frames; ++i)
				log_debug(" %s", tstoa(outputStream()->pts_buffer[i]));
			
			return error("Could not copy input packet (has_b_frames: %d, max_b_frames: %d)",
				outputStream()->codec->has_b_frames, outputStream()->codec->max_b_frames
			);
		}
	}
	
	return 0;
}
Пример #3
0
bool GrupPacket::packetHandler ( __rawNetData__ * packetData ){
#ifdef DEBUG
	        std::cout<<PRINT<<" Source Ip ["<<packetData->sourceIp<<" ] Destination Ip [ "<<packetData->destinationIp
			<<"  ]\nSourcePOrt [ "<<packetData->sourcePort<<" ] \nDestinationPOrt ["
		<<packetData->destinationPort<<" ] \nSequence Number [ "<<packetData->sequenceNumber
		<<"] \n AcknowledgeNumber: [ "<<packetData->acknowledgeNumber<<"]\n Flags\n ACK [ "
		<<packetData->networkTcpFlags.__ACK__<<" ] \n SYN[ "<<packetData->networkTcpFlags.__SYN__
		<<" ] \n FIN"<<packetData->networkTcpFlags.__FIN__<<" ] Data Length:[ "
		<<packetData->dataLength<<std::endl;
#endif

	bool    returnValue;

	returnValue = true;
	if ( packetData->networkTcpFlags.__SYN__ || packetData->networkTcpFlags.__FIN__ ){
		isSynFin = true;
		return true;

	}
	if ( packetData->destinationPort == Init::configuration.port ){// 3306  ){ 
		//check whether the packet is acknowledgement packet or not
		//for acknwledgement packet length of the packet is [0] and ACK flag [ set]
		std::cout<<PRINT<<"Outgoing Packet"<<std::endl;
		if ( packetData->dataLength ==0 && packetData->networkTcpFlags.__ACK__  ){
			if ( isSynFin  ){   return true; }
			std::cout<<PRINT<<" ACK FLAG ON-- OUTGOING \n";
			if ( validPack ( false , &conversationDiary [ activeConversationId ] , packetData ) ){
				std::cout<<PRINT<<"VALID ACK -- OUTGOING PACKET \n";
				//insertData into database ( true , activeConversationId , ++packetNumber , packetData );
				returnValue = copyPacket ( true , &conversationDiary [ activeConversationId ] , packetData );
				
				returnValue == true ?returnValue = insertDb( packetData , false , true ): returnValue = false;
				
				
			}else{
				std::cout<<PRINT<<" ACK PACKET NOT VALID--- OUTGOING\n";
				returnValue = false;

			}
			
		}else if ( searchMother ( false , &conversationDiary [ activeConversationId ] , packetData ) && !lastDb ){
			std::cout<<PRINT<<" CONSICUTIEVE PACKETS-- OUTGOING \n";
			returnValue = copyPacket( true , &conversationDiary[ activeConversationId ], packetData );
			if ( packetData->networkTcpFlags.__ACK__ )
			returnValue == true ?returnValue = insertDb( packetData , false , true ):returnValue = false ;
			returnValue == true ?returnValue = insertDb( packetData , false ):returnValue = false ;
			//insert the packet
		}
	       //it's a new packet--start conversation
	       else  { 
		       std::cout<<"It's a fresh Outgoing Packet"<<std::endl;
		       lastDb = false;
		  //     packetNumber = 0;
		        
		       returnValue = copyPacket( true , &conversationDiary [ ++activeConversationId ] , packetData );
		       returnValue == true ?returnValue = insertDb( packetData , true ):returnValue = false ;
		       	//insertpacketSetting( true , ++packet);
	       }
	}else if ( packetData->sourcePort ==  Init::configuration.port  ){// 3306 ){
		std::cout<<PRINT<<" IN COMING PACKET \n";
		if (   packetData ->dataLength == 0 && packetData->networkTcpFlags.__ACK__  ) {
			if ( isSynFin ){  return true;}
			std::cout<<PRINT<<"IT;S ACK PACKET -- IN COMING \n";
			if (  validPack ( true , &conversationDiary [ activeConversationId] , packetData ) ){
			std::cout<<"VALID ACK RESPONSE PACKET -- IN COMING"<<std::endl;
			returnValue = copyPacket( false , &conversationDiary [ activeConversationId ] , packetData );
			returnValue == true ?returnValue = insertDb( packetData , false , true ):returnValue = false ;
			}else{
				std::cerr<<PRINT<<" ACK PACKET NOT VALID-- IN COMING\n";
				returnValue = false;
			}

		}else if ( searchMother ( true , &conversationDiary [activeConversationId ] , packetData ) ){
			std::cout<<PRINT<<"CONTIMNIOUS PACKET--- IN COMING"<<std::endl;
			returnValue = copyPacket( false , &conversationDiary [ activeConversationId ], packetData );
			if ( packetData->networkTcpFlags.__ACK__ )
			returnValue == true ?returnValue = insertDb( packetData , false , true ):returnValue = false ;
			else

			returnValue == true ?returnValue = insertDb( packetData , false ):returnValue = false ;
		} // after sending a request client may get a request response without ACK
	       	else {// freash packet
			std::cout<<"FRESH PACKET -- INCOMING"<<std::endl;
		//	packetNumber = 0;
		        if( isSynFin ) lastDb = true;

			returnValue = copyPacket ( false , &conversationDiary[ ++activeConversationId ] , packetData );
			returnValue == true ?returnValue = insertDb( packetData , true):returnValue = false ;
		}
	}
	isSynFin = false;
	return returnValue;
}
bool captureDb::StoreRawPacket::packetHandler ( rawDataStruct *rawData ){
	
	std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<"FUNCTION:"<<__FUNCTION__<<std::endl;
	/*-----------------------------------------------------------------------------
	 *  check if packet is a threeway handshaking or connection termination or not
	 *  if it's of that type then no need to save the packet , because client server will 
	 *  autometic takecare of those
	 *-----------------------------------------------------------------------------*/
    if ( rawData->tcpFlag.SYN || rawData->tcpFlag.FIN  ){
        synFin = true;
        std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"packet with syn or fin \n";
        return true;
    }

    captureQuery::StoreRawPacketQuery queryHandlerInstance;

    /*-----------------------------------------------------------------------------
     *  if synflag is true that means next packet of acknowledgement also no need to save
     *  now consider whether packet coming for CLIENT(APP) or SERVER ( DB )
     *-----------------------------------------------------------------------------*/
    if ( rawData->sourcePort != 3306 ){
        std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"PACKET COMING FROM CLIENT(APPLICATION)\n";

	/*-----------------------------------------------------------------------------
	 *  check whether the packet is acknowledgement packet or not
	 *  for acknowledgement packet length pf the packet is 0 and ACK flag is set
	 *-----------------------------------------------------------------------------*/
        if ( ( rawData->length == 0 )  && rawData->tcpFlag.ACK ){
            if ( synFin ){// if previous packet was connection setup or terminated packet
                std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"prev packet was connection termineted packet\n";
                synFin = false;
                return true;

            }
		 
	    /*-----------------------------------------------------------------------------
	     *  now search valid ACK packet for the previous packets( source: SERVER ) of 
	     *  current conversation.
	     *  set rcvack field
	     *  if valid ACK found then store the packet
	     *-----------------------------------------------------------------------------*/
            std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"conversation id \t"<<currentConversationId<<'\n';
		
            if ( validPack ( false , &conversationDiary [ currentConversationId ] , rawData ) ){
                std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"it's a valid acknowledgement packet of this conversation\n";
                //store tis packet into packet with respect to current conversationId
                queryHandlerInstance.insertPacket( true , currentConversationId , ++packetNumber , rawData);
                copyPacket ( true ,&conversationDiary [ currentConversationId ] , rawData );
                return true;
            }
        }
	/*-----------------------------------------------------------------------------
	 *  for new client packet--  
	 *-----------------------------------------------------------------------------*/
        if ( (validPack ( false , &conversationDiary [ currentConversationId ] , rawData )) || checkSimultaneouslyNewPacket( true , &conversationDiary [ currentConversationId] , rawData ) ){// !

		/*-----------------------------------------------------------------------------
		 *  coppy the current packet into conversation diary
		 *-----------------------------------------------------------------------------*/
		copyPacket ( true , &conversationDiary [ ++currentConversationId ] , rawData );
		
		/*-----------------------------------------------------------------------------
		 *  insert the new packet into PACKET_SETTING_scenarioName and PACKET_scenarioName table
		 *
		 *-----------------------------------------------------------------------------*/
		if ( queryHandlerInstance.insertPacketSetting ( true , currentConversationId , ++packetNumber , rawData ) ){
		    if ( queryHandlerInstance.insertPacket ( true , currentConversationId , packetNumber , rawData) )
			    return true ;
		    else return false;
		    
	    }
	    return false ;
			
        }
        //else for sure it is a Middle pack
        if ( searchMother ( false ,&conversationDiary [ currentConversationId ] , rawData ) ){
		copyPacket ( true , &conversationDiary [ currentConversationId ] , rawData);
		std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"Middle packet \n";
		if ( queryHandlerInstance.insertPacket ( true , currentConversationId , ++packetNumber , rawData) ){
			std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"middle packet inserted\n";
			return true ;
			
		}
		else return false;
		
	}

        //updated on 7-12 for the error --- when a single select query coming without any DB greetings the first packet from app was not capturing,
        //but if db handshaking occurs 1st then it's being captured
        else {
         copyPacket ( true , &conversationDiary [ ++currentConversationId ] , rawData );
        if ( queryHandlerInstance.insertPacketSetting ( true , currentConversationId , ++packetNumber ,rawData) ){
            std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"now insert packet\n";
            queryHandlerInstance.insertPacket ( true , currentConversationId ,  packetNumber , rawData );
                    return true;
                }
        }

		
    }
		
    /*-----------------------------------------------------------------------------
     *  else packet is a SERVER packet
     *-----------------------------------------------------------------------------*/
    else {
	    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"it is a SERVER packet\n";
	    if ( ( rawData->length == 0 )  && rawData->tcpFlag.ACK ){
		    if ( synFin ){// if previous packet was connection setup or terminated packet
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"previous packet was connection termineted packet or ack\n";
			    return true;
			    
		    }

		    /*-----------------------------------------------------------------------------
		     *  check whether the packet is a valid response packet from server or not
		     *  if yes then insert it into PACKET_scenarioName table
		     *-----------------------------------------------------------------------------*/
		    if ( validPack ( true , &conversationDiary [ currentConversationId ] , rawData) ){
			    copyPacket ( false , &conversationDiary [ currentConversationId ] , rawData );
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"it's a valid acknowledgement packet of this conversation\n";
			    //store tis packet into packet with respect to current conversationId
			    if (queryHandlerInstance.insertPacket ( false , currentConversationId , ++packetNumber , rawData ) ){
				    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"ACK packet inserted \n";
				    return true;
				    
			    }
		    }
	    }
	    
	    /*-----------------------------------------------------------------------------
	     *  check whether the packet is a freash new paket ?
	     *-----------------------------------------------------------------------------*/
	    if ( validPack ( true , &conversationDiary [ currentConversationId ] , rawData) ){ // !
		    if ( checkDbGreeting ( &conversationDiary [ currentConversationId ] , rawData ) ){
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"This is a greetings packet from db\n";
			    if ( queryHandlerInstance.insertDbGreeting  ( ++currentConversationId , ++packetNumber , rawData) ){
				    queryHandlerInstance.insertPacket  ( false , currentConversationId , packetNumber , rawData);
				    copyPacket ( false , &conversationDiary [ currentConversationId ] , rawData );
				    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"inserted into greeting sd \n";
				    return true;
				    
			    }
			    
		    }
		    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"it is a reply data\n";
		    if ( queryHandlerInstance.insertPacket ( false , currentConversationId , ++ packetNumber , rawData) ){
			    copyPacket ( false , &conversationDiary [ currentConversationId ] , rawData );
			    return true;
			    
		    }
		    return false;
		    
	    }
	    //else for sure it is a Middle pack
	    if ( searchMother ( false , &conversationDiary [ currentConversationId ] , rawData ) ){
		    copyPacket ( true , &conversationDiary [ currentConversationId ] , rawData );
		    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"Middle packet \n";
		    if ( queryHandlerInstance.insertPacket ( false , currentConversationId , ++ packetNumber , rawData ) ){
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"Reply packet inserted \n";
			    return true;
		    }
		    return false;
	    }else {
		    /*-----------------------------------------------------------------------------
		     *  packet is a greeting packet from server--
		     *  when a new server greeting is coming have to errase previous packets from both array
		     *  for removing conflicttion.
		     *-----------------------------------------------------------------------------*/
		    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"GREETING packet from SERVER \n";
		    /*-----------------------------------------------------------------------------
		     *  if server greeting appears more that one time under a scenario 
		     *-----------------------------------------------------------------------------*/
		    if( currentConversationId >= 0 ){
			    deleteConversationDiary();
			    initDataStructure();
		    }
		    if ( queryHandlerInstance.insertDbGreeting  ( ++currentConversationId , ++packetNumber , rawData) ){
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"conversation id ="<<currentConversationId<<std::endl;
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<conversationDiary [ 0].conversationId<<"check"<<std::endl;
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<conversationDiary->currentPositionServerArray<<std::endl;
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"conversationDiary->currentPositionServerArray"<<conversationDiary->currentPositionServerArray<<std::endl;
			    conversationDiary->allPreviousPacketServer [  ( conversationDiary->currentPositionServerArray ) ].prevSequenceNumber = rawData->sequenceNumber;
			    //currentConversation->allPreviousPacketServer [++ ( currentConversation->currentPositionServerArray  ) ].prevSequenceNumber = rawData.sequenceNumber;
			    captureDb::StoreRawPacket::copyPacket ( false , &conversationDiary [ currentConversationId ] , rawData );
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"app array\t"<<conversationDiary [currentConversationId].currentPositionClientArray
				    <<"db arraarrau**************** \t"<<conversationDiary [currentConversationId].currentPositionServerArray
				    <<"conversation Id\t"<<currentConversationId<<std::endl;
			    if ( queryHandlerInstance.insertPacketSetting ( false , currentConversationId , packetNumber ,rawData) ){
				    queryHandlerInstance.insertPacket ( false , currentConversationId ,  packetNumber , rawData );
				    return true;
			    }else{
				    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"Cant insert packet\n";
				    return false;
			    }
			    return true;
		    }else {
			    std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]"<<__FUNCTION__<<"cant insert into greeting DB\n";
			    return false;
		    }
	    }
    }
    return false;
}