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.orgReview at https://gerrit.osmocom.org/1318 mgcp_network.c: Use libosmocore socket functions Use libosmocore osmo_sock_init_ofd() in mgcp_create_bind(), rather than using a hand-coded version using OS socket functions. The locally implemented verison of the code didn't check setsockopt() return value. Change-Id: I1de4de12245847a6d30d1bf7c91dc813d2178dee Fixes: Coverity CID 57646 --- M openbsc/src/libmgcp/mgcp_network.c 1 file changed, 4 insertions(+), 23 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/18/1318/1 diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index abce6e4..a98a60f 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -28,10 +28,10 @@ #include <time.h> #include <limits.h> -#include <sys/socket.h> #include <arpa/inet.h> #include <osmocom/core/msgb.h> +#include <osmocom/core/socket.h> #include <osmocom/core/select.h> #include <osmocom/netif/rtp.h> @@ -884,28 +884,9 @@ int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port) { - struct sockaddr_in addr; - int on = 1; - - fd->fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd->fd < 0) { - LOGP(DMGCP, LOGL_ERROR, "Failed to create UDP port.\n"); - return -1; - } - - setsockopt(fd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - inet_aton(source_addr, &addr.sin_addr); - - if (bind(fd->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - close(fd->fd); - fd->fd = -1; - return -1; - } - - return 0; + return osmo_sock_init_ofd(fd, AF_INET, SOCK_DGRAM, IPPROTO_UDP, + source_addr, port, + OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK); } int mgcp_set_ip_tos(int fd, int tos) -- To view, visit https://gerrit.osmocom.org/1318 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1de4de12245847a6d30d1bf7c91dc813d2178dee Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org>