Skip to content

Commit

Permalink
Merge bf42afb into f864993
Browse files Browse the repository at this point in the history
  • Loading branch information
faicker committed Jun 13, 2016
2 parents f864993 + bf42afb commit 0decb49
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ryu/lib/packet/tcp.py
Expand Up @@ -20,6 +20,7 @@
from . import packet_base
from . import packet_utils
from ryu.lib import stringify
from ryu.exception import RyuException


LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -127,6 +128,9 @@ def parser(cls, buf):
'Encounter an error during parsing TCP option field.'
'Skip parsing TCP option.')
option = buf[tcp._MIN_LEN:length]
except TCPOption.TCPMalformedOption as e:
LOG.warning(str(e))
option = buf[tcp._MIN_LEN:length]
else:
option = None
msg = cls(src_port, dst_port, seq, ack, offset, bits,
Expand Down Expand Up @@ -179,9 +183,16 @@ class TCPOption(stringify.StringifyMixin):
cls_kind = None
cls_length = None

class TCPMalformedOption(RyuException):
message = '%(msg)s'

def __init__(self, kind=None, length=None):
self.kind = self.cls_kind if kind is None else kind
self.length = self.cls_length if length is None else length
if self.kind > 1 and self.length < 2:
raise TCPOption.TCPMalformedOption(
msg='Malformed TCP option (announced length is %i)'
% self.length)

@classmethod
def register(cls, kind, length):
Expand Down

0 comments on commit 0decb49

Please sign in to comment.