Change in osmo-mgw[master]: switch from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()

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

laforge gerrit-no-reply at lists.osmocom.org
Wed Apr 28 17:35:02 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/23964 )


Change subject: switch from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()
......................................................................

switch from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()

libosmocore If22988735fe05e51226c6b091a5348dcf1208cdf introduces
an even more convenient mechanism for specifying the DSCP of
an IP socket via OSMO_SOCK_F_DSCP()

Change-Id: If0b11dea08716ed3952a25b546b2a9bd013857bf
---
M include/osmocom/mgcp/mgcp.h
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
3 files changed, 6 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/64/23964/1

diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index f3f225e..e0aeb83 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -208,5 +208,5 @@
 int mgcp_send_reset_all(struct mgcp_config *cfg);
 
 
-int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port);
+int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port, uint8_t dscp);
 int mgcp_udp_send(int fd, struct osmo_sockaddr *addr, int port, char *buf, int len);
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 675a0fc..76fe730 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1519,12 +1519,12 @@
  *  \param[in] fd associated file descriptor.
  *  \param[in] port to bind on.
  *  \returns 0 on success, -1 on ERROR. */
-int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port)
+int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port, uint8_t dscp)
 {
 	int rc;
 
 	rc = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, source_addr, port,
-			     NULL, 0, OSMO_SOCK_F_BIND);
+			     NULL, 0, OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(dscp));
 	if (rc < 0) {
 		LOGP(DRTP, LOGL_ERROR, "failed to bind UDP port (%s:%i).\n",
 		     source_addr, port);
@@ -1543,26 +1543,20 @@
 	/* NOTE: The port that is used for RTCP is the RTP port incremented by one
 	 * (e.g. RTP-Port = 16000 ==> RTCP-Port = 16001) */
 
-	if (mgcp_create_bind(source_addr, &rtp_end->rtp,
-			     rtp_end->local_port) != 0) {
+	if (mgcp_create_bind(source_addr, &rtp_end->rtp, rtp_end->local_port, cfg->endp_dscp) != 0) {
 		LOGPENDP(endp, DRTP, LOGL_ERROR,
 			 "failed to create RTP port: %s:%d\n",
 			 source_addr, rtp_end->local_port);
 		goto cleanup0;
 	}
 
-	if (mgcp_create_bind(source_addr, &rtp_end->rtcp,
-			     rtp_end->local_port + 1) != 0) {
+	if (mgcp_create_bind(source_addr, &rtp_end->rtcp, rtp_end->local_port + 1, cfg->endp_dscp) != 0) {
 		LOGPENDP(endp, DRTP, LOGL_ERROR,
 			 "failed to create RTCP port: %s:%d\n",
 			 source_addr, rtp_end->local_port + 1);
 		goto cleanup1;
 	}
 
-	/* Set Type of Service (DSCP-Value) as configured via VTY */
-	osmo_sock_set_dscp(rtp_end->rtp.fd, cfg->endp_dscp);
-	osmo_sock_set_dscp(rtp_end->rtcp.fd, cfg->endp_dscp);
-
 	if (osmo_fd_register(&rtp_end->rtp) != 0) {
 		LOGPENDP(endp, DRTP, LOGL_ERROR,
 			 "failed to register RTP port %d\n",
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 6c40307..62a6720 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -418,13 +418,12 @@
 
 	osmo_fd_setup(&osmux_fd, -1, OSMO_FD_READ, osmux_read_fd_cb, cfg, 0);
 
-	ret = mgcp_create_bind(cfg->osmux_addr, &osmux_fd, cfg->osmux_port);
+	ret = mgcp_create_bind(cfg->osmux_addr, &osmux_fd, cfg->osmux_port, cfg->endp_dscp);
 	if (ret < 0) {
 		LOGP(DLMGCP, LOGL_ERROR, "cannot bind OSMUX socket to %s:%u\n",
 		     cfg->osmux_addr, cfg->osmux_port);
 		return ret;
 	}
-	osmo_sock_set_dscp(osmux_fd.fd, cfg->endp_dscp);
 
 	ret = osmo_fd_register(&osmux_fd);
 	if (ret < 0) {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/23964
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: If0b11dea08716ed3952a25b546b2a9bd013857bf
Gerrit-Change-Number: 23964
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210428/38f23715/attachment.htm>


More information about the gerrit-log mailing list