/**
* Max header options data length
*/
-#define CA_MAX_HEADER_OPTION_DATA_LENGTH 16
+#define CA_MAX_HEADER_OPTION_DATA_LENGTH 20
/**
* Max token length
CA_ADAPTER_GATT_BTLE = (1 << 1), // GATT over Bluetooth LE
CA_ADAPTER_RFCOMM_BTEDR = (1 << 2), // RFCOMM over Bluetooth EDR
- #ifdef RA_ADAPTER
+#ifdef RA_ADAPTER
CA_ADAPTER_REMOTE_ACCESS = (1 << 3), // Remote Access over XMPP.
- #endif
+#endif
+ CA_ADAPTER_TCP = (1 << 4), // CoAP over TCP
CA_ALL_ADAPTERS = 0xffffffff
} CATransportAdapter_t;
uint16_t port; // for IP
char addr[MAX_ADDR_STR_SIZE_CA]; // address for all
uint32_t interface; // usually zero for default interface
+#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
+ char routeData[MAX_ADDR_STR_SIZE_CA]; /**< GatewayId:ClientId of
+ destination. **/
+#endif
} CAEndpoint_t;
/**
{
/* Response status code - START HERE */
CA_EMPTY = 0, /**< Empty */
- CA_SUCCESS = 200, /**< Success */
CA_CREATED = 201, /**< Created */
CA_DELETED = 202, /**< Deleted */
CA_VALID = 203, /**< Valid */
CA_BAD_OPT = 402, /**< Bad Option */
CA_FORBIDDEN_REQ = 403, /**< Forbidden Request */
CA_NOT_FOUND = 404, /**< Not found */
+ CA_NOT_ACCEPTABLE = 406, /**< Not Acceptable */
CA_REQUEST_ENTITY_INCOMPLETE = 408, /**< Request Entity Incomplete */
CA_REQUEST_ENTITY_TOO_LARGE = 413, /**< Request Entity Too Large */
CA_INTERNAL_SERVER_ERROR = 500, /**< Internal Server Error */
} CAAdapterState_t;
/**
+ * Format indicating which encoding has been used on the payload.
+ */
+typedef enum
+{
+ CA_FORMAT_UNDEFINED = 0, /**< Undefined enoding format */
+ CA_FORMAT_TEXT_PLAIN,
+ CA_FORMAT_APPLICATION_LINK_FORMAT,
+ CA_FORMAT_APPLICATION_XML,
+ CA_FORMAT_APPLICATION_OCTET_STREAM,
+ CA_FORMAT_APPLICATION_RDF_XML,
+ CA_FORMAT_APPLICATION_EXI,
+ CA_FORMAT_APPLICATION_JSON,
+ CA_FORMAT_APPLICATION_CBOR,
+ CA_FORMAT_UNSUPPORTED
+} CAPayloadFormat_t;
+
+/**
* Header options structure to be filled
*
* This structure is used to hold header information.
{
CAMessageType_t type; /**< Qos for the request */
+#ifdef ROUTING_GATEWAY
+ bool skipRetransmission; /**< Will not attempt retransmission even if type is CONFIRM.
+ Required for packet forwarding */
+#endif
uint16_t messageId; /**< Message id.
* if message id is zero, it will generated by CA inside.
* otherwise, you can use it */
uint8_t numOptions; /**< Number of Header options */
CAPayload_t payload; /**< payload of the request */
size_t payloadSize; /**< size in bytes of the payload */
+ CAPayloadFormat_t payloadFormat; /**< encoding format of the request payload */
+ CAPayloadFormat_t acceptFormat; /**< accept format for the response payload */
CAURI_t resourceUri; /**< Resource URI information **/
CARemoteId_t identity; /**< endpoint identity */
} CAInfo_t;
{
CATransportFlags_t flags;
uint16_t messageId;
+ char token[CA_MAX_TOKEN_LEN];
+ uint8_t tokenLength;
} CAHistoryItem_t;
typedef struct
CATransportFlags_t previousRequestFlags;/**< address family filtering */
uint16_t previousRequestMessageId; /**< address family filtering */
} ca;
+
+#ifdef TCP_ADAPTER
+ /**
+ * Hold global variables for TCP Adapter.
+ */
+ struct tcpsockets
+ {
+ void *threadpool; /**< threadpool between Initialize and Start */
+ void *svrlist; /**< unicast IPv4 TCP server information*/
+ int selectTimeout; /**< in seconds */
+ int listenBacklog; /**< backlog counts*/
+ int maxfd; /**< highest fd (for select) */
+ bool started; /**< the TCP adapter has started */
+ bool terminate; /**< the TCP adapter needs to stop */
+ bool ipv4tcpenabled; /**< IPv4 TCP enabled by OCInit flags */
+ } tcp;
+#endif
} CAGlobals_t;
extern CAGlobals_t caglobals;