From 35813be24160b474f3e58438a2841f829d92bb09 Mon Sep 17 00:00:00 2001 From: Sashi Penta Date: Thu, 25 Dec 2014 00:05:48 -0800 Subject: [PATCH] Fixes to send the correct sender info when a presence notification is sent Change-Id: Id903483a5f329692fc57275076af2c36d0d1adf0 Signed-off-by: Sashi Penat --- resource/csdk/stack/src/ocstack.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index 1108663..1a09e35 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -238,6 +238,17 @@ OCStackResult CAToOCStackResult(CAResponseResult_t caCode) return ret; } +// update response.addr appropriately from endPoint.addressInfo +void UpdateResponseAddr(OCClientResponse *response, const CARemoteEndpoint_t* endPoint) +{ + struct sockaddr_in sa; + inet_pton(AF_INET, endPoint->addressInfo.IP.ipAddress, &(sa.sin_addr)); + sa.sin_port = htons(endPoint->addressInfo.IP.port); + static OCDevAddr address; + memcpy((void*)&address.addr, &(sa), sizeof(sa)); + response->addr = &address; +} + void HandlePresenceResponse(const CARemoteEndpoint_t* endPoint, const CAResponseInfo_t* responseInfo) { OCStackApplicationResult cbResult = OC_STACK_DELETE_TRANSACTION; @@ -247,6 +258,8 @@ void HandlePresenceResponse(const CARemoteEndpoint_t* endPoint, const CAResponse char * bufRes = responseInfo->info.payload; OCClientResponse *response = (OCClientResponse *) OCMalloc(sizeof(OCClientResponse)); + UpdateResponseAddr(response, endPoint); + if(!bufRes) { goto exit; @@ -321,16 +334,10 @@ void HandleCAResponses(const CARemoteEndpoint_t* endPoint, const CAResponseInfo_ { OC_LOG(INFO, TAG, PCF("Calling into application address space")); OCClientResponse response; - struct sockaddr_in sa; - inet_pton(AF_INET, endPoint->addressInfo.IP.ipAddress, &(sa.sin_addr)); - sa.sin_port = htons(endPoint->addressInfo.IP.port); - static OCDevAddr address; - memcpy((void*)&address.addr, &(sa), sizeof(sa)); - response.addr = &address; - #ifdef CA_INT + UpdateResponseAddr(&response, endPoint); response.connType = endPoint->connectivityType; - #endif + response.result = CAToOCStackResult(responseInfo->result); response.resJSONPayload = (unsigned char*)responseInfo->info.payload; response.numRcvdVendorSpecificHeaderOptions = 0; -- 2.7.4