firewall-controller.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:p4c_firewall 作者: open-nfpsw 项目源码 文件源码
def natAndSend(self,packet,port):
        # NAT for first packet - This removes the need to dynamically add the 3rd rule (Controller Rule)
        # A static rule in P4 now sends packets received back form the controller out the external port.
        packet[IP].src = self.router_ext_ip
        packet[TCP].sport = port

        # Recalculate checksum Scapy way?
        del packet[IP].chksum
        del packet[TCP].chksum
        packet = packet.__class__(str(packet))

        # packet already processed so don't process again - resubmit so reason won't be valid anymore
        new_p_str = '\x00' * 6 + str(packet)

        #print "threading.active_count " + str(threading.active_count())
        s = conf.L2socket(iface=self.controller_port)
        # sendp(new_p_str, iface=self.controller_port, verbose=0)
        s.send(new_p_str)
        print port
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号