/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "stream-provider.h"
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
for (i = 0; i < ARRAY_SIZE(stream_classes); i++) {
const struct stream_class *class = stream_classes[i];
- assert(class->name != NULL);
- assert(class->open != NULL);
+ ovs_assert(class->name != NULL);
+ ovs_assert(class->open != NULL);
if (class->close || class->recv || class->send || class->run
|| class->run_wait || class->wait) {
- assert(class->close != NULL);
- assert(class->recv != NULL);
- assert(class->send != NULL);
- assert(class->wait != NULL);
+ ovs_assert(class->close != NULL);
+ ovs_assert(class->recv != NULL);
+ ovs_assert(class->send != NULL);
+ ovs_assert(class->wait != NULL);
} else {
/* This class delegates to another one. */
}
for (i = 0; i < ARRAY_SIZE(pstream_classes); i++) {
const struct pstream_class *class = pstream_classes[i];
- assert(class->name != NULL);
- assert(class->listen != NULL);
+ ovs_assert(class->name != NULL);
+ ovs_assert(class->listen != NULL);
if (class->close || class->accept || class->wait) {
- assert(class->close != NULL);
- assert(class->accept != NULL);
- assert(class->wait != NULL);
+ ovs_assert(class->close != NULL);
+ ovs_assert(class->accept != NULL);
+ ovs_assert(class->wait != NULL);
} else {
/* This class delegates to another one. */
}
stream_connect_wait(stream);
poll_block();
}
- assert(error != EINPROGRESS);
+ ovs_assert(error != EINPROGRESS);
}
if (error) {
scs_connecting(struct stream *stream)
{
int retval = (stream->class->connect)(stream);
- assert(retval != EINPROGRESS);
+ ovs_assert(retval != EINPROGRESS);
if (!retval) {
stream->state = SCS_CONNECTED;
} else if (retval != EAGAIN) {
void
stream_wait(struct stream *stream, enum stream_wait_type wait)
{
- assert(wait == STREAM_CONNECT || wait == STREAM_RECV
- || wait == STREAM_SEND);
+ ovs_assert(wait == STREAM_CONNECT || wait == STREAM_RECV
+ || wait == STREAM_SEND);
switch (stream->state) {
case SCS_CONNECTING:
if (retval) {
*new_stream = NULL;
} else {
- assert((*new_stream)->state != SCS_CONNECTING
- || (*new_stream)->class->connect);
+ ovs_assert((*new_stream)->state != SCS_CONNECTING
+ || (*new_stream)->class->connect);
}
return retval;
}
}
return 0;
}
+
+/* Returns the transport port on which 'pstream' is listening, or 0 if the
+ * concept doesn't apply. */
+ovs_be16
+pstream_get_bound_port(const struct pstream *pstream)
+{
+ return pstream->bound_port;
+}
\f
/* Initializes 'stream' as a new stream named 'name', implemented via 'class'.
* The initial connection status, supplied as 'connect_status', is interpreted
: SCS_DISCONNECTED);
stream->error = connect_status;
stream->name = xstrdup(name);
- assert(stream->state != SCS_CONNECTING || class->connect);
+ ovs_assert(stream->state != SCS_CONNECTING || class->connect);
}
void
pstream_init(struct pstream *pstream, const struct pstream_class *class,
const char *name)
{
+ memset(pstream, 0, sizeof *pstream);
pstream->class = class;
pstream->name = xstrdup(name);
}
+
+void
+pstream_set_bound_port(struct pstream *pstream, ovs_be16 port)
+{
+ pstream->bound_port = port;
+}
\f
static int
count_fields(const char *s_)