7 #include <netinet/sctp.h> 15 #include "../config.h" 17 #define OSMO_IO_DEFAULT_MSGB_SIZE 1024 18 #define OSMO_IO_DEFAULT_MSGB_HEADROOM 128 21 #define OSMO_IO_BACKEND_DEFAULT "POLL" 23 #if defined(HAVE_URING) 38 #define IOFD_FLAG_CLOSED (1<<0) 39 #define IOFD_FLAG_IN_CALLBACK (1<<1) 40 #define IOFD_FLAG_TO_FREE (1<<2) 41 #define IOFD_FLAG_NOTIFY_CONNECTED (1<<3) 42 #define IOFD_FLAG_FD_REGISTERED (1<<4) 44 #define IOFD_FLAG_SET(iofd, flag) \ 45 (iofd)->flags |= (flag) 47 #define IOFD_FLAG_UNSET(iofd, flag) \ 48 (iofd)->flags &= ~(flag) 50 #define IOFD_FLAG_ISSET(iofd, flag) ((iofd)->flags & (flag)) Definition: osmo_io_internal.h:116
void(* read_enable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:33
struct osmo_io_ops io_ops
send/recv (msg) callback functions
Definition: osmo_io_internal.h:67
struct msgb * iofd_msgb_pending(struct osmo_io_fd *iofd)
return the pending msgb in iofd or NULL if there is none
Definition: osmo_io.c:180
void(* write_disable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:32
struct msgb * iofd_msgb_alloc(struct osmo_io_fd *iofd)
convenience wrapper to call msgb_alloc with parameters from osmo_io_fd
Definition: osmo_io.c:171
io(_uring) abstraction osmo fd compatibility
Definition: osmo_io_internal.h:117
struct msgb * pending
Pending msgb to keep partial data during segmentation.
Definition: osmo_io_internal.h:69
Osmocom message buffer.
Definition: msgb.h:31
void iofd_msghdr_free(struct iofd_msghdr *msghdr)
Free the msghdr.
Definition: osmo_io.c:163
serialized version of 'struct msghdr' employed by sendmsg/recvmsg
Definition: osmo_io_internal.h:124
const void * ctx
talloc context from which to allocate msgb when reading
Definition: osmo_io_internal.h:81
Definition: osmo_io_internal.h:119
unsigned int size
size of msgb to allocate (excluding headroom)
Definition: osmo_io_internal.h:83
bool write_enabled
Definition: osmo_io_internal.h:103
uint32_t flags
flags to guard closing/freeing of iofd
Definition: osmo_io_internal.h:61
int(* unregister_fd)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:29
iofd_msg_action
Definition: osmo_io_internal.h:113
struct osmo_io_fd::@40::@41 poll
void iofd_handle_send_completion(struct osmo_io_fd *iofd, int rc, struct iofd_msghdr *msghdr)
completion handler: Internal function called by osmo_io_backend after a given I/O operation has compl...
Definition: osmo_io.c:381
unsigned int current_length
current length of write queue
Definition: osmo_io_internal.h:92
Definition: osmo_io_internal.h:148
int iofd_txqueue_enqueue(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr)
Enqueue a message to be sent.
Definition: osmo_io.c:210
int(* close)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:30
struct iofd_msghdr * iofd_txqueue_dequeue(struct osmo_io_fd *iofd)
Dequeue a message from the front.
Definition: osmo_io.c:245
enum osmo_io_fd_mode mode
type of read/write mode to use
Definition: osmo_io_internal.h:58
void iofd_handle_segmented_read(struct osmo_io_fd *iofd, struct msgb *msg, int rc)
Restore message boundaries on read() and pass individual messages to the read callback.
Definition: osmo_io.c:328
bool read_enabled
Definition: osmo_io_internal.h:102
void * data
data pointer passed through to call-back function
Definition: osmo_io_internal.h:72
Definition: osmo_io_internal.h:118
Definition: osmo_io_internal.h:52
struct osmo_io_fd::@38 msgb_alloc
Simple doubly linked list implementation.
osmo_io_fd_mode
The mode of an osmo_io_fd determines if read/write, recvfrom/sendmsg or recvmsg/sendmsg semantics are...
Definition: osmo_io.h:64
struct msghdr hdr
the 'struct msghdr' we are wrapping/ecapsulating here
Definition: osmo_io_internal.h:129
(double) linked list header structure
Definition: linuxlist.h:46
struct osmo_fd ofd
Definition: osmo_io_internal.h:99
struct msgb * msg
message-buffer containing data for this I/O operation
Definition: osmo_io_internal.h:139
char * name
human-readable name to associte with fd
Definition: osmo_io_internal.h:64
char cmsg[0]
control message buffer for passing sctp_sndrcvinfo along
Definition: osmo_io_internal.h:144
int fd
actual operating-system level file decriptor
Definition: osmo_io_internal.h:56
struct osmo_io_fd * iofd
I/O file descriptor on which we perform this I/O operation.
Definition: osmo_io_internal.h:141
struct llist_head list
linked list for internal management
Definition: osmo_io_internal.h:54
Definition: osmo_io_internal.h:27
size_t cmsg_size
size of iofd_msghdr.cmsg[] when allocated in recvmsg path
Definition: osmo_io_internal.h:77
struct llist_head list
entry into osmo_io_fd.tx_queue.msg_queue
Definition: osmo_io_internal.h:126
enum iofd_msg_action action
Definition: osmo_io_internal.h:127
void * read_msghdr
Definition: osmo_io_internal.h:104
I/O operations (call-back functions) related to an osmo_io_fd.
Definition: osmo_io.h:93
struct iovec iov[1]
io-vector we need to pass as argument to sendmsg/recvmsg; is set up to point into msg below ...
Definition: osmo_io_internal.h:134
struct msgb * iofd_msgb_pending_or_alloc(struct osmo_io_fd *iofd)
Return the pending msgb or allocate and return a new one.
Definition: osmo_io.c:191
const struct iofd_backend_ops iofd_poll_ops
Definition: osmo_io_poll.c:190
iofd_seg_act
Definition: osmo_io_internal.h:147
void(* notify_connected)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:35
struct osmo_fd connect_ofd
Definition: osmo_io_internal.h:108
Definition: osmo_io_internal.h:115
unsigned int max_length
maximum length of write queue
Definition: osmo_io_internal.h:90
struct osmo_io_fd::@39 tx_queue
void(* write_enable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:31
Definition: osmo_io_internal.h:150
void iofd_handle_recv(struct osmo_io_fd *iofd, struct msgb *msg, int rc, struct iofd_msghdr *msghdr)
completion handler: Internal function called by osmo_io_backend after a given I/O operation has compl...
Definition: osmo_io.c:357
struct osmo_sockaddr osa
socket address of the remote peer
Definition: osmo_io_internal.h:131
unsigned int headroom
headroom to allocate when allocating msgb's
Definition: osmo_io_internal.h:85
int(* register_fd)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:28
Definition: osmo_io_internal.h:114
void iofd_txqueue_enqueue_front(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr)
Enqueue a message at the front.
Definition: osmo_io.c:231
struct llist_head msg_queue
actual linked list implementing the transmit queue
Definition: osmo_io_internal.h:94
Structure representing a file dsecriptor.
Definition: select.h:31
Osmocom socket convenience functions.
void(* read_disable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:34
int flags
flags we pass as argument to sendmsg / recvmsg
Definition: osmo_io_internal.h:136
void * write_msghdr
Definition: osmo_io_internal.h:105
Definition: osmo_io_internal.h:149
unsigned int priv_nr
private number, extending data
Definition: osmo_io_internal.h:74
struct iofd_msghdr * iofd_msghdr_alloc(struct osmo_io_fd *iofd, enum iofd_msg_action action, struct msgb *msg, size_t cmsg_size)
Allocate the msghdr.
Definition: osmo_io.c:131
struct osmo_io_fd::@40::@42 uring