From f57a550e397e6c6e1928eefc6217b1b83660dbaa Mon Sep 17 00:00:00 2001 From: "watanabe.fumitaka" Date: Wed, 31 Jul 2013 19:42:37 +0900 Subject: link to LLC sub layer Signed-off-by: WATANABE Fumitaka Signed-off-by: FUJITA Tomonori --- ryu/lib/packet/ethernet.py | 12 ++++++++++++ ryu/lib/packet/vlan.py | 14 ++++++++++++++ ryu/ofproto/ether.py | 1 + 3 files changed, 27 insertions(+) diff --git a/ryu/lib/packet/ethernet.py b/ryu/lib/packet/ethernet.py index 3db0e163..83cc1d63 100644 --- a/ryu/lib/packet/ethernet.py +++ b/ryu/lib/packet/ethernet.py @@ -54,6 +54,18 @@ class ethernet(packet_base.PacketBase): return struct.pack(ethernet._PACK_STR, self.dst, self.src, self.ethertype) + @classmethod + def get_packet_type(cls, type_): + """Override method for the ethernet IEEE802.3 Length/Type + field (self.ethertype). + + If the value of Length/Type field is less than or equal to + 1500 decimal(05DC hexadecimal), it means Length interpretation + and be passed to the LLC sublayer.""" + if type_ <= ether.ETH_TYPE_IEEE802_3: + type_ = ether.ETH_TYPE_IEEE802_3 + return cls._TYPES.get(type_) + # copy vlan _TYPES ethernet._TYPES = vlan.vlan._TYPES diff --git a/ryu/lib/packet/vlan.py b/ryu/lib/packet/vlan.py index cbd63968..477b8eef 100644 --- a/ryu/lib/packet/vlan.py +++ b/ryu/lib/packet/vlan.py @@ -20,6 +20,7 @@ from . import ipv4 from . import ipv6 from . import lldp from . import slow +from . import llc from ryu.ofproto import ether from ryu.ofproto.ofproto_parser import msg_pack_into @@ -51,6 +52,18 @@ class vlan(packet_base.PacketBase): self.vid = vid self.ethertype = ethertype + @classmethod + def get_packet_type(cls, type_): + """Override method for the Length/Type field (self.ethertype). + The Length/Type field means Length or Type interpretation, + same as ethernet IEEE802.3. + If the value of Length/Type field is less than or equal to + 1500 decimal(05DC hexadecimal), it means Length interpretation + and be passed to the LLC sublayer.""" + if type_ <= ether.ETH_TYPE_IEEE802_3: + type_ = ether.ETH_TYPE_IEEE802_3 + return cls._TYPES.get(type_) + @classmethod def parser(cls, buf): tci, ethertype = struct.unpack_from(cls._PACK_STR, buf) @@ -69,3 +82,4 @@ vlan.register_packet_type(ipv4.ipv4, ether.ETH_TYPE_IP) vlan.register_packet_type(ipv6.ipv6, ether.ETH_TYPE_IPV6) vlan.register_packet_type(lldp.lldp, ether.ETH_TYPE_LLDP) vlan.register_packet_type(slow.slow, ether.ETH_TYPE_SLOW) +vlan.register_packet_type(llc.llc, ether.ETH_TYPE_IEEE802_3) diff --git a/ryu/ofproto/ether.py b/ryu/ofproto/ether.py index a4f55255..f4883a39 100644 --- a/ryu/ofproto/ether.py +++ b/ryu/ofproto/ether.py @@ -21,3 +21,4 @@ ETH_TYPE_IPV6 = 0x86dd ETH_TYPE_MPLS = 0x8847 ETH_TYPE_SLOW = 0x8809 ETH_TYPE_LLDP = 0x88cc +ETH_TYPE_IEEE802_3 = 0x05dc -- cgit v1.2.3