]> git.proxmox.com Git - mirror_ovs.git/blame - lib/stream.h
openflow: Table maintenance commands for Geneve options.
[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);
766407ea 37int stream_open_block(int error, struct stream **);
c34b65c7
BP
38void stream_close(struct stream *);
39const char *stream_get_name(const struct stream *);
4408d18a
BP
40ovs_be32 stream_get_remote_ip(const struct stream *);
41ovs_be16 stream_get_remote_port(const struct stream *);
42ovs_be32 stream_get_local_ip(const struct stream *);
43ovs_be16 stream_get_local_port(const struct stream *);
c34b65c7
BP
44int stream_connect(struct stream *);
45int stream_recv(struct stream *, void *buffer, size_t n);
46int stream_send(struct stream *, const void *buffer, size_t n);
47
539e96f6
BP
48void stream_run(struct stream *);
49void stream_run_wait(struct stream *);
50
c34b65c7
BP
51enum stream_wait_type {
52 STREAM_CONNECT,
53 STREAM_RECV,
54 STREAM_SEND
55};
56void stream_wait(struct stream *, enum stream_wait_type);
57void stream_connect_wait(struct stream *);
58void stream_recv_wait(struct stream *);
59void stream_send_wait(struct stream *);
60
61/* Passive streams: listeners for incoming stream connections. */
26ad129e 62int pstream_verify_name(const char *name);
f125905c 63int pstream_open(const char *name, struct pstream **, uint8_t dscp);
c34b65c7
BP
64const char *pstream_get_name(const struct pstream *);
65void pstream_close(struct pstream *);
66int pstream_accept(struct pstream *, struct stream **);
8d76bcca 67int pstream_accept_block(struct pstream *, struct stream **);
c34b65c7 68void pstream_wait(struct pstream *);
798e1352
BP
69
70ovs_be16 pstream_get_bound_port(const struct pstream *);
f39dc942 71\f
cc1ad532 72/* Convenience functions. */
f39dc942 73
ca843648
JP
74int stream_open_with_default_port(const char *name,
75 uint16_t default_port,
76 struct stream **,
77 uint8_t dscp);
78int pstream_open_with_default_port(const char *name,
79 uint16_t default_port,
80 struct pstream **,
f125905c 81 uint8_t dscp);
ca843648
JP
82bool stream_parse_target_with_default_port(const char *target,
83 uint16_t default_port,
e731d71b 84 struct sockaddr_storage *ss);
f1936eb6 85int stream_or_pstream_needs_probes(const char *name);
ac4c900d 86
1e3c0047
BP
87/* Error reporting. */
88
89enum stream_content_type {
90 STREAM_UNKNOWN,
91 STREAM_OPENFLOW,
92 STREAM_SSL,
93 STREAM_JSONRPC
94};
95
c55acc2e 96void stream_report_content(const void *, ssize_t, enum stream_content_type,
480ce8ab 97 struct vlog_module *, const char *stream_name);
c34b65c7
BP
98
99#endif /* stream.h */