Change in ...libosmocore[master]: vty/telnet_interface.c: log connection accept() / close() events

fixeria gerrit-no-reply at lists.osmocom.org
Sat Jul 27 19:35:14 UTC 2019


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/14972


Change subject: vty/telnet_interface.c: log connection accept() / close() events
......................................................................

vty/telnet_interface.c: log connection accept() / close() events

Change-Id: I77b31abfa159d2f269deaa5a08d94b7bbba7d23c
---
M src/vty/telnet_interface.c
1 file changed, 13 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/72/14972/1

diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c
index d44754c..dbbbfec 100644
--- a/src/vty/telnet_interface.c
+++ b/src/vty/telnet_interface.c
@@ -123,6 +123,16 @@
 int telnet_close_client(struct osmo_fd *fd)
 {
 	struct telnet_connection *conn = (struct telnet_connection*)fd->data;
+	struct sockaddr_in sockaddr;
+	socklen_t len = sizeof(sockaddr);
+	int rc;
+
+	/* FIXME: getsockname() always fails: "Bad file descriptor" */
+	rc = getsockname(fd->fd, (struct sockaddr *) &sockaddr, &len);
+	if (rc == 0) {
+		LOGP(DLGLOBAL, LOGL_INFO, "Closing telnet connection %s:%u\n",
+		     inet_ntoa(sockaddr.sin_addr), ntohs(sockaddr.sin_port));
+	}
 
 	close(fd->fd);
 	osmo_fd_unregister(fd);
@@ -173,6 +183,9 @@
 		return new_connection;
 	}
 
+	LOGP(DLGLOBAL, LOGL_INFO, "Accept()ed new telnet connection from %s:%u\n",
+	     inet_ntoa(sockaddr.sin_addr), ntohs(sockaddr.sin_port));
+
 	connection = talloc_zero(tall_telnet_ctx, struct telnet_connection);
 	connection->priv = fd->data;
 	connection->fd.data = connection;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/14972
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I77b31abfa159d2f269deaa5a08d94b7bbba7d23c
Gerrit-Change-Number: 14972
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190727/c731d454/attachment.html>


More information about the gerrit-log mailing list