|
@@ -26,6 +26,7 @@ extern "C" {
|
|
|
#define FMT_ATTR_CONTAINER 99
|
|
#define FMT_ATTR_CONTAINER 99
|
|
|
#define FMT_APP_RAW_BINARY 98
|
|
#define FMT_APP_RAW_BINARY 98
|
|
|
|
|
|
|
|
|
|
+/* the request structure */
|
|
|
typedef struct request {
|
|
typedef struct request {
|
|
|
// message id
|
|
// message id
|
|
|
uint32 mid;
|
|
uint32 mid;
|
|
@@ -42,11 +43,14 @@ typedef struct request {
|
|
|
// payload of the request, currently only support attr_container_t type
|
|
// payload of the request, currently only support attr_container_t type
|
|
|
void *payload;
|
|
void *payload;
|
|
|
|
|
|
|
|
|
|
+ //length in bytes of the payload
|
|
|
int payload_len;
|
|
int payload_len;
|
|
|
|
|
|
|
|
|
|
+ //sender of the request
|
|
|
unsigned long sender;
|
|
unsigned long sender;
|
|
|
} request_t;
|
|
} request_t;
|
|
|
|
|
|
|
|
|
|
+/* the response structure */
|
|
|
typedef struct response {
|
|
typedef struct response {
|
|
|
// message id
|
|
// message id
|
|
|
uint32 mid;
|
|
uint32 mid;
|
|
@@ -60,8 +64,10 @@ typedef struct response {
|
|
|
// payload of the response,
|
|
// payload of the response,
|
|
|
void *payload;
|
|
void *payload;
|
|
|
|
|
|
|
|
|
|
+ //length in bytes of the payload
|
|
|
int payload_len;
|
|
int payload_len;
|
|
|
|
|
|
|
|
|
|
+ //receiver of the response
|
|
|
unsigned long reciever;
|
|
unsigned long reciever;
|
|
|
} response_t;
|
|
} response_t;
|
|
|
|
|
|
|
@@ -76,11 +82,49 @@ void request_cleaner(request_t *request);
|
|
|
response_t * clone_response(response_t * response);
|
|
response_t * clone_response(response_t * response);
|
|
|
void response_cleaner(response_t * response);
|
|
void response_cleaner(response_t * response);
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @brief Set fields of response.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param response pointer of the response to be set
|
|
|
|
|
+ * @param status status of response
|
|
|
|
|
+ * @param fmt format of the response payload
|
|
|
|
|
+ * @param payload payload of the response
|
|
|
|
|
+ * @param payload_len length in bytes of the response payload
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return pointer to the response
|
|
|
|
|
+ *
|
|
|
|
|
+ * @warning the response pointer MUST NOT be NULL
|
|
|
|
|
+ */
|
|
|
response_t * set_response(response_t * response, int status, int fmt,
|
|
response_t * set_response(response_t * response, int status, int fmt,
|
|
|
const char *payload, int payload_len);
|
|
const char *payload, int payload_len);
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @brief Make a response for a request.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request pointer of the request
|
|
|
|
|
+ * @param response pointer of the response to be made
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return pointer to the response
|
|
|
|
|
+ *
|
|
|
|
|
+ * @warning the request and response pointers MUST NOT be NULL
|
|
|
|
|
+ */
|
|
|
response_t * make_response_for_request(request_t * request,
|
|
response_t * make_response_for_request(request_t * request,
|
|
|
response_t * response);
|
|
response_t * response);
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @brief Initialize a request.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request pointer of the request to be initialized
|
|
|
|
|
+ * @param url url of the request
|
|
|
|
|
+ * @param action action of the request
|
|
|
|
|
+ * @param fmt format of the request payload
|
|
|
|
|
+ * @param payload payload of the request
|
|
|
|
|
+ * @param payload_len length in bytes of the request payload
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return pointer to the request
|
|
|
|
|
+ *
|
|
|
|
|
+ * @warning the request pointer MUST NOT be NULL
|
|
|
|
|
+ */
|
|
|
request_t * init_request(request_t * request, char *url, int action, int fmt,
|
|
request_t * init_request(request_t * request, char *url, int action, int fmt,
|
|
|
void *payload, int payload_len);
|
|
void *payload, int payload_len);
|
|
|
|
|
|