def parse_opts(buf):
    """Parse TCP option buffer into a list of (option, data) tuples."""
    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 __HOLE__:
                #print 'bad option', repr(str(buf))
                opts.append(None) # XXX
                break
        else:
            d, buf = '', buf[1:]
        opts.append((o,d))
    return opts
dataset/ETHPy150Open dragondjf/QMarkdowner/dpkt/tcp.py/parse_opts