Commit Graph

186 Commits

Author SHA1 Message Date
Xiang Xiao 4d2794250f net/local: Support the abstract path
https://man7.org/linux/man-pages/man7/unix.7.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-18 20:12:30 +02:00
Xiang Xiao 6b36ba0b6e net/local: Remove LOCAL_TYPE_UNTYPED
let's represent the unbound local socket as LOCAL_TYPE_UNNAMED

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-18 20:12:30 +02:00
Xiang Xiao aea8f8175a net/local: Return -EINVAL if the address length passed to local_bind is too small
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-18 20:12:30 +02:00
ligd 139663ba89 local: add net_lock to local_listen
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-28 16:36:39 +08:00
wangbowen6 c37d90c194 net/local: support FIONWRITE for domain socket ioctl
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-11-24 19:47:08 +08:00
dongjiuzhu1 ccf0c3566e net/local: support cmd SO_PEERCRED
the credentials of the peer process connected to this socket.
refs:https://man7.org/linux/man-pages/man7/unix.7.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 15:01:54 +08:00
anjiahao 5724c6b2e4 sem:remove sem default protocl
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
anjiahao d1d46335df Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
chao an 8e146590a9 net/local: unified formatting name function
fix build warning on GCC 12.2.0

In file included from local/local_fifo.c:25:
In function 'local_hd_name',
    inlined from 'local_open_receiver' at local/local_fifo.c:593:3:
local/local_fifo.c:128:12: warning: '%s' directive output may be truncated writing up to 107 bytes into a region of size 97 [-Wformat-truncation=]
  128 |            CONFIG_NET_LOCAL_VFS_PATH "/%s" LOCAL_HD_SUFFIX, inpath);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~
local/local_fifo.c: In function 'local_open_receiver':
local/local_fifo.c:128:40: note: format string is defined here
  128 |            CONFIG_NET_LOCAL_VFS_PATH "/%s" LOCAL_HD_SUFFIX, inpath);
      |                                        ^~
In function 'local_hd_name',
    inlined from 'local_open_receiver' at local/local_fifo.c:593:3:
local/local_fifo.c:127:3: note: 'snprintf' output between 15 and 122 bytes into a destination of size 109
  127 |   snprintf(outpath, LOCAL_FULLPATH_LEN - 1,
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  128 |            CONFIG_NET_LOCAL_VFS_PATH "/%s" LOCAL_HD_SUFFIX, inpath);
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-11 00:53:57 +08:00
Xiang Xiao bdeaea3742 Remove the unnessary empty line after label
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-30 17:54:56 +02:00
chao an aa42f29465 net/local: remove dead code
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-27 21:31:48 +08:00
Xiang Xiao 40ef5bc6db libc: Move queue.h from include to include/nuttx
to avoid the conflict with libuv's queue.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-26 08:04:58 +02:00
wangbowen6 344c8be049 poll: add poll_notify() api and call it in all drivers
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-09-26 12:06:32 +08:00
Xiang Xiao e0bb281e7a net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 22:46:37 +08:00
Huang Qi e4e3208180 Replace all strncpy with strlcpy for safety
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-08-25 13:38:36 +08:00
Xiang Xiao 838690fc9f net/local: Remove the sync preamble from datagram
since pipe is a reliable transport, the sync just waste the space and time

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-10 09:50:25 +03:00
田昕 20b9cc37d5 net/local:Make local send multi-thread safe
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-08-08 22:45:44 +08:00
ligd 5b9a953381 local: fix nx_style
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd 390de249a0 local: connect operation should jump self's connection
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd cd5ab80f2f local: server accept should wait client connect done
server:
at accept last nxsem_post(&client->lc_waitsem);

client:
connect wait(&client->lc_waitsem) then local_open_client_rx();

But if the server priority is higher then client,
and after server accept return, immediately call send().
At this time the client has no way do local_open_client_rx().
Then server send() return error.

Fix:
add lc_done sem to client

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd e489a308c8 local_socket: remove error log when use nonblock mode
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
Jiuzhu Dong d87cf8d4ca fs/poll: change format for type pollevent_t
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-07 12:14:06 +08:00
Xiang Xiao e4b73d90d7 net/local: change 255 to UINT8_MAX
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-01 23:14:15 +08:00
zhanghu6 fb912da252 local socket: cancel assert about backlog exceed 255
Signed-off-by: zhanghu6 <zhanghu6@xiaomi.com>
2022-04-01 23:14:15 +08:00
ligd ad9ba8f454 local_socket: default set block mode if accept() a new socket
reference:
https: //man7.org/linux/man-pages/man2/accept.2.html

1. default set block mode if accept() a new socket
2. local_socket support FIONBIO

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-28 23:26:34 +08:00
chao.an b0d553a068 net/local: correct the socket flags from client socket
socket flags from connect() should used from client

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-17 23:15:40 +08:00
chao.an 40f056e92c net/local: correct the socket flags from server socket
newsock = accept(server, &addr, &addrlen);

