Signed-off-by: ISHIDA Wataru <[email protected]>
---
ryu/app/bmpstation.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 ryu/app/bmpstation.py
diff --git a/ryu/app/bmpstation.py b/ryu/app/bmpstation.py
new file mode 100644
index 0000000..e90abc1
--- /dev/null
+++ b/ryu/app/bmpstation.py
@@ -0,0 +1,48 @@
+import socket
+import logging
+logging.basicConfig(level=logging.DEBUG)
+
+from ryu.base import app_manager
+
+from ryu.lib import hub
+from ryu.lib.hub import StreamServer
+from ryu.lib.packet.bmp import *
+
+SERVER_HOST = '0.0.0.0'
+SERVER_PORT = 11019
+
+
+class BMPStation(app_manager.RyuApp):
+ def __init__(self):
+ super(BMPStation, self).__init__()
+ self.name = 'bmpstation'
+
+ def start(self):
+ super(BMPStation, self).start()
+
+ return hub.spawn(StreamServer((SERVER_HOST, SERVER_PORT),
+ self.loop).serve_forever)
+
+ def loop(self, sock, addr):
+ logging.debug("started bmp loop.")
+ self.is_active = True
+
+ buf = bytearray()
+ required_len = BMPMessage._HDR_LEN
+
+ while self.is_active:
+ buf = sock.recv(BMPMessage._HDR_LEN)
+ if len(buf) == 0:
+ self.is_active = False
+ break
+
+ _, len_, _ = BMPMessage.parse_header(buf)
+
+ body = sock.recv(len_ - BMPMessage._HDR_LEN)
+ if len(body) == 0:
+ self.is_active = False
+ break
+
+ msg, rest = BMPMessage.parser(buf + body)
+ assert len(rest) == 0
+ print msg, '\n'
--
1.7.10.4
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel