mirror of https://gerrit.osmocom.org/libosmocore
select: use namespace prefix osmo_fd* and osmo_select*
Summary of changes: s/struct bsc_fd/struct osmo_fd/g s/bsc_register_fd/osmo_fd_register/g s/bsc_unregister_fd/osmo_fd_unregister/g s/bsc_select_main/osmo_select_main/g
This commit is contained in:
parent
0b21c1c885
commit
f7f89d0cfe
|
@ -7,16 +7,16 @@
|
|||
#define BSC_FD_WRITE 0x0002
|
||||
#define BSC_FD_EXCEPT 0x0004
|
||||
|
||||
struct bsc_fd {
|
||||
struct osmo_fd {
|
||||
struct llist_head list;
|
||||
int fd;
|
||||
unsigned int when;
|
||||
int (*cb)(struct bsc_fd *fd, unsigned int what);
|
||||
int (*cb)(struct osmo_fd *fd, unsigned int what);
|
||||
void *data;
|
||||
unsigned int priv_nr;
|
||||
};
|
||||
|
||||
int bsc_register_fd(struct bsc_fd *fd);
|
||||
void bsc_unregister_fd(struct bsc_fd *fd);
|
||||
int bsc_select_main(int polling);
|
||||
int osmo_fd_register(struct osmo_fd *fd);
|
||||
void osmo_fd_unregister(struct osmo_fd *fd);
|
||||
int osmo_select_main(int polling);
|
||||
#endif /* _BSC_SELECT_H */
|
||||
|
|
|
@ -27,20 +27,20 @@
|
|||
#include <osmocom/core/msgb.h>
|
||||
|
||||
struct write_queue {
|
||||
struct bsc_fd bfd;
|
||||
struct osmo_fd bfd;
|
||||
unsigned int max_length;
|
||||
unsigned int current_length;
|
||||
|
||||
struct llist_head msg_queue;
|
||||
|
||||
int (*read_cb)(struct bsc_fd *fd);
|
||||
int (*write_cb)(struct bsc_fd *fd, struct msgb *msg);
|
||||
int (*except_cb)(struct bsc_fd *fd);
|
||||
int (*read_cb)(struct osmo_fd *fd);
|
||||
int (*write_cb)(struct osmo_fd *fd, struct msgb *msg);
|
||||
int (*except_cb)(struct osmo_fd *fd);
|
||||
};
|
||||
|
||||
void write_queue_init(struct write_queue *queue, int max_length);
|
||||
void write_queue_clear(struct write_queue *queue);
|
||||
int write_queue_enqueue(struct write_queue *queue, struct msgb *data);
|
||||
int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what);
|
||||
int write_queue_bfd_cb(struct osmo_fd *fd, unsigned int what);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
struct telnet_connection {
|
||||
struct llist_head entry;
|
||||
void *priv;
|
||||
struct bsc_fd fd;
|
||||
struct osmo_fd fd;
|
||||
struct vty *vty;
|
||||
struct log_target *dbg;
|
||||
};
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
static struct bsc_fd gsmtap_bfd = { .fd = -1 };
|
||||
static struct bsc_fd gsmtap_sink_bfd = { .fd = -1 };
|
||||
static struct osmo_fd gsmtap_bfd = { .fd = -1 };
|
||||
static struct osmo_fd gsmtap_sink_bfd = { .fd = -1 };
|
||||
static LLIST_HEAD(gsmtap_txqueue);
|
||||
|
||||
uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t link_id)
|
||||
|
@ -137,7 +137,7 @@ int gsmtap_sendmsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss,
|
|||
}
|
||||
|
||||
/* Callback from select layer if we can write to the socket */
|
||||
static int gsmtap_fd_cb(struct bsc_fd *fd, unsigned int flags)
|
||||
static int gsmtap_fd_cb(struct osmo_fd *fd, unsigned int flags)
|
||||
{
|
||||
struct msgb *msg;
|
||||
int rc;
|
||||
|
@ -195,11 +195,11 @@ int gsmtap_init(uint32_t dst_ip)
|
|||
gsmtap_bfd.cb = gsmtap_fd_cb;
|
||||
gsmtap_bfd.data = NULL;
|
||||
|
||||
return bsc_register_fd(&gsmtap_bfd);
|
||||
return osmo_fd_register(&gsmtap_bfd);
|
||||
}
|
||||
|
||||
/* Callback from select layer if we can read from the sink socket */
|
||||
static int gsmtap_sink_fd_cb(struct bsc_fd *fd, unsigned int flags)
|
||||
static int gsmtap_sink_fd_cb(struct osmo_fd *fd, unsigned int flags)
|
||||
{
|
||||
int rc;
|
||||
uint8_t buf[4096];
|
||||
|
@ -246,7 +246,7 @@ int gsmtap_sink_init(uint32_t bind_ip)
|
|||
gsmtap_sink_bfd.cb = gsmtap_sink_fd_cb;
|
||||
gsmtap_sink_bfd.data = NULL;
|
||||
|
||||
return bsc_register_fd(&gsmtap_sink_bfd);
|
||||
return osmo_fd_register(&gsmtap_sink_bfd);
|
||||
|
||||
}
|
||||
|
||||
|
|
22
src/select.c
22
src/select.c
|
@ -31,10 +31,10 @@
|
|||
#ifdef HAVE_SYS_SELECT_H
|
||||
|
||||
static int maxfd = 0;
|
||||
static LLIST_HEAD(bsc_fds);
|
||||
static LLIST_HEAD(osmo_fds);
|
||||
static int unregistered_count;
|
||||
|
||||
int bsc_register_fd(struct bsc_fd *fd)
|
||||
int osmo_fd_register(struct osmo_fd *fd)
|
||||
{
|
||||
int flags;
|
||||
|
||||
|
@ -52,29 +52,29 @@ int bsc_register_fd(struct bsc_fd *fd)
|
|||
maxfd = fd->fd;
|
||||
|
||||
#ifdef BSC_FD_CHECK
|
||||
struct bsc_fd *entry;
|
||||
llist_for_each_entry(entry, &bsc_fds, list) {
|
||||
struct osmo_fd *entry;
|
||||
llist_for_each_entry(entry, &osmo_fds, list) {
|
||||
if (entry == fd) {
|
||||
fprintf(stderr, "Adding a bsc_fd that is already in the list.\n");
|
||||
fprintf(stderr, "Adding a osmo_fd that is already in the list.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
llist_add_tail(&fd->list, &bsc_fds);
|
||||
llist_add_tail(&fd->list, &osmo_fds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bsc_unregister_fd(struct bsc_fd *fd)
|
||||
void osmo_fd_unregister(struct osmo_fd *fd)
|
||||
{
|
||||
unregistered_count++;
|
||||
llist_del(&fd->list);
|
||||
}
|
||||
|
||||
int bsc_select_main(int polling)
|
||||
int osmo_select_main(int polling)
|
||||
{
|
||||
struct bsc_fd *ufd, *tmp;
|
||||
struct osmo_fd *ufd, *tmp;
|
||||
fd_set readset, writeset, exceptset;
|
||||
int work = 0, rc;
|
||||
struct timeval no_time = {0, 0};
|
||||
|
@ -84,7 +84,7 @@ int bsc_select_main(int polling)
|
|||
FD_ZERO(&exceptset);
|
||||
|
||||
/* prepare read and write fdsets */
|
||||
llist_for_each_entry(ufd, &bsc_fds, list) {
|
||||
llist_for_each_entry(ufd, &osmo_fds, list) {
|
||||
if (ufd->when & BSC_FD_READ)
|
||||
FD_SET(ufd->fd, &readset);
|
||||
|
||||
|
@ -109,7 +109,7 @@ int bsc_select_main(int polling)
|
|||
/* call registered callback functions */
|
||||
restart:
|
||||
unregistered_count = 0;
|
||||
llist_for_each_entry_safe(ufd, tmp, &bsc_fds, list) {
|
||||
llist_for_each_entry_safe(ufd, tmp, &osmo_fds, list) {
|
||||
int flags = 0;
|
||||
|
||||
if (FD_ISSET(ufd->fd, &readset)) {
|
||||
|
|
|
@ -39,9 +39,9 @@ LLIST_HEAD(active_connections);
|
|||
static void *tall_telnet_ctx;
|
||||
|
||||
/* per network data */
|
||||
static int telnet_new_connection(struct bsc_fd *fd, unsigned int what);
|
||||
static int telnet_new_connection(struct osmo_fd *fd, unsigned int what);
|
||||
|
||||
static struct bsc_fd server_socket = {
|
||||
static struct osmo_fd server_socket = {
|
||||
.when = BSC_FD_READ,
|
||||
.cb = telnet_new_connection,
|
||||
.priv_nr = 0,
|
||||
|
@ -85,7 +85,7 @@ int telnet_init(void *tall_ctx, void *priv, int port)
|
|||
|
||||
server_socket.data = priv;
|
||||
server_socket.fd = fd;
|
||||
bsc_register_fd(&server_socket);
|
||||
osmo_fd_register(&server_socket);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -104,12 +104,12 @@ static void print_welcome(int fd)
|
|||
ret = write(fd, host.app_info->copyright, strlen(host.app_info->copyright));
|
||||
}
|
||||
|
||||
int telnet_close_client(struct bsc_fd *fd)
|
||||
int telnet_close_client(struct osmo_fd *fd)
|
||||
{
|
||||
struct telnet_connection *conn = (struct telnet_connection*)fd->data;
|
||||
|
||||
close(fd->fd);
|
||||
bsc_unregister_fd(fd);
|
||||
osmo_fd_unregister(fd);
|
||||
|
||||
if (conn->dbg) {
|
||||
log_del_target(conn->dbg);
|
||||
|
@ -121,7 +121,7 @@ int telnet_close_client(struct bsc_fd *fd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int client_data(struct bsc_fd *fd, unsigned int what)
|
||||
static int client_data(struct osmo_fd *fd, unsigned int what)
|
||||
{
|
||||
struct telnet_connection *conn = fd->data;
|
||||
int rc = 0;
|
||||
|
@ -144,7 +144,7 @@ static int client_data(struct bsc_fd *fd, unsigned int what)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int telnet_new_connection(struct bsc_fd *fd, unsigned int what)
|
||||
static int telnet_new_connection(struct osmo_fd *fd, unsigned int what)
|
||||
{
|
||||
struct telnet_connection *connection;
|
||||
struct sockaddr_in sockaddr;
|
||||
|
@ -162,7 +162,7 @@ static int telnet_new_connection(struct bsc_fd *fd, unsigned int what)
|
|||
connection->fd.fd = new_connection;
|
||||
connection->fd.when = BSC_FD_READ;
|
||||
connection->fd.cb = client_data;
|
||||
bsc_register_fd(&connection->fd);
|
||||
osmo_fd_register(&connection->fd);
|
||||
llist_add_tail(&connection->entry, &active_connections);
|
||||
|
||||
print_welcome(new_connection);
|
||||
|
@ -182,7 +182,7 @@ static int telnet_new_connection(struct bsc_fd *fd, unsigned int what)
|
|||
void vty_event(enum event event, int sock, struct vty *vty)
|
||||
{
|
||||
struct telnet_connection *connection = vty->priv;
|
||||
struct bsc_fd *bfd = &connection->fd;
|
||||
struct osmo_fd *bfd = &connection->fd;
|
||||
|
||||
if (vty->type != VTY_TERM)
|
||||
return;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <osmocom/core/write_queue.h>
|
||||
|
||||
int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what)
|
||||
int write_queue_bfd_cb(struct osmo_fd *fd, unsigned int what)
|
||||
{
|
||||
struct write_queue *queue;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ int main(int argc, char** argv)
|
|||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
while (1) {
|
||||
bsc_select_main(0);
|
||||
osmo_select_main(0);
|
||||
}
|
||||
#else
|
||||
printf("Select not supported on this platform!\n");
|
||||
|
|
Loading…
Reference in New Issue