X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fstack%2Finclude%2Finternal%2Focserverrequest.h;h=565c6e18f8e244c1c6138a03045be17c01bdc5e3;hb=e536bc9edf0ad1fea100e07755462dc0914304eb;hp=28a0a871cb246d55f06bcaa91b8d807e4af859e0;hpb=8abe951654df71c79a6230399c15e0c7340e1c00;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/stack/include/internal/ocserverrequest.h b/resource/csdk/stack/include/internal/ocserverrequest.h index 28a0a87..565c6e1 100644 --- a/resource/csdk/stack/include/internal/ocserverrequest.h +++ b/resource/csdk/stack/include/internal/ocserverrequest.h @@ -18,74 +18,130 @@ // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +/** + * @file + * + * This file contains the definition, types and interfaces for server request + * + */ + #ifndef OC_SERVER_REQUEST_H #define OC_SERVER_REQUEST_H #include "cacommon.h" #include "cainterface.h" + /** * The signature of the internal call back functions to handle responses from entity handler */ typedef OCStackResult (* OCEHResponseHandler)(OCEntityHandlerResponse * ehResponse); -// following structure will be created in occoap and passed up the stack on the server side +/** + * following structure will be created in occoap and passed up the stack on the server side. + */ typedef struct OCServerRequest { - // the REST method retrieved from received request PDU + /** The REST method retrieved from received request PDU.*/ OCMethod method; - // resourceUrl will be filled in occoap using the path options in received request PDU + + /** Accept format retrieved from the received request PDU. */ + OCPayloadFormat acceptFormat; + + /** resourceUrl will be filled in occoap using the path options in received request PDU.*/ char resourceUrl[MAX_URI_LENGTH]; - // resource query send by client + + /** resource query send by client.*/ char query[MAX_QUERY_LENGTH]; - // qos is indicating if the request is CON or NON + /** qos is indicating if the request is CON or NON.*/ OCQualityOfService qos; - // Observe option field + + /** Observe option field.*/ uint32_t observationOption; + + /** Observe Result field.*/ OCStackResult observeResult; + + /** number of Responses.*/ uint8_t numResponses; + + /** Response Entity Handler .*/ OCEHResponseHandler ehResponseHandler; - /** Remote Endpoint address **/ - CAAddress_t addressInfo; - /** Connectivity of the endpoint**/ - CAConnectivityType_t connectivityType; - // token for the request + + /** Remote endpoint address **/ + OCDevAddr devAddr; + + /** The ID of server request*/ + uint32_t requestId; + + /** Token for the request.*/ CAToken_t requestToken; - // token length the request + + /** token length the request.*/ uint8_t tokenLength; - // The ID of CoAP pdu //Kept in - uint16_t coapID; //CoAP + + /** The ID of CoAP pdu (Kept in CoAp).*/ + uint16_t coapID; + + /** For Delayed Response.*/ uint8_t delayedResNeeded; - uint8_t secured; - ////////////////////////////////////////////////////////// - // An array of the received vendor specific header options + + /** Number of vendor specific header options.*/ uint8_t numRcvdVendorSpecificHeaderOptions; - OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS]; + + /** An Array of received vendor specific header options.*/ + OCHeaderOption *rcvdVendorSpecificHeaderOptions; + + /** Request to complete.*/ uint8_t requestComplete; + + /** Linked list; for multiple server request.*/ struct OCServerRequest * next; - // Flag indicating slow response + + /** Flag indicating slow response.*/ uint8_t slowFlag; + + /** Flag indicating notification.*/ uint8_t notificationFlag; - // reqJSON is retrieved from the payload of the received request PDU - char reqJSONPayload[1]; + + /** Payload Size.*/ + size_t payloadSize; + + /** payload is retrieved from the payload of the received request PDU.*/ + uint8_t payload[1]; + + // WARNING: Do NOT add attributes after payload as they get overwritten + // when payload content gets copied over! + } OCServerRequest; -// following structure will be created in ocstack to aggregate responses (in future: for block transfer) +/** + * Following structure will be created in ocstack to aggregate responses + * (in future: for block transfer). + */ typedef struct OCServerResponse { + + /** Linked list; for multiple server response.*/ struct OCServerResponse * next; - // this is the pointer to server payload data to be transferred - char *payload; + + /** this is the pointer to server payload data to be transferred.*/ + OCPayload* payload; + + /** Remaining size of the payload data to be transferred.*/ uint16_t remainingPayloadSize; + + /** Requests to handle.*/ OCRequestHandle requestHandle; } OCServerResponse; /** * Handler function for sending a response from a single resource * - * @param ehResponse - pointer to the response from the resource + * @param ehResponse Pointer to the response from the resource. * * @return - * OCStackResult + * ::OCStackResult */ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse); @@ -96,18 +152,18 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse); * * TODO: Need to add a timeout in case a (remote?) resource does not respond * - * @param ehResponse - pointer to the response from the resource + * @param ehResponse Pointer to the response from the resource. * * @return - * OCStackResult + * ::OCStackResult */ OCStackResult HandleAggregateResponse(OCEntityHandlerResponse * ehResponse); /** * Get a server request from the server request list using the specified token. * - * @param token - token of server request - * @param tokenLength - length of token + * @param token Token of server request. + * @param tokenLength Length of token. * * @return * OCServerRequest* @@ -117,83 +173,94 @@ OCServerRequest * GetServerRequestUsingToken (const CAToken_t token, uint8_t tok /** * Get a server request from the server request list using the specified handle * - * @param handle - handle of server request + * @param handle Handle of server request. * @return * OCServerRequest* */ -OCServerRequest * GetServerRequestUsingHandle (const OCServerRequest * handle); +OCServerRequest * GetServerRequestUsingHandle (const OCRequestHandle handle); /** * Get a server response from the server response list using the specified handle * - * @param handle - handle of server response + * @param handle handle of server response. * * @return * OCServerResponse* */ -OCServerResponse * GetServerResponseUsingHandle (const OCServerRequest * handle); +OCServerResponse * GetServerResponseUsingHandle (const OCRequestHandle handle); /** * Add a server request to the server request list * - * @param request - initialized server request that is created by this function - * @param coapID - ID of CoAP pdu - * @param delayedResNeeded - delayed response required 0=no 1=yes - * @param secured - secure endpoint 0=no 1=yes - * @param notificationFlag - //TODO: remove - does not appear to be used any longer - * @param method - RESTful method - * @param numRcvdVendorSpecificHeaderOptions - number of received vendor specific header options - * @param observationOption - value of observation option - * @param qos - request QOS - * @param query - request query - * @param rcvdVendorSpecificHeaderOptions - received vendor specific header options - * @param reqJSONPayload - request JSON payload - * @param requestToken - request token - * @param tokenLength - request token length - * @param resourceUrl - URL of resource - * @param reqTotalSize - total size of the request - * @param addressInfo - CA Address - * @param connectivityType - connection type + * @param request Initialized server request that is created by this function. + * @param coapID ID of CoAP pdu. + * @param delayedResNeeded Delayed response required 0=no 1=yes. + * @param notificationFlag TODO: remove - does not appear to be used any longer. + * @param method RESTful method. + * @param numRcvdVendorSpecificHeaderOptions Number of received vendor specific header options. + * @param observationOption Value of observation option. + * @param qos Request QOS. + * @param query Request query. + * @param rcvdVendorSpecificHeaderOptions Received vendor specific header options. + * @param reqJSONPayload Request JSON payload. + * @param requestToken Request token. + * @param tokenLength Request token length. + * @param resourceUrl URL of resource. + * @param reqTotalSize Total size of the request. + * @param acceptFormat The format requested for the payload encoding. + * @param devAddr Device Address. * * @return - * OCStackResult + * ::OCStackResult */ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID, - uint8_t delayedResNeeded, uint8_t secured, uint8_t notificationFlag, OCMethod method, + uint8_t delayedResNeeded, uint8_t notificationFlag, OCMethod method, uint8_t numRcvdVendorSpecificHeaderOptions, uint32_t observationOption, OCQualityOfService qos, char * query, OCHeaderOption * rcvdVendorSpecificHeaderOptions, - char * reqJSONPayload, CAToken_t * requestToken, + uint8_t * payload, CAToken_t requestToken, uint8_t tokenLength, char * resourceUrl, size_t reqTotalSize, - CAAddress_t *addressInfo, CAConnectivityType_t connectivityType); + OCPayloadFormat acceptFormat, + const OCDevAddr *devAddr); /** * Form the OCEntityHandlerRequest struct that is passed to a resource's entity handler * - * @param entityHandlerRequest - pointer to the OCEntityHandlerRequest struct that is created - * @param request - request handle - * @param method - RESTful method - * @param resource - resource handle - * @param queryBuf - resource query of request - * @param bufReqPayload - JSON payload of request - * @param numVendorOptions - number of vendor options - * @param vendorOptions - vendor options - * @param observeAction - observe action flag - * @param observeID - observe ID + * @param entityHandlerRequest pointer to the OCEntityHandlerRequest struct that is created. + * @param request Request handle. + * @param method RESTful method. + * @param resource Resource handle. + * @param queryBuf Resource query of request. + * @param bufReqPayload JSON payload of request. + * @param numVendorOptions Number of vendor options. + * @param vendorOptions Vendor options. + * @param observeAction Observe action flag. + * @param observeID Observe ID. * * @return * OCStackResult */ -OCStackResult FormOCEntityHandlerRequest(OCEntityHandlerRequest * entityHandlerRequest, OCRequestHandle request, - OCMethod method, OCResourceHandle resource, char * queryBuf, char * bufReqPayload, - uint8_t numVendorOptions, OCHeaderOption * vendorOptions, OCObserveAction observeAction, - OCObservationId observeID); +OCStackResult FormOCEntityHandlerRequest( + OCEntityHandlerRequest * entityHandlerRequest, + OCRequestHandle request, + OCMethod method, + OCDevAddr *endpoint, + OCResourceHandle resource, + char * queryBuf, + OCPayloadType payloadType, + uint8_t * payload, + size_t payloadSize, + uint8_t numVendorOptions, + OCHeaderOption * vendorOptions, + OCObserveAction observeAction, + OCObservationId observeID, + uint16_t messageID); /** * Find a server request in the server request list and delete * - * @param serverRequest - server request to find and delete + * @param serverRequest server request to find and delete. */ void FindAndDeleteServerRequest(OCServerRequest * serverRequest);