14202651b2
libuvtestcase: TEST_IMPL(udp_connect) { RETURN_SKIP( "IBMi PASE's UDP connection can not be disconnected with AF_UNSPEC."); uv_udp_send_t req; struct sockaddr_in ext_addr; struct sockaddr_in tmp_addr; int r; int addrlen; close_cb_called = 0; cl_send_cb_called = 0; sv_recv_cb_called = 0; ASSERT(0 == uv_ip4_addr("[0.0.0.0](http://0.0.0.0/)", TEST_PORT, &lo_addr)); r = uv_udp_init(uv_default_loop(), &server); ASSERT(r == 0); r = uv_udp_bind(&server, (const struct sockaddr*) &lo_addr, 0); ASSERT(r == 0); r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); ASSERT(r == 0); r = uv_udp_init(uv_default_loop(), &client); ASSERT(r == 0); buf = uv_buf_init("EXIT", 4); /* connect() to INADDR_ANY fails on Windows wih WSAEADDRNOTAVAIL */ ASSERT_EQ(0, uv_ip4_addr("[0.0.0.0](http://0.0.0.0/)", TEST_PORT, &tmp_addr)); r = uv_udp_connect(&client, (const struct sockaddr*) &tmp_addr); ASSERT_EQ(r, UV_EADDRNOTAVAIL); ASSERT_EQ(r, 0); r = uv_udp_connect(&client, NULL); ASSERT_EQ(r, 0); ASSERT(0 == uv_ip4_addr("[8.8.8.8](http://8.8.8.8/)", TEST_PORT, &ext_addr)); ASSERT(0 == uv_ip4_addr("[127.0.0.1](http://127.0.0.1/)", TEST_PORT, &lo_addr)); r = uv_udp_connect(&client, (const struct sockaddr*) &lo_addr); ASSERT(r == 0); r = uv_udp_connect(&client, (const struct sockaddr*) &ext_addr); ASSERT(r == UV_EISCONN); addrlen = sizeof(tmp_addr); r = uv_udp_getpeername(&client, (struct sockaddr*) &tmp_addr, &addrlen); ASSERT(r == 0); /* To send messages in connected UDP sockets addr must be NULL */ r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &lo_addr); ASSERT(r == UV_EISCONN); r = uv_udp_try_send(&client, &buf, 1, NULL); ASSERT(r == 4); r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &ext_addr); ASSERT(r == UV_EISCONN); r = uv_udp_connect(&client, NULL); ASSERT(r == 0); r = uv_udp_connect(&client, NULL); ASSERT(r == UV_ENOTCONN); addrlen = sizeof(tmp_addr); r = uv_udp_getpeername(&client, (struct sockaddr*) &tmp_addr, &addrlen); ASSERT(r == UV_ENOTCONN); /* To send messages in disconnected UDP sockets addr must be set */ r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &lo_addr); ASSERT(r == 4); r = uv_udp_try_send(&client, &buf, 1, NULL); ASSERT(r == UV_EDESTADDRREQ); r = uv_udp_connect(&client, (const struct sockaddr*) &lo_addr); ASSERT(r == 0); r = uv_udp_send(&req, &client, &buf, 1, (const struct sockaddr*) &lo_addr, cl_send_cb); ASSERT(r == UV_EISCONN); r = uv_udp_send(&req, &client, &buf, 1, NULL, cl_send_cb); ASSERT(r == 0); uv_run(uv_default_loop(), UV_RUN_DEFAULT); ASSERT(close_cb_called == 2); ASSERT(sv_recv_cb_called == 4); ASSERT(cl_send_cb_called == 2); ASSERT(client.send_queue_size == 0); ASSERT(server.send_queue_size == 0); MAKE_VALGRIND_HAPPY(); return 0; } Signed-off-by: wangchen <wangchen41@xiaomi.com> |
||
---|---|---|
.. | ||
arp | ||
bluetooth | ||
can | ||
devif | ||
icmp | ||
icmpv6 | ||
ieee802154 | ||
igmp | ||
inet | ||
ipforward | ||
ipfrag | ||
local | ||
mld | ||
nat | ||
neighbor | ||
netdev | ||
netfilter | ||
netlink | ||
pkt | ||
procfs | ||
route | ||
rpmsg | ||
sixlowpan | ||
socket | ||
tcp | ||
udp | ||
usrsock | ||
utils | ||
CMakeLists.txt | ||
Kconfig | ||
Makefile | ||
net_initialize.c | ||
README.txt |
README ====== Directory Structure =================== nuttx/ | `- net/ | +- arp - Address resolution protocol (IPv4) +- bluetooth - PF_BLUETOOTH socket interface +- devif - Stack/device interface layer +- ipfrag - Fragmentation and reassembly +- icmp - Internet Control Message Protocol (IPv4) +- icmpv6 - Internet Control Message Protocol (IPv6) +- ieee802154 - PF_IEEE802154 socket interface +- inet - PF_INET/PF_INET6 socket interface +- ipforward - IP forwarding logic +- local - Unix domain (local) sockets +- mld - Multicast Listener Discovery (MLD) +- neighbor - Neighbor Discovery Protocol (IPv6) +- netdev - Socket network device interface +- netlink - Netlink IPC socket interface +- pkt - "Raw" packet socket support +- sixlowpan - 6LoWPAN implementation +- socket - BSD socket interface +- route - Routing table support +- tcp - Transmission Control Protocol +- udp - User Datagram Protocol +- usrsock - User socket API for user-space networking stack `- utils - Miscellaneous utility functions +-------------------------------------------------------------------++------------------------+ | Application layer || usrsock daemon | +-------------------------------------------------------------------++------------------------+ +-------------------------------------------------------------------++----------------+ +-----+ | Socket layer (socket/) || /dev/usrsock | | | +-------------------------------------------------------------------++----------------+ | | +------------++--------------------------------------------------++-------------------+ | | | Network || Protocol stacks (arp, ipv6, icmp, pkt, tcp, udp) || usrsock/ | | | | Device |+--------------------------------------------------++-------------------+ | | | Interface |+------------------------------------++---------------------------------+ | | | (netdev/) || Network Device Interface (devif/) || Utilities | | | +------------++------------------------------------++---------------------------------+ | | +----------------------------------------------------------------+ | | | Network Device Drivers | | HAL | +----------------------------------------------------------------+ +-----+ +----------------------------------------------------------------+ +--------------------------+ | Networking Hardware | | Hardware TCP/IP Stack | +----------------------------------------------------------------+ +--------------------------+