int probe_interval; /* Secs of inactivity before sending probe. */
time_t last_activity; /* Last time we saw some activity. */
- /* When we create a vconn we obtain these values, to save them past the end
- * of the vconn's lifetime. Otherwise, in-band control will only allow
- * traffic when a vconn is actually open, but it is nice to allow ARP to
- * complete even between connection attempts, and it is also polite to
- * allow traffic from other switches to go through to the controller
- * whether or not we are connected.
- *
- * We don't cache the local port, because that changes from one connection
- * attempt to the next. */
- ovs_be32 local_ip, remote_ip;
- ovs_be16 remote_port;
uint8_t dscp;
/* Messages sent or received are copied to the monitor connections. */
retval = vconn_open(rc->target, rc->allowed_versions, rc->dscp,
&rc->vconn);
if (!retval) {
- rc->remote_ip = vconn_get_remote_ip(rc->vconn);
- rc->local_ip = vconn_get_local_ip(rc->vconn);
- rc->remote_port = vconn_get_remote_port(rc->vconn);
rc->backoff_deadline = time_now() + rc->backoff;
state_transition(rc, S_CONNECTING);
} else {
return duration;
}
-/* Returns the IP address of the peer, or 0 if the peer's IP address is not
- * known. */
-ovs_be32
-rconn_get_remote_ip(const struct rconn *rconn)
-{
- return rconn->remote_ip;
-}
-
-/* Returns the transport port of the peer, or 0 if the peer's port is not
- * known. */
-ovs_be16
-rconn_get_remote_port(const struct rconn *rconn)
-{
- return rconn->remote_port;
-}
-
-/* Returns the IP address used to connect to the peer, or 0 if the
- * connection is not an IP-based protocol or if its IP address is not
- * known. */
-ovs_be32
-rconn_get_local_ip(const struct rconn *rconn)
-{
- return rconn->local_ip;
-}
-
-/* Returns the transport port used to connect to the peer, or 0 if the
- * connection does not contain a port or if the port is not known. */
-ovs_be16
-rconn_get_local_port(const struct rconn *rconn)
- OVS_EXCLUDED(rconn->mutex)
-{
- ovs_be16 port;
-
- ovs_mutex_lock(&rconn->mutex);
- port = rconn->vconn ? vconn_get_local_port(rconn->vconn) : 0;
- ovs_mutex_unlock(&rconn->mutex);
-
- return port;
-}
-
static int
rconn_get_version__(const struct rconn *rconn)
OVS_REQUIRES(rconn->mutex)
rc->name = xstrdup(name ? name : target);
free(rc->target);
rc->target = xstrdup(target);
- rc->local_ip = 0;
- rc->remote_ip = 0;
- rc->remote_port = 0;
}
/* Tries to send a packet from 'rc''s send buffer. Returns 0 if successful,
bool rconn_is_admitted(const struct rconn *);
int rconn_failure_duration(const struct rconn *);
-ovs_be32 rconn_get_remote_ip(const struct rconn *);
-ovs_be16 rconn_get_remote_port(const struct rconn *);
-ovs_be32 rconn_get_local_ip(const struct rconn *);
-ovs_be16 rconn_get_local_port(const struct rconn *);
int rconn_get_version(const struct rconn *);
const char *rconn_get_state(const struct rconn *);
const struct stream_class *class;
int state;
int error;
- ovs_be32 remote_ip;
- ovs_be16 remote_port;
- ovs_be32 local_ip;
- ovs_be16 local_port;
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);
-void stream_set_local_port(struct stream *, ovs_be16 local_port);
static inline void stream_assert_class(const struct stream *stream,
const struct stream_class *class)
{
static int
new_ssl_stream(const char *name, int fd, enum session_type type,
- enum ssl_state state, const struct sockaddr_in *remote,
- struct stream **streamp)
+ enum ssl_state state, struct stream **streamp)
{
struct sockaddr_in local;
socklen_t local_len = sizeof local;
/* Create and return the ssl_stream. */
sslv = xmalloc(sizeof *sslv);
stream_init(&sslv->stream, &ssl_stream_class, EAGAIN, name);
- stream_set_remote_ip(&sslv->stream, remote->sin_addr.s_addr);
- stream_set_remote_port(&sslv->stream, remote->sin_port);
- stream_set_local_ip(&sslv->stream, local.sin_addr.s_addr);
- stream_set_local_port(&sslv->stream, local.sin_port);
sslv->state = state;
sslv->type = type;
sslv->fd = fd;
static int
ssl_open(const char *name, char *suffix, struct stream **streamp, uint8_t dscp)
{
- struct sockaddr_in sin;
int error, fd;
error = ssl_init();
return error;
}
- error = inet_open_active(SOCK_STREAM, suffix, OFP_OLD_PORT, &sin, &fd,
+ error = inet_open_active(SOCK_STREAM, suffix, OFP_OLD_PORT, NULL, &fd,
dscp);
if (fd >= 0) {
int state = error ? STATE_TCP_CONNECTING : STATE_SSL_CONNECTING;
- return new_ssl_stream(name, fd, CLIENT, state, &sin, streamp);
+ return new_ssl_stream(name, fd, CLIENT, state, streamp);
} else {
VLOG_ERR("%s: connect: %s", name, ovs_strerror(error));
return error;
if (sin.sin_port != htons(OFP_OLD_PORT)) {
sprintf(strchr(name, '\0'), ":%"PRIu16, ntohs(sin.sin_port));
}
- return new_ssl_stream(name, new_fd, SERVER, STATE_SSL_CONNECTING, &sin,
+ return new_ssl_stream(name, new_fd, SERVER, STATE_SSL_CONNECTING,
new_streamp);
}
static int
new_tcp_stream(const char *name, int fd, int connect_status,
- const struct sockaddr_in *remote, struct stream **streamp)
+ struct stream **streamp)
{
struct sockaddr_in local;
socklen_t local_len = sizeof local;
return errno;
}
- retval = new_fd_stream(name, fd, connect_status, streamp);
- if (!retval) {
- struct stream *stream = *streamp;
- stream_set_remote_ip(stream, remote->sin_addr.s_addr);
- stream_set_remote_port(stream, remote->sin_port);
- stream_set_local_ip(stream, local.sin_addr.s_addr);
- stream_set_local_port(stream, local.sin_port);
- }
- return retval;
+ return new_fd_stream(name, fd, connect_status, streamp);
}
static int
tcp_open(const char *name, char *suffix, struct stream **streamp, uint8_t dscp)
{
- struct sockaddr_in sin;
int fd, error;
- error = inet_open_active(SOCK_STREAM, suffix, 0, &sin, &fd, dscp);
+ error = inet_open_active(SOCK_STREAM, suffix, 0, NULL, &fd, dscp);
if (fd >= 0) {
- return new_tcp_stream(name, fd, error, &sin, streamp);
+ return new_tcp_stream(name, fd, error, streamp);
} else {
VLOG_ERR("%s: connect: %s", name, ovs_strerror(error));
return error;
} else {
strcpy(name, "tcp");
}
- return new_tcp_stream(name, fd, 0, sin, streamp);
+ return new_tcp_stream(name, fd, 0, streamp);
}
const struct pstream_class ptcp_pstream_class = {
return stream ? stream->name : "(null)";
}
-/* Returns the IP address of the peer, or 0 if the peer is not connected over
- * an IP-based protocol or if its IP address is not yet known. */
-ovs_be32
-stream_get_remote_ip(const struct stream *stream)
-{
- return stream->remote_ip;
-}
-
-/* Returns the transport port of the peer, or 0 if the connection does not
- * contain a port or if the port is not yet known. */
-ovs_be16
-stream_get_remote_port(const struct stream *stream)
-{
- return stream->remote_port;
-}
-
-/* Returns the IP address used to connect to the peer, or 0 if the connection
- * is not an IP-based protocol or if its IP address is not yet known. */
-ovs_be32
-stream_get_local_ip(const struct stream *stream)
-{
- return stream->local_ip;
-}
-
-/* Returns the transport port used to connect to the peer, or 0 if the
- * connection does not contain a port or if the port is not yet known. */
-ovs_be16
-stream_get_local_port(const struct stream *stream)
-{
- return stream->local_port;
-}
-
static void
scs_connecting(struct stream *stream)
{
ovs_assert(stream->state != SCS_CONNECTING || class->connect);
}
-void
-stream_set_remote_ip(struct stream *stream, ovs_be32 ip)
-{
- stream->remote_ip = ip;
-}
-
-void
-stream_set_remote_port(struct stream *stream, ovs_be16 port)
-{
- stream->remote_port = port;
-}
-
-void
-stream_set_local_ip(struct stream *stream, ovs_be32 ip)
-{
- stream->local_ip = ip;
-}
-
-void
-stream_set_local_port(struct stream *stream, ovs_be16 port)
-{
- stream->local_port = port;
-}
-
void
pstream_init(struct pstream *pstream, const struct pstream_class *class,
const char *name)
enum ofp_version version; /* Negotiated version (or 0). */
bool recv_any_version; /* True to receive a message of any version. */
- ovs_be32 remote_ip;
- ovs_be16 remote_port;
- ovs_be32 local_ip;
- ovs_be16 local_port;
-
char *name;
};
void vconn_init(struct vconn *, const struct vconn_class *, int connect_status,
const char *name, uint32_t allowed_versions);
void vconn_free_data(struct vconn *vconn);
-void vconn_set_remote_ip(struct vconn *, ovs_be32 remote_ip);
-void vconn_set_remote_port(struct vconn *, ovs_be16 remote_port);
-void vconn_set_local_ip(struct vconn *, ovs_be32 local_ip);
-void vconn_set_local_port(struct vconn *, ovs_be16 local_port);
static inline void vconn_assert_class(const struct vconn *vconn,
const struct vconn_class *class)
{
s->txbuf = NULL;
s->rxbuf = NULL;
s->n_packets = 0;
- s->vconn.remote_ip = stream_get_remote_ip(stream);
- s->vconn.remote_port = stream_get_remote_port(stream);
- s->vconn.local_ip = stream_get_local_ip(stream);
- s->vconn.local_port = stream_get_local_port(stream);
return &s->vconn;
}
vconn->allowed_versions = allowed_versions;
}
-/* Returns the IP address of the peer, or 0 if the peer is not connected over
- * an IP-based protocol or if its IP address is not yet known. */
-ovs_be32
-vconn_get_remote_ip(const struct vconn *vconn)
-{
- return vconn->remote_ip;
-}
-
-/* Returns the transport port of the peer, or 0 if the connection does not
- * contain a port or if the port is not yet known. */
-ovs_be16
-vconn_get_remote_port(const struct vconn *vconn)
-{
- return vconn->remote_port;
-}
-
-/* Returns the IP address used to connect to the peer, or 0 if the
- * connection is not an IP-based protocol or if its IP address is not
- * yet known. */
-ovs_be32
-vconn_get_local_ip(const struct vconn *vconn)
-{
- return vconn->local_ip;
-}
-
-/* Returns the transport port used to connect to the peer, or 0 if the
- * connection does not contain a port or if the port is not yet known. */
-ovs_be16
-vconn_get_local_port(const struct vconn *vconn)
-{
- return vconn->local_port;
-}
-
/* Returns the OpenFlow version negotiated with the peer, or -1 if version
* negotiation is not yet complete.
*
ovs_assert(vconn->state != VCS_CONNECTING || class->connect);
}
-void
-vconn_set_remote_ip(struct vconn *vconn, ovs_be32 ip)
-{
- vconn->remote_ip = ip;
-}
-
-void
-vconn_set_remote_port(struct vconn *vconn, ovs_be16 port)
-{
- vconn->remote_port = port;
-}
-
-void
-vconn_set_local_ip(struct vconn *vconn, ovs_be32 ip)
-{
- vconn->local_ip = ip;
-}
-
-void
-vconn_set_local_port(struct vconn *vconn, ovs_be16 port)
-{
- vconn->local_port = port;
-}
-
void
pvconn_init(struct pvconn *pvconn, const struct pvconn_class *class,
const char *name, uint32_t allowed_versions)
int vconn_get_version(const struct vconn *);
void vconn_set_recv_any_version(struct vconn *);
-ovs_be32 vconn_get_remote_ip(const struct vconn *);
-ovs_be16 vconn_get_remote_port(const struct vconn *);
-ovs_be32 vconn_get_local_ip(const struct vconn *);
-ovs_be16 vconn_get_local_port(const struct vconn *);
-
int vconn_connect(struct vconn *);
int vconn_recv(struct vconn *, struct ofpbuf **);
int vconn_send(struct vconn *, struct ofpbuf *);