00001 //--------------------------------------------------------------------------
00002 // Copyright (C) 2014-2017 Cisco and/or its affiliates. All rights reserved.
00003 //
00004 // This program is free software; you can redistribute it and/or modify it
00005 // under the terms of the GNU General Public License Version 2 as published
00006 // by the Free Software Foundation. You may not use, modify or distribute
00007 // this program under any other version of the GNU General Public License.
00008 //
00009 // This program is distributed in the hope that it will be useful, but
00010 // WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License along
00015 // with this program; if not, write to the Free Software Foundation, Inc.,
00016 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 //--------------------------------------------------------------------------
00018 // http_stream_splitter.h author Tom Peters <thopeter@cisco.com>
00019
00020 #ifndef HTTP_STREAM_SPLITTER_H
00021 #define HTTP_STREAM_SPLITTER_H
00022
00023 #include <zlib.h>
00024
00025 #include "stream/stream_splitter.h"
00026
00027 #include "http_flow_data.h"
00028 #include "http_test_manager.h"
00029
00030 class HttpInspect;
00031
00032 class HttpStreamSplitter : public StreamSplitter
00033 {
00034 public:
00035 HttpStreamSplitter(bool is_client_to_server, HttpInspect* my_inspector_) :
00036 StreamSplitter(is_client_to_server),
00037 source_id(is_client_to_server ? HttpEnums::SRC_CLIENT : HttpEnums::SRC_SERVER),
00038 my_inspector(my_inspector_) { }
00039 Status scan(Flow* flow, const uint8_t* data, uint32_t length, uint32_t not_used,
00040 uint32_t* flush_offset) override;
00041 const StreamBuffer reassemble(Flow* flow, unsigned total, unsigned, const
00042 uint8_t* data, unsigned len, uint32_t flags, unsigned& copied) override;
00043 bool finish(Flow* flow) override;
00044 bool is_paf() override { return true; }
00045
00046 // FIXIT-M should return actual packet buffer size
00047 unsigned max(Flow*) override { return HttpEnums::MAX_OCTETS; }
00048
00049 private:
00050 void prepare_flush(HttpFlowData* session_data, uint32_t* flush_offset, HttpEnums::SectionType
00051 section_type, uint32_t num_flushed, uint32_t num_excess, int32_t num_head_lines,
00052 bool is_broken_chunk, uint32_t num_good_chunks, uint32_t octets_seen, bool strict_length)
00053 const;
00054 HttpCutter* get_cutter(HttpEnums::SectionType type, const HttpFlowData* session) const;
00055 void chunk_spray(HttpFlowData* session_data, uint8_t* buffer, const uint8_t* data,
00056 unsigned length) const;
00057 static void decompress_copy(uint8_t* buffer, uint32_t& offset, const uint8_t* data,
00058 uint32_t length, HttpEnums::CompressId& compression, z_stream*& compress_stream,
00059 bool at_start, HttpInfractions* infractions, HttpEventGen* events);
00060
00061 const HttpEnums::SourceId source_id;
00062 HttpInspect* const my_inspector;
00063 };
00064
00065 #endif
00066
END OF CODE