summaryrefslogtreecommitdiffstats
path: root/src/socket.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-05-26 12:39:53 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2017-05-26 12:56:07 +0200
commit75989e677dae515e2f9efc3a3b0ae3f198380ec6 (patch)
treea64f127d901c7f8c02e82134a8ffa25ee7d51d59 /src/socket.c
parentcd8e7a46b66e9b2c883867efab9c8db586f764ba (diff)
socket: Add osmo_sock_init2_ofd() function
Will be used by osmo-bts-trx Change-Id: I3c655a4af64fb80497a5aaa811cce8005dba9cd9
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/socket.c b/src/socket.c
index ad0f69bb..9d22d61d 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -363,6 +363,29 @@ int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto,
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