Changeset 2f19103 in mainline for uspace/srv/net/udp/pdu.c


Ignore:
Timestamp:
2015-05-22T07:21:37Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
58e9dec
Parents:
bf7587b0
Message:

TCP and UDP servers can make use of inet/endpoint.h types internally.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/udp/pdu.c

    rbf7587b0 r2f19103  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2015 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    162162
    163163/** Decode incoming PDU */
    164 int udp_pdu_decode(udp_pdu_t *pdu, udp_sockpair_t *sp, udp_msg_t **msg)
     164int udp_pdu_decode(udp_pdu_t *pdu, inet_ep2_t *epp, udp_msg_t **msg)
    165165{
    166166        udp_msg_t *nmsg;
     
    179179        hdr = (udp_header_t *)pdu->data;
    180180
    181         sp->foreign.port = uint16_t_be2host(hdr->src_port);
    182         sp->foreign.addr = pdu->src;
    183         sp->local.port = uint16_t_be2host(hdr->dest_port);
    184         sp->local.addr = pdu->dest;
     181        epp->remote.port = uint16_t_be2host(hdr->src_port);
     182        epp->remote.addr = pdu->src;
     183        epp->local.port = uint16_t_be2host(hdr->dest_port);
     184        epp->local.addr = pdu->dest;
    185185
    186186        length = uint16_t_be2host(hdr->length);
     
    208208
    209209/** Encode outgoing PDU */
    210 int udp_pdu_encode(udp_sockpair_t *sp, udp_msg_t *msg, udp_pdu_t **pdu)
     210int udp_pdu_encode(inet_ep2_t *epp, udp_msg_t *msg, udp_pdu_t **pdu)
    211211{
    212212        udp_pdu_t *npdu;
     
    218218                return ENOMEM;
    219219
    220         npdu->iplink = sp->iplink;
    221         npdu->src = sp->local.addr;
    222         npdu->dest = sp->foreign.addr;
     220        npdu->iplink = epp->local_link;
     221        npdu->src = epp->local.addr;
     222        npdu->dest = epp->remote.addr;
    223223
    224224        npdu->data_size = sizeof(udp_header_t) + msg->data_size;
     
    230230
    231231        hdr = (udp_header_t *)npdu->data;
    232         hdr->src_port = host2uint16_t_be(sp->local.port);
    233         hdr->dest_port = host2uint16_t_be(sp->foreign.port);
     232        hdr->src_port = host2uint16_t_be(epp->local.port);
     233        hdr->dest_port = host2uint16_t_be(epp->remote.port);
    234234        hdr->length = host2uint16_t_be(npdu->data_size);
    235235        hdr->checksum = 0;
Note: See TracChangeset for help on using the changeset viewer.