Changeset b9be9b0 in mainline


Ignore:
Timestamp:
2022-03-04T09:11:58Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af259da
Parents:
917324b
git-author:
Jiri Svoboda <jiri@…> (2022-03-03 18:11:14)
git-committer:
Jiri Svoboda <jiri@…> (2022-03-04 09:11:58)
Message:

Fix handling of UDP default destination in udp_assoc_send_msg()

Fixes netecho failing to send any message.

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/netecho/comm.c

    r917324b rb9be9b0  
    5252static udp_t *udp;
    5353static udp_assoc_t *assoc;
    54 static inet_ep_t remote;
    5554
    5655#define RECV_BUF_SIZE 1024
     
    185184errno_t comm_send(void *data, size_t size)
    186185{
    187         errno_t rc = udp_assoc_send_msg(assoc, &remote, data, size);
     186        errno_t rc = udp_assoc_send_msg(assoc, NULL, data, size);
    188187        if (rc != EOK)
    189188                return EIO;
  • uspace/lib/inet/src/udp.c

    r917324b rb9be9b0  
    256256{
    257257        async_exch_t *exch;
     258        inet_ep_t ddest;
    258259
    259260        exch = async_exchange_begin(assoc->udp->sess);
    260261        aid_t req = async_send_1(exch, UDP_ASSOC_SEND_MSG, assoc->id, NULL);
     262
     263        /* If dest is null, use default destination */
     264        if (dest == NULL) {
     265                inet_ep_init(&ddest);
     266                dest = &ddest;
     267        }
    261268
    262269        errno_t rc = async_data_write_start(exch, (void *)dest,
  • uspace/srv/net/udp/assoc.c

    r917324b rb9be9b0  
    243243 *
    244244 * @param assoc         Association
    245  * @param remote        Remote endpoint or NULL not to override @a assoc
     245 * @param remote        Remote endpoint or inet_addr_any/inet_port_any
     246 *                      not to override association's remote endpoint
    246247 * @param msg           Message
    247248 *
     
    261262        /* @a remote can be used to override the remote endpoint */
    262263        epp = assoc->ident;
    263         if (remote != NULL)
     264        if (!inet_addr_is_any(&remote->addr) &&
     265            remote->port != inet_port_any)
    264266                epp.remote = *remote;
    265267
  • uspace/srv/net/udp/test/assoc.c

    r917324b rb9be9b0  
    250250}
    251251
    252 /** Sending message with destination set in association and NULL destination
    253  * argument
     252/** Sending message with destination set in association and inet_addr_any /
     253 * inet_port_any destination argument
    254254 */
    255 PCUT_TEST(send_assoc_null_dest)
    256 {
    257         udp_assoc_t *assoc;
    258         inet_ep2_t epp;
     255PCUT_TEST(send_assoc_any_dest)
     256{
     257        udp_assoc_t *assoc;
     258        inet_ep2_t epp;
     259        inet_ep_t ep;
    259260        errno_t rc;
    260261        udp_msg_t *msg;
     
    272273        epp.local.port = 1;
    273274
     275        inet_ep_init(&ep);
     276
    274277        assoc = udp_assoc_new(&epp, &test_assoc_cb, NULL);
    275278        PCUT_ASSERT_NOT_NULL(assoc);
     
    281284        sent_msg = NULL;
    282285
    283         rc = udp_assoc_send(assoc, NULL, msg);
     286        rc = udp_assoc_send(assoc, &ep, msg);
    284287        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    285288        PCUT_ASSERT_EQUALS(msg, sent_msg);
     
    311314
    312315        inet_ep2_init(&epp);
    313         inet_addr(&epp.remote.addr, 127, 0, 0, 1);
    314         epp.remote.port = 42;
    315316        inet_addr(&epp.local.addr, 127, 0, 0, 1);
    316317        epp.local.port = 1;
Note: See TracChangeset for help on using the changeset viewer.