[MERGED] osmocom-bb[master]: VIRT-PHY mcast_sock: Use uint16_t for ports, bool and const

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
Thu Jul 13 12:36:58 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY mcast_sock: Use uint16_t for ports, bool and const
......................................................................


VIRT-PHY mcast_sock: Use uint16_t for ports, bool and const

Change-Id: I4eab1da8d43fdad05c04f23d89711081c4696fe7
---
M src/host/virt_phy/include/virtphy/osmo_mcast_sock.h
M src/host/virt_phy/src/shared/osmo_mcast_sock.c
2 files changed, 16 insertions(+), 14 deletions(-)

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



diff --git a/src/host/virt_phy/include/virtphy/osmo_mcast_sock.h b/src/host/virt_phy/include/virtphy/osmo_mcast_sock.h
index 31b2fd4..aa2013c 100644
--- a/src/host/virt_phy/include/virtphy/osmo_mcast_sock.h
+++ b/src/host/virt_phy/include/virtphy/osmo_mcast_sock.h
@@ -1,5 +1,7 @@
 #pragma once
 
+#include <stdbool.h>
+#include <stdint.h>
 #include <netinet/in.h>
 #include <osmocom/core/select.h>
 
@@ -9,19 +11,19 @@
 };
 
 struct mcast_bidir_sock *mcast_bidir_sock_setup(void *ctx,
-                const char *tx_mcast_group, int tx_mcast_port,
-                const char *rx_mcast_group, int rx_mcast_port, int loopback,
+                const char *tx_mcast_group, uint16_t tx_mcast_port,
+                const char *rx_mcast_group, uint16_t rx_mcast_port, bool loopback,
                 int (*fd_rx_cb)(struct osmo_fd *ofd, unsigned int what),
                 void *osmo_fd_data);
 
 int mcast_server_sock_setup(struct osmo_fd *ofd, const char *tx_mcast_group,
-			    int tx_mcast_port, int loopback);
+			    uint16_t tx_mcast_port, bool loopback);
 
-int mcast_client_sock_setup(struct osmo_fd *ofd, const char *mcast_group, int mcast_port,
+int mcast_client_sock_setup(struct osmo_fd *ofd, const char *mcast_group, uint16_t mcast_port,
 			    int (*fd_rx_cb)(struct osmo_fd *ofd, unsigned int what),
 			    void *osmo_fd_data);
 
-int mcast_bidir_sock_tx(struct mcast_bidir_sock *bidir_sock, void *data, int data_len);
-int mcast_bidir_sock_rx(struct mcast_bidir_sock *bidir_sock, void *buf, int buf_len);
+int mcast_bidir_sock_tx(struct mcast_bidir_sock *bidir_sock, const uint8_t *data, unsigned int data_len);
+int mcast_bidir_sock_rx(struct mcast_bidir_sock *bidir_sock, uint8_t *buf, unsigned int buf_len);
 void mcast_bidir_sock_close(struct mcast_bidir_sock* bidir_sock);
 
diff --git a/src/host/virt_phy/src/shared/osmo_mcast_sock.c b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
index 3a3c77a..df3abc3 100644
--- a/src/host/virt_phy/src/shared/osmo_mcast_sock.c
+++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
@@ -24,8 +24,8 @@
 /* server socket is what we use for transmission. It is not subscribed
  * to a multicast group or locally bound, but it is just a normal UDP
  * socket that's connected to the remote mcast group + port */
-int mcast_server_sock_setup(struct osmo_fd *ofd, const char* tx_mcast_group, int tx_mcast_port,
-			    int loopback)
+int mcast_server_sock_setup(struct osmo_fd *ofd, const char* tx_mcast_group,
+			    uint16_t tx_mcast_port, bool loopback)
 {
 	int rc;
 
@@ -52,7 +52,7 @@
 /* the client socket is what we use for reception.  It is a UDP socket
  * that's bound to the GSMTAP UDP port and subscribed to the respective
  * multicast group */
-int mcast_client_sock_setup(struct osmo_fd *ofd, const char *mcast_group, int mcast_port,
+int mcast_client_sock_setup(struct osmo_fd *ofd, const char *mcast_group, uint16_t mcast_port,
 			    int (*fd_rx_cb)(struct osmo_fd *ofd, unsigned int what),
 			    void *osmo_fd_data)
 {
@@ -105,8 +105,8 @@
 }
 
 struct mcast_bidir_sock *
-mcast_bidir_sock_setup(void *ctx, const char *tx_mcast_group, int tx_mcast_port,
-			const char *rx_mcast_group, int rx_mcast_port, int loopback,
+mcast_bidir_sock_setup(void *ctx, const char *tx_mcast_group, uint16_t tx_mcast_port,
+			const char *rx_mcast_group, uint16_t rx_mcast_port, bool loopback,
 			int (*fd_rx_cb)(struct osmo_fd *ofd, unsigned int what),
 			void *osmo_fd_data)
 {
@@ -132,13 +132,13 @@
 
 }
 
-int mcast_bidir_sock_tx(struct mcast_bidir_sock *bidir_sock, void* data,
-                        int data_len)
+int mcast_bidir_sock_tx(struct mcast_bidir_sock *bidir_sock, const uint8_t *data,
+                        unsigned int data_len)
 {
 	return send(bidir_sock->tx_ofd.fd, data, data_len, 0);
 }
 
-int mcast_bidir_sock_rx(struct mcast_bidir_sock *bidir_sock, void* buf, int buf_len)
+int mcast_bidir_sock_rx(struct mcast_bidir_sock *bidir_sock, uint8_t *buf, unsigned int buf_len)
 {
 	return recv(bidir_sock->rx_ofd.fd, buf, buf_len, 0);
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4eab1da8d43fdad05c04f23d89711081c4696fe7
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list