summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ryu/app/simple_switch.py15
-rw-r--r--ryu/app/simple_switch_12.py14
-rw-r--r--ryu/app/simple_switch_13.py12
-rw-r--r--ryu/app/simple_switch_14.py11
4 files changed, 16 insertions, 36 deletions
diff --git a/ryu/app/simple_switch.py b/ryu/app/simple_switch.py
index a443fa49..862b8303 100644
--- a/ryu/app/simple_switch.py
+++ b/ryu/app/simple_switch.py
@@ -17,11 +17,8 @@
An OpenFlow 1.0 L2 learning switch implementation.
"""
-import logging
-import struct
from ryu.base import app_manager
-from ryu.controller import mac_to_port
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
@@ -29,7 +26,7 @@ from ryu.ofproto import ofproto_v1_0
from ryu.lib.mac import haddr_to_bin
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
-from ryu.topology.switches import LLDPPacket
+from ryu.lib.packet import ether_types
class SimpleSwitch(app_manager.RyuApp):
@@ -55,19 +52,15 @@ class SimpleSwitch(app_manager.RyuApp):
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
-
- try:
- # ignore lldp packet
- LLDPPacket.lldp_parse(msg.data)
- return
- except LLDPPacket.LLDPUnknownFormat:
- pass
datapath = msg.datapath
ofproto = datapath.ofproto
pkt = packet.Packet(msg.data)
eth = pkt.get_protocol(ethernet.ethernet)
+ if eth.ethertype == ether_types.ETH_TYPE_LLDP:
+ # ignore lldp packet
+ return
dst = eth.dst
src = eth.src
diff --git a/ryu/app/simple_switch_12.py b/ryu/app/simple_switch_12.py
index ee53d9e0..6895b074 100644
--- a/ryu/app/simple_switch_12.py
+++ b/ryu/app/simple_switch_12.py
@@ -13,9 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import logging
-import struct
-
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
@@ -23,7 +20,7 @@ from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_2
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
-from ryu.topology.switches import LLDPPacket
+from ryu.lib.packet import ether_types
class SimpleSwitch12(app_manager.RyuApp):
@@ -53,12 +50,6 @@ class SimpleSwitch12(app_manager.RyuApp):
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
- try:
- # ignore lldp packet
- LLDPPacket.lldp_parse(msg.data)
- return
- except LLDPPacket.LLDPUnknownFormat:
- pass
datapath = msg.datapath
ofproto = datapath.ofproto
in_port = msg.match['in_port']
@@ -66,6 +57,9 @@ class SimpleSwitch12(app_manager.RyuApp):
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
+ if eth.ethertype == ether_types.ETH_TYPE_LLDP:
+ # ignore lldp packet
+ return
dst = eth.dst
src = eth.src
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index e224958f..3e7c598c 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -20,7 +20,7 @@ from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
-from ryu.topology.switches import LLDPPacket
+from ryu.lib.packet import ether_types
class SimpleSwitch13(app_manager.RyuApp):
@@ -71,13 +71,6 @@ class SimpleSwitch13(app_manager.RyuApp):
self.logger.debug("packet truncated: only %s of %s bytes",
ev.msg.msg_len, ev.msg.total_len)
msg = ev.msg
-
- try:
- # ignore lldp packet
- LLDPPacket.lldp_parse(msg.data)
- return
- except LLDPPacket.LLDPUnknownFormat:
- pass
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
@@ -86,6 +79,9 @@ class SimpleSwitch13(app_manager.RyuApp):
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
+ if eth.ethertype == ether_types.ETH_TYPE_LLDP:
+ # ignore lldp packet
+ return
dst = eth.dst
src = eth.src
diff --git a/ryu/app/simple_switch_14.py b/ryu/app/simple_switch_14.py
index 4cf66a8c..d3151bc0 100644
--- a/ryu/app/simple_switch_14.py
+++ b/ryu/app/simple_switch_14.py
@@ -20,7 +20,7 @@ from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_4
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
-from ryu.topology.switches import LLDPPacket
+from ryu.lib.packet import ether_types
class SimpleSwitch14(app_manager.RyuApp):
@@ -62,12 +62,6 @@ class SimpleSwitch14(app_manager.RyuApp):
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
- try:
- # ignore lldp packet
- LLDPPacket.lldp_parse(msg.data)
- return
- except LLDPPacket.LLDPUnknownFormat:
- pass
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
@@ -76,6 +70,9 @@ class SimpleSwitch14(app_manager.RyuApp):
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
+ if eth.ethertype == ether_types.ETH_TYPE_LLDP:
+ # ignore lldp packet
+ return
dst = eth.dst
src = eth.src