[PATCH] wpa_supplicant: add DBus method for changing debug parameters

Dan Williams dcbw
Fri Mar 27 14:19:48 PDT 2009


On Fri, 2009-03-27 at 09:56 +0100, Helmut Schaa wrote:
> Jouni, did you have time already to have a look at this patch?
> 
> Dan might be interested as well :)

Yeah, I'm interested; though you could use DBUS_TYPE_BOOLEAN for
timestamp & show keys.  Any particular reason the patch echoes the new
debug options back?  If the caller set them, the caller knows what they
are already.

Dan

> Thanks,
> Helmut
> 
> Am Donnerstag, 12. M?rz 2009 schrieb Helmut Schaa:
> > Add a new DBus method "setDebugParams" which takes the parameters
> > debug_level, debug_timestamp and show_keys as input, updates the
> > internal debug variables and returns the newly set values.
> > 
> > Signed-off-by: Helmut Schaa <helmut.schaa at googlemail.com>
> > 
> > ---
> > diff --git a/wpa_supplicant/ctrl_iface_dbus.c b/wpa_supplicant/ctrl_iface_dbus.c
> > index c4e329c..a23f02f 100644
> > --- a/wpa_supplicant/ctrl_iface_dbus.c
> > +++ b/wpa_supplicant/ctrl_iface_dbus.c
> > @@ -603,6 +603,9 @@ static DBusHandlerResult wpas_message_handler(DBusConnection *connection,
> >  		} else if (!strcmp(method, "getInterface")) {
> >  			reply = wpas_dbus_global_get_interface(
> >  				message, ctrl_iface->global);
> > +		} else if (!strcmp(method, "setDebugParams")) {
> > +			reply = wpas_dbus_global_set_debugparams(
> > +				message, ctrl_iface->global);
> >  		}
> >  	}
> >  
> > diff --git a/wpa_supplicant/ctrl_iface_dbus_handlers.c b/wpa_supplicant/ctrl_iface_dbus_handlers.c
> > index 161f7f8..60fa018 100644
> > --- a/wpa_supplicant/ctrl_iface_dbus_handlers.c
> > +++ b/wpa_supplicant/ctrl_iface_dbus_handlers.c
> > @@ -25,6 +25,9 @@
> >  #include "wpas_glue.h"
> >  #include "eapol_supp/eapol_supp_sm.h"
> >  
> > +extern int wpa_debug_level;
> > +extern int wpa_debug_show_keys;
> > +extern int wpa_debug_timestamp;
> >  
> >  /**
> >   * wpas_dbus_new_invalid_opts_error - Return a new invalid options error message
> > @@ -277,6 +280,68 @@ out:
> >  	return reply;
> >  }
> >  
> > +/**
> > + * wpas_dbus_global_set_debugparams- Set the debug params
> > + * @message: Pointer to incoming dbus message
> > + * @global: %wpa_supplicant global data structure
> > + * Returns: the newly set debug level
> > + *
> > + * Handler function for "setDebugParams" method call. Handles requests
> > + * by dbus clients for the object path of an specific network interface.
> > + */
> > +DBusMessage * wpas_dbus_global_set_debugparams(DBusMessage *message,
> > +					     struct wpa_global *global)
> > +{
> > +	DBusMessage *reply = NULL;
> > +	int debug_level;	
> > +	int debug_timestamp;	
> > +	int debug_show_keys;
> > +
> > +	if (!dbus_message_get_args(message, NULL,
> > +	                           DBUS_TYPE_INT32, &debug_level,
> > +	                           DBUS_TYPE_INT32, &debug_timestamp,
> > +	                           DBUS_TYPE_INT32, &debug_show_keys,
> > +	                           DBUS_TYPE_INVALID)) {
> > +		reply = wpas_dbus_new_invalid_opts_error(message, NULL);
> > +		goto out;
> > +	}
> > +
> > +	/* check for allowed debuglevels */
> > +	if (debug_level != MSG_MSGDUMP &&
> > +	    debug_level != MSG_DEBUG &&
> > +	    debug_level != MSG_INFO &&
> > +	    debug_level != MSG_WARNING &&
> > +	    debug_level != MSG_ERROR) {
> > +		reply = wpas_dbus_new_invalid_opts_error(message, NULL);
> > +		goto out;
> > +	}
> > +
> > +	if (debug_timestamp != 0 &&
> > +	    debug_timestamp != 1) {
> > +		reply = wpas_dbus_new_invalid_opts_error(message, NULL);
> > +		goto out;
> > +	}
> > +
> > +	if (debug_show_keys != 0 &&
> > +	    debug_show_keys != 1) {
> > +		reply = wpas_dbus_new_invalid_opts_error(message, NULL);
> > +		goto out;
> > +	}
> > +
> > +	wpa_debug_level = debug_level;
> > +	wpa_debug_timestamp = debug_timestamp;
> > +	wpa_debug_show_keys = debug_show_keys;
> > +
> > +	reply = dbus_message_new_method_return(message);
> > +	dbus_message_append_args(reply,
> > +	                         DBUS_TYPE_INT32, &wpa_debug_level,
> > +	                         DBUS_TYPE_INT32, &wpa_debug_timestamp,
> > +	                         DBUS_TYPE_INT32, &wpa_debug_show_keys,
> > +	                         DBUS_TYPE_INVALID);
> > +
> > +out:
> > +	return reply;
> > +}
> >  
> >  /**
> >   * wpas_dbus_iface_scan - Request a wireless scan on an interface
> > diff --git a/wpa_supplicant/ctrl_iface_dbus_handlers.h b/wpa_supplicant/ctrl_iface_dbus_handlers.h
> > index 9660f95..65fa721 100644
> > --- a/wpa_supplicant/ctrl_iface_dbus_handlers.h
> > +++ b/wpa_supplicant/ctrl_iface_dbus_handlers.h
> > @@ -28,6 +28,9 @@ DBusMessage * wpas_dbus_global_remove_interface(DBusMessage *message,
> >  DBusMessage * wpas_dbus_global_get_interface(DBusMessage *message,
> >  					     struct wpa_global *global);
> >  
> > +DBusMessage * wpas_dbus_global_set_debugparams(DBusMessage *message,
> > +					     struct wpa_global *global);
> > +
> >  DBusMessage * wpas_dbus_iface_scan(DBusMessage *message,
> >  				   struct wpa_supplicant *wpa_s);
> > 
> 
> 




More information about the Hostap mailing list