diff options
author | Brian Freeman <bf1936@att.com> | 2017-08-24 19:06:13 +0000 |
---|---|---|
committer | Brian Freeman <bf1936@att.com> | 2017-08-24 19:12:39 +0000 |
commit | c358a56bd31e8294a72a5fee92c7a2d38a061146 (patch) | |
tree | f9a57f33e9dea317a72a50ee987b112aa1904e76 /vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc | |
parent | eb0c348a4baf6fd2026a7a3953d8f754ff71a1bf (diff) |
DMaaP url and POST data
Change-Id: I36a2fc8d2b36cb3730d4c9b14c09f78dc3d3da0c
Signed-off-by: Brian Freeman <bf1936@att.com>
Issue-Id: UCA-35
Diffstat (limited to 'vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc')
-rw-r--r-- | vnfs/vCPE/kea-sdnc-notify-mod/src/pkt4_send.cc | 13 |
1 files changed, 6 insertions, 7 deletions
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); |