Signed-off-by: Isaku Yamahata <[email protected]>
---
Changes v1 -> v2:
- copyright
---
 ryu/{controller/dp_type.py => lib/dpid.py} |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)
 copy ryu/{controller/dp_type.py => lib/dpid.py} (62%)

diff --git a/ryu/controller/dp_type.py b/ryu/lib/dpid.py
similarity index 62%
copy from ryu/controller/dp_type.py
copy to ryu/lib/dpid.py
index dc9704c..8c8bf75 100644
--- a/ryu/controller/dp_type.py
+++ b/ryu/lib/dpid.py
@@ -1,5 +1,5 @@
 # Copyright (C) 2012 Nippon Telegraph and Telephone Corporation.
-# Copyright (C) 2012 Isaku Yamahata <yamahata at valinux co jp>
+# Copyright (C) 2012 Isaku Yamahata <yamahata at private email ne jp>
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -14,14 +14,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-#
-# datapath type
-# At this moment, this information is not used yet and unknown type is
-# defined as place-holder.
-# switches are categorized by its rolls and openflow controller may want to
-# handle switch differently depending on it role.
-#
-# unknown:
-#
+# Internal representation of datapath id is quad int
+# string representation is in hex without '0x'
+
+_DPID_LEN = 16
+_DPID_FMT = '%0' + str(_DPID_LEN) + 'x'
+
+
+def dpid_to_str(dpid):
+    return _DPID_FMT % dpid
+
 
-UNKNOWN = 'UNKNOWN'
+def str_to_dpid(dpid_str):
+    assert len(dpid_str) == _DPID_LEN
+    return int(dpid_str, 16)
-- 
1.7.1.1


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to