Пример #1
0
 def testFormatter(self):
     e = Ethernet()
     ip = IPv4()
     icmp = ICMP()
     fullpkt = e + ip + icmp
     self.assertEqual(PacketFormatter.format_pkt(fullpkt), str(fullpkt))
     partial = ip + icmp
     self.assertEqual(PacketFormatter.format_pkt(fullpkt, cls=IPv4), str(partial))
     with self.assertLogs(level='WARN') as cm:
         self.assertEqual(PacketFormatter.format_pkt(fullpkt, cls=IPv6), str(fullpkt))
     self.assertIn('non-existent header', cm.output[0])
     PacketFormatter.full_display()
     self.assertEqual(PacketFormatter.format_pkt(fullpkt), str(fullpkt))
Пример #2
0
    parser.add_argument("-s", "--scenario", help="Specify scenario file to use in test mode.", dest="scenario", action="append")
    parser.add_argument("--dryrun", help="Get everything ready to go, but don't actually do anything.", action='store_true', dest='dryrun', default=False)
    parser.add_argument("-v", "--verbose", help="Turn on verbose output, including full packet dumps in test results.  Can be specified multiple times to increase verbosity.", dest="verbose", action="count", default=0)
    parser.add_argument("-d", "--debug", help="Turn on debug logging output.", dest="debug", action="store_true", default=False)
    parser.add_argument("--nopdb", help="Don't enter pdb on crash.", dest="nopdb", action="store_true", default=False)
    parser.add_argument("-f", "--firewall", help="Specify host firewall rules (for real/live mode only)", dest="fwconfig", action="append")
    parser.add_argument("-a", "--app", help="Specify application layer (socket-based) program to start (EXPERIMENTAL!)", dest="app", default=None)
    parser.add_argument("-e", "--nohandle", help="Don't trap exceptions.  Use of this option is helpful if you want to use Switchyard with a different symbolic debugger than pdb", dest="nohandle", action="store_true", default=False)
    args = parser.parse_args()

    # assume test mode if the compile flag is set
    if args.compile:
        args.testmode = True

    if args.verbose:
        PacketFormatter.full_display(True)

    setup_logging(args.debug)

    if args.usercode is None and not args.compile:
        log_failure("You need to specify the name of your module to run as the last argument")
        sys.exit()

    waiters = 1
    if args.app:
        waiters = 2
    barrier = Barrier(waiters)

    if args.app:
        ApplicationLayer.init()
        _appt = Thread(target=start_app, args=(args.app,barrier))