]> git.proxmox.com Git - mirror_ovs.git/blame - lib/stream.h
datapath: Fix vxlan gso with vlan.
[mirror_ovs.git] / lib / stream.h
CommitLineData
c34b65c7 1/*
798e1352 2 * Copyright (c) 2009, 2010, 2011, 2013 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 *);
f89b7ce5 68int pstream_set_dscp(struct pstream *, uint8_t dscp);
798e1352
BP
69
70ovs_be16 pstream_get_bound_port(const struct pstream *);
f39dc942 71\f
cc1ad532 72/* Convenience functions. */
f39dc942
BP
73
74int stream_open_with_default_ports(const char *name,
75 uint16_t default_tcp_port,
76 uint16_t default_ssl_port,
f125905c
MM
77 struct stream **,
78 uint8_t dscp);
f39dc942
BP
79int pstream_open_with_default_ports(const char *name,
80 uint16_t default_ptcp_port,
81 uint16_t default_pssl_port,
f125905c
MM
82 struct pstream **,
83 uint8_t dscp);
ac4c900d
AA
84bool stream_parse_target_with_default_ports(const char *target,
85 uint16_t default_tcp_port,
86 uint16_t default_ssl_port,
87 struct sockaddr_in *sin);
f1936eb6 88int stream_or_pstream_needs_probes(const char *name);
ac4c900d 89
1e3c0047
BP
90/* Error reporting. */
91
92enum stream_content_type {
93 STREAM_UNKNOWN,
94 STREAM_OPENFLOW,
95 STREAM_SSL,
96 STREAM_JSONRPC
97};
98
c55acc2e 99void stream_report_content(const void *, ssize_t, enum stream_content_type,
480ce8ab 100 struct vlog_module *, const char *stream_name);
c34b65c7
BP
101
102#endif /* stream.h */