[ofa-general] [PATCH] librdmacm: provide wrapper functions to extract src/dst addresses
Sean Hefty
sean.hefty at intel.com
Wed Oct 17 11:39:40 PDT 2007
Provide wrapper functions to retrieve the source and destination
addresses. This is based on feedback from Doug Ledford.
Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
If there are no objections, I would like to include this change in the next
release of librdmacm, and request that it go into OFED 1.3.
Makefile.am | 2 ++
include/rdma/rdma_cma.h | 10 ++++++++++
man/rdma_bind_addr.3 | 3 ++-
man/rdma_cm.7 | 1 +
man/rdma_get_dst_addr.3 | 16 ++++++++++++++++
man/rdma_get_dst_port.3 | 3 ++-
man/rdma_get_src_addr.3 | 17 +++++++++++++++++
man/rdma_get_src_port.3 | 3 ++-
man/rdma_resolve_addr.3 | 3 ++-
9 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 1195bd9..c688283 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,6 +49,8 @@ man_MANS = \
man/rdma_get_devices.3 \
man/rdma_get_src_port.3 \
man/rdma_get_dst_port.3 \
+ man/rdma_get_src_addr.3 \
+ man/rdma_get_dst_addr.3 \
man/rdma_join_multicast.3 \
man/rdma_leave_multicast.3 \
man/rdma_listen.3 \
diff --git a/include/rdma/rdma_cma.h b/include/rdma/rdma_cma.h
index b0848d5..8ebcaf6 100644
--- a/include/rdma/rdma_cma.h
+++ b/include/rdma/rdma_cma.h
@@ -494,6 +494,16 @@ static inline uint16_t rdma_get_dst_port(struct rdma_cm_id *id)
((struct sockaddr_in *) &id->route.addr.dst_addr)->sin_port;
}
+static inline struct sockaddr *rdma_get_src_addr(struct rdma_cm_id *id)
+{
+ return &id->route.addr.src_addr;
+}
+
+static inline struct sockaddr *rdma_get_dst_addr(struct rdma_cm_id *id)
+{
+ return &id->route.addr.dst_addr;
+}
+
/**
* rdma_get_devices - Get list of RDMA devices currently available.
* @num_devices: If non-NULL, set to the number of devices returned.
diff --git a/man/rdma_bind_addr.3 b/man/rdma_bind_addr.3
index bed7f0b..dc7a868 100644
--- a/man/rdma_bind_addr.3
+++ b/man/rdma_bind_addr.3
@@ -25,4 +25,5 @@ address.
If used to bind to port 0, the rdma_cm will select an available port
and return it to the user.
.SH "SEE ALSO"
-rdma_create_id(3), rdma_listen(3), rdma_resolve_addr(3), rdma_create_qp(3)
+rdma_create_id(3), rdma_listen(3), rdma_resolve_addr(3), rdma_create_qp(3),
+rdma_get_src_addr(3), rdma_get_src_port(3)
diff --git a/man/rdma_cm.7 b/man/rdma_cm.7
index bfb3493..2e07706 100644
--- a/man/rdma_cm.7
+++ b/man/rdma_cm.7
@@ -110,5 +110,6 @@ rdma_resolve_route(3), rdma_connect(3), rdma_listen(3), rdma_accept(3),
rdma_reject(3), rdma_join_multicast(3), rdma_leave_multicast(3), rdma_notify(3),
rdma_ack_cm_event(3), rdma_disconnect(3), rdma_destroy_qp(3), rdma_destroy_id(3),
rdma_destroy_event_channel(3), rdma_get_devices(3), rdma_free_devices(3),
+rdma_get_dst_addr(3), rdma_get_src_addr(3),
rdma_get_dst_port(3), rdma_get_src_port(3), rdma_set_option(3)
ucmatose(1), udaddy(1), mckey(1), rping(1)
diff --git a/man/rdma_get_dst_addr.3 b/man/rdma_get_dst_addr.3
new file mode 100644
index 0000000..054445f
--- /dev/null
+++ b/man/rdma_get_dst_addr.3
@@ -0,0 +1,16 @@
+.TH "RDMA_GET_DST_ADDR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_get_dst_addr \- Returns the remote IP address of a bound rdma_cm_id.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_cma.h>"
+.P
+.B "struct sockaddr *" rdma_get_dst_addr
+.BI "(struct rdma_cm_id *" id ");"
+.SH ARGUMENTS
+.IP "id" 12
+RDMA identifier.
+.SH "DESCRIPTION"
+Returns the remote IP address associated with an rdma_cm_id.
+.SH "SEE ALSO"
+rdma_resolve_addr(3), rdma_get_src_port(3), rdma_get_dst_port(3),
+rdma_get_src_addr(3)
diff --git a/man/rdma_get_dst_port.3 b/man/rdma_get_dst_port.3
index 88e6ec2..658c9f7 100644
--- a/man/rdma_get_dst_port.3
+++ b/man/rdma_get_dst_port.3
@@ -13,4 +13,5 @@ RDMA identifier.
Returns the remote port number for an rdma_cm_id that has been bound to
a remote address.
.SH "SEE ALSO"
-rdma_connect(3), rdma_accept(3), rdma_get_cm_event(3), rdma_get_src_port(3)
+rdma_connect(3), rdma_accept(3), rdma_get_cm_event(3), rdma_get_src_port(3),
+rdma_get_src_addr(3), rdma_get_dst_addr(3)
diff --git a/man/rdma_get_src_addr.3 b/man/rdma_get_src_addr.3
new file mode 100644
index 0000000..fa9b256
--- /dev/null
+++ b/man/rdma_get_src_addr.3
@@ -0,0 +1,17 @@
+.TH "RDMA_GET_SRC_ADDR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_get_src_addr \- Returns the local IP address of a bound rdma_cm_id.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_cma.h>"
+.P
+.B "struct sockaddr *" rdma_get_src_addr
+.BI "(struct rdma_cm_id *" id ");"
+.SH ARGUMENTS
+.IP "id" 12
+RDMA identifier.
+.SH "DESCRIPTION"
+Returns the local IP address for an rdma_cm_id that has been bound to
+a local device.
+.SH "SEE ALSO"
+rdma_bind_addr(3), rdma_resolve_addr(3), rdma_get_src_port(3),
+rdma_get_dst_port(3), rdma_get_dst_addr(3)
diff --git a/man/rdma_get_src_port.3 b/man/rdma_get_src_port.3
index 63ee564..88f0920 100644
--- a/man/rdma_get_src_port.3
+++ b/man/rdma_get_src_port.3
@@ -13,4 +13,5 @@ RDMA identifier.
Returns the local port number for an rdma_cm_id that has been bound to
a local address.
.SH "SEE ALSO"
-rdma_bind_addr(3), rdma_resolve_addr(3), rdma_get_dst_port(3)
+rdma_bind_addr(3), rdma_resolve_addr(3), rdma_get_dst_port(3),
+rdma_get_src_addr(3), rdma_get_dst_addr(3)
diff --git a/man/rdma_resolve_addr.3 b/man/rdma_resolve_addr.3
index 32cd5cf..a9b7f61 100644
--- a/man/rdma_resolve_addr.3
+++ b/man/rdma_resolve_addr.3
@@ -33,4 +33,5 @@ an RDMA device. This call is typically made from the active side of a
connection before calling rdma_resolve_route and rdma_connect.
.SH "SEE ALSO"
rdma_create_id(3), rdma_resolve_route(3), rdma_connect(3), rdma_create_qp(3),
-rdma_get_cm_event(3), rdma_bind_addr(3)
+rdma_get_cm_event(3), rdma_bind_addr(3), rdma_get_src_port(3),
+rdma_get_dst_port(3), rdma_get_src_addr(3), rdma_get_dst_addr(3)
More information about the general
mailing list