nuttx/net/local
wangchen d528d2c410 net/local/local_sockif.c:add local_getpeername function implementation
this testcast
TEST_IMPL(udp_send_unix) {
  /* Test that "uv_udp_send()" supports sending over
     a "sockaddr_un" address. */
  struct sockaddr_un addr;
  uv_udp_t handle;
  uv_udp_send_t req;
  uv_loop_t* loop;
  uv_buf_t buf = uv_buf_init("PING", 4);
  int fd;
  int r;

  loop = uv_default_loop();

  memset(&addr, 0, sizeof addr);
  addr.sun_family = AF_UNIX;
  ASSERT(strlen(TEST_PIPENAME) < sizeof(addr.sun_path));
  memcpy(addr.sun_path, TEST_PIPENAME, strlen(TEST_PIPENAME));

  fd = socket(AF_UNIX, SOCK_STREAM, 0);
  ASSERT(fd >= 0);

  unlink(TEST_PIPENAME);
  ASSERT(0 == bind(fd, (const struct sockaddr*)&addr, sizeof addr));
  ASSERT(0 == listen(fd, 1));

  r = uv_udp_init(loop, &handle);
  ASSERT(r == 0);
  r = uv_udp_open(&handle, fd);
  ASSERT(r == 0);
  uv_run(loop, UV_RUN_DEFAULT);

  r = uv_udp_send(&req,
                  &handle,
                  &buf,
                  1,
                  (const struct sockaddr*) &addr,
                  NULL);
  ASSERT(r == 0);

  uv_close((uv_handle_t*)&handle, NULL);
  uv_run(loop, UV_RUN_DEFAULT);
  close(fd);
  unlink(TEST_PIPENAME);

  MAKE_VALGRIND_HAPPY();
  return 0;
}

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2023-08-03 03:23:17 -07:00
..
CMakeLists.txt build: add initial cmake build system 2023-07-08 13:50:48 +08:00
Kconfig net/local: rename NET_LOCAL_VFS_PATH to follow linux 2023-01-04 20:50:38 +08:00
local_accept.c net/local/local_sockif.c:add local_getpeername function implementation 2023-08-03 03:23:17 -07:00
local_bind.c net: remove conn-related casts 2023-05-10 19:32:09 -03:00
local_conn.c net/local/local_sockif.c:add local_getpeername function implementation 2023-08-03 03:23:17 -07:00
local_connect.c net: remove conn-related casts 2023-05-10 19:32:09 -03:00
local_fifo.c net/local: Support the socketpair interface of local udp socket. 2023-07-12 03:31:43 +08:00
local_listen.c net/local: Support the abstract path to connect 2023-07-14 09:57:24 +08:00
local_netpoll.c net/local: Support the abstract path to connect 2023-07-14 09:57:24 +08:00
local_recvmsg.c net/local:Add support for MSG_DONTWAIT to SOCK_STREAM 2023-08-01 22:55:40 -07:00
local_recvutils.c net/local: Return -EINVAL if the address length passed to local_bind is too small 2022-12-18 20:12:30 +02:00
local_release.c net/local: remove client from server.lc_waiters when client close 2023-07-17 09:01:36 +02:00
local_sendmsg.c net/local: Support the socketpair interface of local udp socket. 2023-07-12 03:31:43 +08:00
local_sendpacket.c net/local: Remove the sync preamble from datagram 2022-08-10 09:50:25 +03:00
local_sockif.c net/local/local_sockif.c:add local_getpeername function implementation 2023-08-03 03:23:17 -07:00
local.h net/local/local_sockif.c:add local_getpeername function implementation 2023-08-03 03:23:17 -07:00
Make.defs