<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pack_multiple(messages):
 """ Converts a list of SMB2CreateEABuffer structures and packs them as a bytes object used when setting to the SMB2CreateContextRequest buffer_data field. This should be used as it would calculate the correct next_entry_offset field value for each buffer entry. :param messages: List of SMB2CreateEABuffer structures :return: bytes object that is set on the SMB2CreateContextRequest buffer_data field. """

        data = b""
        msg_count = len(messages)
        for i, msg in enumerate(messages):
            if i == msg_count - 1:
                msg['next_entry_offset'] = 0
            else:
                # because the end padding val won't be populated if the entry
                # offset is 0, we set to 1 so the len calc is correct
                msg['next_entry_offset'] = 1
                msg['next_entry_offset'] = len(msg)
            data += msg.pack()

        return data