Change in libosmocore[master]: select: Rename BSC_FD_* constants to OSMO_FD_*

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Mar 20 09:35:25 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13335


Change subject: select: Rename BSC_FD_* constants to OSMO_FD_*
......................................................................

select: Rename BSC_FD_* constants to OSMO_FD_*

The naming of these constants dates back to when the code was private
within OpenBSC.  Everything else was renamed (bsc_fd -> osmo_fd) at
the time, but somehow the BSC_FD_* defines have been missed at the
time.

Keep compatibility #defines around, but allow us to migrate the
applications to a less confusing naming meanwhile.

Change-Id: Ifae33ed61a7cf0ae54ad487399e7dd2489986436
---
M include/osmocom/core/select.h
M src/ctrl/control_if.c
M src/gb/gprs_ns.c
M src/gb/gprs_ns_frgre.c
M src/gsmtap_util.c
M src/select.c
M src/socket.c
M src/vty/telnet_interface.c
M src/write_queue.c
9 files changed, 42 insertions(+), 37 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/35/13335/1

diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h
index 1ba6b83..e4787b0 100644
--- a/include/osmocom/core/select.h
+++ b/include/osmocom/core/select.h
@@ -13,11 +13,16 @@
  * \file select.h */
 
 /*! Indicate interest in reading from the file descriptor */
-#define BSC_FD_READ	0x0001
+#define OSMO_FD_READ	0x0001
 /*! Indicate interest in writing to the file descriptor */
-#define BSC_FD_WRITE	0x0002
+#define OSMO_FD_WRITE	0x0002
 /*! Indicate interest in exceptions from the file descriptor */
