#include <TCP_Contents.h>
Inheritance diagram for TCP_Contents:


Public Member Functions | |
| TCP_Contents (TCP_Endpoint *endp, int stop_on_gap=0) | |
| virtual | ~TCP_Contents () |
| int | DataSent (double t, int seq, int len, const u_char *data) |
| void | AckReceived (int seq) |
| void | CheckEOF () |
| int | HasUndeliveredData () const |
| int | DataPending () const |
| void | MatchUndeliveredData () |
| int | DataSeq () const |
| virtual void | Deliver (double t, int seq, int len, u_char *data) |
| virtual void | Undelivered (int seq, int len) |
| int | SkippingDeliveries () const |
| void | SetSkipDeliveries (int should_skip) |
| void | SetContentsFile (BroFile *f) |
| TCP_Endpoint * | Endpoint () |
| const TCP_Endpoint * | Endpoint () const |
| TCP_Connection * | Conn () |
| const TCP_Connection * | Conn () const |
| int | IsOrig () const |
| bool | Serialize (Serializer *s) const |
Static Public Member Functions | |
| TCP_Contents * | Unserialize (Serializer *ser) |
Protected Member Functions | |
| TCP_Contents () | |
Protected Attributes | |
| TCP_Endpoint * | endp |
| TCP_Reassembler * | t_reassem |
| unsigned int | skip_deliveries:1 |
| unsigned int | stop_on_gap:1 |
| unsigned int | did_EOF:1 |
|
||||||||||||
|
Definition at line 245 of file TCP_Contents.cc. References TCP_Endpoint::AddContentsProcessor(), did_EOF, skip_deliveries, TCP_Endpoint::src_addr, stop_on_gap, and t_reassem.
00247 {
00248 endp = arg_endp;
00249 endp->AddContentsProcessor(this);
00250 t_reassem = new TCP_Reassembler(this, endp->src_addr);
00251 skip_deliveries = 0;
00252 stop_on_gap = arg_stop_on_gap;
00253 did_EOF = 0;
00254 }
|
|
|
Definition at line 256 of file TCP_Contents.cc. References t_reassem, and Unref().
00257 {
00258 Unref(t_reassem);
00259 }
|
|
|
Definition at line 102 of file TCP_Contents.h.
00102 {}
|
|
|
Definition at line 292 of file TCP_Contents.cc. References CheckEOF(), Conn(), Connection::Event(), TCP_Endpoint::FIN_cnt, TCP_Endpoint::FIN_seq, TCP_Endpoint::peer, reading_live, Connection::Skipping(), SkippingDeliveries(), TCP_Endpoint::state, t_reassem, TCP_PARTIAL, and Reassembler::TrimToSeq(). Referenced by TCP_Endpoint::AckReceived().
00293 {
00294 if ( endp->FIN_cnt > 0 && seq >= endp->FIN_seq )
00295 // TrimToSeq: FIN_seq - 1
00296 seq = endp->FIN_seq - 1;
00297
00298 if ( ! SkippingDeliveries() && ! Conn()->Skipping() &&
00299 ! t_reassem->TrimToSeq(seq) &&
00300 reading_live && endp->state != TCP_PARTIAL && endp->peer->state != TCP_PARTIAL )
00301 // Only generate these events when reading live; from
00302 // a trace file, the hole might exist because the
00303 // file was trimmed while writing it.
00304 Conn()->Event(ack_above_hole);
00305
00306 // Check EOF here because t_reassem->LastReassemSeq() may have
00307 // changed after calling TrimToSeq().
00308 CheckEOF();
00309 }
|
|
|
Definition at line 311 of file TCP_Contents.cc. References Conn(), did_EOF, TCP_Connection::EndpointEOF(), TCP_Endpoint::FIN_cnt, Reassembler::LastReassemSeq(), TCP_Endpoint::LastSeq(), skip_deliveries, Connection::Skipping(), TCP_Endpoint::StartSeq(), TCP_Endpoint::state, t_reassem, TCP_CLOSED, and TCP_RESET. Referenced by AckReceived(), and TCP_Endpoint::CheckEOF().
00312 {
00313 if ( ! did_EOF &&
00314 (endp->FIN_cnt > 0 || endp->state == TCP_CLOSED || endp->state == TCP_RESET) &&
00315 (Conn()->Skipping() || skip_deliveries ||
00316 endp->StartSeq() + t_reassem->LastReassemSeq() >= endp->LastSeq() - 1) )
00317 {
00318 // We've now delivered all of the data.
00319 did_EOF = 1;
00320 Conn()->EndpointEOF(this);
00321 }
00322 }
|
|
|
Definition at line 94 of file TCP_Contents.h. References TCP_Endpoint::Conn().
|
|
|
|
Definition at line 342 of file TCP_Contents.cc. References DataSeq(), Endpoint(), TCP_Endpoint::HasUndeliveredData(), TCP_Endpoint::LastSeq(), TCP_Endpoint::peer, TCP_Endpoint::StartSeq(), TCP_Endpoint::state, TCP_RESET, and uint32. Referenced by TCP_Endpoint::DataPending().
00343 {
00344 uint32 delivered_seq = Endpoint()->StartSeq() + DataSeq();
00345
00346 // We've delivered everything if we're up to the penultimate
00347 // sequence number (since a FIN consumes an octet in the
00348 // sequence space), or right at it (because a RST does not).
00349 if ( delivered_seq != Endpoint()->LastSeq() - 1 &&
00350 delivered_seq != Endpoint()->LastSeq() )
00351 return 1;
00352
00353 // If we've sent RST, then we can't send ACKs any more.
00354 if ( Endpoint()->state != TCP_RESET &&
00355 Endpoint()->peer->HasUndeliveredData() )
00356 return 1;
00357
00358 return 0;
00359 }
|
|
||||||||||||||||||||
|
Definition at line 261 of file TCP_Contents.cc. References TCP_Endpoint::AckSeq(), Reassembler::NewBlock(), skip_deliveries, TCP_Endpoint::StartSeq(), and t_reassem. Referenced by TCP_Endpoint::DataSent().
00263 {
00264 if ( skip_deliveries )
00265 return 0;
00266
00267 int ack = endp->AckSeq() - endp->StartSeq();
00268 int upper_seq = seq + len;
00269
00270 if ( seq < ack )
00271 {
00272 if ( upper_seq <= ack )
00273 // We've already delivered this and it's been acked.
00274 return 0;
00275
00276 // We've seen an ack for part of this packet, but not the
00277 // whole thing. This can happen when, for example, a previous
00278 // packet held [a, a+b) and this packet holds [a, a+c) for c>b
00279 // (which some TCP's will do when retransmitting). Trim the
00280 // packet to just the unacked data.
00281 int amount_acked = ack - seq;
00282 seq += amount_acked;
00283 data += amount_acked;
00284 len -= amount_acked;
00285 }
00286
00287 t_reassem->NewBlock(t, seq, len, data);
00288
00289 return 1;
00290 }
|
|
|
Definition at line 79 of file TCP_Contents.h. References Reassembler::LastReassemSeq(), and t_reassem. Referenced by DataPending().
00079 { return t_reassem->LastReassemSeq(); }
|
|
||||||||||||||||||||
|
Reimplemented in TCP_Contents_DCE_RPC, TCP_Contents_DNS, TCP_Contents_NetbiosSSN, TCP_Contents_RPC, SSL_ProxyEndpoint, and TCP_ContentLine. Definition at line 324 of file TCP_Contents.cc. References Conn(), and TCP_Connection::Deliver(). Referenced by TCP_Reassembler::BlockInserted().
|
|
|
Definition at line 91 of file TCP_Contents.h.
00091 { return endp; }
|
|
|
|
Definition at line 76 of file TCP_Contents.h. References Reassembler::HasBlocks(), and t_reassem. Referenced by TCP_Endpoint::HasUndeliveredData().
|
|
|
|
Definition at line 78 of file TCP_Contents.h. References TCP_Reassembler::MatchUndelivered(), and t_reassem. Referenced by TCP_Endpoint::MatchUndeliveredData().
00078 { t_reassem->MatchUndelivered(); }
|
|
|
Definition at line 368 of file TCP_Contents.cc. References SerialObj::Serialize().
00369 {
00370 SerialInfo serial;
00371 return SerialObj::Serialize(s, &serial, true);
00372 }
|
|
|
Definition at line 361 of file TCP_Contents.cc. References TCP_Reassembler::SetContentsFile(), and t_reassem. Referenced by TCP_Endpoint::AddContentsProcessor(), and TCP_Endpoint::SetContentsFile().
00362 {
00363 t_reassem->SetContentsFile(f);
00364 }
|
|
|
Definition at line 85 of file TCP_Contents.h. References skip_deliveries. Referenced by SSH_Conn::NewLine(), Undelivered(), and HTTP_Conn::Undelivered().
00086 { skip_deliveries = should_skip; }
|
|
|
Definition at line 84 of file TCP_Contents.h. References skip_deliveries. Referenced by AckReceived().
00084 { return skip_deliveries; }
|
|
||||||||||||
|
Definition at line 329 of file TCP_Contents.cc. References Conn(), SetSkipDeliveries(), stop_on_gap, and TCP_Connection::Undelivered(). Referenced by TCP_Reassembler::Undelivered().
00330 {
00331 if ( stop_on_gap )
00332 // No more data will be sent to the reassembler via
00333 // DataSent, and thus no data will be delivered. Note
00334 // that it is safe to stop right here because all the data
00335 // before seq that exists in the trace must have already
00336 // appeared.
00337 SetSkipDeliveries(1);
00338
00339 Conn()->Undelivered(endp, seq, len);
00340 }
|
|
|
Definition at line 374 of file TCP_Contents.cc. References SER_TCP_CONTENTS, and SerialObj::Unserialize().
00375 {
00376 return (TCP_Contents*) SerialObj::Unserialize(s, SER_TCP_CONTENTS, true);
00377 }
|
|
|
Definition at line 110 of file TCP_Contents.h. Referenced by CheckEOF(), and TCP_Contents(). |
|
|
Definition at line 106 of file TCP_Contents.h. |
|
|
Definition at line 108 of file TCP_Contents.h. Referenced by CheckEOF(), DataSent(), SetSkipDeliveries(), SkippingDeliveries(), and TCP_Contents(). |
|
|
Definition at line 109 of file TCP_Contents.h. Referenced by TCP_Contents(), and Undelivered(). |
|
|
Definition at line 107 of file TCP_Contents.h. Referenced by AckReceived(), CheckEOF(), DataSent(), DataSeq(), HasUndeliveredData(), MatchUndeliveredData(), SetContentsFile(), TCP_Contents(), and ~TCP_Contents(). |
1.3.6