diff options
author | Justin Pettit <jpettit@nicira.com> | 2009-07-06 15:15:11 -0700 |
---|---|---|
committer | Justin Pettit <jpettit@nicira.com> | 2009-07-08 11:19:51 -0700 |
commit | 193456d581423f894e57e8463ff5049c0d802f0a (patch) | |
tree | 0649f9e6300bb00b86c6d84ce9a7c9827fecf726 /lib/vconn-stream.c | |
parent | ab9c78ff5099e6c45166b47202741b4071176ba3 (diff) | |
download | openvswitch-193456d581423f894e57e8463ff5049c0d802f0a.tar.gz |
Have rconn and vconn export information about IPs and ports
Previously, rconn and vconn only allowed users to find out about the
remote IP address. This set of changes allows users to retrieve the
remote port, local IP, and local port used for the connection.
Diffstat (limited to 'lib/vconn-stream.c')
-rw-r--r-- | lib/vconn-stream.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/vconn-stream.c b/lib/vconn-stream.c index a9fcd98df..46279e57e 100644 --- a/lib/vconn-stream.c +++ b/lib/vconn-stream.c @@ -41,6 +41,7 @@ struct stream_vconn { struct vconn vconn; int fd; + void (*connect_success_cb)(struct vconn *, int); struct ofpbuf *rxbuf; struct ofpbuf *txbuf; struct poll_waiter *tx_waiter; @@ -54,17 +55,21 @@ static void stream_clear_txbuf(struct stream_vconn *); int new_stream_vconn(const char *name, int fd, int connect_status, - uint32_t ip, bool reconnectable, struct vconn **vconnp) + uint32_t remote_ip, uint16_t remote_port, + bool reconnectable, + connect_success_cb_func *connect_success_cb, + struct vconn **vconnp) { struct stream_vconn *s; s = xmalloc(sizeof *s); - vconn_init(&s->vconn, &stream_vconn_class, connect_status, ip, name, - reconnectable); + vconn_init(&s->vconn, &stream_vconn_class, connect_status, remote_ip, + remote_port, name, reconnectable); s->fd = fd; s->txbuf = NULL; s->tx_waiter = NULL; s->rxbuf = NULL; + s->connect_success_cb = connect_success_cb; *vconnp = &s->vconn; return 0; } @@ -91,7 +96,14 @@ static int stream_connect(struct vconn *vconn) { struct stream_vconn *s = stream_vconn_cast(vconn); - return check_connection_completion(s->fd); + int retval = check_connection_completion(s->fd); + if (retval) { + return retval; + } + if (s->connect_success_cb) { + s->connect_success_cb(vconn, s->fd); + } + return 0; } static int |