libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-transport-sequencer.h
Go to the documentation of this file.
1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2026 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24#if !defined(__LWS_TRANSPORT_SEQUENCER_H__)
25#define __LWS_TRANSPORT_SEQUENCER_H__
26
27#include <stdint.h>
28#include <stddef.h>
29
30#if defined(LWS_WITH_TRANSPORT_SEQUENCER)
31
32
41
42struct lws_transport_sequencer;
43
44typedef int (*lws_transport_sequencer_cb_t)(struct lws_transport_sequencer *ts,
45 uint64_t offset, uint8_t *buf,
46 size_t *len);
47
48typedef struct lws_transport_sequencer_sack_block {
49 uint64_t start;
50 uint32_t len;
51} lws_transport_sequencer_sack_block_t;
52
53typedef struct lws_transport_sequencer_ops {
54 const char *name;
55
56 int (*tx_chunk)(struct lws_transport_sequencer *ts, uint64_t offset,
57 const uint8_t *buf, size_t len);
60
61 int (*tx_ack)(struct lws_transport_sequencer *ts, uint64_t offset,
62 size_t len);
64
65 int (*on_rx_data)(struct lws_transport_sequencer *ts, uint64_t offset,
66 const uint8_t *buf, size_t len);
68
69 void (*on_state_change)(struct lws_transport_sequencer *ts, int state, int status);
73
74} lws_transport_sequencer_ops_t;
75
76typedef struct lws_transport_sequencer_stats {
77 uint32_t tx_packets;
78 uint32_t tx_retries;
79 uint32_t rx_packets;
80 uint32_t rx_duplicates;
81 uint64_t tx_bytes;
82 uint64_t rx_bytes;
83 uint64_t ack_offset;
84} lws_transport_sequencer_stats_t;
85
86typedef struct lws_transport_sequencer_info {
87 struct lws_context *cx;
88 const lws_transport_sequencer_ops_t *ops;
89 const lws_retry_bo_t *retry_policy;
90 void *user_data;
91
92 uint32_t window_size;
94} lws_transport_sequencer_info_t;
95
101LWS_VISIBLE LWS_EXTERN struct lws_transport_sequencer *
102lws_transport_sequencer_create(const lws_transport_sequencer_info_t *i);
103
110lws_transport_sequencer_destroy(struct lws_transport_sequencer **pts);
111
120lws_transport_sequencer_write(struct lws_transport_sequencer *ts,
121 const uint8_t *buf, size_t len);
122
134lws_transport_sequencer_write_at(struct lws_transport_sequencer *ts,
135 uint64_t offset, const uint8_t *buf, size_t len);
136
145lws_transport_sequencer_acknowledge(struct lws_transport_sequencer *ts,
146 uint64_t offset, size_t len, int status);
147
158lws_transport_sequencer_acknowledge_sack(struct lws_transport_sequencer *ts,
159 uint64_t cumulative_offset,
160 const lws_transport_sequencer_sack_block_t *blocks,
161 size_t num_blocks, int status);
162
163LWS_VISIBLE LWS_EXTERN const lws_transport_sequencer_stats_t *
164lws_transport_sequencer_get_stats(struct lws_transport_sequencer *ts);
165
175lws_transport_sequencer_rx(struct lws_transport_sequencer *ts,
176 uint64_t offset, const uint8_t *buf, size_t len);
177
188lws_transport_sequencer_get_sack_blocks(struct lws_transport_sequencer *ts,
189 lws_transport_sequencer_sack_block_t *blocks,
190 size_t max_blocks);
191
192LWS_VISIBLE LWS_EXTERN const lws_transport_sequencer_info_t *
193lws_transport_sequencer_get_info(struct lws_transport_sequencer *ts);
194
196
197#endif /* LWS_WITH_TRANSPORT_SEQUENCER */
198
199#endif /* __LWS_TRANSPORT_SEQUENCER_H__ */
unsigned int uint32_t
#define LWS_EXTERN
unsigned char uint8_t
#define LWS_VISIBLE
struct lws_retry_bo lws_retry_bo_t