replace the socket flags from newsock to server to ensure that
the nonblock flags is handled correctly

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-15 23:04:59 +09:00
Xiang Xiao 716e27cbeb net/local: Remove local_initialize
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-12 19:24:17 +02:00
Xiang Xiao 4a16cf71f9 Fix -Werror=nonnull-compare and -Werror=format-truncation=
Error: module/mod_insmod.c:203:3: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
  203 |   strncpy(modp->modname, modname, MODLIB_NAMEMAX);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

wqueue/kwork_thread.c: In function 'work_start_lowpri':
Error: wqueue/kwork_thread.c:212:22: error: '%lx' directive output may be truncated writing between 1 and 16 bytes into a region of size 14 [-Werror=format-truncation=]
  212 |   snprintf(args, 16, "0x%" PRIxPTR, (uintptr_t)wqueue);

local/local_sockif.c: In function 'local_getsockname':
Error: local/local_sockif.c:392:11: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  392 |           strncpy(unaddr->sun_path, conn->lc_path, namelen);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

chip/esp32_wifi_utils.c: In function 'esp_wifi_scan_event_parse':
Error: chip/esp32_wifi_utils.c:373:37: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
   memset(ap_list_buffer, 0x0, sizeof(ap_list_buffer));
                                     ^

stdio/lib_fputs.c: In function 'fputs':
Error: stdio/lib_fputs.c:99:9: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
         ^
Error: stdio/lib_fputs.c:99:27: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
                           ^

stdio/lib_vfprintf.c: In function 'vfprintf':
Error: stdio/lib_vfprintf.c:40:6: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (stream)
      ^

string/lib_strdup.c: In function 'strdup':
Error: string/lib_strdup.c:39:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strndup.c: In function 'strndup':
Error: string/lib_strndup.c:56:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strpbrk.c: In function 'strpbrk':
Error: string/lib_strpbrk.c:39:7: error: nonnull argument 'str' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
       ^~~~
Error: string/lib_strpbrk.c:39:15: error: nonnull argument 'charset' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
               ^~~~~~~~

string/lib_strrchr.c: In function 'strrchr':
Error: string/lib_strrchr.c:40:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

Error: time/lib_asctimer.c:73:50: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 12 [-Werror=format-truncation=]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                                                  ^~
time/lib_asctimer.c:73:21: note: directive argument in the range [-2147481748, 2147483647]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
time/lib_asctimer.c:73:3: note: 'snprintf' output between 17 and 68 bytes into a destination of size 26
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            g_wday_name[tp->tm_wday], g_mon_name[tp->tm_mon],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            1900 + tp->tm_year);
            ~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-02 15:55:38 +08:00
chao.an 99cde13a11 net/inet: move socket flags into socket_conn_s
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an af1cf5eaae net/local: replace the common connect prologue
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an 3d62d5106d net/local: remove duplicate assert condition
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
Xiang Xiao 108a5004c5 net/local: Rename NET_LOCAL_PATH_PREFIX to NET_LOCAL_VFS_PATH
align with other similiar config which suffix with _VFS_PATH

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-06 19:42:00 +01:00
Juha Niskanen 422ceec99b Fix typos in comments and Kconfig files
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2021-12-21 03:26:16 -06:00
ligd 68bbcf74c4 local_socket: filename use "/var/socket/xx" instead of "/var/socketxx"
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 02:37:11 -06:00
ligd 391ccdc42b local_socket: recv should return 0 NOT -ECONNRESET if remote closed
ref:
https://man7.org/linux/man-pages/man2/recv.2.html

Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-02 08:59:06 +01:00
ligd 1970ce5116 local_socket: set lc_peer when accept() instead of connect()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-02 08:59:06 +01:00
chao.an 1b5d6aa068 net/local: add socket message control support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an ea82a0b638 net/local: add local_peerconn helper
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an 1e078795fb net/local: split the waiter node from lc_node
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an 1ba922a826 net/local: replace the listener list to global
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an b991b75e87 net/local: add FIONSPACE support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-15 12:11:32 +08:00
buyuer 001eb7786b net/local: Return the partial write size.
Signed-off-by: buyuer <dingddding@163.com>
2021-08-26 13:28:11 +08:00
chao.an efaf72a1b1 net/local: correct the return length of sendmsg
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-21 14:59:59 +08:00
chao.an 1a55d933ef net/local: add nonblock connect(2) support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 19:18:52 -07:00
SPRESENSE d17d877764 net/local: Fix receive data size calculation for local_recvmsg
In psock_dgram_recvfrom function, fix code logic.
2021-08-19 01:31:05 -07:00
chao.an a48513ad65 local/stream: remove preamble header in stream mode
Preable sync header is no necessary in stream mode

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-21 23:43:10 -07:00
chao.an cc5c7ee088 net/local: remove unused client lc_remaining
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-21 23:43:10 -07:00
chao.an 1dbe8de750 net/local: add AF_[UNIX|LOCAL] socketpair support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -05:00
chao.an 9f3f4fb558 net/local: extern local_generate_instance_id() interface
Change-Id: I14273d11b1fe4d6bdc15b14e32da609cc7883713
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -05:00