]> git.proxmox.com Git - mirror_ovs.git/blame - lib/stream.h
Global replace of Nicira Networks.
[mirror_ovs.git] / lib / stream.h
CommitLineData
c34b65c7 1/*
e0edde6f 2 * Copyright (c) 2009, 2010, 2011 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"
1e3c0047 25#include "vlog.h"
ac4c900d 26#include "socket-util.h"
c34b65c7 27
c34b65c7
BP
28struct pstream;
29struct stream;
30
9467fe62 31void stream_usage(const char *name, bool active, bool passive, bool bootstrap);
c34b65c7
BP
32
33/* Bidirectional byte streams. */
26ad129e 34int stream_verify_name(const char *name);
f125905c 35int stream_open(const char *name, struct stream **, uint8_t dscp);
766407ea 36int stream_open_block(int error, struct stream **);
c34b65c7
BP
37void stream_close(struct stream *);
38const char *stream_get_name(const struct stream *);
4408d18a
BP
39ovs_be32 stream_get_remote_ip(const struct stream *);
40ovs_be16 stream_get_remote_port(const struct stream *);
41ovs_be32 stream_get_local_ip(const struct stream *);
42ovs_be16 stream_get_local_port(const struct stream *);
c34b65c7
BP
43int stream_connect(struct stream *);
44int stream_recv(struct stream *, void *buffer, size_t n);
45int stream_send(struct stream *, const void *buffer, size_t n);
46
539e96f6
BP
47void stream_run(struct stream *);
48void stream_run_wait(struct stream *);
49
c34b65c7
BP
50enum stream_wait_type {
51 STREAM_CONNECT,
52 STREAM_RECV,
53 STREAM_SEND
54};
55void stream_wait(struct stream *, enum stream_wait_type);
56void stream_connect_wait(struct stream *);
57void stream_recv_wait(struct stream *);
58void stream_send_wait(struct stream *);
59
60/* Passive streams: listeners for incoming stream connections. */
26ad129e 61int pstream_verify_name(const char *name);
f125905c 62int pstream_open(const char *name, struct pstream **, uint8_t dscp);
c34b65c7
BP
63const char *pstream_get_name(const struct pstream *);
64void pstream_close(struct pstream *);
65int pstream_accept(struct pstream *, struct stream **);
8d76bcca 66int pstream_accept_block(struct pstream *, struct stream **);
c34b65c7 67void pstream_wait(struct pstream *);
f39dc942 68\f
cc1ad532 69/* Convenience functions. */
f39dc942
BP
70
71int stream_open_with_default_ports(const char *name,
72 uint16_t default_tcp_port,
73 uint16_t default_ssl_port,
f125905c
MM
74 struct stream **,
75 uint8_t dscp);
f39dc942
BP
76int pstream_open_with_default_ports(const char *name,
77 uint16_t default_ptcp_port,
78 uint16_t default_pssl_port,
f125905c
MM
79 struct pstream **,
80 uint8_t dscp);
ac4c900d
AA
81bool stream_parse_target_with_default_ports(const char *target,
82 uint16_t default_tcp_port,
83 uint16_t default_ssl_port,
84 struct sockaddr_in *sin);
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 */