aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Freeman <bf1936@att.com>2017-08-24 19:06:13 +0000
committerBrian Freeman <bf1936@att.com>2017-08-24 19:12:39 +0000
commitc358a56bd31e8294a72a5fee92c7a2d38a061146 (patch)
treef9a57f33e9dea317a72a50ee987b112aa1904e76
parenteb0c348a4baf6fd2026a7a3953d8f754ff71a1bf (diff)
DMaaP url and POST data
Change-Id: I36a2fc8d2b36cb3730d4c9b14c09f78dc3d3da0c Signed-off-by: Brian Freeman <bf1936@att.com> Issue-Id: UCA-35
-rw-r--r--vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf3
-rw-r--r--vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf.test4
-rw-r--r--vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc13
3 files changed, 12 insertions, 8 deletions
diff --git a/vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf b/vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf
index 1a8ee2e3..9538ec6d 100644
--- a/vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf
+++ b/vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf
@@ -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
index 00000000..beba0f15
--- /dev/null
+++ b/vnfs/vCPE/kea-sdnc-notify-mod/etc/kea-sdnc-notify.conf.test
@@ -0,0 +1,4 @@
+{
+ "url": "http://localhost/sdnc.php",
+ "siaddr": "siaddr"
+}
diff --git a/vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc b/vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc
index 231a0a8b..70d86289 100644
--- a/vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc
+++ b/vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc
@@ -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);