[MERGED] libosmocore[master]: socket: Add osmo_sock_init2_ofd() function

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun May 28 23:00:45 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: socket: Add osmo_sock_init2_ofd() function
......................................................................


socket: Add osmo_sock_init2_ofd() function

Will be used by osmo-bts-trx

Change-Id: I3c655a4af64fb80497a5aaa811cce8005dba9cd9
---
M include/osmocom/core/socket.h
M src/socket.c
2 files changed, 27 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h
index e19e8f2..09376c3 100644
--- a/include/osmocom/core/socket.h
+++ b/include/osmocom/core/socket.h
@@ -31,6 +31,10 @@
 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_init2_ofd(struct osmo_fd *ofd, int family, int type, int proto,
+			const char *local_host, uint16_t local_port,
+			const char *remote_host, uint16_t remote_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 ad0f69b..9d22d61 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -363,6 +363,29 @@
 	return osmo_fd_init_ofd(ofd, osmo_sock_init(family, type, proto, host, port, flags));
 }
 
+/*! \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] local_host local host name or IP address in string form
+ *  \param[in] local_port local port number in host byte order
+ *  \param[in] remote_host remote host name or IP address in string form
+ *  \param[in] remote_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_init2, but also fills the \a ofd structure.
+ */
+int osmo_sock_init2_ofd(struct osmo_fd *ofd, int family, int type, int proto,
+			const char *local_host, uint16_t local_port,
+			const char *remote_host, uint16_t remote_port, unsigned int flags)
+{
+	return osmo_fd_init_ofd(ofd, osmo_sock_init2(family, type, proto, local_host,
+					local_port, remote_host, remote_port, flags));
+}
+
 /*! \brief Initialize a socket and fill \ref sockaddr
  *  \param[out] ss socket address (will be filled in)
  *  \param[in] type Socket type like SOCK_DGRAM, SOCK_STREAM

-- 
To view, visit https://gerrit.osmocom.org/2744
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3c655a4af64fb80497a5aaa811cce8005dba9cd9
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list