summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-07-13 14:24:57 +0200
committerHarald Welte <laforge@gnumonks.org>2017-07-13 14:24:57 +0200
commit48d2a55b40871c584b0af8ff4c918a7734a12b59 (patch)
tree1c7742fab2b3090c3b1e2a45fe76e2a9f9fe3914
parent16da443e7376fcf7c88757f8ce2a342a0fd48a99 (diff)
VIRT-PHY mcast_sock: Use uint16_t for ports, bool and const
-rw-r--r--src/host/virt_phy/include/virtphy/osmo_mcast_sock.h14
-rw-r--r--src/host/virt_phy/src/shared/osmo_mcast_sock.c16
2 files changed, 16 insertions, 14 deletions
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 31b2fd41..aa2013c6 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 {
};
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 3a3c77a9..df3abc36 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 @@ static void fd_close(struct osmo_fd *ofd)
/* 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 @@ int mcast_server_sock_setup(struct osmo_fd *ofd, const char* tx_mcast_group, int
/* 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 @@ int mcast_client_sock_setup(struct osmo_fd *ofd, const char *mcast_group, int mc
}
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 @@ mcast_bidir_sock_setup(void *ctx, const char *tx_mcast_group, int tx_mcast_port,
}
-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);
}