From 4950c85704e94480fc2aab2201423bb1c92153dd Mon Sep 17 00:00:00 2001 From: "James R. Leu" Date: Wed, 22 Nov 2006 00:40:00 -0600 Subject: [PATCH] Add mpls_socket_get_local_name and mpls_socket_get_remote_name to socket API. We then use this API to show both ends of the TCP session established by peers [git-p4: depot-paths = "//depot/ldp-portable/": change = 1548] --- common/mpls_socket_impl.h | 8 ++++++++ ldp/ldp_cfg.c | 14 ++++++++++++++ ldp/ldp_cfg.h | 2 ++ ldp/ldp_struct.h | 3 +++ 4 files changed, 27 insertions(+) diff --git a/common/mpls_socket_impl.h b/common/mpls_socket_impl.h index 5dc806b..2df1c9b 100644 --- a/common/mpls_socket_impl.h +++ b/common/mpls_socket_impl.h @@ -184,4 +184,12 @@ extern int mpls_socket_udp_sendto(const mpls_socket_mgr_handle handle, extern int mpls_socket_udp_recvfrom(const mpls_socket_mgr_handle handle, mpls_socket_handle socket, uint8_t * buffer, const int size, mpls_dest * from); +extern mpls_return_enum +mpls_socket_get_local_name(const mpls_socket_mgr_handle handle, + mpls_socket_handle socket, mpls_dest *name); + +extern mpls_return_enum +mpls_socket_get_remote_name(const mpls_socket_mgr_handle handle, + mpls_socket_handle socket, mpls_dest *name); + #endif diff --git a/ldp/ldp_cfg.c b/ldp/ldp_cfg.c index 3a1af45..c88877d 100644 --- a/ldp/ldp_cfg.c +++ b/ldp/ldp_cfg.c @@ -1953,6 +1953,20 @@ mpls_return_enum ldp_cfg_session_get(mpls_cfg_handle handle, ldp_session * s, if (flag & LDP_SESSION_CFG_MESG_RX) { s->mesg_rx = session->mesg_rx; } + if (flag & LDP_SESSION_CFG_LOCAL_NAME) { + if (mpls_socket_handle_verify(global->socket_handle, + session->socket) == MPLS_BOOL_TRUE) { + mpls_socket_get_local_name(global->socket_handle, session->socket, + &s->local_name); + } + } + if (flag & LDP_SESSION_CFG_REMOTE_NAME) { + if (mpls_socket_handle_verify(global->socket_handle, + session->socket) == MPLS_BOOL_TRUE) { + mpls_socket_get_remote_name(global->socket_handle, session->socket, + &s->remote_name); + } + } retval = MPLS_SUCCESS; ldp_cfg_session_get_end: diff --git a/ldp/ldp_cfg.h b/ldp/ldp_cfg.h index a6c36e9..533d6a2 100644 --- a/ldp/ldp_cfg.h +++ b/ldp/ldp_cfg.h @@ -125,6 +125,8 @@ #define LDP_SESSION_CFG_MESG_TX 0x00080000 #define LDP_SESSION_CFG_MESG_RX 0x00100000 #define LDP_SESSION_CFG_OPER_UP 0x00200000 +#define LDP_SESSION_CFG_LOCAL_NAME 0x00400000 +#define LDP_SESSION_CFG_REMOTE_NAME 0x00800000 #define LDP_SESSION_RADDR_CFG_ADDR 0x00000002 #define LDP_SESSION_RADDR_CFG_INDEX 0x00000004 diff --git a/ldp/ldp_struct.h b/ldp/ldp_struct.h index d4aad51..7a72769 100644 --- a/ldp/ldp_struct.h +++ b/ldp/ldp_struct.h @@ -449,6 +449,9 @@ typedef struct ldp_session { /* only used by cfg gets */ uint32_t adj_index; + + mpls_dest local_name; + mpls_dest remote_name; } ldp_session; typedef struct ldp_adj { -- 2.11.4.GIT