aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/datagram.c11
-rw-r--r--src/rs232.c4
-rw-r--r--src/stream.c16
3 files changed, 7 insertions, 24 deletions
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;