コード例 #1
0
 def test_pkt_in_filter_discard(self):
     datapath = ProtocolDesc(version=ofproto_v1_3.OFP_VERSION)
     e = ethernet.ethernet(mac.BROADCAST_STR, mac.BROADCAST_STR,
                           ether.ETH_TYPE_IP)
     i = ipv4.ipv4()
     pkt = (e / i)
     pkt.serialize()
     pkt_in = ofproto_v1_3_parser.OFPPacketIn(datapath,
                                              data=buffer(pkt.data))
     ev = ofp_event.EventOFPPacketIn(pkt_in)
     ok_(not self.app.packet_in_handler(ev))
コード例 #2
0
 def test_pkt_in_filter_pass(self):
     datapath = ProtocolDesc(version=ofproto_v1_3.OFP_VERSION)
     e = ethernet.ethernet(mac.BROADCAST_STR, mac.BROADCAST_STR,
                           ether.ETH_TYPE_8021Q)
     v = vlan.vlan()
     i = ipv4.ipv4()
     pkt = (e / v / i)
     pkt.serialize()
     pkt_in = ofproto_v1_3_parser.OFPPacketIn(datapath,
                                              data=six.binary_type(
                                                  pkt.data))
     ev = ofp_event.EventOFPPacketIn(pkt_in)
     ok_(self.app.packet_in_handler(ev))
コード例 #3
0
 def test_pkt_in_filter_truncated(self):
     datapath = ProtocolDesc(version=ofproto_v1_3.OFP_VERSION)
     truncated_data = ''
     pkt_in = ofproto_v1_3_parser.OFPPacketIn(datapath, data=truncated_data)
     ev = ofp_event.EventOFPPacketIn(pkt_in)
     ok_(not self.app.packet_in_handler(ev))
コード例 #4
0
ファイル: convert_ryu.py プロジェクト: wandsdn/ofequivalence
    from pickle import UnpicklingError
import json
import sys

import six
from six import viewitems
from ryu.ofproto import ofproto_v1_3
from ryu.ofproto import ofproto_v1_3_parser as parser
from ryu.ofproto.ofproto_protocol import ProtocolDesc
from ryu.ofproto.ofproto_parser import ofp_msg_from_jsondict

from .rule import Rule, Match, Instructions, ActionSet, ActionList, Group
from .utils import as_file_handle
from .format_utils import normalise_bytes

DP = ProtocolDesc(version=ofproto_v1_3.OFP_VERSION)

# ~~~~ Functions converting from ryu to the internal rule representation ~~~~ #


def match_from_ryu(ryu_match):
    """ Converts a ryu OFPMatch to a Match

    ryu_match: A ryu OFPMatch
    return: A Match object
    """
    if ryu_match is None:
        return Match()
    ret = Match()
    for field in ryu_match._fields2:
        oxm = ofproto_v1_3.oxm_from_user(*field)
コード例 #5
0
import socket
import threading
from ..sdn_message_reader import SDNMessageReader
from ryu.ofproto.ofproto_v1_0 import OFPT_BARRIER_REQUEST, OFPT_FLOW_MOD

# handling failure messages
from ryu.ofproto.ofproto_v1_0 import OFPET_FLOW_MOD_FAILED, OFPFMFC_UNSUPPORTED
from ryu.ofproto.ofproto_v1_0 import OFP_VERSION
from ryu.ofproto.ofproto_protocol import ProtocolDesc
from ryu.ofproto.ofproto_v1_0_parser import OFPErrorMsg
OF_1_0_DATAPATH = ProtocolDesc(OFP_VERSION)


def generate_error_from_flow_mod(flow_mod_message):
    '''
    Should already be compiled
    '''
    datapath = OF_1_0_DATAPATH
    fail_type = OFPET_FLOW_MOD_FAILED
    fail_code = OFPFMFC_UNSUPPORTED
    data = flow_mod_message.buf[0:60]
    to_return = OFPErrorMsg(datapath, fail_type, fail_code, data)
    to_return.serialize()
    to_return.xid = flow_mod_message.xid
    return to_return


class ErrorFlowmodsMessageManager(object):
    '''
    When receive sdn messages on incoming queue, instantly write it
    out on sender socket.
コード例 #6
0
ファイル: test_ofctl_string.py プロジェクト: MrCocoaCat/ryu
 def __init__(self, methodName):
     print('init %s' % methodName)
     self.fake_dp_of15 = ProtocolDesc(ofproto_v1_5.OFP_VERSION)
     self.maxDiff = None
     super(Test_OfctlString, self).__init__(methodName)
コード例 #7
0
ファイル: openflow_util.py プロジェクト: hodiapa/sdn_fuzz
import os
import sys

sys.path.append(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), '..',
                 'submodules', 'ryu'))

from ryu.lib import addrconv
from ryu.ofproto import nx_match
from ryu.ofproto import ofproto_v1_0_parser
from ryu.ofproto import ofproto_v1_0
from ryu.ofproto.ofproto_protocol import ProtocolDesc
import ryu.ofproto.ofproto_v1_0 as ofproto_v1_0

OF_1_0_DATAPATH = ProtocolDesc(ofproto_v1_0.OFP_VERSION)


def generate_add_flowmod(in_port=None):
    if in_port is None:
        in_port = 32
    rule = nx_match.ClsRule()
    rule.set_in_port(in_port)
    match_tuple = rule.match_tuple()
    match = ofproto_v1_0_parser.OFPMatch(*match_tuple)

    cookie = 0
    command = ofproto_v1_0.OFPFC_ADD
    idle_timeout = 0
    hard_timeout = 0
    priority = ofproto_v1_0.OFP_DEFAULT_PRIORITY
    buffer_id = 0xffffffff