#define CA_BUFSIZE (128)
#define CA_PDU_MIN_SIZE (4)
-#define CA_PORT_BUFFER_SIZE (4)
+#define CA_ENCODE_BUFFER_SIZE (4)
static const char COAP_URI_HEADER[] = "coap://[::]/";
transport = coap_get_tcp_header_type_from_initbyte(((unsigned char *)data)[0] >> 4);
}
else
-#else
- (void) endpoint;
#endif
{
transport = coap_udp;
if (0 >= ret)
{
OIC_LOG(ERROR, TAG, "pdu parse failed");
- coap_delete_pdu(outpdu);
- return NULL;
+ goto exit;
}
#ifdef WITH_TCP
{
OIC_LOG_V(ERROR, TAG, "coap version is not available : %d",
outpdu->hdr->coap_hdr_udp_t.version);
- coap_delete_pdu(outpdu);
- return NULL;
+ goto exit;
}
if (outpdu->hdr->coap_hdr_udp_t.token_length > CA_MAX_TOKEN_LEN)
{
OIC_LOG_V(ERROR, TAG, "token length has been exceed : %d",
outpdu->hdr->coap_hdr_udp_t.token_length);
- coap_delete_pdu(outpdu);
- return NULL;
+ goto exit;
}
}
}
return outpdu;
+
+exit:
+ coap_delete_pdu(outpdu);
+ return NULL;
}
coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
if (uri.port != COAP_DEFAULT_PORT)
{
- unsigned char portbuf[CA_PORT_BUFFER_SIZE] = { 0 };
+ unsigned char portbuf[CA_ENCODE_BUFFER_SIZE] = { 0 };
int ret = coap_insert(optlist,
CACreateNewOptionNode(COAP_OPTION_URI_PORT,
coap_encode_var_bytes(portbuf, uri.port),
if (CA_FORMAT_UNDEFINED != info->payloadFormat)
{
coap_list_t* node = NULL;
- uint8_t buf[3] = {0};
+ uint8_t buf[CA_ENCODE_BUFFER_SIZE] = {0};
switch (info->payloadFormat)
{
case CA_FORMAT_APPLICATION_CBOR:
node = CACreateNewOptionNode(
COAP_OPTION_CONTENT_FORMAT,
- coap_encode_var_bytes(buf, (uint16_t)COAP_MEDIATYPE_APPLICATION_CBOR),
+ coap_encode_var_bytes(buf, (unsigned short)COAP_MEDIATYPE_APPLICATION_CBOR),
(char *)buf);
break;
default:
if (CA_FORMAT_UNDEFINED != info->acceptFormat)
{
coap_list_t* node = NULL;
- uint8_t buf[3] = {0};
+ uint8_t buf[CA_ENCODE_BUFFER_SIZE] = {0};
switch (info->acceptFormat)
{
case CA_FORMAT_APPLICATION_CBOR:
node = CACreateNewOptionNode(
COAP_OPTION_ACCEPT,
- coap_encode_var_bytes(buf, (uint16_t)COAP_MEDIATYPE_APPLICATION_CBOR),
+ coap_encode_var_bytes(buf, (unsigned short)COAP_MEDIATYPE_APPLICATION_CBOR),
(char *)buf);
break;
default:
&& COAP_OPTION_BLOCK1 != opt_iter.type && COAP_OPTION_BLOCK2 != opt_iter.type
&& COAP_OPTION_SIZE1 != opt_iter.type && COAP_OPTION_SIZE2 != opt_iter.type
&& COAP_OPTION_CONTENT_FORMAT != opt_iter.type
- && COAP_OPTION_ACCEPT != opt_iter.type)
+ && COAP_OPTION_ACCEPT != opt_iter.type
+ && COAP_OPTION_URI_HOST != opt_iter.type && COAP_OPTION_URI_PORT != opt_iter.type
+ && COAP_OPTION_ETAG != opt_iter.type && COAP_OPTION_MAXAGE != opt_iter.type
+ && COAP_OPTION_PROXY_URI != opt_iter.type && COAP_OPTION_PROXY_SCHEME != opt_iter.type)
{
count++;
}
transport = coap_get_tcp_header_type_from_initbyte(((unsigned char *)pdu->hdr)[0] >> 4);
}
else
-#else
- (void) endpoint;
#endif
{
transport = coap_udp;
{
outInfo->payloadFormat = CA_FORMAT_UNSUPPORTED;
OIC_LOG_V(DEBUG, TAG, "option[%d] has an unsupported format [%d]",
- opt_iter.type, (uint8_t)buf[0]);
+ opt_iter.type, (uint8_t)buf[0]);
}
}
else if (COAP_OPTION_ACCEPT == opt_iter.type)
outInfo->acceptFormat = CA_FORMAT_UNSUPPORTED;
}
OIC_LOG_V(DEBUG, TAG, "option[%d] has an unsupported format [%d]",
- opt_iter.type, (uint8_t)buf[0]);
+ opt_iter.type, (uint8_t)buf[0]);
+ }
+ else if (COAP_OPTION_URI_PORT == opt_iter.type ||
+ COAP_OPTION_URI_HOST == opt_iter.type ||
+ COAP_OPTION_ETAG == opt_iter.type ||
+ COAP_OPTION_MAXAGE == opt_iter.type ||
+ COAP_OPTION_PROXY_URI == opt_iter.type ||
+ COAP_OPTION_PROXY_SCHEME== opt_iter.type)
+ {
+ OIC_LOG_V(INFO, TAG, "option[%d] has an unsupported format [%d]",
+ opt_iter.type, (uint8_t)buf[0]);
}
else
{
OICFree(token);
}
-void CADestroyInfo(CAInfo_t *info)
-{
- if (NULL != info)
- {
- OIC_LOG(DEBUG, TAG, "free options");
- OICFree(info->options);
-
- OIC_LOG(DEBUG, TAG, "free token");
- OICFree(info->token);
-
- OIC_LOG(DEBUG, TAG, "free payload");
- OICFree(info->payload);
- }
-}
-
uint32_t CAGetOptionData(uint16_t key, const uint8_t *data, uint32_t len,
uint8_t *option, uint32_t buflen)
{
}
}
+#ifdef WITH_BWT
+bool CAIsSupportedBlockwiseTransfer(CATransportAdapter_t adapter)
+{
+ if (CA_ADAPTER_IP & adapter || CA_ADAPTER_NFC & adapter
+ || CA_DEFAULT_ADAPTER == adapter)
+ {
+ return true;
+ }
+ return false;
+}
+#endif
+
#ifdef WITH_TCP
bool CAIsSupportedCoAPOverTCP(CATransportAdapter_t adapter)
{
- if (CA_ADAPTER_GATT_BTLE == adapter || CA_ADAPTER_RFCOMM_BTEDR == adapter
- || CA_ADAPTER_TCP == adapter)
+ if (CA_ADAPTER_GATT_BTLE & adapter || CA_ADAPTER_RFCOMM_BTEDR & adapter
+ || CA_ADAPTER_TCP & adapter || CA_DEFAULT_ADAPTER == adapter)
{
return true;
}