/*
- * 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-ssl.h"
#include "dhparams.h"
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include "coverage.h"
#include "dynamic-string.h"
#include "entropy.h"
-#include "leak-checker.h"
#include "ofpbuf.h"
#include "openflow/openflow.h"
#include "packets.h"
/* Disable Nagle. */
retval = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on);
if (retval) {
- VLOG_ERR("%s: setsockopt(TCP_NODELAY): %s", name, strerror(errno));
+ VLOG_ERR("%s: setsockopt(TCP_NODELAY): %s", name, ovs_strerror(errno));
retval = errno;
goto error;
}
int state = error ? STATE_TCP_CONNECTING : STATE_SSL_CONNECTING;
return new_ssl_stream(name, fd, CLIENT, state, &sin, streamp);
} else {
- VLOG_ERR("%s: connect: %s", name, strerror(error));
+ VLOG_ERR("%s: connect: %s", name, ovs_strerror(error));
return error;
}
}
return EPROTO;
} else {
VLOG_ERR("could not bootstrap CA cert: creating %s failed: %s",
- ca_cert.file_name, strerror(errno));
+ ca_cert.file_name, ovs_strerror(errno));
return errno;
}
}
if (!file) {
error = errno;
VLOG_ERR("could not bootstrap CA cert: fdopen failed: %s",
- strerror(error));
+ ovs_strerror(error));
unlink(ca_cert.file_name);
return error;
}
if (fclose(file)) {
error = errno;
VLOG_ERR("could not bootstrap CA cert: writing %s failed: %s",
- ca_cert.file_name, strerror(error));
+ ca_cert.file_name, ovs_strerror(error));
unlink(ca_cert.file_name);
return error;
}
case STATE_SSL_CONNECTING:
/* Capture the first few bytes of received data so that we can guess
- * what kind of funny data we've been sent if SSL negotation fails. */
+ * what kind of funny data we've been sent if SSL negotiation fails. */
if (sslv->n_head <= 0) {
sslv->n_head = recv(sslv->fd, sslv->head, sizeof sslv->head,
MSG_PEEK);
if (ret < 0) {
int status = errno;
VLOG_WARN_RL(&rl, "%s: system error (%s)",
- function, strerror(status));
+ function, ovs_strerror(status));
return status;
} else {
VLOG_WARN_RL(&rl, "%s: unexpected SSL connection close",
ssize_t ret;
/* Behavior of zero-byte SSL_read is poorly defined. */
- assert(n > 0);
+ ovs_assert(n > 0);
old_state = SSL_get_state(sslv->ssl);
ret = SSL_read(sslv->ssl, buffer, n);
ssl_clear_txbuf(sslv);
return n;
case EAGAIN:
- leak_checker_claim(buffer);
return n;
default:
sslv->txbuf = NULL;
return -fd;
}
sprintf(bound_name, "pssl:%"PRIu16":"IP_FMT,
- ntohs(sin.sin_port), IP_ARGS(&sin.sin_addr.s_addr));
+ ntohs(sin.sin_port), IP_ARGS(sin.sin_addr.s_addr));
pssl = xmalloc(sizeof *pssl);
pstream_init(&pssl->pstream, &pssl_pstream_class, bound_name);
+ pstream_set_bound_port(&pssl->pstream, sin.sin_port);
pssl->fd = fd;
*pstreamp = &pssl->pstream;
return 0;
if (new_fd < 0) {
error = errno;
if (error != EAGAIN) {
- VLOG_DBG_RL(&rl, "accept: %s", strerror(error));
+ VLOG_DBG_RL(&rl, "accept: %s", ovs_strerror(error));
}
return error;
}
return error;
}
- sprintf(name, "ssl:"IP_FMT, IP_ARGS(&sin.sin_addr));
+ sprintf(name, "ssl:"IP_FMT, IP_ARGS(sin.sin_addr.s_addr));
if (sin.sin_port != htons(OFP_SSL_PORT)) {
sprintf(strchr(name, '\0'), ":%"PRIu16, ntohs(sin.sin_port));
}
poll_fd_wait(pssl->fd, POLLIN);
}
+static int
+pssl_set_dscp(struct pstream *pstream, uint8_t dscp)
+{
+ struct pssl_pstream *pssl = pssl_pstream_cast(pstream);
+ return set_dscp(pssl->fd, dscp);
+}
+
const struct pstream_class pssl_pstream_class = {
"pssl",
true,
pssl_close,
pssl_accept,
pssl_wait,
+ pssl_set_dscp,
};
\f
/*
static int init_status = -1;
if (init_status < 0) {
init_status = do_ssl_init();
- assert(init_status >= 0);
+ ovs_assert(init_status >= 0);
}
return init_status;
}
* here. */
error = get_mtime(file_name, &mtime);
if (error && error != ENOENT) {
- VLOG_ERR_RL(&rl, "%s: stat failed (%s)", file_name, strerror(error));
+ VLOG_ERR_RL(&rl, "%s: stat failed (%s)",
+ file_name, ovs_strerror(error));
}
if (config->file_name
&& !strcmp(config->file_name, file_name)
file = fopen(file_name, "r");
if (!file) {
VLOG_ERR("failed to open %s for reading: %s",
- file_name, strerror(errno));
+ file_name, ovs_strerror(errno));
return errno;
}