diff --git a/src/common/request.h b/src/common/request.h --- a/src/common/request.h +++ b/src/common/request.h @@ -20,6 +20,8 @@ #ifndef _DISTREN_REQUEST_H #define _DISTREN_REQUEST_H +#include "common/protocol.h" + /** * @file functions to initialize various requests that the server and * client may both use. @@ -32,6 +34,26 @@ int distren_request_free_with_data(struct distren_request *req, void *data); /** + * Initialize a VERSION request. + * + * @param req pointer to where the poitner to the new req should be stored.. + * @param data pointer to where the newly allocated data's address should go. + * @param servertype the ORing of different DISTREN_SERVERTYPE_* constants. + * @param package_string the PACKAGE_STRING constant. + */ +int distren_request_version(struct distren_request **req, void **data, uint32_t servertype, const char *package_string); + +/** + * Parses a DISTREN_REQUEST_VERSION packet. + * + * @param req the request to parse. + * @param data the request's data. + * @param version where the result should be stored. + * @return 0 on success, 1 if the packet is invalid (if the length of package_version is longer than 32-bytes, for example). + */ +int distren_request_parse_version(struct distren_request *req, void *data, struct distren_request_version *version); + +/** * Initialize a PING or PONG request. * * @param data a place to allocate storage for the data associated with this request