aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c40
-rw-r--r--src/uri/vppcom.c41
2 files changed, 39 insertions, 42 deletions
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c
index 1686c4fc3cf..fdcf13791d9 100644
--- a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c
@@ -1272,8 +1272,11 @@ vcom_socket_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
int
vppcom_session_getsockname (int sid, vppcom_endpt_t * ep)
{
- /* TBD: move it to vppcom */
- return 0;
+ int rv;
+ uint32_t size = sizeof (*ep);
+
+ rv = vppcom_session_attr (sid, VPPCOM_ATTR_GET_LCL_ADDR, ep, &size);
+ return rv;
}
int
@@ -1305,18 +1308,6 @@ vcom_socket_getsockname (int __fd, __SOCKADDR_ARG __addr,
return -EINVAL;
}
- /* TBD: remove libc_getsockname code snippet
- * once vppcom implements vppcom_session_getsockname */
- rv = libc_getsockname (__fd, __addr, __len);
- if (rv != 0)
- {
- rv = -errno;
- return rv;
- }
-
- /* TBD: use the below code snippet when vppcom
- * implements vppcom_session_getsockname */
-#if 0
vppcom_endpt_t ep;
ep.ip = (u8 *) & ((const struct sockaddr_in *) __addr)->sin_addr;
rv = vppcom_session_getsockname (vsock->sid, &ep);
@@ -1342,7 +1333,6 @@ vcom_socket_getsockname (int __fd, __SOCKADDR_ARG __addr,
}
}
}
-#endif
return rv;
}
@@ -1394,8 +1384,11 @@ vcom_socket_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
int
vppcom_session_getpeername (int sid, vppcom_endpt_t * ep)
{
- /* TBD: move it to vppcom */
- return 0;
+ int rv;
+ uint32_t size = sizeof (*ep);
+
+ rv = vppcom_session_attr (sid, VPPCOM_ATTR_GET_PEER_ADDR, ep, &size);
+ return rv;
}
int
@@ -1441,18 +1434,6 @@ vcom_socket_getpeername (int __fd, __SOCKADDR_ARG __addr,
return 0;
}
- /* TBD: remove libc_getpeername code snippet
- * once vppcom implements vppcom_session_getpeername */
- rv = libc_getpeername (__fd, __addr, __len);
- if (rv != 0)
- {
- rv = -errno;
- return rv;
- }
-
- /* TBD: use the below code snippet when vppcom
- * implements vppcom_session_getpeername */
-#if 0
vppcom_endpt_t ep;
ep.ip = (u8 *) & ((const struct sockaddr_in *) __addr)->sin_addr;
rv = vppcom_session_getpeername (vsock->sid, &ep);
@@ -1478,7 +1459,6 @@ vcom_socket_getpeername (int __fd, __SOCKADDR_ARG __addr,
}
}
}
-#endif
return rv;
}
diff --git a/src/uri/vppcom.c b/src/uri/vppcom.c
index 7c06451abc4..a8e3a5005ba 100644
--- a/src/uri/vppcom.c
+++ b/src/uri/vppcom.c
@@ -3036,7 +3036,7 @@ vppcom_session_attr (uint32_t session_index, uint32_t op,
session_t *session;
int rv = VPPCOM_OK;
u32 *flags = buffer;
- vppcom_ip46_t *vcl_addr = buffer;
+ vppcom_endpt_t *ep = buffer;
VCL_LOCK_AND_GET_SESSION (session_index, &session);
switch (op)
@@ -3080,28 +3080,45 @@ vppcom_session_attr (uint32_t session_index, uint32_t op,
break;
case VPPCOM_ATTR_GET_PEER_ADDR:
- if (buffer && buflen && (*buflen >= sizeof (*vcl_addr)))
+ if (buffer && buflen && (*buflen >= sizeof (*ep)))
{
- *vcl_addr = session->peer_addr;
- *buflen = sizeof (*vcl_addr);
+ ep->vrf = session->vrf;
+ ep->is_ip4 = session->peer_addr.is_ip4;
+ ep->port = session->port;
+ if (session->peer_addr.is_ip4)
+ clib_memcpy (ep->ip, &session->peer_addr.ip46.ip4,
+ sizeof (ip4_address_t));
+ else
+ clib_memcpy (ep->ip, &session->peer_addr.ip46.ip6,
+ sizeof (ip6_address_t));
+ *buflen = sizeof (*ep);
if (VPPCOM_DEBUG > 0)
clib_warning ("VPPCOM_ATTR_GET_PEER_ADDR: is_ip4 = %u, "
- "addr = %U", vcl_addr->is_ip4, format_ip46_address,
- &vcl_addr->ip46, vcl_addr->is_ip4);
+ "addr = %U", ep->is_ip4, format_ip46_address,
+ &session->peer_addr.ip46, ep->is_ip4);
}
else
rv = VPPCOM_EINVAL;
break;
case VPPCOM_ATTR_GET_LCL_ADDR:
- if (buffer && buflen && (*buflen >= sizeof (*vcl_addr)))
+ if (buffer && buflen && (*buflen >= sizeof (*ep)))
{
- *vcl_addr = session->lcl_addr;
- *buflen = sizeof (*vcl_addr);
+ ep->vrf = session->vrf;
+ ep->is_ip4 = session->lcl_addr.is_ip4;
+ ep->port = session->port;
+ if (session->lcl_addr.is_ip4)
+ clib_memcpy (ep->ip, &session->lcl_addr.ip46.ip4,
+ sizeof (ip4_address_t));
+ else
+ clib_memcpy (ep->ip, &session->lcl_addr.ip46.ip6,
+ sizeof (ip6_address_t));
+ *buflen = sizeof (*ep);
if (VPPCOM_DEBUG > 0)
- clib_warning ("VPPCOM_ATTR_GET_LCL_ADDR: is_ip4 = %u, "
- "addr = %U", vcl_addr->is_ip4, format_ip46_address,
- &vcl_addr->ip46, vcl_addr->is_ip4);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("VPPCOM_ATTR_GET_LCL_ADDR: is_ip4 = %u, "
+ "addr = %U", ep->is_ip4, format_ip46_address,
+ &session->lcl_addr.ip46, ep->is_ip4);
}
else
rv = VPPCOM_EINVAL;