This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgHello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1624 to look at the new patch set (#2). Add osmo_sock_init_ifd() It's similar to osmo_sock_init_ofd() as it also creates and register sockets but instead of registering for READ events it uses WRITE events. Change-Id: I938de74c28df29221071913b769e7a2df9d041fa --- M include/osmocom/core/socket.h M src/socket.c 2 files changed, 32 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/24/1624/2 diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h index 6ef0912..0aaf5ce 100644 --- a/include/osmocom/core/socket.h +++ b/include/osmocom/core/socket.h @@ -26,7 +26,8 @@ int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, const char *host, uint16_t port, unsigned int flags); - +int osmo_sock_init_ifd(struct osmo_fd *ifd, int family, int type, int proto, + const char *host, uint16_t port, unsigned int flags); int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type, uint8_t proto, unsigned int flags); diff --git a/src/socket.c b/src/socket.c index cdafadd..5587c11 100644 --- a/src/socket.c +++ b/src/socket.c @@ -166,11 +166,12 @@ /*! \brief fill \ref osmo_fd for a give sfd * \param[out] ofd file descriptor (will be filled in) * \param[in] sfd socket file descriptor + * \param[in] when event type (read, write...) * \returns socket fd on success; negative on error * * This function fills the \a ofd structure. */ -static inline int osmo_fd_init_ofd(struct osmo_fd *ofd, int sfd) +static inline int fd_init_reg(struct osmo_fd *ofd, int sfd, unsigned int when) { int rc; @@ -178,7 +179,7 @@ return sfd; ofd->fd = sfd; - ofd->when = BSC_FD_READ; + ofd->when = when; rc = osmo_fd_register(ofd); if (rc < 0) { @@ -200,12 +201,35 @@ * \returns socket fd on success; negative on error * * This function creates (and optionall binds/connects) a socket using - * \ref osmo_sock_init, but also fills the \a ofd structure. + * \ref osmo_sock_init, but also fills the \a ofd structure, registering for READ + * events. */ int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, const char *host, uint16_t port, unsigned int flags) { - return osmo_fd_init_ofd(ofd, osmo_sock_init(family, type, proto, host, port, flags)); + return fd_init_reg(ofd, osmo_sock_init(family, type, proto, host, port, + flags), BSC_FD_READ); +} + +/*! \brief Initialize a socket and fill \ref osmo_fd + * \param[out] ofd file descriptor (will be filled in) + * \param[in] family Address Family like AF_INET, AF_INET6, AF_UNSPEC + * \param[in] type Socket type like SOCK_DGRAM, SOCK_STREAM + * \param[in] proto Protocol like IPPROTO_TCP, IPPROTO_UDP + * \param[in] host remote host name or IP address in string form + * \param[in] port remote port number in host byte order + * \param[in] flags flags like \ref OSMO_SOCK_F_CONNECT + * \returns socket fd on success; negative on error + * + * This function creates (and optionall binds/connects) a socket using + * \ref osmo_sock_init, but also fills the \a ifd structure, registering for WRITE + * events. + */ +int osmo_sock_init_ifd(struct osmo_fd *ifd, int family, int type, int proto, + const char *host, uint16_t port, unsigned int flags) +{ + return fd_init_reg(ifd, osmo_sock_init(family, type, proto, host, port, + flags), BSC_FD_WRITE); } /*! \brief Initialize a socket and fill \ref sockaddr @@ -390,7 +414,8 @@ int osmo_sock_unix_init_ofd(struct osmo_fd *ofd, uint16_t type, uint8_t proto, const char *socket_path, unsigned int flags) { - return osmo_fd_init_ofd(ofd, osmo_sock_unix_init(type, proto, socket_path, flags)); + return fd_init_reg(ofd, osmo_sock_unix_init(type, proto, socket_path, + flags), BSC_FD_READ); } #endif /* HAVE_SYS_SOCKET_H */ -- To view, visit https://gerrit.osmocom.org/1624 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I938de74c28df29221071913b769e7a2df9d041fa Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Holger Freyther <holger at freyther.de> Gerrit-Reviewer: Jenkins Builder