*
* This structure should be treated as opaque by implementation. */
struct stream {
- struct stream_class *class;
+ const struct stream_class *class;
int state;
int error;
ovs_be32 remote_ip;
char *name;
};
-void stream_init(struct stream *, struct stream_class *, int connect_status,
- const char *name);
+void stream_init(struct stream *, const struct stream_class *,
+ int connect_status, const char *name);
void stream_set_remote_ip(struct stream *, ovs_be32 remote_ip);
void stream_set_remote_port(struct stream *, ovs_be16 remote_port);
void stream_set_local_ip(struct stream *, ovs_be32 local_ip);
*
* This structure should be treated as opaque by stream implementations. */
struct pstream {
- struct pstream_class *class;
+ const struct pstream_class *class;
char *name;
};
-void pstream_init(struct pstream *, struct pstream_class *, const char *name);
+void pstream_init(struct pstream *, const struct pstream_class *, const char *name);
static inline void pstream_assert_class(const struct pstream *pstream,
const struct pstream_class *class)
{
};
/* Active and passive stream classes. */
-extern struct stream_class tcp_stream_class;
-extern struct pstream_class ptcp_pstream_class;
-extern struct stream_class unix_stream_class;
-extern struct pstream_class punix_pstream_class;
+extern const struct stream_class tcp_stream_class;
+extern const struct pstream_class ptcp_pstream_class;
+extern const struct stream_class unix_stream_class;
+extern const struct pstream_class punix_pstream_class;
#ifdef HAVE_OPENSSL
-extern struct stream_class ssl_stream_class;
-extern struct pstream_class pssl_pstream_class;
+extern const struct stream_class ssl_stream_class;
+extern const struct pstream_class pssl_pstream_class;
#endif
#endif /* stream-provider.h */
SCS_DISCONNECTED /* Connection failed or connection closed. */
};
-static struct stream_class *stream_classes[] = {
+static const struct stream_class *stream_classes[] = {
&tcp_stream_class,
&unix_stream_class,
#ifdef HAVE_OPENSSL
#endif
};
-static struct pstream_class *pstream_classes[] = {
+static const struct pstream_class *pstream_classes[] = {
&ptcp_pstream_class,
&punix_pstream_class,
#ifdef HAVE_OPENSSL
size_t i;
for (i = 0; i < ARRAY_SIZE(stream_classes); i++) {
- struct stream_class *class = stream_classes[i];
+ const struct stream_class *class = stream_classes[i];
assert(class->name != NULL);
assert(class->open != NULL);
if (class->close || class->recv || class->send || class->run
}
for (i = 0; i < ARRAY_SIZE(pstream_classes); i++) {
- struct pstream_class *class = pstream_classes[i];
+ const struct pstream_class *class = pstream_classes[i];
assert(class->name != NULL);
assert(class->listen != NULL);
if (class->close || class->accept || class->wait) {
* a null pointer into '*classp' if 'name' is in the wrong form or if no such
* class exists. */
static int
-stream_lookup_class(const char *name, struct stream_class **classp)
+stream_lookup_class(const char *name, const struct stream_class **classp)
{
size_t prefix_len;
size_t i;
return EAFNOSUPPORT;
}
for (i = 0; i < ARRAY_SIZE(stream_classes); i++) {
- struct stream_class *class = stream_classes[i];
+ const struct stream_class *class = stream_classes[i];
if (strlen(class->name) == prefix_len
&& !memcmp(class->name, name, prefix_len)) {
*classp = class;
int
stream_verify_name(const char *name)
{
- struct stream_class *class;
+ const struct stream_class *class;
return stream_lookup_class(name, &class);
}
int
stream_open(const char *name, struct stream **streamp)
{
- struct stream_class *class;
+ const struct stream_class *class;
struct stream *stream;
char *suffix_copy;
int error;
* a null pointer into '*classp' if 'name' is in the wrong form or if no such
* class exists. */
static int
-pstream_lookup_class(const char *name, struct pstream_class **classp)
+pstream_lookup_class(const char *name, const struct pstream_class **classp)
{
size_t prefix_len;
size_t i;
return EAFNOSUPPORT;
}
for (i = 0; i < ARRAY_SIZE(pstream_classes); i++) {
- struct pstream_class *class = pstream_classes[i];
+ const struct pstream_class *class = pstream_classes[i];
if (strlen(class->name) == prefix_len
&& !memcmp(class->name, name, prefix_len)) {
*classp = class;
int
pstream_verify_name(const char *name)
{
- struct pstream_class *class;
+ const struct pstream_class *class;
return pstream_lookup_class(name, &class);
}
int
pstream_open(const char *name, struct pstream **pstreamp)
{
- struct pstream_class *class;
+ const struct pstream_class *class;
struct pstream *pstream;
char *suffix_copy;
int error;
*
* The caller retains ownership of 'name'. */
void
-stream_init(struct stream *stream, struct stream_class *class,
+stream_init(struct stream *stream, const struct stream_class *class,
int connect_status, const char *name)
{
memset(stream, 0, sizeof *stream);
}
void
-pstream_init(struct pstream *pstream, struct pstream_class *class,
+pstream_init(struct pstream *pstream, const struct pstream_class *class,
const char *name)
{
pstream->class = class;