[PATCH] add 'strict' argument to GET_CAPABILITY

Dan Williams dcbw
Mon Aug 21 11:21:56 PDT 2006


Add a 'strict' mode to GET_CAPABILITY checking, reporting only those
capabilities which the interface definitely supports.

Index: ctrl_iface.c
===================================================================
RCS file: /cvs/hostap/wpa_supplicant/ctrl_iface.c,v
retrieving revision 1.91
diff -u -p -r1.91 ctrl_iface.c
--- ctrl_iface.c	20 Aug 2006 16:10:15 -0000	1.91
+++ ctrl_iface.c	21 Aug 2006 18:12:23 -0000
@@ -812,9 +812,18 @@ static int wpa_supplicant_ctrl_iface_get
 {
 	struct wpa_driver_capa capa;
 	int res, first = 1, ret;
-	char *pos, *end;
+	char *pos, *end, *strict;
 
-	wpa_printf(MSG_DEBUG, "CTRL_IFACE: GET_CAPABILITY '%s'", field);
+	/* Determine whether or not strict checking was requested */
+	strict = strchr(field, ' ');
+	if (strict != NULL) {
+		*strict++ = '\0';
+		if (strcmp(strict, "strict") != 0)
+			return -1;
+	}
+
+	wpa_printf(MSG_DEBUG, "CTRL_IFACE: GET_CAPABILITY '%s' %s",
+		field, strict ? strict : "");
 
 	if (strcmp(field, "eap") == 0) {
 		return eap_get_names(buf, buflen);
@@ -827,6 +836,8 @@ static int wpa_supplicant_ctrl_iface_get
 
 	if (strcmp(field, "pairwise") == 0) {
 		if (res < 0) {
+			if (strict)
+				return 0;
 			ret = snprintf(buf, buflen, "CCMP TKIP NONE");
 			if (ret < 0 || (size_t) ret >= buflen)
 				return -1;
@@ -865,6 +876,8 @@ static int wpa_supplicant_ctrl_iface_get
 
 	if (strcmp(field, "group") == 0) {
 		if (res < 0) {
+			if (strict)
+				return 0;
 			ret = snprintf(buf, buflen, "CCMP TKIP WEP104 WEP40");
 			if (ret < 0 || (size_t) ret >= buflen)
 				return -1;
@@ -912,6 +925,8 @@ static int wpa_supplicant_ctrl_iface_get
 
 	if (strcmp(field, "key_mgmt") == 0) {
 		if (res < 0) {
+			if (strict)
+				return 0;
 			ret = snprintf(buf, buflen, "WPA-PSK WPA-EAP "
 				       "IEEE8021X WPA-NONE NONE");
 			if (ret < 0 || (size_t) ret >= buflen)
@@ -952,6 +967,8 @@ static int wpa_supplicant_ctrl_iface_get
 
 	if (strcmp(field, "proto") == 0) {
 		if (res < 0) {
+			if (strict)
+				return 0;
 			ret = snprintf(buf, buflen, "RSN WPA");
 			if (ret < 0 || (size_t) ret >= buflen)
 				return -1;
@@ -983,6 +1000,8 @@ static int wpa_supplicant_ctrl_iface_get
 
 	if (strcmp(field, "auth_alg") == 0) {
 		if (res < 0) {
+			if (strict)
+				return 0;
 			ret = snprintf(buf, buflen, "OPEN SHARED LEAP");
 			if (ret < 0 || (size_t) ret >= buflen)
 				return -1;
Index: wpa_cli.c
===================================================================
RCS file: /cvs/hostap/wpa_supplicant/wpa_cli.c,v
retrieving revision 1.77
diff -u -p -r1.77 wpa_cli.c
--- wpa_cli.c	5 Aug 2006 18:14:17 -0000	1.77
+++ wpa_cli.c	21 Aug 2006 18:12:24 -0000
@@ -875,12 +875,20 @@ static int wpa_cli_cmd_get_capability(st
 {
 	char cmd[64];
 
-	if (argc != 1) {
-		printf("Invalid GET_CAPABILITY command: needs one argument\n");
+	if (argc < 1 || argc > 2) {
+		printf("Invalid GET_CAPABILITY command: need either one or"
+		       " two arguments\n");
 		return 0;
 	}
 
-	snprintf(cmd, sizeof(cmd), "GET_CAPABILITY %s", argv[0]);
+	if ((argc == 2) && strcmp(argv[1], "strict") != 0) {
+		printf("Invalid GET_CAPABILITY command: second argument,"
+		       " if any, must be 'strict'\n");
+		return 0;
+	}
+	
+	snprintf(cmd, sizeof(cmd), "GET_CAPABILITY %s%s", argv[0],
+		 (argc == 2) ? " strict" : "");
 	cmd[sizeof(cmd) - 1] = '\0';
 
 	return wpa_ctrl_command(ctrl, cmd);






More information about the Hostap mailing list