DMaaP url and POST data 75/8675/1
authorBrian Freeman <bf1936@att.com>
Thu, 24 Aug 2017 19:06:13 +0000 (19:06 +0000)
committerBrian Freeman <bf1936@att.com>
Thu, 24 Aug 2017 19:12:39 +0000 (19:12 +0000)
Change-Id: I36a2fc8d2b36cb3730d4c9b14c09f78dc3d3da0c
Signed-off-by: Brian Freeman <bf1936@att.com>
Issue-Id: UCA-35

vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf
vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf.test [new file with mode: 0644]
vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc

index 1a8ee2e..9538ec6 100644 (file)
@@ -1,3 +1,4 @@
-{"url": "http://localhost/sdnc.php?macaddr=",
+{
+ "url": "http://10.0.11.1:3904/events/VCPE-DHCP-EVENT/",
  "siaddr": "siaddr"
 }
diff --git a/vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf.test b/vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf.test
new file mode 100644 (file)
index 0000000..beba0f1
--- /dev/null
@@ -0,0 +1,4 @@
+{
+ "url": "http://localhost/sdnc.php",
+ "siaddr": "siaddr"
+}
index 231a0a8..70d8628 100644 (file)
@@ -84,10 +84,12 @@ int pkt4_send(CalloutHandle& handle) {
     hwaddr = hwaddr_ptr->toText(false);
     yiaddr = new_yiaddr.toText();
     msg_name = response4_ptr->getName();
-    post_data = "{ macaddr=" + hwaddr + "&yiaddr=" + yiaddr + "&msg=" + msg_name + "}";
-    final_url = json_params[0] + hwaddr;
+    /* POST string for DMaaP */
+    post_data = "{\n\"macaddr\":\"" + hwaddr + "\",\n\"yiaddr\":\"" + yiaddr + "\",\n\"msg_name\":\"" + msg_name + "\"\n}";
+    final_url = json_params[0] ;
     LOG_DEBUG(logger, 0, "SNL_BASE").arg(final_url);
     LOG_DEBUG(logger, 0, "SNL_BASE").arg(yiaddr);
+    LOG_DEBUG(logger, 0, "SNL_BASE").arg(post_data);
 
 
     if ( msg_name == "DHCPACK")
@@ -106,6 +108,7 @@ int pkt4_send(CalloutHandle& handle) {
         return(1);
     }
 
+    list = curl_slist_append(list, "Content-type: application/json");
     list = curl_slist_append(list, "Accept: application/json");
     if (list == NULL) {
         curl_easy_cleanup(curl);
@@ -126,15 +129,11 @@ int pkt4_send(CalloutHandle& handle) {
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
 
-    // If we don't set a timeout, curl will try for 300 seconds by default.
+    // Default curl timeout is 300 seconds 
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1L);
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 1L);
-    // libcurl's docs say to cast as void, don't blame me.
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)response_memfile);
-    // CURLOPT_URL takes a char*
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_URL, (final_url).c_str());
-    
-    // let curl use strlen
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, -1L );
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_data.c_str() );
     curl_opt_res += curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);