Changeset 1812a0d in mainline for uspace/srv/net/tl/tcp/header.c


Ignore:
Timestamp:
2011-11-23T19:06:15Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
762b48a
Parents:
6896409c
Message:

Hook TCP into network stack IP layer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/tcp/header.c

    r6896409c r1812a0d  
    164164}
    165165
     166/** Create PDU with the specified header and text data.
     167 *
     168 * Note that you still need to set addresses in the returned PDU.
     169 *
     170 * @param hdr           Header data
     171 * @param hdr_size      Header size in bytes
     172 * @param text          Text data
     173 * @param text_size     Text size in bytes
     174 * @return              New PDU
     175 */
     176tcp_pdu_t *tcp_pdu_create(void *hdr, size_t hdr_size, void *text,
     177    size_t text_size)
     178{
     179        tcp_pdu_t *pdu;
     180
     181        pdu = tcp_pdu_new();
     182        if (pdu == NULL)
     183                return NULL;
     184
     185        pdu->header = malloc(hdr_size);
     186        pdu->text = malloc(text_size);
     187        if (pdu->header == NULL || pdu->text == NULL)
     188                goto error;
     189
     190        memcpy(pdu->header, hdr, hdr_size);
     191        memcpy(pdu->text, text, text_size);
     192
     193        pdu->header_size = hdr_size;
     194        pdu->text_size = text_size;
     195
     196        return pdu;
     197
     198error:
     199        if (pdu->header != NULL)
     200                free(pdu->header);
     201        if (pdu->text != NULL)
     202                free(pdu->text);
     203
     204        return NULL;
     205}
     206
    166207void tcp_pdu_delete(tcp_pdu_t *pdu)
    167208{
     209        free(pdu->header);
    168210        free(pdu->text);
    169211        free(pdu);
Note: See TracChangeset for help on using the changeset viewer.