ble_gatt_client
|
set of function to manage io part of the mainloop feature More...
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include "mainloop.h"
#include "util.h"
#include "io.h"
Go to the source code of this file.
Data Structures | |
struct | io |
data structure to manage io More... | |
Functions | |
static struct io * | io_ref (struct io *io) |
static void | io_unref (struct io *io) |
static void | io_cleanup (void *user_data) |
static void | io_callback (int fd, uint32_t events, void *user_data) |
struct io * | io_new (int fd) |
void | io_destroy (struct io *io) |
int | io_get_fd (struct io *io) |
bool | io_set_close_on_destroy (struct io *io, bool do_close) |
bool | io_set_read_handler (struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy) |
bool | io_set_write_handler (struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy) |
bool | io_set_disconnect_handler (struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy) |
ssize_t | io_send (struct io *io, const struct iovec *iov, int iovcnt) |
bool | io_shutdown (struct io *io) |
set of function to manage io part of the mainloop feature
Definition in file io-mainloop.c.
|
static |
depending on events epoll event and read, write or disconnect prepare for the appropriate call back calling mainloop_modify_fd
epoll event value (some 'ored' combination allowed) EPOLLRDHUP | EPOLLHUP | EPOLLERR | EPOLLIN | EPOLLOUT )
fd | file descriptor data structure (can be socket) |
events | epoll event |
user_data | pointer to io data structure |
Definition at line 128 of file io-mainloop.c.
References io::disconnect_callback, io::disconnect_data, io::disconnect_destroy, io::events, io::fd, io_ref(), io_unref(), mainloop_modify_fd(), mainloop_remove_fd(), io::read_callback, io::read_data, io::read_destroy, io::write_callback, io::write_data, and io::write_destroy.
Referenced by io_new().
|
static |
io data structure house keeping
user_data | pointer to io data structure |
Definition at line 100 of file io-mainloop.c.
References io::close_on_destroy, io::disconnect_data, io::disconnect_destroy, io::fd, io::read_data, io::read_destroy, io::write_data, and io::write_destroy.
Referenced by io_new().
void io_destroy | ( | struct io * | io | ) |
remove the fd from the 'mainloop' and reset all io call back, unref the io data structure
io | pointer to the io data structure |
Definition at line 226 of file io-mainloop.c.
References io::disconnect_callback, io::fd, io_unref(), mainloop_remove_fd(), io::read_callback, and io::write_callback.
Referenced by bt_att_free(), and disconnect_cb().
int io_get_fd | ( | struct io * | io | ) |
return the fd (file descriptor, can be a socket) attached to the io data structure
io | pointer to io data structure |
Definition at line 246 of file io-mainloop.c.
References io::fd.
struct io* io_new | ( | int | fd | ) |
create a new io data structure
fd | file descriptor (includes socket) |
Definition at line 197 of file io-mainloop.c.
References io::close_on_destroy, io::events, io::fd, io_callback(), io_cleanup(), io_ref(), mainloop_add_fd(), and new0.
Referenced by bt_att_new().
Increment &io->ref_count
io | point to io data structure |
Definition at line 70 of file io-mainloop.c.
References io::ref_count.
Referenced by io_callback(), and io_new().
ssize_t io_send | ( | struct io * | io, |
const struct iovec * | iov, | ||
int | iovcnt | ||
) |
send data to the underlying socket (actual write)
io | io structure which describe the underlying socket and its context |
iov | pointer to pdu, pdu length structure |
iovcnt | number of pdu to send (iov is an array) |
Definition at line 395 of file io-mainloop.c.
References io::fd.
Referenced by can_write_data().
bool io_set_close_on_destroy | ( | struct io * | io, |
bool | do_close | ||
) |
io | |
do_close |
Definition at line 260 of file io-mainloop.c.
References io::close_on_destroy.
Referenced by bt_att_set_close_on_unref().
bool io_set_disconnect_handler | ( | struct io * | io, |
io_callback_func_t | callback, | ||
void * | user_data, | ||
io_destroy_func_t | destroy | ||
) |
io | |
callback | |
user_data | |
destroy |
Definition at line 356 of file io-mainloop.c.
References io::disconnect_callback, io::disconnect_data, io::disconnect_destroy, io::events, io::fd, and mainloop_modify_fd().
Referenced by bt_att_new().
bool io_set_read_handler | ( | struct io * | io, |
io_callback_func_t | callback, | ||
void * | user_data, | ||
io_destroy_func_t | destroy | ||
) |
io | |
callback | |
user_data | |
destroy |
Definition at line 278 of file io-mainloop.c.
References io::events, io::fd, mainloop_modify_fd(), io::read_callback, io::read_data, and io::read_destroy.
Referenced by bt_att_new().
bool io_set_write_handler | ( | struct io * | io, |
io_callback_func_t | callback, | ||
void * | user_data, | ||
io_destroy_func_t | destroy | ||
) |
io | |
callback | |
user_data | |
destroy |
Definition at line 317 of file io-mainloop.c.
References io::events, io::fd, mainloop_modify_fd(), io::write_callback, io::write_data, and io::write_destroy.
Referenced by wakeup_writer().
bool io_shutdown | ( | struct io * | io | ) |
io |
Definition at line 417 of file io-mainloop.c.
References io::fd.
Referenced by can_read_data(), handle_conf(), handle_rsp(), and timeout_cb().
|
static |
Decrement &io->ref_count and free io data structure when count reaches 0
io | point to io data structure |
Definition at line 85 of file io-mainloop.c.
References io::ref_count.
Referenced by io_callback(), and io_destroy().