def createProtocolMessages( data, flags=const.FLAG_PAYLOAD ):
    """
    Create protocol messages out of the given payload.

    The given `data' is turned into a list of protocol messages with the given
    `flags' set.  The list is then returned.  If possible, all messages fill
    the MTU.
    """

    messages = []

    while len(data) > const.MPU:
        messages.append(ProtocolMessage(data[:const.MPU], flags=flags))
        data = data[const.MPU:]

    messages.append(ProtocolMessage(data, flags=flags))

    log.debug("Created %d protocol messages." % len(messages))

    return messages
dataset/ETHPy150Open isislovecruft/obfsproxy/obfsproxy/transports/scramblesuit/message.py/createProtocolMessages/original