/src/zeek/src/analyzer/protocol/sip/SIP_TCP.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // See the file "COPYING" in the main distribution directory for copyright. |
2 | | // |
3 | | // TODO: This is preliminary code that's not yet functional and not |
4 | | // activated. We don't yet support SIP-over-TCP. |
5 | | |
6 | | #include "zeek/analyzer/protocol/sip/SIP_TCP.h" |
7 | | |
8 | | #include "zeek/analyzer/protocol/tcp/TCP_Reassembler.h" |
9 | | |
10 | | namespace zeek::analyzer::sip_tcp { |
11 | | |
12 | 0 | SIP_Analyzer::SIP_Analyzer(Connection* conn) : analyzer::tcp::TCP_ApplicationAnalyzer("SIP_TCP", conn) { |
13 | 0 | interp = new binpac::SIP_TCP::SIP_Conn(this); |
14 | 0 | had_gap = false; |
15 | 0 | } |
16 | | |
17 | 0 | SIP_Analyzer::~SIP_Analyzer() { delete interp; } |
18 | | |
19 | 0 | void SIP_Analyzer::Done() { |
20 | 0 | analyzer::tcp::TCP_ApplicationAnalyzer::Done(); |
21 | |
|
22 | 0 | interp->FlowEOF(true); |
23 | 0 | interp->FlowEOF(false); |
24 | 0 | } |
25 | | |
26 | 0 | void SIP_Analyzer::EndpointEOF(bool is_orig) { |
27 | 0 | analyzer::tcp::TCP_ApplicationAnalyzer::EndpointEOF(is_orig); |
28 | 0 | interp->FlowEOF(is_orig); |
29 | 0 | } |
30 | | |
31 | 0 | void SIP_Analyzer::DeliverStream(int len, const u_char* data, bool orig) { |
32 | 0 | analyzer::tcp::TCP_ApplicationAnalyzer::DeliverStream(len, data, orig); |
33 | |
|
34 | 0 | if ( TCP() && TCP()->IsPartial() ) |
35 | 0 | return; |
36 | | |
37 | 0 | if ( had_gap ) |
38 | | // If only one side had a content gap, we could still try to |
39 | | // deliver data to the other side if the script layer can |
40 | | // handle this. |
41 | 0 | return; |
42 | | |
43 | 0 | try { |
44 | 0 | interp->NewData(orig, data, data + len); |
45 | 0 | } catch ( const binpac::Exception& e ) { |
46 | 0 | AnalyzerViolation(util::fmt("Binpac exception: %s", e.c_msg())); |
47 | 0 | } |
48 | 0 | } |
49 | | |
50 | 0 | void SIP_Analyzer::Undelivered(uint64_t seq, int len, bool orig) { |
51 | 0 | analyzer::tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, orig); |
52 | 0 | had_gap = true; |
53 | 0 | interp->NewGap(orig, len); |
54 | 0 | } |
55 | | |
56 | | } // namespace zeek::analyzer::sip_tcp |