void TCPStream::processPacket( const Packet &p ) { uint32_t senderip; std::vector< uint8_t > data; //Is TCP? if( p.transSize() > 0 && p.transIs<TCP>() ) { TCP tcp = p.getTrans<TCP>(); //check for syn packet if( tcp.SYN_Flag() ) { //if syn initialize stream if( tcp.ACK_Flag() ) initSynAck( p ); else initSyn( p ); } else { TCPSegment segment; if( p.appSize() > 0 && p.appIs< Raw >() ) { segment.setData( p.getApp<Raw>( ).makePacket().vector() ); if( p.inetSize() > 0 && p.inetIs< IPv4 >() ) { segment.setSource( p.getInet<IPv4>().sourceAddress() ); } if( segment.source() == serverIp_ ) { serverSequenceNumber_ = tcp.sequenceNumber(); serverAcknowledgeNumber_ = tcp.acknowledgementNumber(); } else { clientSequenceNumber_ = tcp.sequenceNumber(); clientAcknowledgeNumber_ = tcp.acknowledgementNumber(); } stream_.push_back( segment ); } } if( tcp.FIN_Flag() || tcp.RST_Flag() ) finished_ = true; } }
bool Signature::quirkAck( const Packet &p ) const { if( p.inetIs< IPv4 >( 0 ) && p.transIs< TCP >( 0 ) ) { TCP tcp = p.getTrans<TCP>( 0 ); if( tcp.acknowledgementNumber() != 0 ) return true; } return false; }