stop import ofproto_v1_0 as ofproto

'from . import ofproto_v1_0 as ofproto' in ryu/ofproto/__init__.py is
a wrong assumption. We need to remove it.

This introduces ryu/ofproto/ofproto_common.py including only constatns
that OF version independent code must use. Note that I don't move data
structures there that multiple OF versions can share (like OVS does).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori 2012-07-17 06:57:34 +09:00
parent ad184686a8
commit 4c2de66d32
5 changed files with 34 additions and 26 deletions

View File

@ -24,7 +24,7 @@ import greenlet
from gevent.server import StreamServer
from gevent.queue import Queue
from ryu.ofproto import ofproto
from ryu.ofproto import ofproto_common
from ryu.ofproto import ofproto_parser
from ryu.ofproto import ofproto_v1_0
from ryu.ofproto import ofproto_v1_0_parser
@ -40,7 +40,7 @@ LOG = logging.getLogger('ryu.controller.controller')
FLAGS = gflags.FLAGS
gflags.DEFINE_string('ofp_listen_host', '', 'openflow listen host')
gflags.DEFINE_integer('ofp_tcp_listen_port', ofproto.OFP_TCP_PORT,
gflags.DEFINE_integer('ofp_tcp_listen_port', ofproto_common.OFP_TCP_PORT,
'openflow tcp listen port')
@ -122,7 +122,7 @@ class Datapath(object):
@_deactivate
def _recv_loop(self):
buf = bytearray()
required_len = ofproto.OFP_HEADER_SIZE
required_len = ofproto_common.OFP_HEADER_SIZE
count = 0
while self.is_active:
@ -143,7 +143,7 @@ class Datapath(object):
self.ev_q.queue(ofp_event.ofp_msg_to_ev(msg))
buf = buf[required_len:]
required_len = ofproto.OFP_HEADER_SIZE
required_len = ofproto_common.OFP_HEADER_SIZE
# We need to schedule other greenlets. Otherwise, ryu
# can't accept new switches or handle the existing

View File

@ -1,17 +0,0 @@
# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from . import ofproto_v1_0 as ofproto

View File

@ -0,0 +1,25 @@
# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from struct import calcsize
OFP_HEADER_PACK_STR = '!BBHI'
OFP_HEADER_SIZE = 8
assert calcsize(OFP_HEADER_PACK_STR) == OFP_HEADER_SIZE
OFP_TCP_PORT = 6633
OFP_SSL_PORT = 6633

View File

@ -1,4 +1,4 @@
# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -19,15 +19,15 @@ import struct
from ryu import exception
from . import ofproto
from . import ofproto_common
LOG = logging.getLogger('ryu.ofproto.ofproto_parser')
def header(buf):
assert len(buf) >= ofproto.OFP_HEADER_SIZE
assert len(buf) >= ofproto_common.OFP_HEADER_SIZE
#LOG.debug('len %d bufsize %d', len(buf), ofproto.OFP_HEADER_SIZE)
return struct.unpack_from(ofproto.OFP_HEADER_PACK_STR, buffer(buf))
return struct.unpack_from(ofproto_common.OFP_HEADER_PACK_STR, buffer(buf))
_MSG_PARSERS = {}

View File

@ -21,7 +21,7 @@ from nose.tools import *
import struct
from ryu import exception
from ryu.ofproto import ofproto, ofproto_parser
from ryu.ofproto import ofproto_common, ofproto_parser
from ryu.ofproto import ofproto_v1_0, ofproto_v1_0_parser
import logging