]> git.proxmox.com Git - mirror_ovs.git/blob - lib/stream.h
stream: Eliminate pstream_set_dscp().
[mirror_ovs.git] / lib / stream.h
1 /*
2 * Copyright (c) 2009, 2010, 2011, 2013, 2015 Nicira, Inc.
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
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include <stdint.h>
23 #include <sys/types.h>
24 #include "openvswitch/types.h"
25 #include "socket-util.h"
26 #include "util.h"
27
28 struct pstream;
29 struct stream;
30 struct vlog_module;
31
32 void stream_usage(const char *name, bool active, bool passive, bool bootstrap);
33
34 /* Bidirectional byte streams. */
35 int stream_verify_name(const char *name);
36 int stream_open(const char *name, struct stream **, uint8_t dscp);
37 int stream_open_block(int error, struct stream **);
38 void stream_close(struct stream *);
39 const char *stream_get_name(const struct stream *);
40 ovs_be32 stream_get_remote_ip(const struct stream *);
41 ovs_be16 stream_get_remote_port(const struct stream *);
42 ovs_be32 stream_get_local_ip(const struct stream *);
43 ovs_be16 stream_get_local_port(const struct stream *);
44 int stream_connect(struct stream *);
45 int stream_recv(struct stream *, void *buffer, size_t n);
46 int stream_send(struct stream *, const void *buffer, size_t n);
47
48 void stream_run(struct stream *);
49 void stream_run_wait(struct stream *);
50
51 enum stream_wait_type {
52 STREAM_CONNECT,
53 STREAM_RECV,
54 STREAM_SEND
55 };
56 void stream_wait(struct stream *, enum stream_wait_type);
57 void stream_connect_wait(struct stream *);
58 void stream_recv_wait(struct stream *);
59 void stream_send_wait(struct stream *);
60
61 /* Passive streams: listeners for incoming stream connections. */
62 int pstream_verify_name(const char *name);
63 int pstream_open(const char *name, struct pstream **, uint8_t dscp);
64 const char *pstream_get_name(const struct pstream *);
65 void pstream_close(struct pstream *);
66 int pstream_accept(struct pstream *, struct stream **);
67 int pstream_accept_block(struct pstream *, struct stream **);
68 void pstream_wait(struct pstream *);
69
70 ovs_be16 pstream_get_bound_port(const struct pstream *);
71 \f
72 /* Convenience functions. */
73
74 int stream_open_with_default_port(const char *name,
75 uint16_t default_port,
76 struct stream **,
77 uint8_t dscp);
78 int pstream_open_with_default_port(const char *name,
79 uint16_t default_port,
80 struct pstream **,
81 uint8_t dscp);
82 bool stream_parse_target_with_default_port(const char *target,
83 uint16_t default_port,
84 struct sockaddr_storage *ss);
85 int stream_or_pstream_needs_probes(const char *name);
86
87 /* Error reporting. */
88
89 enum stream_content_type {
90 STREAM_UNKNOWN,
91 STREAM_OPENFLOW,
92 STREAM_SSL,
93 STREAM_JSONRPC
94 };
95
96 void stream_report_content(const void *, ssize_t, enum stream_content_type,
97 struct vlog_module *, const char *stream_name);
98
99 #endif /* stream.h */