Probleme bei TCP (Arduino Taiji-Uino)

Schönen guten Tag,

ich habe ein kleines Problem bei meinem Projekt. Ich habe einen Arduino Taiji-Uino und verwende die vorgegebenen Dateien von dieser Seite: GitHub - elechouse/EMAC-DEMO: EMAC demo for TAIJIUINO Due Pro R2.
Dieses wurde bereits mit UDP erweitert und jetzt soll noch TCP hinzukommen.

Die entsprechenden Header empfange ich und kann diese auch auswerten. Wenn ich dann z.B. ein SYN bekomme um eine Verbindung aufzubauen, werte ich den Header aus, erstelle dann meinen SYN-ACK Header um den Verbindungsaufbau zu bestätigen und muss diesen dann zurückschicken. Nur da liegt leider das Problem... Es gibt bereits eine Funktion doch ich weiß leider nicht wie ich diese verwenden soll.

Hier mal die Funktion:

/**
* \brief Send ulLength bytes from pcFrom. This copies the buffer to one of the
* EMAC Tx buffers, and then indicates to the EMAC that the buffer is ready.
* If lEndOfFrame is true then the data being copied is the end of the frame
* and the frame can be transmitted.
*
* \param p_emac_dev Pointer to the EMAC device instance.
* \param p_buffer Pointer to the data buffer.
* \param ul_size Length of the frame.
* \param func_tx_cb Transmit callback function.
*
* \return Length sent.
*/
uint32_t emac_dev_write(emac_device_t* p_emac_dev, void* p_buffer,
uint32_t ul_size, emac_dev_tx_cb_t func_tx_cb)
{

    volatile emac_tx_descriptor_t *p_tx_td;
    volatile emac_dev_tx_cb_t *p_func_tx_cb;

    Emac *p_hw = p_emac_dev->p_hw;


    /* Check parameter */
    if (ul_size > EMAC_TX_UNITSIZE) {
        return EMAC_PARAM;
    }

    /* Pointers to the current transmit descriptor */
    p_tx_td = &p_emac_dev->p_tx_dscr[p_emac_dev->us_tx_head];

    /* If no free TxTd, buffer can't be sent, schedule the wakeup callback */
    if (CIRC_SPACE(p_emac_dev->us_tx_head, p_emac_dev->us_tx_tail,
    p_emac_dev->us_tx_list_size) == 0) {
        return EMAC_TX_BUSY;
    }

    /* Pointers to the current Tx callback */
    p_func_tx_cb = &p_emac_dev->func_tx_cb_list[p_emac_dev->us_tx_head];

    /* Set up/copy data to transmission buffer */
    if (p_buffer && ul_size) {
        /* Driver manages the ring buffer */
        memcpy((void *)p_tx_td->addr, p_buffer, ul_size);
    }

    /* Tx callback */
    *p_func_tx_cb = func_tx_cb;

    /* Update transmit descriptor status */

    /* The buffer size defined is the length of ethernet frame,
    so it's always the last buffer of the frame. */
    if (p_emac_dev->us_tx_head == p_emac_dev->us_tx_list_size - 1) {
        p_tx_td->status.val =
        (ul_size & EMAC_TXD_LEN_MASK) | EMAC_TXD_LAST
        | EMAC_TXD_WRAP;
    } else {
        p_tx_td->status.val =
        (ul_size & EMAC_TXD_LEN_MASK) | EMAC_TXD_LAST;
    }

    circ_inc(&p_emac_dev->us_tx_head, p_emac_dev->us_tx_list_size);

    /* Now start to transmit if it is still not done */
    emac_start_transmission(p_hw);

    return EMAC_OK;
}

Und hier der Aufruf:

ul_rc = emac_dev_write(&gs_emac_dev, p_uc_data, SWAP16(p_ip_header->ip_len) + 14, NULL);

Noch zu erwähnen ist, dass mein Header, den ich erstelle in einem uint32_t Array steht.

Vielleicht kennt jemand das Problem oder hat eine Lösung und könnte mir helfen.

Mfg KK