libosmocore 1.13.1.1-afb4 Osmocom core library

write_queue.h
Go to the documentation of this file.
1
3/*
4 * (C) 2010 by Holger Hans Peter Freyther
5 * (C) 2010 by On-Waves
6 *
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 */
20#pragma once
21
26#include <osmocom/core/select.h>
27#include <osmocom/core/msgb.h>
28
30 struct osmo_wqueue {
32 struct osmo_fd bfd;
34 unsigned int max_length;
36 unsigned int current_length;
37
39 struct llist_head msg_queue;
40
42 int (*read_cb)(struct osmo_fd *fd);
44 int (*write_cb)(struct osmo_fd *fd, struct msgb *msg);
46 int (*except_cb)(struct osmo_fd *fd);
47};
48
49 void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length);
50 void osmo_wqueue_clear(struct osmo_wqueue *queue);
51 int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data);
52 int osmo_wqueue_enqueue_quiet(struct osmo_wqueue *queue, struct msgb *data);
53 size_t osmo_wqueue_set_maxlen(struct osmo_wqueue *queue, unsigned int len);
54 int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what);
55
len
static size_t len(const char *str)
data
uint8_t data[0]
osmo_wqueue_bfd_cb
int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
Select loop function for write queue handling.
Definition: write_queue.c:40
osmo_wqueue_set_maxlen
size_t osmo_wqueue_set_maxlen(struct osmo_wqueue *queue, unsigned int len)
Update write queue length & drop excess messages.
Definition: write_queue.c:158
osmo_wqueue_enqueue_quiet
int osmo_wqueue_enqueue_quiet(struct osmo_wqueue *queue, struct msgb *data)
Enqueue a new Message buffers into a write queue (without logging full queue events)
Definition: write_queue.c:108
osmo_wqueue_clear
void osmo_wqueue_clear(struct osmo_wqueue *queue)
Clear a osmo_wqueue.
Definition: write_queue.c:140
osmo_wqueue_enqueue
int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data)
Enqueue a new Message buffers into a write queue.
Definition: write_queue.c:124
osmo_wqueue_init
void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length)
Initialize a osmo_wqueue structure.
Definition: write_queue.c:92
msg
uint8_t msg[0]
msgb.h
select.h
libmnl integration
llist_head
(double) linked list header structure
Definition: linuxlist.h:46
msgb
Osmocom message buffer.
Definition: msgb.h:31
osmo_fd
Structure representing a file dsecriptor.
Definition: select.h:31
osmo_fd::fd
int fd
actual operating-system level file decriptor
Definition: select.h:35
osmo_wqueue
write queue instance
Definition: write_queue.h:30
osmo_wqueue::msg_queue
struct llist_head msg_queue
actual linked list implementing the queue
Definition: write_queue.h:39
osmo_wqueue::max_length
unsigned int max_length
maximum length of write queue
Definition: write_queue.h:34
osmo_wqueue::bfd
struct osmo_fd bfd
osmocom file descriptor
Definition: write_queue.h:32
osmo_wqueue::current_length
unsigned int current_length
current length of write queue
Definition: write_queue.h:36
osmo_wqueue::except_cb
int(* except_cb)(struct osmo_fd *fd)
call-back in case qeueue has exceptions.
Definition: write_queue.h:46
osmo_wqueue::write_cb
int(* write_cb)(struct osmo_fd *fd, struct msgb *msg)
call-back in case qeueue is writable.
Definition: write_queue.h:44
osmo_wqueue::read_cb
int(* read_cb)(struct osmo_fd *fd)
call-back in case qeueue is readable.
Definition: write_queue.h:42