NAN: Fix to update subscribe id in subscribe followup

Subscribe id is not updated as part of subscribe follow up request,
which makes the follow up request to be sent out as new subscribe
request.

Fix the issue by updating the subscribe id from the earlier subscribe
request if the service name of subscribe request matches with the
current one.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
diff --git a/nan.c b/nan.c
index 95793b3..0a435f2 100644
--- a/nan.c
+++ b/nan.c
@@ -42,6 +42,8 @@
 static char global_event_resp_buf[1024];
 static u8 global_publish_service_name[NAN_MAX_SERVICE_NAME_LEN];
 static u32 global_publish_service_name_len = 0;
+static u8 global_subscribe_service_name[NAN_MAX_SERVICE_NAME_LEN];
+static u32 global_subscribe_service_name_len = 0;
 
 static int nan_further_availability_tx(struct sigma_dut *dut,
 				       struct sigma_conn *conn,
@@ -489,6 +491,17 @@
 	req.subscribe_match_indicator = NAN_MATCH_ALG_MATCH_CONTINUOUS;
 	req.subscribe_count = 0;
 
+	if (global_subscribe_service_name_len &&
+	    service_name &&
+	    strcasecmp((char *) global_subscribe_service_name,
+		       service_name) == 0 &&
+	    global_subscribe_id) {
+		req.subscribe_id = global_subscribe_id;
+		sigma_dut_print(dut, DUT_MSG_INFO,
+				"%s: updating subscribe_id = %d in subscribe request",
+				__func__, req.subscribe_id);
+	}
+
 	if (subscribe_type) {
 		if (strcasecmp(subscribe_type, "Active") == 0) {
 			req.subscribe_type = 1;
@@ -573,6 +586,10 @@
 		strlcpy((char *) req.service_name, service_name,
 			strlen(service_name) + 1);
 		req.service_name_len = strlen(service_name);
+		strlcpy((char *) global_subscribe_service_name, service_name,
+			sizeof(global_subscribe_service_name));
+		global_subscribe_service_name_len =
+			strlen((char *) global_subscribe_service_name);
 	}
 
 #if NAN_CERT_VERSION >= 3