]> git.proxmox.com Git - ovs.git/blame - lib/byteq.h
ofproto-dpif: Print slow-path actions instead of "drop" in dump-flows.
[ovs.git] / lib / byteq.h
CommitLineData
e0edde6f 1/* Copyright (c) 2008, 2009 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
23/* Maximum number of bytes in a byteq. */
24#define BYTEQ_SIZE 512
25
26/* General-purpose circular queue of bytes. */
27struct byteq {
28 uint8_t buffer[BYTEQ_SIZE]; /* Circular queue. */
29 unsigned int head; /* Head of queue. */
30 unsigned int tail; /* Chases the head. */
31};
32
33void byteq_init(struct byteq *);
34int byteq_used(const struct byteq *);
35int byteq_avail(const struct byteq *);
36bool byteq_is_empty(const struct byteq *);
37bool byteq_is_full(const struct byteq *);
38void byteq_put(struct byteq *, uint8_t c);
39void byteq_putn(struct byteq *, const void *, size_t n);
40void byteq_put_string(struct byteq *, const char *);
41uint8_t byteq_get(struct byteq *);
42int byteq_write(struct byteq *, int fd);
43int byteq_read(struct byteq *, int fd);
44
1c617a49
BP
45uint8_t *byteq_head(struct byteq *);
46int byteq_headroom(const struct byteq *);
47void byteq_advance_head(struct byteq *, unsigned int n);
48int byteq_tailroom(const struct byteq *);
49const uint8_t *byteq_tail(const struct byteq *);
50void byteq_advance_tail(struct byteq *, unsigned int n);
51
064af421 52#endif /* byteq.h */