changeset 4823:a287a14cf718 draft

dhcpcd: report SSID connected to when we gain carrier Helps debugging without the need for explicit debug.
author Roy Marples <roy@marples.name>
date Tue, 12 Nov 2019 16:01:50 +0000
parents 8ea5c8980467
children 07a031bf48fd
files src/dhcpcd.c
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/dhcpcd.c	Sun Nov 10 21:12:31 2019 +0000
+++ b/src/dhcpcd.c	Tue Nov 12 16:01:50 2019 +0000
@@ -708,6 +708,21 @@
 	dhcpcd_initstate1(ifp, ifp->ctx->argc, ifp->ctx->argv, options);
 }
 
+static void
+dhcpcd_reportssid(struct interface *ifp)
+{
+	char pssid[IF_SSIDLEN * 4];
+
+	if (print_string(pssid, sizeof(pssid), OT_ESCSTRING,
+	    ifp->ssid, ifp->ssid_len) == -1)
+	{
+		logerr(__func__);
+		return;
+	}
+
+	loginfox("%s: connected to Access Point `%s'", ifp->name, pssid);
+}
+
 void
 dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags,
     const char *ifname)
@@ -779,6 +794,7 @@
 				if (ifp->ssid_len != olen ||
 				    memcmp(ifp->ssid, ossid, ifp->ssid_len))
 				{
+					dhcpcd_reportssid(ifp);
 #ifdef NOCARRIER_PRESERVE_IP
 					dhcpcd_drop(ifp, 0);
 #endif
@@ -976,7 +992,8 @@
 		return;
 
 	script_runreason(ifp, "PREINIT");
-
+	if (ifp->wireless)
+		dhcpcd_reportssid(ifp);
 	if (ifp->options->options & DHCPCD_LINK && ifp->carrier != LINK_UNKNOWN)
 		script_runreason(ifp,
 		    ifp->carrier == LINK_UP ? "CARRIER" : "NOCARRIER");