]> git.proxmox.com Git - mirror_ovs.git/blame - lib/byteq.h
netdev-offload-tc: Use single 'once' variable for probing tc features
[mirror_ovs.git] / lib / byteq.h
CommitLineData
00ecc5ce 1/* Copyright (c) 2008, 2009, 2013 Nicira, Inc.
064af421 2 *
a14bc59f
BP
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
064af421 6 *
a14bc59f 7 * http://www.apache.org/licenses/LICENSE-2.0
064af421 8 *
a14bc59f
BP
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
064af421
BP
14 */
15
16#ifndef BYTEQ_H
17#define BYTEQ_H 1
18
19#include <stdbool.h>
20#include <stddef.h>
21#include <stdint.h>
22
064af421
BP
23/* General-purpose circular queue of bytes. */
24struct byteq {
00ecc5ce
BP
25 uint8_t *buffer; /* Circular queue. */
26 unsigned int size; /* Number of bytes allocated for 'buffer'. */
064af421
BP
27 unsigned int head; /* Head of queue. */
28 unsigned int tail; /* Chases the head. */
29};
30
00ecc5ce 31void byteq_init(struct byteq *, uint8_t *buffer, size_t size);
064af421
BP
32int byteq_used(const struct byteq *);
33int byteq_avail(const struct byteq *);
34bool byteq_is_empty(const struct byteq *);
35bool byteq_is_full(const struct byteq *);
36void byteq_put(struct byteq *, uint8_t c);
37void byteq_putn(struct byteq *, const void *, size_t n);
38void byteq_put_string(struct byteq *, const char *);
39uint8_t byteq_get(struct byteq *);
40int byteq_write(struct byteq *, int fd);
41int byteq_read(struct byteq *, int fd);
42
1c617a49
BP
43uint8_t *byteq_head(struct byteq *);
44int byteq_headroom(const struct byteq *);
45void byteq_advance_head(struct byteq *, unsigned int n);
46int byteq_tailroom(const struct byteq *);
47const uint8_t *byteq_tail(const struct byteq *);
48void byteq_advance_tail(struct byteq *, unsigned int n);
49
064af421 50#endif /* byteq.h */