-
Notifications
You must be signed in to change notification settings - Fork 8.2k
posix: Add headers related to BSD Sockets API #17346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
jukkar
wants to merge
1
commit into
zephyrproject-rtos:master
from
jukkar:pfalcon-posix-socket-headers
+166
−0
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright (c) 2019 Linaro Limited | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #ifndef ZEPHYR_INCLUDE_POSIX_ARPA_INET_H_ | ||
| #define ZEPHYR_INCLUDE_POSIX_ARPA_INET_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #include <net/socket.h> | ||
|
|
||
| static inline char *inet_ntop(sa_family_t family, const void *src, char *dst, | ||
| size_t size) | ||
| { | ||
| return zsock_inet_ntop(family, src, dst, size); | ||
| } | ||
|
|
||
| static inline int inet_pton(sa_family_t family, const char *src, void *dst) | ||
| { | ||
| return zsock_inet_pton(family, src, dst); | ||
| } | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* ZEPHYR_INCLUDE_POSIX_ARPA_INET_H_ */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Copyright (c) 2019 Linaro Limited | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #ifndef ZEPHYR_INCLUDE_POSIX_NETDB_H_ | ||
| #define ZEPHYR_INCLUDE_POSIX_NETDB_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #include <net/socket.h> | ||
|
|
||
| #define addrinfo zsock_addrinfo | ||
|
|
||
| static inline int getaddrinfo(const char *host, const char *service, | ||
| const struct zsock_addrinfo *hints, | ||
| struct zsock_addrinfo **res) | ||
| { | ||
| return zsock_getaddrinfo(host, service, hints, res); | ||
| } | ||
|
|
||
| static inline void freeaddrinfo(struct zsock_addrinfo *ai) | ||
| { | ||
| zsock_freeaddrinfo(ai); | ||
| } | ||
|
|
||
| static inline const char *gai_strerror(int errcode) | ||
| { | ||
| return zsock_gai_strerror(errcode); | ||
| } | ||
|
|
||
| static inline int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, | ||
| char *host, socklen_t hostlen, | ||
| char *serv, socklen_t servlen, int flags) | ||
| { | ||
| return zsock_getnameinfo(addr, addrlen, host, hostlen, | ||
| serv, servlen, flags); | ||
| } | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* ZEPHYR_INCLUDE_POSIX_NETDB_H_ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * Copyright (c) 2019 Linaro Limited | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #ifndef ZEPHYR_INCLUDE_POSIX_SYS_SOCKET_H_ | ||
| #define ZEPHYR_INCLUDE_POSIX_SYS_SOCKET_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #include <sys/types.h> | ||
| #include <net/socket.h> | ||
|
|
||
| static inline int socket(int family, int type, int proto) | ||
| { | ||
| return zsock_socket(family, type, proto); | ||
| } | ||
|
|
||
| #define SHUT_RD ZSOCK_SHUT_RD | ||
| #define SHUT_WR ZSOCK_SHUT_WR | ||
| #define SHUT_RDWR ZSOCK_SHUT_RDWR | ||
|
|
||
| static inline int shutdown(int sock, int how) | ||
| { | ||
| return zsock_shutdown(sock, how); | ||
| } | ||
|
|
||
| static inline int bind(int sock, const struct sockaddr *addr, socklen_t addrlen) | ||
| { | ||
| return zsock_bind(sock, addr, addrlen); | ||
| } | ||
|
|
||
| static inline int connect(int sock, const struct sockaddr *addr, | ||
| socklen_t addrlen) | ||
| { | ||
| return zsock_connect(sock, addr, addrlen); | ||
| } | ||
|
|
||
| static inline int listen(int sock, int backlog) | ||
| { | ||
| return zsock_listen(sock, backlog); | ||
| } | ||
|
|
||
| static inline int accept(int sock, struct sockaddr *addr, socklen_t *addrlen) | ||
| { | ||
| return zsock_accept(sock, addr, addrlen); | ||
| } | ||
|
|
||
| static inline ssize_t send(int sock, const void *buf, size_t len, int flags) | ||
| { | ||
| return zsock_send(sock, buf, len, flags); | ||
| } | ||
|
|
||
| static inline ssize_t recv(int sock, void *buf, size_t max_len, int flags) | ||
| { | ||
| return zsock_recv(sock, buf, max_len, flags); | ||
| } | ||
|
|
||
| static inline ssize_t sendto(int sock, const void *buf, size_t len, int flags, | ||
| const struct sockaddr *dest_addr, | ||
| socklen_t addrlen) | ||
| { | ||
| return zsock_sendto(sock, buf, len, flags, dest_addr, addrlen); | ||
| } | ||
|
|
||
| static inline ssize_t recvfrom(int sock, void *buf, size_t max_len, int flags, | ||
| struct sockaddr *src_addr, socklen_t *addrlen) | ||
| { | ||
| return zsock_recvfrom(sock, buf, max_len, flags, src_addr, addrlen); | ||
| } | ||
|
|
||
| static inline int getsockopt(int sock, int level, int optname, | ||
| void *optval, socklen_t *optlen) | ||
| { | ||
| return zsock_getsockopt(sock, level, optname, optval, optlen); | ||
| } | ||
|
|
||
| static inline int setsockopt(int sock, int level, int optname, | ||
| const void *optval, socklen_t optlen) | ||
| { | ||
| return zsock_setsockopt(sock, level, optname, optval, optlen); | ||
| } | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* ZEPHYR_INCLUDE_POSIX_SYS_SOCKET_H_ */ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't sa_family_t and any other structures needed here be also defined in this namespace rather than in zephyr specific headers under include/net/?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of zsock_* functions come from net/socket.h together with sa_family_t, to me this looks just fine.