From b972220492f72d79d00b29d30cdae95256463f37 Mon Sep 17 00:00:00 2001
From: Ravinder Konka <rkonka@codeaurora.org>
Date: Mon, 23 Mar 2015 21:53:46 +0530
Subject: [PATCH] presentation-page

Change-Id: I75997749a17a10ac765bc63dc34d401a0e81d06d
---
 upnphttp.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/upnphttp.c b/upnphttp.c
index a6dd865..4742090 100755
--- a/upnphttp.c
+++ b/upnphttp.c
@@ -28,6 +28,7 @@
 #include "upnpsoap.h"
 #include "upnpevents.h"
 #include "upnputils.h"
+#include "upnpglobalvars.h"
 
 #ifdef ENABLE_HTTPS
 #include <openssl/err.h>
@@ -524,11 +525,13 @@ ProcessHTTPPOST_upnphttp(struct upnphttp
 static int
 checkCallbackURL(struct upnphttp * h)
 {
-	char addrstr[48];
+	char addrstr[48], addrstr1[48];
 	int ipv6;
-	const char * p;
+	const char * p,*t;
 	unsigned int i;
-
+/*
+'<http://[fe80::6c4f:b721:4e2d:ea6%13]:49240/urn:upnp-org:serviceId:WANIPv6FC1
+/143598522>'*/
 start_again:
 	if(h->req_CallbackOff <= 0 || h->req_CallbackLen < 10)
 		return 0;
@@ -542,10 +545,15 @@ start_again:
 	if(*p == '[') {
 		p++;
 		ipv6 = 1;
-		while(*p != ']' && *p != '>' && i < (sizeof(addrstr)-1)
+		while(*p != ']' && *p != '>' && *p!='%' && i < (sizeof(addrstr)-1)
 		      && p < (h->req_buf + h->req_CallbackOff + h->req_CallbackLen))
 			addrstr[i++] = *(p++);
-	} else {
+		while(*p != ']' && *p != '>' && i < (sizeof(addrstr)-1)
+		      && p < (h->req_buf + h->req_CallbackOff + h->req_CallbackLen))
+			p++;
+	}
+    else 
+       {
 		ipv6 = 0;
 		while(*p != '/' && *p != ':' && *p != '>' && i < (sizeof(addrstr)-1)
 		      && p < (h->req_buf + h->req_CallbackOff + h->req_CallbackLen))
@@ -556,6 +564,9 @@ start_again:
 	if(ipv6) {
 #ifdef ENABLE_IPV6
 		struct in6_addr addr;
+
+        inet_ntop(AF_INET6,&(h->clientaddr_v6), addrstr1, 48);
+        syslog(LOG_INFO, "ADDR1= %s ADDR2%s\n",addrstr,addrstr1);
 		if(inet_pton(AF_INET6, addrstr, &addr) <= 0)
 			goto invalid;
 		if(!h->ipv6
@@ -701,6 +712,26 @@ ProcessHTTPUnSubscribe_upnphttp(struct u
 }
 #endif
 
+#ifdef QCMAP
+static void
+SendResp_presentation(struct upnphttp * h)
+{
+	char body[1024];
+	int l;
+	h->respflags = FLAG_HTML;
+
+	l = snprintf(body, sizeof(body),
+		"<HTML><HEAD><TITLE>UPnP</TITLE></HEAD>"
+		"<BODY><div style=\"text-align: center\">"
+                "<h3> UPnP is Running!</h3>"
+		"</BODY></HTML>\r\n");
+
+	BuildResp_upnphttp(h, body, l);
+	SendResp_upnphttp(h);
+	CloseSocket_upnphttp(h);
+}
+#endif
+
 /* Parse and process Http Query
  * called once all the HTTP headers have been received,
  * so it is guaranteed that h->req_buf contains the \r\n\r\n
@@ -823,6 +854,12 @@ ProcessHttpQuery_upnphttp(struct upnphtt
 			return;
 		}
 #endif
+#ifdef QCMAP
+		else if(0 == memcmp(HttpUrl, presentationurl, 19)) {
+			SendResp_presentation(h);
+			return;
+		}
+#endif
 		syslog(LOG_NOTICE, "%s not found, responding ERROR 404", HttpUrl);
 		Send404(h);
 	}
-- 
1.8.2.1

