Commit f7e8c4ba authored by Andrii Shtompel's avatar Andrii Shtompel Committed by Randeep

PSK check before ciphersuite selection

Checking identity added to avoid including PSK suite
if no appropriate PSK in SVR DB.

Change-Id: I118c4b5864929cc8fdd0597af855f3c06b9332dc
Signed-off-by: default avatarDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Signed-off-by: default avatarAndrii Shtompel <a.shtompel@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16731Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarOleksii Beketov <ol.beketov@samsung.com>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
parent bbf7c5c5
......@@ -22,10 +22,11 @@
#define TIMER_H_
#include "iotivity_config.h"
#ifdef HAVE_SYS_TIME_H
#ifdef HAVE_TIME_H
#include <time.h>
#elif defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
#ifdef HAVE_ARDUINO_TIME_H
#elif defined(HAVE_ARDUINO_TIME_H)
#include <Time.h>
#endif
......
......@@ -104,10 +104,11 @@ bool CAGetSecureEndpointAttributes(const CAEndpoint_t* peer, uint32_t* allAttrib
* This internal callback is used by CA layer to
* retrieve all credential types from SRM
*
* @param[out] list of enabled credential types for CA handshake
* @param[out] list of enabled credential types for CA handshake.
* @param[in] device uuid.
*
*/
typedef void (*CAgetCredentialTypesHandler)(bool * list);
typedef void (*CAgetCredentialTypesHandler)(bool * list, const char* deviceId);
/**
* Binary structure containing PKIX related info
* own certificate chain, public key, CA's and CRL's
......
......@@ -1271,7 +1271,8 @@ static int InitPskIdentity(mbedtls_ssl_config * config)
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
return 0;
}
static void SetupCipher(mbedtls_ssl_config * config, CATransportAdapter_t adapter)
static void SetupCipher(mbedtls_ssl_config * config, CATransportAdapter_t adapter,
const char* deviceId)
{
int index = 0;
OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
......@@ -1290,7 +1291,8 @@ static void SetupCipher(mbedtls_ssl_config * config, CATransportAdapter_t adapte
return;
}
g_getCredentialTypesCallback(g_caSslContext->cipherFlag);
g_getCredentialTypesCallback(g_caSslContext->cipherFlag, deviceId);
// Retrieve the PSK credential from SRM
if (true == g_caSslContext->cipherFlag[0] && 0 != InitPskIdentity(config))
{
......@@ -1377,7 +1379,7 @@ static SslEndPoint_t * InitiateTlsHandshake(const CAEndpoint_t *endpoint)
}
//Load allowed SVR suites from SVR DB
SetupCipher(config, endpoint->adapter);
SetupCipher(config, endpoint->adapter, endpoint->remoteId);
ret = u_arraylist_add(g_caSslContext->peerList, (void *) tep);
if (!ret)
......@@ -1928,7 +1930,7 @@ CAResult_t CAdecryptSsl(const CASecureEndpoint_t *sep, uint8_t *data, size_t dat
return CA_STATUS_FAILED;
}
//Load allowed TLS suites from SVR DB
SetupCipher(config, sep->endpoint.adapter);
SetupCipher(config, sep->endpoint.adapter, sep->endpoint.remoteId);
ret = u_arraylist_add(g_caSslContext->peerList, (void *) peer);
if (!ret)
......
......@@ -1372,11 +1372,7 @@ CASocketFd_t CAConnectTCPSession(const CAEndpoint_t *endpoint)
OIC_LOG(ERROR, TAG, "Out of memory");
return OC_INVALID_SOCKET;
}
memcpy(svritem->sep.endpoint.addr, endpoint->addr, sizeof(svritem->sep.endpoint.addr));
svritem->sep.endpoint.adapter = endpoint->adapter;
svritem->sep.endpoint.port = endpoint->port;
svritem->sep.endpoint.flags = endpoint->flags;
svritem->sep.endpoint.ifindex = endpoint->ifindex;
svritem->sep.endpoint = *endpoint;
svritem->state = CONNECTING;
svritem->isClient = true;
......
......@@ -27,6 +27,7 @@
#include "iotivity_config.h"
#include "gtest/gtest.h"
#include "time.h"
#include "octypes.h"
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
......@@ -999,8 +1000,10 @@ static void socketClose_server()
OC_CLOSE_SOCKET(sockfd);
}
static void clutch(bool * list)
static void clutch(bool * list, const char *deviceId)
{
OC_UNUSED(deviceId);
list[1] = true;
}
......@@ -1908,6 +1911,7 @@ static ssize_t CATCPPacketSendCB_forInitHsTest(CAEndpoint_t *, const void * buf,
static void * test0CAinitiateSslHandshake(void * arg)
{
CAEndpoint_t serverAddr;
memset(&serverAddr, 0, sizeof(serverAddr));
serverAddr.adapter = CA_ADAPTER_TCP;
serverAddr.flags = CA_SECURE;
serverAddr.port = 4433;
......@@ -2082,6 +2086,7 @@ static void * testCAencryptSsl(void * arg)
{
int ret = 0;
CAEndpoint_t serverAddr;
memset(&serverAddr, 0, sizeof(serverAddr));
serverAddr.adapter = CA_ADAPTER_TCP;
serverAddr.flags = CA_SECURE;
serverAddr.port = 4433;
......@@ -2536,6 +2541,7 @@ static void * testCAdecryptSsl(void * arg)
int buflen = 0;
CAEndpoint_t serverAddr;
memset(&serverAddr, 0, sizeof(serverAddr));
serverAddr.adapter = CA_ADAPTER_TCP;
serverAddr.flags = CA_SECURE;
serverAddr.port = 4433;
......@@ -3084,6 +3090,7 @@ static void * testCAsslGenerateOwnerPsk(void * arg)
{
int ret = 0;
CAEndpoint_t serverAddr;
memset(&serverAddr, 0, sizeof(serverAddr));
serverAddr.adapter = CA_ADAPTER_TCP;
serverAddr.flags = CA_SECURE;
serverAddr.port = 4433;
......
......@@ -251,10 +251,11 @@ void GetDerKey(ByteArray_t * key, const char * usage);
/**
* Used by CA to retrieve credential types
*
* @param[out] key key to be filled.
* @param[out] list list of suites to be filled.
* @param[in] usage credential usage string.
* @param[in] device uuid.
*/
void InitCipherSuiteListInternal(bool *list, const char * usage);
void InitCipherSuiteListInternal(bool *list, const char * usage, const char* deviceId);
#endif // __WITH_TLS__
// Helpers shared by cred and roles resources
......
......@@ -45,15 +45,17 @@ void GetManufacturerPkixInfo(PkiInfo_t * inf);
* Used by CA to retrieve credential types
*
* @param[out] list TLS suites boolean map.
* @param[in] device uuid.
*/
void InitCipherSuiteList(bool * list);
void InitCipherSuiteList(bool * list, const char* deviceId);
/**
* Used by CA to retrieve manufacturer credential types
*
* @param[out] list TLS suites boolean map.
* @param[in] device uuid.
*/
void InitManufacturerCipherSuiteList(bool * list);
void InitManufacturerCipherSuiteList(bool * list, const char* deviceId);
#ifdef __cplusplus
}
#endif
......
......@@ -57,6 +57,7 @@
#include "oxmpreconfpin.h"
#include "oxmrandompin.h"
#include "otmcontextlist.h"
#include "ocstackinternal.h"
#include "mbedtls/ssl_ciphersuites.h"
#include "ocrandom.h"
......@@ -660,11 +661,18 @@ static OCStackResult SaveSubOwnerPSK(OCProvisionDev_t *selectedDeviceInfo)
OCStackResult res = OC_STACK_ERROR;
CAEndpoint_t endpoint;
memset(&endpoint, 0x00, sizeof(CAEndpoint_t));
OICStrcpy(endpoint.addr, MAX_ADDR_STR_SIZE_CA, selectedDeviceInfo->endpoint.addr);
endpoint.addr[MAX_ADDR_STR_SIZE_CA - 1] = '\0';
endpoint.port = selectedDeviceInfo->securePort;
endpoint.adapter = selectedDeviceInfo->endpoint.adapter;
CopyDevAddrToEndpoint(&selectedDeviceInfo->endpoint, &endpoint);
if (CA_ADAPTER_IP == endpoint.adapter)
{
endpoint.port = selectedDeviceInfo->securePort;
}
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
endpoint.port = selectedDeviceInfo->tcpPort;
}
#endif
OicUuid_t ownerDeviceID = {.id={0}};
if (OC_STACK_OK != GetDoxmDeviceID(&ownerDeviceID))
......
......@@ -776,12 +776,18 @@ static OCStackResult SaveOwnerPSK(OCProvisionDev_t *selectedDeviceInfo)
OCStackResult res = OC_STACK_ERROR;
CAEndpoint_t endpoint;
memset(&endpoint, 0x00, sizeof(CAEndpoint_t));
OICStrcpy(endpoint.addr, MAX_ADDR_STR_SIZE_CA, selectedDeviceInfo->endpoint.addr);
endpoint.addr[MAX_ADDR_STR_SIZE_CA - 1] = '\0';
endpoint.port = selectedDeviceInfo->securePort;
endpoint.adapter = selectedDeviceInfo->endpoint.adapter;
uint8_t ownerPSK[OWNER_PSK_LENGTH_128] = { 0 };
CopyDevAddrToEndpoint(&selectedDeviceInfo->endpoint, &endpoint);
if (CA_ADAPTER_IP == endpoint.adapter)
{
endpoint.port = selectedDeviceInfo->securePort;
}
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
endpoint.port = selectedDeviceInfo->tcpPort;
}
#endif
OicUuid_t ownerDeviceID = {.id={0}};
if (OC_STACK_OK != GetDoxmDeviceID(&ownerDeviceID))
......@@ -792,6 +798,8 @@ static OCStackResult SaveOwnerPSK(OCProvisionDev_t *selectedDeviceInfo)
OicSecKey_t ownerKey;
memset(&ownerKey, 0, sizeof(ownerKey));
uint8_t ownerPSK[OWNER_PSK_LENGTH_128] = { 0 };
ownerKey.data = ownerPSK;
ownerKey.len = OWNER_PSK_LENGTH_128;
ownerKey.encoding = OIC_ENCODING_RAW;
......@@ -1740,6 +1748,15 @@ static OCStackResult PostOwnerAcl(OTMContext_t* otmCtx)
OicSecAcl_t* ownerAcl = NULL;
assert(deviceInfo->connType & CT_FLAG_SECURE);
CAEndpoint_t endpoint;
CopyDevAddrToEndpoint(&deviceInfo->endpoint, &endpoint);
if (CA_STATUS_OK != CAInitiateHandshake(&endpoint))
{
OIC_LOG(ERROR, TAG, "Failed to pass ssl handshake");
return OC_STACK_ERROR;
}
if(!PMGenerateQuery(true,
deviceInfo->endpoint.addr, deviceInfo->securePort,
deviceInfo->connType,
......
......@@ -28,6 +28,7 @@
#include "logger.h"
#include "pmtypes.h"
#include "ownershiptransfermanager.h"
#include "ocstackinternal.h"
#include "mbedtls/ssl_ciphersuites.h"
#define TAG "OIC_OXM_JustWorks"
......@@ -108,26 +109,22 @@ OCStackResult CreateSecureSessionJustWorksCallback(OTMContext_t* otmCtx)
}
OIC_LOG(INFO, TAG, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA256 cipher suite selected.");
OCProvisionDev_t *selDevInfo = otmCtx->selectedDeviceInfo;
CAEndpoint_t endpoint;
memcpy(&endpoint, &selDevInfo->endpoint, sizeof(CAEndpoint_t));
OCProvisionDev_t *selDevInfo = otmCtx->selectedDeviceInfo;
CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint);
if(CA_ADAPTER_IP == endpoint.adapter)
if (CA_ADAPTER_IP == endpoint.adapter)
{
endpoint.port = selDevInfo->securePort;
caresult = CAInitiateHandshake(&endpoint);
}
else if (CA_ADAPTER_GATT_BTLE == endpoint.adapter)
{
caresult = CAInitiateHandshake(&endpoint);
}
#ifdef __WITH_TLS__
else
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
endpoint.port = selDevInfo->tcpPort;
caresult = CAinitiateSslHandshake(&endpoint);
}
#endif
caresult = CAInitiateHandshake(&endpoint);
if (CA_STATUS_OK != caresult)
{
OIC_LOG_V(ERROR, TAG, "DTLS/TLS handshake failure.");
......
......@@ -37,6 +37,7 @@
#include "srmresourcestrings.h"
#include "pkix_interface.h"
#include "mbedtls/ssl_ciphersuites.h"
#include "ocstackinternal.h"
#define TAG "OXM_MCertificate"
......@@ -137,16 +138,22 @@ OCStackResult CreateSecureSessionMCertificateCallback(OTMContext_t* otmCtx)
}
OIC_LOG(INFO, TAG, "MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 cipher suite selected.");
CAEndpoint_t endpoint;
OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo;
CAEndpoint_t *endpoint = (CAEndpoint_t *)OICCalloc(1, sizeof (CAEndpoint_t));
if (NULL == endpoint)
CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint);
if (CA_ADAPTER_IP == endpoint.adapter)
{
endpoint.port = selDevInfo->securePort;
}
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
return OC_STACK_NO_MEMORY;
endpoint.port = selDevInfo->tcpPort;
}
memcpy(endpoint,&selDevInfo->endpoint,sizeof(CAEndpoint_t));
endpoint->port = selDevInfo->securePort;
caresult = CAInitiateHandshake(endpoint);
OICFree(endpoint);
#endif
caresult = CAInitiateHandshake(&endpoint);
if (CA_STATUS_OK != caresult)
{
OIC_LOG_V(ERROR, TAG, "DTLS handshake failure.");
......
......@@ -36,6 +36,7 @@
#include "ownershiptransfermanager.h"
#include "pinoxmcommon.h"
#include "srmresourcestrings.h"
#include "ocstackinternal.h"
#include "mbedtls/ssl_ciphersuites.h"
#define TAG "OIC_OXM_PreconfigPIN"
......@@ -194,16 +195,22 @@ OCStackResult CreateSecureSessionPreconfigPinCallback(OTMContext_t* otmCtx)
}
OIC_LOG(INFO, TAG, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 cipher suite selected.");
CAEndpoint_t endpoint;
OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo;
CAEndpoint_t *endpoint = (CAEndpoint_t *)OICCalloc(1, sizeof (CAEndpoint_t));
if (NULL == endpoint)
CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint);
if (CA_ADAPTER_IP == endpoint.adapter)
{
endpoint.port = selDevInfo->securePort;
}
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
return OC_STACK_NO_MEMORY;
endpoint.port = selDevInfo->tcpPort;
}
memcpy(endpoint,&selDevInfo->endpoint,sizeof(CAEndpoint_t));
endpoint->port = selDevInfo->securePort;
caresult = CAInitiateHandshake(endpoint);
OICFree(endpoint);
#endif
caresult = CAInitiateHandshake(&endpoint);
if (CA_STATUS_OK != caresult)
{
OIC_LOG_V(ERROR, TAG, "DTLS handshake failure.");
......
......@@ -34,6 +34,7 @@
#include "oxmrandompin.h"
#include "ownershiptransfermanager.h"
#include "pinoxmcommon.h"
#include "ocstackinternal.h"
#include "mbedtls/ssl_ciphersuites.h"
#define TAG "OIC_OXM_RandomPIN"
......@@ -146,26 +147,22 @@ OCStackResult CreateSecureSessionRandomPinCallback(OTMContext_t* otmCtx)
}
OIC_LOG(INFO, TAG, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 cipher suite selected.");
OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo;
CAEndpoint_t endpoint;
memcpy(&endpoint, &selDevInfo->endpoint, sizeof(CAEndpoint_t));
OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo;
CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint);
if(CA_ADAPTER_IP == endpoint.adapter)
if (CA_ADAPTER_IP == endpoint.adapter)
{
endpoint.port = selDevInfo->securePort;
caresult = CAInitiateHandshake(&endpoint);
}
else if (CA_ADAPTER_GATT_BTLE == endpoint.adapter)
{
caresult = CAInitiateHandshake(&endpoint);
}
#ifdef __WITH_TLS__
else
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
endpoint.port = selDevInfo->tcpPort;
caresult = CAinitiateSslHandshake(&endpoint);
}
#endif
caresult = CAInitiateHandshake(&endpoint);
if (CA_STATUS_OK != caresult)
{
OIC_LOG_V(ERROR, TAG, "DTLS handshake failure.");
......
......@@ -3363,7 +3363,7 @@ void GetDerKey(ByteArray_t * key, const char * usage)
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
}
void InitCipherSuiteListInternal(bool * list, const char * usage)
void InitCipherSuiteListInternal(bool * list, const char * usage, const char *deviceId)
{
OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
if (NULL == list || NULL == usage)
......@@ -3385,8 +3385,15 @@ void InitCipherSuiteListInternal(bool * list, const char * usage)
}
case SYMMETRIC_PAIR_WISE_KEY:
{
list[0] = true;
OIC_LOG(DEBUG, TAG, "SYMMETRIC_PAIR_WISE_KEY found");
OicUuid_t uuid;
if (NULL == deviceId ||
OC_STACK_OK != ConvertStrToUuid(deviceId, &uuid) ||
0 == memcmp(uuid.id, temp->subject.id, sizeof(uuid.id)))
{
list[0] = true;
OIC_LOG(DEBUG, TAG, "SYMMETRIC_PAIR_WISE_KEY found");
}
break;
}
case SIGNED_ASYMMETRIC_KEY:
......
......@@ -51,6 +51,7 @@
#include "pmtypes.h"
#include "pmutility.h"
#include "srmutility.h"
#include "ocstackinternal.h"
#if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
#include <mbedtls/ssl_ciphersuites.h>
#endif
......@@ -635,15 +636,12 @@ static OCStackApplicationResult DirectPairingHandler(void *ctx, OCDoHandle UNUSE
VERIFY_SUCCESS(TAG, CA_STATUS_OK == caresult, ERROR);
// initiate dtls
CAEndpoint_t *endpoint = (CAEndpoint_t *)OICCalloc(1, sizeof (CAEndpoint_t));
VERIFY_NOT_NULL(TAG, endpoint, FATAL);
memcpy(endpoint,&dpairData->peer->endpoint,sizeof(CAEndpoint_t));
endpoint->port = dpairData->peer->securePort;
OIC_LOG_V(INFO, TAG, "Initiate DTLS handshake to %s(%d)", endpoint->addr,
endpoint->port);
caresult = CAInitiateHandshake(endpoint);
OICFree(endpoint);
CAEndpoint_t endpoint;
CopyDevAddrToEndpoint(&dpairData->peer->endpoint, &endpoint);
endpoint.port = dpairData->peer->securePort;
OIC_LOG_V(INFO, TAG, "Initiate DTLS handshake to %s(%d)", endpoint.addr,
endpoint.port);
caresult = CAInitiateHandshake(&endpoint);
VERIFY_SUCCESS(TAG, CA_STATUS_OK == caresult, ERROR);
#endif // __WITH_DTLS__ or __WITH_TLS__
......
......@@ -76,7 +76,7 @@ void GetManufacturerPkixInfo(PkiInfo_t * inf)
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
}
void InitCipherSuiteList(bool * list)
void InitCipherSuiteList(bool * list, const char* deviceId)
{
OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
if (NULL == list)
......@@ -85,11 +85,11 @@ void InitCipherSuiteList(bool * list)
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
return;
}
InitCipherSuiteListInternal(list, TRUST_CA);
InitCipherSuiteListInternal(list, TRUST_CA, deviceId);
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
}
void InitManufacturerCipherSuiteList(bool * list)
void InitManufacturerCipherSuiteList(bool * list, const char* deviceId)
{
OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
if (NULL == list)
......@@ -98,6 +98,6 @@ void InitManufacturerCipherSuiteList(bool * list)
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
return;
}
InitCipherSuiteListInternal(list, MF_TRUST_CA);
InitCipherSuiteListInternal(list, MF_TRUST_CA, deviceId);
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
}
......@@ -53,7 +53,6 @@ static int WithTcp = 0;
static char DISCOVERY_QUERY[] = "%s/oic/res";
OCConnectivityType discoveryReqConnType = CT_ADAPTER_IP;
static OCDevAddr endpoint;
static std::string coapServerResource;
static int coapSecureResource;
......@@ -198,21 +197,20 @@ OCStackApplicationResult discoveryReqCB(void *, OCDoHandle,
OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
ocConnType = clientResponse->connType;
endpoint = clientResponse->devAddr;
if (parseClientResponse(clientResponse) != -1)
{
switch (TestCase)
{
case TEST_NON_CON_OP:
InitGetRequest(OC_LOW_QOS);
InitPutRequest(OC_LOW_QOS);
InitPostRequest(OC_LOW_QOS);
InitGetRequest(&clientResponse->devAddr, OC_LOW_QOS);
InitPutRequest(&clientResponse->devAddr, OC_LOW_QOS);
InitPostRequest(&clientResponse->devAddr, OC_LOW_QOS);
break;
case TEST_CON_OP:
InitGetRequest(OC_HIGH_QOS);
InitPutRequest(OC_HIGH_QOS);
InitPostRequest(OC_HIGH_QOS);
InitGetRequest(&clientResponse->devAddr, OC_HIGH_QOS);
InitPutRequest(&clientResponse->devAddr, OC_HIGH_QOS);
InitPostRequest(&clientResponse->devAddr, OC_HIGH_QOS);
break;
}
}
......@@ -222,21 +220,17 @@ OCStackApplicationResult discoveryReqCB(void *, OCDoHandle,
return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
}
int InitPutRequest(OCQualityOfService qos)
int InitPutRequest(OCDevAddr *endpoint, OCQualityOfService qos)
{
OIC_LOG_V(INFO, TAG, "Executing %s", __func__);
std::ostringstream query;
query << coapServerResource;
if (WithTcp)
{
endpoint.adapter = OC_ADAPTER_TCP;
}
endpoint.flags = (OCTransportFlags)(endpoint.flags | OC_SECURE);
return (InvokeOCDoResource(query, OC_REST_PUT, &endpoint,
return (InvokeOCDoResource(query, OC_REST_PUT, endpoint,
((qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS), putReqCB, NULL, 0));
}
int InitPostRequest(OCQualityOfService qos)
int InitPostRequest(OCDevAddr *endpoint, OCQualityOfService qos)
{
OCStackResult result;
......@@ -244,14 +238,8 @@ int InitPostRequest(OCQualityOfService qos)
std::ostringstream query;
query << coapServerResource;
if (WithTcp)
{
endpoint.adapter = OC_ADAPTER_TCP;
}
endpoint.flags = (OCTransportFlags)(endpoint.flags | OC_SECURE);
// First POST operation (to create an LED instance)
result = InvokeOCDoResource(query, OC_REST_POST, &endpoint,
result = InvokeOCDoResource(query, OC_REST_POST, endpoint,
((qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS),
postReqCB, NULL, 0);
if (OC_STACK_OK != result)
......@@ -261,7 +249,7 @@ int InitPostRequest(OCQualityOfService qos)
}
// Second POST operation (to create an LED instance)
result = InvokeOCDoResource(query, OC_REST_POST, &endpoint,
result = InvokeOCDoResource(query, OC_REST_POST, endpoint,
((qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS),
postReqCB, NULL, 0);
if (OC_STACK_OK != result)
......@@ -271,7 +259,7 @@ int InitPostRequest(OCQualityOfService qos)
// This POST operation will update the original resourced /a/led (as long as
// the server is set to max 2 /lcd resources)
result = InvokeOCDoResource(query, OC_REST_POST, &endpoint,
result = InvokeOCDoResource(query, OC_REST_POST, endpoint,
((qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS),
postReqCB, NULL, 0);
if (OC_STACK_OK != result)
......@@ -281,18 +269,13 @@ int InitPostRequest(OCQualityOfService qos)
return result;
}
int InitGetRequest(OCQualityOfService qos)
int InitGetRequest(OCDevAddr *endpoint, OCQualityOfService qos)
{
OIC_LOG_V(INFO, TAG, "Executing %s", __func__);
std::ostringstream query;
query << coapServerResource;
if (WithTcp)
{
endpoint.adapter = OC_ADAPTER_TCP;
}
endpoint.flags = (OCTransportFlags)(endpoint.flags | OC_SECURE);
return (InvokeOCDoResource(query, OC_REST_GET, &endpoint,
return (InvokeOCDoResource(query, OC_REST_GET, endpoint,
((qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS),
getReqCB, NULL, 0));