libosmo-netif
0.2.0-dirty
Osmocom network interface library
|
00001 #pragma once 00002 00003 #include <stdint.h> 00004 #include <stdbool.h> 00005 #include <time.h> 00006 00007 #include <osmocom/core/timer.h> 00008 00017 typedef void (*osmo_jibuf_dequeue_cb)(struct msgb *msg, void *data); 00018 00020 struct osmo_jibuf { 00021 void *talloc_ctx; 00022 bool started; 00023 struct osmo_timer_list timer; 00024 struct llist_head msg_list; /* sorted by output ts */ 00025 uint32_t min_delay; /* in msec */ 00026 uint32_t max_delay; /* in msec */ 00027 uint32_t threshold_delay; /* in msec */ 00028 00029 osmo_jibuf_dequeue_cb dequeue_cb; 00030 void *dequeue_cb_data; 00031 00032 /* number of pkt drops since we last changed the buffer size */ 00033 uint32_t last_dropped; 00034 uint32_t consecutive_drops; 00035 00036 uint32_t ref_rx_ts; 00037 uint32_t ref_tx_ts; 00038 uint16_t ref_tx_seq; 00039 00040 struct timeval last_enqueue_time; 00041 struct timeval next_dequeue_time; 00042 00043 bool skew_enabled; 00044 int32_t skew_us; /* src clock skew, in usec */ 00045 00046 struct { 00047 uint32_t total_enqueued; 00048 uint64_t total_dropped; 00049 } stats; 00050 }; 00051 00052 00053 struct osmo_jibuf *osmo_jibuf_alloc(void *talloc_ctx); 00054 00055 void osmo_jibuf_delete(struct osmo_jibuf *jb); 00056 00057 int osmo_jibuf_enqueue(struct osmo_jibuf *jb, struct msgb *msg); 00058 00059 bool osmo_jibuf_empty(struct osmo_jibuf *jb); 00060 00061 void osmo_jibuf_set_min_delay(struct osmo_jibuf *jb, uint32_t min_delay); 00062 void osmo_jibuf_set_max_delay(struct osmo_jibuf *jb, uint32_t max_delay); 00063 00064 void osmo_jibuf_enable_skew_compensation(struct osmo_jibuf *jb, bool enable); 00065 00066 void osmo_jibuf_set_dequeue_cb(struct osmo_jibuf *jb, osmo_jibuf_dequeue_cb dequeue_cb, void* cb_data); 00067