-#define BSC_FD_EXCEPT	0x0004
+#define OSMO_FD_EXCEPT	0x0004
+
+/* legacy naming dating back to early OpenBSC / bsc_hack of 2008 */
+#define BSC_FD_READ	OSMO_FD_READ
+#define BSC_FD_WRITE	OSMO_FD_WRITE
+#define BSC_FD_EXCEPT	OSMO_FD_EXCEPT
 
 /*! Structure representing a file dsecriptor */
 struct osmo_fd {
@@ -25,8 +30,8 @@
 	struct llist_head list;	
 	/*! actual operating-system level file decriptor */
 	int fd;
-	/*! bit-mask or of \ref BSC_FD_READ, \ref BSC_FD_WRITE and/or
-	 * \ref BSC_FD_EXCEPT */
+	/*! bit-mask or of \ref OSMO_FD_READ, \ref OSMO_FD_WRITE and/or
+	 * \ref OSMO_FD_EXCEPT */
 	unsigned int when;
 	/*! call-back function to be called once file descriptor becomes
 	 * available */
diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 0209f3b..ce2e367 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -524,7 +524,7 @@
 	char *name;
 
 
-	if (!(what & BSC_FD_READ))
+	if (!(what & OSMO_FD_READ))
 		return 0;
 
 	fd = accept(listen_bfd->fd, NULL, NULL);
@@ -554,7 +554,7 @@
 	LOGP(DLCTRL, LOGL_INFO, "accept()ed new CTRL connection from %s\n", name);
 
 	ccon->write_queue.bfd.fd = fd;
-	ccon->write_queue.bfd.when = BSC_FD_READ;
+	ccon->write_queue.bfd.when = OSMO_FD_READ;
 
 	ret = osmo_fd_register(&ccon->write_queue.bfd);
 	if (ret < 0) {
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 8c3b0fa..c7ff78e 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -2006,9 +2006,9 @@
 {
 	int rc = 0;
 
-	if (what & BSC_FD_READ)
+	if (what & OSMO_FD_READ)
 		rc = handle_nsip_read(bfd);
-	if (what & BSC_FD_WRITE)
+	if (what & OSMO_FD_WRITE)
 		rc = handle_nsip_write(bfd);
 
 	return rc;
diff --git a/src/gb/gprs_ns_frgre.c b/src/gb/gprs_ns_frgre.c
index 483fdb6..dbbd8d2 100644
--- a/src/gb/gprs_ns_frgre.c
+++ b/src/gb/gprs_ns_frgre.c
@@ -315,9 +315,9 @@
 {
 	int rc = 0;
 
-	if (what & BSC_FD_READ)
+	if (what & OSMO_FD_READ)
 		rc = handle_nsfrgre_read(bfd);
-	if (what & BSC_FD_WRITE)
+	if (what & OSMO_FD_WRITE)
 		rc = handle_nsfrgre_write(bfd);
 
 	return rc;
diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 385b467..996830f 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -355,7 +355,7 @@
 	int rc;
 	uint8_t buf[4096];
 
-	if (!(flags & BSC_FD_READ))
+	if (!(flags & OSMO_FD_READ))
 		return 0;
 
 	rc = read(fd->fd, buf, sizeof(buf));
@@ -395,7 +395,7 @@
 
 		sink_ofd = &gti->sink_ofd;
 		sink_ofd->fd = fd;
-		sink_ofd->when = BSC_FD_READ;
+		sink_ofd->when = OSMO_FD_READ;
 		sink_ofd->cb = gsmtap_sink_fd_cb;
 
 		rc = osmo_fd_register(sink_ofd);
diff --git a/src/select.c b/src/select.c
index 4e7be35..7ce135f 100644
--- a/src/select.c
+++ b/src/select.c
@@ -55,7 +55,7 @@
 /*! Set up an osmo-fd. Will not register it.
  *  \param[inout] ofd Osmo FD to be set-up
  *  \param[in] fd OS-level file descriptor number
- *  \param[in] when bit-mask of BSC_FD_{READ,WRITE,EXECEPT}
+ *  \param[in] when bit-mask of OSMO_FD_{READ,WRITE,EXECEPT}
  *  \param[in] cb Call-back function to be called
  *  \param[in] data Private context pointer
  *  \param[in] priv_nr Private number
@@ -171,13 +171,13 @@
 	int highfd = 0;
 
 	llist_for_each_entry(ufd, &osmo_fds, list) {
-		if (ufd->when & BSC_FD_READ)
+		if (ufd->when & OSMO_FD_READ)
 			FD_SET(ufd->fd, readset);
 
-		if (ufd->when & BSC_FD_WRITE)
+		if (ufd->when & OSMO_FD_WRITE)
 			FD_SET(ufd->fd, writeset);
 
-		if (ufd->when & BSC_FD_EXCEPT)
+		if (ufd->when & OSMO_FD_EXCEPT)
 			FD_SET(ufd->fd, exceptset);
 
 		if (ufd->fd > highfd)
@@ -199,17 +199,17 @@
 		int flags = 0;
 
 		if (FD_ISSET(ufd->fd, readset)) {
-			flags |= BSC_FD_READ;
+			flags |= OSMO_FD_READ;
 			FD_CLR(ufd->fd, readset);
 		}
 
 		if (FD_ISSET(ufd->fd, writeset)) {
-			flags |= BSC_FD_WRITE;
+			flags |= OSMO_FD_WRITE;
 			FD_CLR(ufd->fd, writeset);
 		}
 
 		if (FD_ISSET(ufd->fd, exceptset)) {
-			flags |= BSC_FD_EXCEPT;
+			flags |= OSMO_FD_EXCEPT;
 			FD_CLR(ufd->fd, exceptset);
 		}
 
@@ -327,7 +327,7 @@
 {
 	ofd->cb = cb;
 	ofd->data = data;
-	ofd->when = BSC_FD_READ;
+	ofd->when = OSMO_FD_READ;
 
 	if (ofd->fd < 0) {
 		int rc;
diff --git a/src/socket.c b/src/socket.c
index 6a3f254..3a46ad0 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -414,7 +414,7 @@
 		return sfd;
 
 	ofd->fd = sfd;
-	ofd->when = BSC_FD_READ;
+	ofd->when = OSMO_FD_READ;
 
 	rc = osmo_fd_register(ofd);
 	if (rc < 0) {
diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c
index e090e17..dc23b12 100644
--- a/src/vty/telnet_interface.c
+++ b/src/vty/telnet_interface.c
@@ -59,7 +59,7 @@
 static int telnet_new_connection(struct osmo_fd *fd, unsigned int what);
 
 static struct osmo_fd server_socket = {
-	.when	    = BSC_FD_READ,
+	.when	    = OSMO_FD_READ,
 	.cb	    = telnet_new_connection,
 	.priv_nr    = 0,
 };
@@ -142,8 +142,8 @@
 	struct telnet_connection *conn = fd->data;
 	int rc = 0;
 
-	if (what & BSC_FD_READ) {
-		conn->fd.when &= ~BSC_FD_READ;
+	if (what & OSMO_FD_READ) {
+		conn->fd.when &= ~OSMO_FD_READ;
 		rc = vty_read(conn->vty);
 	}
 
@@ -151,10 +151,10 @@
 	if (rc == -EBADF)
 		return rc;
 
-	if (what & BSC_FD_WRITE) {
+	if (what & OSMO_FD_WRITE) {
 		rc = buffer_flush_all(conn->vty->obuf, fd->fd);
 		if (rc == BUFFER_EMPTY)
-			conn->fd.when &= ~BSC_FD_WRITE;
+			conn->fd.when &= ~OSMO_FD_WRITE;
 	}
 
 	return rc;
@@ -177,7 +177,7 @@
 	connection->priv = fd->data;
 	connection->fd.data = connection;
 	connection->fd.fd = new_connection;
-	connection->fd.when = BSC_FD_READ;
+	connection->fd.when = OSMO_FD_READ;
 	connection->fd.cb = client_data;
 	rc = osmo_fd_register(&connection->fd);
 	if (rc < 0) {
@@ -219,10 +219,10 @@
 
 	switch (event) {
 	case VTY_READ:
-		bfd->when |= BSC_FD_READ;
+		bfd->when |= OSMO_FD_READ;
 		break;
 	case VTY_WRITE:
-		bfd->when |= BSC_FD_WRITE;
+		bfd->when |= OSMO_FD_WRITE;
 		break;
 	case VTY_CLOSED:
 		/* vty layer is about to free() vty */
diff --git a/src/write_queue.c b/src/write_queue.c
index fb6839a..3399b0f 100644
--- a/src/write_queue.c
+++ b/src/write_queue.c
@@ -47,22 +47,22 @@
 
 	queue = container_of(fd, struct osmo_wqueue, bfd);
 
-	if (what & BSC_FD_READ) {
+	if (what & OSMO_FD_READ) {
 		rc = queue->read_cb(fd);
 		if (rc == -EBADF)
 			goto err_badfd;
 	}
 
-	if (what & BSC_FD_EXCEPT) {
+	if (what & OSMO_FD_EXCEPT) {
 		rc = queue->except_cb(fd);
 		if (rc == -EBADF)
 			goto err_badfd;
 	}
 
-	if (what & BSC_FD_WRITE) {
+	if (what & OSMO_FD_WRITE) {
 		struct msgb *msg;
 
-		fd->when &= ~BSC_FD_WRITE;
+		fd->when &= ~OSMO_FD_WRITE;
 
 		/* the queue might have been emptied */
 		if (!llist_empty(&queue->msg_queue)) {
@@ -76,7 +76,7 @@
 				goto err_badfd;
 
 			if (!llist_empty(&queue->msg_queue))
-				fd->when |= BSC_FD_WRITE;
+				fd->when |= OSMO_FD_WRITE;
 		}
 	}
 
@@ -115,7 +115,7 @@
 
 	++queue->current_length;
 	msgb_enqueue(&queue->msg_queue, data);
-	queue->bfd.when |= BSC_FD_WRITE;
+	queue->bfd.when |= OSMO_FD_WRITE;
 
 	return 0;
 }
@@ -133,7 +133,7 @@
 	}
 
 	queue->current_length = 0;
-	queue->bfd.when &= ~BSC_FD_WRITE;
+	queue->bfd.when &= ~OSMO_FD_WRITE;
 }
 
 /*! @} */

-- 
To view, visit https://gerrit.osmocom.org/13335
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifae33ed61a7cf0ae54ad487399e7dd2489986436
Gerrit-Change-Number: 13335
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190320/bfa52351/attachment.html>


More information about the gerrit-log mailing list