]> git.proxmox.com Git - mirror_ovs.git/blame - lib/stream.h
ofproto: Fix typo in comment.
[mirror_ovs.git] / lib / stream.h
CommitLineData
c34b65c7 1/*
26ad129e 2 * Copyright (c) 2009, 2010 Nicira Networks.
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>
1e3c0047 23#include "vlog.h"
c34b65c7 24
c34b65c7
BP
25struct pstream;
26struct stream;
27
9467fe62 28void stream_usage(const char *name, bool active, bool passive, bool bootstrap);
c34b65c7
BP
29
30/* Bidirectional byte streams. */
26ad129e 31int stream_verify_name(const char *name);
c34b65c7 32int stream_open(const char *name, struct stream **);
766407ea 33int stream_open_block(int error, struct stream **);
c34b65c7
BP
34void stream_close(struct stream *);
35const char *stream_get_name(const struct stream *);
36uint32_t stream_get_remote_ip(const struct stream *);
37uint16_t stream_get_remote_port(const struct stream *);
38uint32_t stream_get_local_ip(const struct stream *);
39uint16_t stream_get_local_port(const struct stream *);
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 *);
56
57/* Passive streams: listeners for incoming stream connections. */
26ad129e 58int pstream_verify_name(const char *name);
c34b65c7
BP
59int pstream_open(const char *name, struct pstream **);
60const char *pstream_get_name(const struct pstream *);
61void pstream_close(struct pstream *);
62int pstream_accept(struct pstream *, struct stream **);
8d76bcca 63int pstream_accept_block(struct pstream *, struct stream **);
c34b65c7 64void pstream_wait(struct pstream *);
f39dc942 65\f
cc1ad532 66/* Convenience functions. */
f39dc942
BP
67
68int stream_open_with_default_ports(const char *name,
69 uint16_t default_tcp_port,
70 uint16_t default_ssl_port,
71 struct stream **);
72int pstream_open_with_default_ports(const char *name,
73 uint16_t default_ptcp_port,
74 uint16_t default_pssl_port,
75 struct pstream **);
1e3c0047
BP
76\f
77/* Error reporting. */
78
79enum stream_content_type {
80 STREAM_UNKNOWN,
81 STREAM_OPENFLOW,
82 STREAM_SSL,
83 STREAM_JSONRPC
84};
85
86void stream_report_content(const void *, size_t, enum stream_content_type,
480ce8ab 87 struct vlog_module *, const char *stream_name);
c34b65c7
BP
88
89#endif /* stream.h */