2009-11-04 15:02:32 -08:00
|
|
|
|
/*
|
2015-02-20 08:44:48 -08:00
|
|
|
|
* Copyright (c) 2009, 2010, 2011, 2013, 2015 Nicira, Inc.
|
2009-11-04 15:02:32 -08:00
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef STREAM_H
|
|
|
|
|
#define STREAM_H 1
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
2011-02-23 11:29:37 -08:00
|
|
|
|
#include <sys/types.h>
|
2010-11-29 13:48:30 -08:00
|
|
|
|
#include "openvswitch/types.h"
|
2011-12-19 12:43:34 -08:00
|
|
|
|
#include "socket-util.h"
|
2014-10-24 13:22:24 -07:00
|
|
|
|
#include "util.h"
|
2009-11-04 15:02:32 -08:00
|
|
|
|
|
|
|
|
|
struct pstream;
|
|
|
|
|
struct stream;
|
2014-10-24 13:22:24 -07:00
|
|
|
|
struct vlog_module;
|
2009-11-04 15:02:32 -08:00
|
|
|
|
|
2009-12-21 13:13:48 -08:00
|
|
|
|
void stream_usage(const char *name, bool active, bool passive, bool bootstrap);
|
2009-11-04 15:02:32 -08:00
|
|
|
|
|
|
|
|
|
/* Bidirectional byte streams. */
|
2010-03-23 15:30:17 -07:00
|
|
|
|
int stream_verify_name(const char *name);
|
2012-03-10 15:58:10 -08:00
|
|
|
|
int stream_open(const char *name, struct stream **, uint8_t dscp);
|
2019-01-09 20:30:16 +03:00
|
|
|
|
int stream_open_block(int error, long long int timeout, struct stream **);
|
2009-11-04 15:02:32 -08:00
|
|
|
|
void stream_close(struct stream *);
|
|
|
|
|
const char *stream_get_name(const struct stream *);
|
|
|
|
|
int stream_connect(struct stream *);
|
|
|
|
|
int stream_recv(struct stream *, void *buffer, size_t n);
|
|
|
|
|
int stream_send(struct stream *, const void *buffer, size_t n);
|
|
|
|
|
|
2010-01-06 14:26:48 -08:00
|
|
|
|
void stream_run(struct stream *);
|
|
|
|
|
void stream_run_wait(struct stream *);
|
|
|
|
|
|
2009-11-04 15:02:32 -08:00
|
|
|
|
enum stream_wait_type {
|
|
|
|
|
STREAM_CONNECT,
|
|
|
|
|
STREAM_RECV,
|
|
|
|
|
STREAM_SEND
|
|
|
|
|
};
|
|
|
|
|
void stream_wait(struct stream *, enum stream_wait_type);
|
|
|
|
|
void stream_connect_wait(struct stream *);
|
|
|
|
|
void stream_recv_wait(struct stream *);
|
|
|
|
|
void stream_send_wait(struct stream *);
|
2017-05-01 10:13:02 -04:00
|
|
|
|
void stream_set_peer_id(struct stream *, const char *);
|
|
|
|
|
const char *stream_get_peer_id(const struct stream *);
|
2009-11-04 15:02:32 -08:00
|
|
|
|
|
|
|
|
|
/* Passive streams: listeners for incoming stream connections. */
|
2010-03-23 15:30:17 -07:00
|
|
|
|
int pstream_verify_name(const char *name);
|
2012-03-10 15:58:10 -08:00
|
|
|
|
int pstream_open(const char *name, struct pstream **, uint8_t dscp);
|
2009-11-04 15:02:32 -08:00
|
|
|
|
const char *pstream_get_name(const struct pstream *);
|
|
|
|
|
void pstream_close(struct pstream *);
|
|
|
|
|
int pstream_accept(struct pstream *, struct stream **);
|
2009-11-12 12:52:12 -08:00
|
|
|
|
int pstream_accept_block(struct pstream *, struct stream **);
|
2009-11-04 15:02:32 -08:00
|
|
|
|
void pstream_wait(struct pstream *);
|
2013-04-18 16:37:05 -07:00
|
|
|
|
|
|
|
|
|
ovs_be16 pstream_get_bound_port(const struct pstream *);
|
2010-03-18 12:59:33 -07:00
|
|
|
|
|
2010-04-20 14:54:10 -07:00
|
|
|
|
/* Convenience functions. */
|
2010-03-18 12:59:33 -07:00
|
|
|
|
|
2013-09-23 14:33:09 -07:00
|
|
|
|
int stream_open_with_default_port(const char *name,
|
|
|
|
|
uint16_t default_port,
|
|
|
|
|
struct stream **,
|
|
|
|
|
uint8_t dscp);
|
|
|
|
|
int pstream_open_with_default_port(const char *name,
|
|
|
|
|
uint16_t default_port,
|
|
|
|
|
struct pstream **,
|
2012-03-10 15:58:10 -08:00
|
|
|
|
uint8_t dscp);
|
2013-09-23 14:33:09 -07:00
|
|
|
|
bool stream_parse_target_with_default_port(const char *target,
|
2018-04-11 11:24:59 -07:00
|
|
|
|
int default_port,
|
2014-02-06 16:04:05 -08:00
|
|
|
|
struct sockaddr_storage *ss);
|
2012-04-11 20:18:34 -07:00
|
|
|
|
int stream_or_pstream_needs_probes(const char *name);
|
2011-12-19 12:43:34 -08:00
|
|
|
|
|
2010-05-05 10:31:44 -07:00
|
|
|
|
/* Error reporting. */
|
|
|
|
|
|
|
|
|
|
enum stream_content_type {
|
|
|
|
|
STREAM_UNKNOWN,
|
|
|
|
|
STREAM_OPENFLOW,
|
|
|
|
|
STREAM_SSL,
|
|
|
|
|
STREAM_JSONRPC
|
|
|
|
|
};
|
|
|
|
|
|
2011-02-23 11:29:37 -08:00
|
|
|
|
void stream_report_content(const void *, ssize_t, enum stream_content_type,
|
2010-07-16 10:53:14 -07:00
|
|
|
|
struct vlog_module *, const char *stream_name);
|
2009-11-04 15:02:32 -08:00
|
|
|
|
|
2021-05-27 15:29:00 +02:00
|
|
|
|
|
|
|
|
|
/* Stream replay helpers. */
|
|
|
|
|
void stream_replay_open_wfd(struct stream *, int open_result,
|
|
|
|
|
const char *name);
|
|
|
|
|
void pstream_replay_open_wfd(struct pstream *, int listen_result,
|
|
|
|
|
const char *name);
|
|
|
|
|
void stream_replay_close_wfd(struct stream *);
|
|
|
|
|
void pstream_replay_close_wfd(struct pstream *);
|
|
|
|
|
void stream_replay_write(struct stream *, const void *, int, bool is_read);
|
|
|
|
|
void pstream_replay_write_accept(struct pstream *, const struct stream *,
|
|
|
|
|
int accept_result);
|
|
|
|
|
|
2009-11-04 15:02:32 -08:00
|
|
|
|
#endif /* stream.h */
|