00001 //--------------------------------------------------------------------------
00002 // Copyright (C) 2015-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
00019 // tcp_state_handler.h author davis mcpherson <davmcphe@@cisco.com>
00020 // Created on: Jun 24, 2015
00021
00022 #ifndef TCP_STATE_HANDLER_H
00023 #define TCP_STATE_HANDLER_H
00024
00025 #include "protocols/tcp.h"
00026 #include "stream/libtcp/tcp_segment_descriptor.h"
00027 #include "stream/libtcp/tcp_stream_tracker.h"
00028
00029 class TcpStateMachine;
00030
00031 class TcpStateHandler
00032 {
00033 public:
00034 TcpStateHandler(TcpStreamTracker::TcpState, TcpStateMachine&);
00035 virtual ~TcpStateHandler();
00036
00037 virtual bool eval(TcpSegmentDescriptor&, TcpStreamTracker&);
00038
00039 TcpStreamTracker::TcpState get_tcp_state() const
00040 {
00041 return tcp_state;
00042 }
00043
00044 const TcpStateMachine* get_tsm() const
00045 {
00046 return tsm;
00047 }
00048
00049 void set_tsm(const TcpStateMachine* tsm)
00050 {
00051 this->tsm = tsm;
00052 }
00053
00054 virtual bool do_pre_sm_packet_actions(TcpSegmentDescriptor&, TcpStreamTracker&);
00055 virtual bool do_post_sm_packet_actions(TcpSegmentDescriptor&, TcpStreamTracker&);
00056
00057 protected:
00058 virtual bool syn_sent(TcpSegmentDescriptor&, TcpStreamTracker&);
00059 virtual bool syn_recv(TcpSegmentDescriptor&, TcpStreamTracker&);
00060 virtual bool syn_ack_sent(TcpSegmentDescriptor&, TcpStreamTracker&);
00061 virtual bool syn_ack_recv(TcpSegmentDescriptor&, TcpStreamTracker&);
00062 virtual bool ack_sent(TcpSegmentDescriptor&, TcpStreamTracker&);
00063 virtual bool ack_recv(TcpSegmentDescriptor&, TcpStreamTracker&);
00064 virtual bool data_seg_sent(TcpSegmentDescriptor&, TcpStreamTracker&);
00065 virtual bool data_seg_recv(TcpSegmentDescriptor&, TcpStreamTracker&);
00066 virtual bool fin_sent(TcpSegmentDescriptor&, TcpStreamTracker&);
00067 virtual bool fin_recv(TcpSegmentDescriptor&, TcpStreamTracker&);
00068 virtual bool rst_sent(TcpSegmentDescriptor&, TcpStreamTracker&);
00069 virtual bool rst_recv(TcpSegmentDescriptor&, TcpStreamTracker&);
00070
00071 bool default_state_action(TcpSegmentDescriptor&, TcpStreamTracker&);
00072
00073 const TcpStateMachine* tsm;
00074 TcpStreamTracker::TcpState tcp_state;
00075 };
00076
00077 #endif
00078
END OF CODE