NAS-Identifier Patch

Gunter Burchardt gbur
Thu Jan 29 02:02:27 PST 2004


Hello,

At the moment hostapd sends only NAS-Ip in radius-packets. For a better
identification of a nas the radius-attribute nas-identifier would be
fine. I patched it into the latest CVS-version of hostapd (0.2.0). In
the atachment is the patch-file.

In each radius-packet the NAS-Identifier attibute will be included. You
can configure it in hostapd.conf.

eg. hostapd.conf:
NASIdentifier=foobar

Perhaps it is a new feature for the cvs.

regards
gunter
-------------- next part --------------
diff -urN hostap/hostapd/accounting.c hostap/hostapd/accounting.c
--- hostap/hostapd/accounting.c	2003-11-09 06:14:06.000000000 +0100
+++ hostap/hostapd/accounting.c	2004-01-09 10:39:48.000000000 +0100
@@ -83,6 +83,11 @@
 		goto fail;
 	}
 
+	if (!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IDENTIFIER, hapd->conf->NAS_Identifier, strlen(hapd->conf->NAS_Identifier))) {
+		printf("Could not add NAS-Identifier\n");
+		goto  fail;
+	}
+
 	if (!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IP_ADDRESS,
 				 (u8 *) &hapd->conf->own_ip_addr, 4)) {
 		printf("Could not add NAS-IP-Address\n");
diff -urN hostap/hostapd/config.c hostap/hostapd/config.c
--- hostap/hostapd/config.c	2003-09-03 04:51:15.000000000 +0200
+++ hostap/hostapd/config.c	2004-01-09 10:45:13.000000000 +0100
@@ -212,6 +212,8 @@
 			conf->logger_stdout = atoi(pos);
 		} else if (strcmp(buf, "dump_file") == 0) {
 			conf->dump_log_name = strdup(pos);
+		} else if (strcmp(buf, "NASIdentifier") == 0) {
+			conf->NAS_Identifier = strdup(pos);
 		} else if (strcmp(buf, "daemonize") == 0) {
 			conf->daemonize = atoi(pos);
 		} else if (strcmp(buf, "ssid") == 0) {
diff -urN hostap/hostapd/config.h hostap/hostapd/config.h
--- hostap/hostapd/config.h	2003-09-03 04:51:15.000000000 +0200
+++ hostap/hostapd/config.h	2004-01-09 10:41:27.000000000 +0100
@@ -60,7 +60,7 @@
 	int ieee802_11f; /* use IEEE 802.11f (IAPP) */
 	char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
 					* frames */
-
+	char *NAS_Identifier;
 	u8 assoc_ap_addr[ETH_ALEN];
 	int assoc_ap; /* whether assoc_ap_addr is set */
 
diff -urN hostap/hostapd/ieee802_11_auth.c hostap/hostapd/ieee802_11_auth.c
--- hostap/hostapd/ieee802_11_auth.c	2003-11-09 06:14:06.000000000 +0100
+++ hostap/hostapd/ieee802_11_auth.c	2004-01-09 10:42:41.000000000 +0100
@@ -126,6 +126,11 @@
 		goto fail;
 	}
 
+	if (!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IDENTIFIER, hapd->conf->NAS_Identifier, strlen(hapd->conf->NAS_Identifier))) {
+		printf("Could not add NAS-Identifier\n");
+		goto  fail;
+	}
+
 	snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
 		 MAC2STR(hapd->own_addr), hapd->conf->ssid);
 	if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLED_STATION_ID,
diff -urN hostap/hostapd/ieee802_1x.c hostap/hostapd/ieee802_1x.c
--- hostap/hostapd/ieee802_1x.c	2003-11-09 06:14:06.000000000 +0100
+++ hostap/hostapd/ieee802_1x.c	2004-01-09 10:43:09.000000000 +0100
@@ -489,6 +489,11 @@
 		goto fail;
 	}
 
+	if (!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IDENTIFIER, hapd->conf->NAS_Identifier, strlen(hapd->conf->NAS_Identifier))) {
+		printf("Could not add NAS-Identifier\n");
+		goto  fail;
+	}
+
 	if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_NAS_PORT_TYPE,
 				       RADIUS_NAS_PORT_TYPE_IEEE_802_11)) {
 		printf("Could not add NAS-Port-Type\n");



More information about the Hostap mailing list