Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/controller/controller.py  | 26 +++++++++++++++++++-------
 ryu/ofproto/ofproto_common.py |  2 ++
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py
index 3bdf81f..4aea6bd 100644
--- a/ryu/controller/controller.py
+++ b/ryu/controller/controller.py
@@ -51,10 +51,10 @@ LOG = logging.getLogger('ryu.controller.controller')
 CONF = cfg.CONF
 CONF.register_cli_opts([
     cfg.StrOpt('ofp-listen-host', default='', help='openflow listen host'),
-    cfg.IntOpt('ofp-tcp-listen-port', default=ofproto_common.OFP_TCP_PORT,
+    cfg.IntOpt('ofp-tcp-listen-port', default=None,
                help='openflow tcp listen port '
                     '(default: %d)' % ofproto_common.OFP_TCP_PORT),
-    cfg.IntOpt('ofp-ssl-listen-port', default=ofproto_common.OFP_SSL_PORT,
+    cfg.IntOpt('ofp-ssl-listen-port', default=None,
                help='openflow ssl listen port '
                     '(default: %d)' % ofproto_common.OFP_SSL_PORT),
     cfg.StrOpt('ctl-privkey', default=None, help='controller private key'),
@@ -78,17 +78,29 @@ CONF.register_opts([
 class OpenFlowController(object):
     def __init__(self):
         super(OpenFlowController, self).__init__()
+        if not CONF.ofp_tcp_listen_port and not CONF.ofp_ssl_listen_port:
+            self.ofp_tcp_listen_port = ofproto_common.OFP_TCP_PORT
+            self.ofp_ssl_listen_port = ofproto_common.OFP_SSL_PORT
+            # For the backward compatibility, we spawn a server loop
+            # listening on the old OpenFlow listen port 6633.
+            hub.spawn(self.server_loop,
+                      ofproto_common.OFP_TCP_PORT_OLD,
+                      ofproto_common.OFP_SSL_PORT_OLD)
+        else:
+            self.ofp_tcp_listen_port = CONF.ofp_tcp_listen_port
+            self.ofp_ssl_listen_port = CONF.ofp_ssl_listen_port
 
     # entry point
     def __call__(self):
         # LOG.debug('call')
-        self.server_loop()
+        self.server_loop(self.ofp_tcp_listen_port,
+                         self.ofp_ssl_listen_port)
 
-    def server_loop(self):
+    def server_loop(self, ofp_tcp_listen_port, ofp_ssl_listen_port):
         if CONF.ctl_privkey is not None and CONF.ctl_cert is not None:
             if CONF.ca_certs is not None:
                 server = StreamServer((CONF.ofp_listen_host,
-                                       CONF.ofp_ssl_listen_port),
+                                       ofp_ssl_listen_port),
                                       datapath_connection_factory,
                                       keyfile=CONF.ctl_privkey,
                                       certfile=CONF.ctl_cert,
@@ -97,14 +109,14 @@ class OpenFlowController(object):
                                       ssl_version=ssl.PROTOCOL_TLSv1)
             else:
                 server = StreamServer((CONF.ofp_listen_host,
-                                       CONF.ofp_ssl_listen_port),
+                                       ofp_ssl_listen_port),
                                       datapath_connection_factory,
                                       keyfile=CONF.ctl_privkey,
                                       certfile=CONF.ctl_cert,
                                       ssl_version=ssl.PROTOCOL_TLSv1)
         else:
             server = StreamServer((CONF.ofp_listen_host,
-                                   CONF.ofp_tcp_listen_port),
+                                   ofp_tcp_listen_port),
                                   datapath_connection_factory)
 
         # LOG.debug('loop')
diff --git a/ryu/ofproto/ofproto_common.py b/ryu/ofproto/ofproto_common.py
index fe2a55a..4f0d995 100644
--- a/ryu/ofproto/ofproto_common.py
+++ b/ryu/ofproto/ofproto_common.py
@@ -26,6 +26,8 @@ assert calcsize(OFP_HEADER_PACK_STR) == OFP_HEADER_SIZE
 # Some applications may still use 6633 as the de facto standard though.
 OFP_TCP_PORT = 6653
 OFP_SSL_PORT = 6653
+OFP_TCP_PORT_OLD = 6633
+OFP_SSL_PORT_OLD = 6633
 
 # Vendor/Experimenter IDs
 # https://rs.opennetworking.org/wiki/display/PUBLIC/ONF+Registry
-- 
2.7.4


------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to