Commit 406d745d69a69d550d5ec8478f06a7ed2cebdc20
1 parent
f1526cdc
Exists in
master
and in
2 other branches
Enabling get peer and name methods required for custom audit plugin.
Showing
4 changed files
with
32 additions
and
1 deletions
Show diff stats
src/include/networking.h
@@ -142,7 +142,7 @@ | @@ -142,7 +142,7 @@ | ||
142 | /// @retval 0 The session is offline. | 142 | /// @retval 0 The session is offline. |
143 | int (*is_connected)(const H3270 *hSession); | 143 | int (*is_connected)(const H3270 *hSession); |
144 | 144 | ||
145 | - /// @brief get socket name. | 145 | + /// @brief Get socket name. |
146 | /// | 146 | /// |
147 | /// @return On success, zero is returned. On error, -1 is returned, and errno is set appropriately. | 147 | /// @return On success, zero is returned. On error, -1 is returned, and errno is set appropriately. |
148 | /// | 148 | /// |
@@ -150,6 +150,14 @@ | @@ -150,6 +150,14 @@ | ||
150 | /// @retval -1 Error (errno is set). | 150 | /// @retval -1 Error (errno is set). |
151 | int (*getsockname)(const H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen); | 151 | int (*getsockname)(const H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen); |
152 | 152 | ||
153 | + /// @brief Get name of connected peer socket. | ||
154 | + /// | ||
155 | + /// @return On success, zero is returned. On error, -1 is returned, and errno is set appropriately. | ||
156 | + /// | ||
157 | + /// @retval 0 Success. | ||
158 | + /// @retval -1 Error (errno is set). | ||
159 | + int (*getpeername)(const H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen); | ||
160 | + | ||
153 | /// @brief Set socket options. | 161 | /// @brief Set socket options. |
154 | int (*setsockopt)(H3270 *hSession, int level, int optname, const void *optval, size_t optlen); | 162 | int (*setsockopt)(H3270 *hSession, int level, int optname, const void *optval, size_t optlen); |
155 | 163 |
src/network_modules/default/main.c
@@ -92,6 +92,10 @@ static int unsecure_network_getsockname(const H3270 *hSession, struct sockaddr * | @@ -92,6 +92,10 @@ static int unsecure_network_getsockname(const H3270 *hSession, struct sockaddr * | ||
92 | return getsockname(hSession->network.context->sock, addr, addrlen); | 92 | return getsockname(hSession->network.context->sock, addr, addrlen); |
93 | } | 93 | } |
94 | 94 | ||
95 | +static int unsecure_network_getpeername(const H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen) { | ||
96 | + return getpeername(hSession->network.context->sock, addr, addrlen); | ||
97 | +} | ||
98 | + | ||
95 | static void * unsecure_network_add_poll(H3270 *hSession, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata) { | 99 | static void * unsecure_network_add_poll(H3270 *hSession, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata) { |
96 | return lib3270_add_poll_fd(hSession,hSession->network.context->sock,flag,call,userdata); | 100 | return lib3270_add_poll_fd(hSession,hSession->network.context->sock,flag,call,userdata); |
97 | } | 101 | } |
@@ -166,6 +170,7 @@ void lib3270_set_default_network_module(H3270 *hSession) { | @@ -166,6 +170,7 @@ void lib3270_set_default_network_module(H3270 *hSession) { | ||
166 | .non_blocking = unsecure_network_non_blocking, | 170 | .non_blocking = unsecure_network_non_blocking, |
167 | .is_connected = unsecure_network_is_connected, | 171 | .is_connected = unsecure_network_is_connected, |
168 | .getsockname = unsecure_network_getsockname, | 172 | .getsockname = unsecure_network_getsockname, |
173 | + .getpeername = unsecure_network_getpeername, | ||
169 | .setsockopt = unsecure_network_setsockopt, | 174 | .setsockopt = unsecure_network_setsockopt, |
170 | .getsockopt = unsecure_network_getsockopt, | 175 | .getsockopt = unsecure_network_getsockopt, |
171 | .reset = unsecure_network_reset | 176 | .reset = unsecure_network_reset |
src/network_modules/openssl/main.c
@@ -186,6 +186,10 @@ static int openssl_network_getsockname(const H3270 *hSession, struct sockaddr *a | @@ -186,6 +186,10 @@ static int openssl_network_getsockname(const H3270 *hSession, struct sockaddr *a | ||
186 | return getsockname(hSession->network.context->sock, addr, addrlen); | 186 | return getsockname(hSession->network.context->sock, addr, addrlen); |
187 | } | 187 | } |
188 | 188 | ||
189 | +static int openssl_network_getpeername(const H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen) { | ||
190 | + return getpeername(hSession->network.context->sock, addr, addrlen); | ||
191 | +} | ||
192 | + | ||
189 | static void * openssl_network_add_poll(H3270 *hSession, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata) { | 193 | static void * openssl_network_add_poll(H3270 *hSession, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata) { |
190 | return lib3270_add_poll_fd(hSession,hSession->network.context->sock,flag,call,userdata); | 194 | return lib3270_add_poll_fd(hSession,hSession->network.context->sock,flag,call,userdata); |
191 | } | 195 | } |
@@ -346,6 +350,7 @@ void lib3270_set_libssl_network_module(H3270 *hSession) { | @@ -346,6 +350,7 @@ void lib3270_set_libssl_network_module(H3270 *hSession) { | ||
346 | .non_blocking = openssl_network_non_blocking, | 350 | .non_blocking = openssl_network_non_blocking, |
347 | .is_connected = openssl_network_is_connected, | 351 | .is_connected = openssl_network_is_connected, |
348 | .getsockname = openssl_network_getsockname, | 352 | .getsockname = openssl_network_getsockname, |
353 | + .getpeername = openssl_network_getpeername, | ||
349 | .setsockopt = openssl_network_setsockopt, | 354 | .setsockopt = openssl_network_setsockopt, |
350 | .getsockopt = openssl_network_getsockopt, | 355 | .getsockopt = openssl_network_getsockopt, |
351 | .getcert = openssl_network_getcert, | 356 | .getcert = openssl_network_getcert, |
src/network_modules/tools.c
@@ -263,3 +263,16 @@ int lib3270_socket_set_non_blocking(H3270 *hSession, int sock, const unsigned ch | @@ -263,3 +263,16 @@ int lib3270_socket_set_non_blocking(H3270 *hSession, int sock, const unsigned ch | ||
263 | 263 | ||
264 | return EINVAL; | 264 | return EINVAL; |
265 | } | 265 | } |
266 | + | ||
267 | + LIB3270_EXPORT int lib3270_getpeername(H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen) | ||
268 | + { | ||
269 | + FAIL_IF_NOT_ONLINE(hSession); | ||
270 | + return hSession->network.module->getpeername(hSession, addr, addrlen); | ||
271 | + } | ||
272 | + | ||
273 | + LIB3270_EXPORT int lib3270_getsockname(H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen) | ||
274 | + { | ||
275 | + FAIL_IF_NOT_ONLINE(hSession); | ||
276 | + return hSession->network.module->getsockname(hSession, addr, addrlen); | ||
277 | + } | ||
278 | + |