コード例 #1
0
    def on_established_outgoing(self, pkt, ip, tcp):
        if FIN & tcp.flags:
            self.end_fin(tcp)
            self.state = STATES.FIN_WAIT_1
            return _drop(pkt, ip)

        if RST & tcp.flags:
            self.state = STATES.CLOSED
            # rst sequence?
            return _drop(pkt, ip)

        self.update_tcp(pkt, ip, tcp, True)
        return _accept(pkt, ip)
コード例 #2
0
    def pkt_outgoing(self, pkt, ip, tcp):
        if tcp.flags & RST:
            self.state = STATES.CLOSED
            return _drop(pkt, ip)

        func = self.outgoing.get(self.state, self.pass_pkt_outgoing)
        return func(self, pkt, ip, tcp)
コード例 #3
0
    def on_listen_incomming(self, pkt, ip, tcp):
        if tcp.flags == ACK:
            self.recover_syn(tcp)

        if tcp.flags == SYN:
            self.state = STATES.SYN_RECV
            _accept(pkt, ip)

        return _drop(pkt, ip)
コード例 #4
0
    def on_recover_incomming(self, pkt, ip, tcp):
        if tcp.flags == ACK:
            # because in some cases the syn ack wont register
            # we skip the syn_sent state and assume the
            # application got the SYN-ACK
            self.recover_syn_ack_local(tcp)
            self.state = STATES.SYN_SENT

        return _drop(pkt, ip)
コード例 #5
0
 def on_fin_wait_1(self, pkt, ip, tcp):
     # we dont distinguesh between fin_wait_1 and fin_wait_2
     if tcp.flags & FIN:
         self.state = STATES.CLOSED
         return _accept(pkt, ip)
     return _drop(pkt, ip)
コード例 #6
0
 def on_syn_sent_outgoing(self, pkt, ip, tcp):
     if tcp.flags == ACK:
         self.state = STATES.ESTABLISHED
     return _drop(pkt, ip)
コード例 #7
0
 def on_syn_sent_incomming(self, pkt, ip, tcp):
     if tcp.flags == SYN | ACK:
         return _accept(pkt, ip)
     return _drop(pkt, ip)
コード例 #8
0
 def on_closed_outgoing(self, pkt, ip, tcp):
     if tcp.flags & SYN:
         self.state = STATES.RECOVER
         self.recover_seq_ack(pkt, ip, tcp)
         return _accept(pkt, ip)
     return _drop(pkt, ip)
コード例 #9
0
 def on_syn_rcv_outgoing(self, pkt, ip, tcp):
     if ACK == tcp.flags:
         self.state = STATES.ESTABLISHED
         return _accept(pkt, ip)
     return _drop(pkt, ip)
コード例 #10
0
 def on_syn_rcv_outgoing(self, pkt, ip, tcp):
     if ACK | SYN == tcp.flags:
         self.recover_ack(tcp)
     return _drop(pkt, ip)