mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
a3226f7b9d
commit
1688699c3f
|
@ -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 osmo_fd {
|
|||
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 */
|
||||
|
|
|
@ -524,7 +524,7 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
|
|||
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 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
|
|||
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) {
|
||||
|
|
|
@ -2006,9 +2006,9 @@ static int nsip_fd_cb(struct osmo_fd *bfd, unsigned int what)
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -315,9 +315,9 @@ static int nsfrgre_fd_cb(struct osmo_fd *bfd, unsigned int what)
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -355,7 +355,7 @@ static int gsmtap_sink_fd_cb(struct osmo_fd *fd, unsigned int flags)
|
|||
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 @@ int gsmtap_source_add_sink(struct gsmtap_inst *gti)
|
|||
|
||||
sink_ofd = >i->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);
|
||||
|
|
16
src/select.c
16
src/select.c
|
@ -55,7 +55,7 @@ static int unregistered_count;
|
|||
/*! 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 @@ inline int osmo_fd_fill_fds(void *_rset, void *_wset, void *_eset)
|
|||
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 @@ restart:
|
|||
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 @@ int osmo_timerfd_setup(struct osmo_fd *ofd, int (*cb)(struct osmo_fd *, unsigned
|
|||
{
|
||||
ofd->cb = cb;
|
||||
ofd->data = data;
|
||||
ofd->when = BSC_FD_READ;
|
||||
ofd->when = OSMO_FD_READ;
|
||||
|
||||
if (ofd->fd < 0) {
|
||||
int rc;
|
||||
|
|
|
@ -414,7 +414,7 @@ static inline int osmo_fd_init_ofd(struct osmo_fd *ofd, int sfd)
|
|||
return sfd;
|
||||
|
||||
ofd->fd = sfd;
|
||||
ofd->when = BSC_FD_READ;
|
||||
ofd->when = OSMO_FD_READ;
|
||||
|
||||
rc = osmo_fd_register(ofd);
|
||||
if (rc < 0) {
|
||||
|
|
|
@ -59,7 +59,7 @@ static void *tall_telnet_ctx;
|
|||
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 @@ static int client_data(struct osmo_fd *fd, unsigned int what)
|
|||
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 @@ static int client_data(struct osmo_fd *fd, unsigned int what)
|
|||
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 @@ static int telnet_new_connection(struct osmo_fd *fd, unsigned int what)
|
|||
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 @@ void vty_event(enum event event, int sock, struct vty *vty)
|
|||
|
||||
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 */
|
||||
|
|
|
@ -47,22 +47,22 @@ int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
|
|||
|
||||
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 @@ int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
|
|||
goto err_badfd;
|
||||
|
||||
if (!llist_empty(&queue->msg_queue))
|
||||
fd->when |= BSC_FD_WRITE;
|
||||
fd->when |= OSMO_FD_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data)
|
|||
|
||||
++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 @@ void osmo_wqueue_clear(struct osmo_wqueue *queue)
|
|||
}
|
||||
|
||||
queue->current_length = 0;
|
||||
queue->bfd.when &= ~BSC_FD_WRITE;
|
||||
queue->bfd.when &= ~OSMO_FD_WRITE;
|
||||
}
|
||||
|
||||
/*! @} */
|
||||
|
|
Loading…
Reference in New Issue