2 * Copyright 2019 Intel Corporation
3 * SPDX-License-Identifier: MIT
10 #if defined(__linux__)
16 #include <sys/socket.h>
21 os_socket_listen_abstract(const char *path
, int count
)
23 int s
= socket(AF_UNIX
, SOCK_STREAM
, 0);
27 struct sockaddr_un addr
;
28 memset(&addr
, 0, sizeof(addr
));
29 addr
.sun_family
= AF_UNIX
;
30 strncpy(addr
.sun_path
+ 1, path
, sizeof(addr
.sun_path
) - 2);
32 /* Create an abstract socket */
33 int ret
= bind(s
, (struct sockaddr
*)&addr
,
34 offsetof(struct sockaddr_un
, sun_path
) +
45 os_socket_accept(int s
)
47 return accept(s
, NULL
, NULL
);
51 os_socket_recv(int socket
, void *buffer
, size_t length
, int flags
)
53 return recv(socket
, buffer
, length
, flags
);
57 os_socket_send(int socket
, const void *buffer
, size_t length
, int flags
)
59 return send(socket
, buffer
, length
, flags
);
63 os_socket_block(int s
, bool block
)
65 int old
= fcntl(s
, F_GETFL
, 0);
71 fcntl(s
, F_SETFL
, old
& ~O_NONBLOCK
);
73 fcntl(s
, F_SETFL
, old
| O_NONBLOCK
);
77 os_socket_close(int s
)
85 os_socket_listen_abstract(const char *path
, int count
)
92 os_socket_accept(int s
)
99 os_socket_recv(int socket
, void *buffer
, size_t length
, int flags
)
106 os_socket_send(int socket
, const void *buffer
, size_t length
, int flags
)
113 os_socket_block(int s
, bool block
)
118 os_socket_close(int s
)