示例#1
0
def main():
    application = faucet.Faucet(
        dpset=dpset.DPSet(),
        faucet_experimental_api=faucet_experimental_api.FaucetExperimentalAPI(
        ))
    application.start()

    # make sure dps are running
    if application.valves_manager is not None:
        for valve in list(application.valves_manager.valves.values()):
            valve.dp.running = True

    while afl.loop(ROUNDS):
        # receive input from afl
        rcv = sys.stdin.read()
        data = None
        try:
            data = bytearray.fromhex(rcv)  # pytype: disable=missing-parameter
        except (ValueError, TypeError):
            continue

        # create fake packet
        dp = Fake.Datapath(1)
        msg = Fake.Message(datapath=dp,
                           cookie=1524372928,
                           port=1,
                           data=data,
                           in_port=1)
        pkt = Fake.RyuEvent(msg)

        # send fake packet to faucet
        application.packet_in_handler(pkt)
示例#2
0
def main():
    # run faucet
    application = faucet.Faucet(dpset=dpset.DPSet(), faucet_experimental_api=faucet_experimental_api.FaucetExperimentalAPI())
    application.start()

    # make sure dps are running
    for dp_id, valve in list(application.valves.items()):
        valve.dp.running = True

    # receive input from afl
    rcv = sys.stdin.read()
    data = None
    try:
        data = bytearray.fromhex(rcv)
    except (ValueError, TypeError):
        pass

    if data is not None:
        # create fake packet
        dp = Fake.Datapath(1)
        msg = Fake.Message(datapath=dp, cookie=1524372928, port=1, data=data, in_port=1)
        pkt = Fake.RyuEvent(msg)

        # send fake packet to faucet
        application.packet_in_handler(pkt)
示例#3
0
def main():
    """Shows the crash in the FAUCET log produced by given input."""

    with open(sys.argv[1]) as pkt:
        packet_data = str(pkt.read())

    # start faucet
    application = faucet.Faucet(
        dpset=dpset.DPSet(),
        faucet_experimental_api=faucet_experimental_api.FaucetExperimentalAPI())
    application.start()

    # make sure dps are running
    if application.valves_manager is not None:
        for valve in list(application.valves_manager.valves.values()):
            state = valve.dp.dyn_finalized
            valve.dp.dyn_finalized = False
            valve.dp.running = True
            valve.dp.dyn_finalized = state

    # create data from read file
    byte_data = None
    try:
        byte_data = bytearray.fromhex(packet_data)  # pytype: disable=missing-parameter,wrong-arg-types
    except (ValueError, TypeError):
        pass

    if byte_data is not None:
        # create fake packet
        _dp = fake_packet.Datapath(1)
        msg = fake_packet.Message(datapath=_dp, cookie=15243729, port=1, data=byte_data, in_port=1)
        pkt = fake_packet.RyuEvent(msg)

        # send packet to faucet and display error produced
        application.packet_in_handler(pkt)
 def test_api(self):
     api = faucet_experimental_api.FaucetExperimentalAPI()
     self.assertFalse(api.is_registered())
     api.reload_config()
     self.assertIsNone(api.get_config())
     self.assertIsNone(api.get_tables(0))
     with self.assertRaises(NotImplementedError):
         api.push_config(None)
     with self.assertRaises(NotImplementedError):
         api.add_port_acl(None, None)
     with self.assertRaises(NotImplementedError):
         api.add_vlan_acl(None, None)
     with self.assertRaises(NotImplementedError):
         api.delete_port_acl(None, None)
     with self.assertRaises(NotImplementedError):
         api.delete_vlan_acl(None, None)
示例#5
0
def main():
    # go through all files in directory
    # read file and store in string
    with open(sys.argv[1]) as pkt:
        packet_data = pkt.read()

    # start faucet
    application = faucet.Faucet(
        dpset=dpset.DPSet(),
        faucet_experimental_api=faucet_experimental_api.FaucetExperimentalAPI(
        ))
    application.start()

    # make sure dps are running
    for dp_id, valve in list(application.valves.items()):
        valve.dp.running = True

    # create data from read file
    byte_data = None
    try:
        byte_data = bytearray.fromhex(packet_data)
    except (ValueError, TypeError):
        pass

    if byte_data is not None:
        # create fake packet
        dp = Fake.Datapath(1)
        msg = Fake.Message(datapath=dp,
                           cookie=1524372928,
                           port=1,
                           data=byte_data,
                           in_port=1)
        pkt = Fake.RyuEvent(msg)

        # send packet to faucet and display error produced
        try:
            application.packet_in_handler(pkt)
        except Exception as err:
            print('FILE: ' + str(sys.argv[1]))
            print('ERROR: ' + str(err))
示例#6
0
def main():
    # go through all files in directory
    # read file and store in string
    with open(sys.argv[1]) as pkt:
        packet_data = str(pkt.read())

    # start faucet
    application = faucet.Faucet(
        dpset=dpset.DPSet(),
        faucet_experimental_api=faucet_experimental_api.FaucetExperimentalAPI(
        ))
    application.start()

    # make sure dps are running
    if application.valves_manager is not None:
        for valve in list(application.valves_manager.valves.values()):
            valve.dp.running = True

    # create data from read file
    byte_data = None
    try:
        byte_data = bytearray.fromhex(packet_data)  # pytype: disable=missing-parameter
    except (ValueError, TypeError):
        pass

    if byte_data is not None:
        # create fake packet
        dp = Fake.Datapath(1)
        msg = Fake.Message(datapath=dp,
                           cookie=1524372928,
                           port=1,
                           data=byte_data,
                           in_port=1)
        pkt = Fake.RyuEvent(msg)

        # send packet to faucet and display error produced
        application.packet_in_handler(pkt)
示例#7
0
def main():
    """Run AFL repeatedly with externally supplied generated packet from STDIN."""
    application = faucet.Faucet(
        dpset=dpset.DPSet(),
        faucet_experimental_api=faucet_experimental_api.FaucetExperimentalAPI(
        ))
    application.start()

    # make sure dps are running
    if application.valves_manager is not None:
        for valve in list(application.valves_manager.valves.values()):
            state = valve.dp.dyn_finalized
            valve.dp.dyn_finalized = False
            valve.dp.running = True
            valve.dp.dyn_finalized = state

    while afl.loop(ROUNDS):
        # receive input from afl
        rcv = sys.stdin.read()
        data = None
        try:
            data = bytearray.fromhex(rcv)  # pytype: disable=missing-parameter
        except (ValueError, TypeError):
            continue

        # create fake packet
        _dp = fake_packet.Datapath(1)
        msg = fake_packet.Message(datapath=_dp,
                                  cookie=15243729,
                                  port=1,
                                  data=data,
                                  in_port=1)
        pkt = fake_packet.RyuEvent(msg)

        # send fake packet to faucet
        application.packet_in_handler(pkt)
示例#8
0
#!/usr/bin/env python3
import logging
import os
import sys
import Fake
from faucet import faucet
from ryu.controller import dpset
from faucet import faucet_experimental_api

logging.disable(logging.CRITICAL)

# run faucet
application = faucet.Faucet(
    dpset=dpset.DPSet(),
    faucet_experimental_api=faucet_experimental_api.FaucetExperimentalAPI())
application.start()

# make sure dps are running
for dp_id, valve in list(application.valves.items()):
    valve.dp.running = True

import afl
while afl.loop(1000):
    # receive input from afl
    rcv = sys.stdin.read()
    data = None
    try:
        data = bytearray.fromhex(rcv)
    except (ValueError, TypeError):
        pass