aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/rs232-write.c5
-rw-r--r--examples/stream-client.c5
-rw-r--r--examples/stream-server.c5
-rw-r--r--src/datagram.c11
-rw-r--r--src/rs232.c4
-rw-r--r--src/stream.c16
6 files changed, 10 insertions, 36 deletions
diff --git a/examples/rs232-write.c b/examples/rs232-write.c
index 508c64a..8639c49 100644
--- a/examples/rs232-write.c
+++ b/examples/rs232-write.c
@@ -376,10 +376,7 @@ int main(void)
LOGP(DRS232TEST, LOGL_ERROR, "OOM\n");
exit(EXIT_FAILURE);
}
- kbd_ofd->fd = STDIN_FILENO;
- kbd_ofd->when = OSMO_FD_READ;
- kbd_ofd->data = NULL;
- kbd_ofd->cb = kbd_cb;
+ osmo_fd_setup(kbd_ofd, STDIN_FILENO, OSMO_FD_READ, kbd_cb, NULL, 0);
rc = osmo_fd_register(kbd_ofd);
if (rc < 0) {
LOGP(DRS232TEST, LOGL_ERROR, "FD Register\n");
diff --git a/examples/stream-client.c b/examples/stream-client.c
index fd1a517..428402e 100644
--- a/examples/stream-client.c
+++ b/examples/stream-client.c
@@ -141,10 +141,7 @@ int main(void)
LOGP(DSTREAMTEST, LOGL_ERROR, "OOM\n");
exit(EXIT_FAILURE);
}
- kbd_ofd->fd = STDIN_FILENO;
- kbd_ofd->when = OSMO_FD_READ;
- kbd_ofd->data = conn;
- kbd_ofd->cb = kbd_cb;
+ osmo_fd_setup(kbd_ofd, STDIN_FILENO, OSMO_FD_READ, kbd_cb, conn, 0);
rc = osmo_fd_register(kbd_ofd);
if (rc < 0) {
LOGP(DSTREAMTEST, LOGL_ERROR, "FD Register\n");
diff --git a/examples/stream-server.c b/examples/stream-server.c
index 4946e13..e4ca480 100644
--- a/examples/stream-server.c
+++ b/examples/stream-server.c
@@ -165,10 +165,7 @@ int main(void)
LOGP(DSTREAMTEST, LOGL_ERROR, "OOM\n");
exit(EXIT_FAILURE);
}
- kbd_ofd->fd = STDIN_FILENO;
- kbd_ofd->when = OSMO_FD_READ;
- kbd_ofd->data = srv;
- kbd_ofd->cb = kbd_cb;
+ osmo_fd_setup(kbd_ofd, STDIN_FILENO, OSMO_FD_READ, kbd_cb, srv, 0);
osmo_fd_register(kbd_ofd);
LOGP(DSTREAMTEST, LOGL_NOTICE, "Entering main loop on %s\n", osmo_stream_srv_link_get_sockname(srv));
diff --git a/src/datagram.c b/src/datagram.c
index d2233d5..4bc7bed 100644
--- a/src/datagram.c
+++ b/src/datagram.c
@@ -135,11 +135,7 @@ struct osmo_dgram_tx *osmo_dgram_tx_create(void *ctx)
if (!conn)
return NULL;
- conn->ofd.fd = -1;
- conn->ofd.when |= OSMO_FD_READ;
- conn->ofd.priv_nr = 0; /* XXX */
- conn->ofd.cb = osmo_dgram_tx_fd_cb;
- conn->ofd.data = conn;
+ osmo_fd_setup(&conn->ofd, -1, OSMO_FD_READ, osmo_dgram_tx_fd_cb, conn, 0);
INIT_LLIST_HEAD(&conn->tx_queue);
return conn;
@@ -309,10 +305,7 @@ struct osmo_dgram_rx *osmo_dgram_rx_create(void *ctx)
if (!conn)
return NULL;
- conn->ofd.fd = -1;
- conn->ofd.when |= OSMO_FD_READ;
- conn->ofd.cb = osmo_dgram_rx_cb;
- conn->ofd.data = conn;
+ osmo_fd_setup(&conn->ofd, -1, OSMO_FD_READ, osmo_dgram_rx_cb, conn, 0);
return conn;
}
diff --git a/src/rs232.c b/src/rs232.c
index 4ebc7b9..8ee658a 100644
--- a/src/rs232.c
+++ b/src/rs232.c
@@ -223,9 +223,7 @@ int osmo_rs232_open(struct osmo_rs232 *r)
return rc;
}
- bfd->when = OSMO_FD_READ;
- bfd->cb = serial_fd_cb;
- bfd->data = r;
+ osmo_fd_setup(bfd, bfd->fd, OSMO_FD_READ, serial_fd_cb, r, 0);
rc = osmo_fd_register(bfd);
if (rc < 0) {
diff --git a/src/stream.c b/src/stream.c
index fc51a49..2bb3e75 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -680,8 +680,7 @@ int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect)
osmo_stream_cli_reconnect(cli);
return ret;
}
- cli->ofd.fd = ret;
- cli->ofd.when = OSMO_FD_READ | OSMO_FD_WRITE;
+ osmo_fd_setup(&cli->ofd, ret, OSMO_FD_READ | OSMO_FD_WRITE, cli->ofd.cb, cli->ofd.data, cli->ofd.priv_nr);
if (cli->flags & OSMO_STREAM_CLI_F_NODELAY) {
ret = setsockopt_nodelay(cli->ofd.fd, cli->proto, 1);
@@ -753,8 +752,7 @@ int osmo_stream_cli_open(struct osmo_stream_cli *cli)
osmo_stream_cli_reconnect(cli);
return ret;
}
- cli->ofd.fd = ret;
- cli->ofd.when = OSMO_FD_READ | OSMO_FD_WRITE;
+ osmo_fd_setup(&cli->ofd, ret, OSMO_FD_READ | OSMO_FD_WRITE, cli->ofd.cb, cli->ofd.data, cli->ofd.priv_nr);
if (cli->flags & OSMO_STREAM_CLI_F_NODELAY) {
ret = setsockopt_nodelay(cli->ofd.fd, cli->proto, 1);
@@ -902,10 +900,7 @@ struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx)
return NULL;
link->proto = IPPROTO_TCP;
- link->ofd.fd = -1;
- link->ofd.when |= OSMO_FD_READ | OSMO_FD_WRITE;
- link->ofd.cb = osmo_stream_srv_fd_cb;
- link->ofd.data = link;
+ osmo_fd_setup(&link->ofd, -1, OSMO_FD_READ | OSMO_FD_WRITE, osmo_stream_srv_fd_cb, link, 0);
return link;
}
@@ -1206,10 +1201,7 @@ osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link,
return NULL;
}
conn->srv = link;
- conn->ofd.fd = fd;
- conn->ofd.data = conn;
- conn->ofd.cb = osmo_stream_srv_cb;
- conn->ofd.when = OSMO_FD_READ;
+ osmo_fd_setup(&conn->ofd, fd, OSMO_FD_READ, osmo_stream_srv_cb, conn, 0);
conn->cb = cb;
conn->closed_cb = closed_cb;
conn->data = data;