if(s_skinnyPacketLog->isDebugEnabled()) { CStdString dbg; unsigned int offset = (u_char*)skinnyHeader - startTcpPayload; dbg.Format("Offset:%x Len:%u Type:%x %s", offset, skinnyHeader->len, skinnyHeader->messageType, SkinnyMessageToString(skinnyHeader->messageType)); LOG4CXX_DEBUG(s_skinnyPacketLog, dbg); }
void HandlePacket(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data){	EthernetHeaderStruct* ethernetHeader = (EthernetHeaderStruct *)pkt_data;	IpHeaderStruct* ipHeader = (IpHeaderStruct*)((char*)ethernetHeader + sizeof(EthernetHeaderStruct));	int ipHeaderLength = ipHeader->ip_hl*4;	u_char* ipPacketEnd = (u_char*)ipHeader + ipHeader->ip_len;	//CStdString source = ACE_OS::inet_ntoa(ipHeader->ip_src);	//CStdString dest = ACE_OS::inet_ntoa(ipHeader->ip_dest);	//CStdString debug;	//debug.Format("%x, %x", ethernetHeader, ipHeader);	//LOG4CXX_INFO(s_log, source + "-" + dest);	//LOG4CXX_DEBUG(s_log, "*");	if(ipHeader->ip_p == IPPROTO_UDP)	{		UdpHeaderStruct* udpHeader = (UdpHeaderStruct*)((char *)ipHeader + ipHeaderLength);		if(	ntohs(udpHeader->source) > 5000 && ntohs(udpHeader->dest) > 5000 )		{			u_char* udpPayload = (u_char *)udpHeader + sizeof(UdpHeaderStruct);			bool detectedUsefulPacket = TryRtp(ethernetHeader, ipHeader, udpHeader, udpPayload);						if(!detectedUsefulPacket)			{				detectedUsefulPacket= TrySipInvite(ethernetHeader, ipHeader, udpHeader, udpPayload);			}			if(!detectedUsefulPacket)			{				detectedUsefulPacket = TrySipBye(ethernetHeader, ipHeader, udpHeader, udpPayload);			}		}	}	else if(ipHeader->ip_p == IPPROTO_TCP)	{		TcpHeaderStruct* tcpHeader = (TcpHeaderStruct*)((char *)ipHeader + ipHeaderLength);				if(ntohs(tcpHeader->source) == SKINNY_CTRL_PORT || ntohs(tcpHeader->dest) == SKINNY_CTRL_PORT)		{			SkinnyHeaderStruct* skinnyHeader = (SkinnyHeaderStruct*)((u_char*)tcpHeader + TCP_HEADER_LENGTH);			// Scan all skinny message in this TCP packet			while(	ipPacketEnd > (u_char*)skinnyHeader && 					(u_char*)skinnyHeader>=((u_char*)tcpHeader + TCP_HEADER_LENGTH) &&					(ipPacketEnd - (u_char*)skinnyHeader) > SKINNY_MIN_MESSAGE_SIZE			)			{				//CStdString dbg;				//dbg.Format("Len:%u, Type:%x, %s", skinnyHeader->len, skinnyHeader->messageType, SkinnyMessageToString(skinnyHeader->messageType));				//LOG4CXX_INFO(s_log, dbg);				HandleSkinnyMessage(skinnyHeader);				// Point to next skinny message within this TCP packet				skinnyHeader = (SkinnyHeaderStruct*)((u_char*)skinnyHeader + SKINNY_HEADER_LENGTH + skinnyHeader->len);			}		}	}	time_t now = time(NULL);	if((now - lastHooveringTime) > 5)	{		lastHooveringTime = now;		RtpSessionsSingleton::instance()->Hoover(now);	}}