def parse_opts(buf):
    opts = []
    while buf:
        o = ord(buf[0])
        if o > TCP_OPT_NOP:
            try:
                l = ord(buf[1])
                d, buf = buf[2:l], buf[l:]
            except ValueError:
                #print 'bad option', repr(str(buf))
                opts.append(None) # XXX
                break
        else:
            d, buf = '', buf[1:]
        opts.append((o,d))
    return opts
Parse TCP option buffer into a list of (option, data) tuples.
dataset/ETHPy150Open dragondjf/QMarkdowner/dpkt/tcp.py/parse_opts