]> git.proxmox.com Git - mirror_ovs.git/blame - lib/stream.h
ovsdb-idl: Fix iteration over tracked rows with no actual data.
[mirror_ovs.git] / lib / stream.h
CommitLineData
c34b65c7 1/*
c2e3cbaf 2 * Copyright (c) 2009, 2010, 2011, 2013, 2015 Nicira, Inc.
c34b65c7
BP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef STREAM_H
18#define STREAM_H 1
19
c34b65c7
BP
20#include <stdbool.h>
21#include <stddef.h>
22#include <stdint.h>
c55acc2e 23#include <sys/types.h>
4408d18a 24#include "openvswitch/types.h"
ac4c900d 25#include "socket-util.h"
e618b42f 26#include "util.h"
c34b65c7 27
c34b65c7
BP
28struct pstream;
29struct stream;
e618b42f 30struct vlog_module;
c34b65c7 31
9467fe62 32void stream_usage(const char *name, bool active, bool passive, bool bootstrap);
c34b65c7
BP
33
34/* Bidirectional byte streams. */
26ad129e 35int stream_verify_name(const char *name);
f125905c 36int stream_open(const char *name, struct stream **, uint8_t dscp);
77f42ca5 37int stream_open_block(int error, long long int timeout, struct stream **);
c34b65c7
BP
38void stream_close(struct stream *);
39const char *stream_get_name(const struct stream *);
c34b65c7
BP
40int stream_connect(struct stream *);
41int stream_recv(struct stream *, void *buffer, size_t n);
42int stream_send(struct stream *, const void *buffer, size_t n);
43
539e96f6
BP
44void stream_run(struct stream *);
45void stream_run_wait(struct stream *);
46
c34b65c7
BP
47enum stream_wait_type {
48 STREAM_CONNECT,
49 STREAM_RECV,
50 STREAM_SEND
51};
52void stream_wait(struct stream *, enum stream_wait_type);
53void stream_connect_wait(struct stream *);
54void stream_recv_wait(struct stream *);
55void stream_send_wait(struct stream *);
c19ae4cc
LR
56void stream_set_peer_id(struct stream *, const char *);
57const char *stream_get_peer_id(const struct stream *);
c34b65c7
BP
58
59/* Passive streams: listeners for incoming stream connections. */
26ad129e 60int pstream_verify_name(const char *name);
f125905c 61int pstream_open(const char *name, struct pstream **, uint8_t dscp);
c34b65c7
BP
62const char *pstream_get_name(const struct pstream *);
63void pstream_close(struct pstream *);
64int pstream_accept(struct pstream *, struct stream **);
8d76bcca 65int pstream_accept_block(struct pstream *, struct stream **);
c34b65c7 66void pstream_wait(struct pstream *);
798e1352
BP
67
68ovs_be16 pstream_get_bound_port(const struct pstream *);
f39dc942 69\f
cc1ad532 70/* Convenience functions. */
f39dc942 71
ca843648
JP
72int stream_open_with_default_port(const char *name,
73 uint16_t default_port,
74 struct stream **,
75 uint8_t dscp);
76int pstream_open_with_default_port(const char *name,
77 uint16_t default_port,
78 struct pstream **,
f125905c 79 uint8_t dscp);
ca843648 80bool stream_parse_target_with_default_port(const char *target,
1bb01121 81 int default_port,
e731d71b 82 struct sockaddr_storage *ss);
f1936eb6 83int stream_or_pstream_needs_probes(const char *name);
ac4c900d 84
1e3c0047
BP
85/* Error reporting. */
86
87enum stream_content_type {
88 STREAM_UNKNOWN,
89 STREAM_OPENFLOW,
90 STREAM_SSL,
91 STREAM_JSONRPC
92};
93
c55acc2e 94void stream_report_content(const void *, ssize_t, enum stream_content_type,
480ce8ab 95 struct vlog_module *, const char *stream_name);
c34b65c7
BP
96
97#endif /* stream.h */