add vty_is_active()

For async callbacks it is useful to determine whether a given VTY pointer is still valid.

For example, in osmo-msc, a silent call can be triggered by VTY, which causes a
Paging. The paging_cb then writes to the VTY console that the silent call has
succeeded. Unless the telnet vty session has already ended, in which case
osmo-msc crashes; e.g. from an osmo_interact_vty.py command invocation. With
this function, osmo-msc can ask whether the vty pointer passed to the paging
callback is still active, and skip vty_out() if not.

Change-Id: I42cf2af47283dd42c101faae0fac293c3a68d599
diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c
index dc23b12..a1fc999 100644
--- a/src/vty/telnet_interface.c
+++ b/src/vty/telnet_interface.c
@@ -197,6 +197,16 @@
 	return 0;
 }
 
+bool vty_is_active(struct vty *vty)
+{
+	struct telnet_connection *connection;
+	llist_for_each_entry(connection, &active_connections, entry) {
+		if (connection->vty == vty)
+			return true;
+	}
+	return false;
+}
+
 /*! callback from core VTY code about VTY related events */
 void vty_event(enum event event, int sock, struct vty *vty)
 {