diff --git a/src/common/protocol.h b/src/common/protocol.h --- a/src/common/protocol.h +++ b/src/common/protocol.h @@ -20,6 +20,7 @@ #ifndef DISTREN_PROTOCOL_H #define DISTREN_PROTOCOL_H +#include #include #include @@ -138,12 +139,34 @@ enum distren_request_type DISTREN_REQUEST_STATUS_GET = 10, /** + * Declare that a client is preparing to post a file using a + * particular post-id and with a user-friendly filename. + * + * Yes, this is evil. Yes, this tries to replicate + * well-established protocols like FTP and HTTP (which is + * sometimes itself mistreated as FTP). Yes, this will be + * buggy. Why is it needed? For my personal coding experience and + * because I don't know off-hand of any libraries that allow a + * file upload to be interleaved over an existing connection with + * its own protocol. Over TCP? We aren't doing real-time streaming + * or anything :-p. + * + * Possible future expansions: ``transparent'' zlib compression. + * + * DATA: struct distren_request_file_post_start + * + * REQUIRED: DISTREN_SERVERTYPE_SUBMIT, DISTREN_SERVERTYPE_DISTRIBUTE + */ + DISTREN_REQUEST_FILE_POST_START = 11, + + /** * Allow a client to upload a job tarball over a remoteio line. A * client that wants to do this must take care not to overbuffer * his sendqueue so as to be able to respond to PING packets in * time. A server receiving such a message will want to write the - * file as directly to disk as possible to avoid bagging a server - * down in swap. + * file as directly to disk as possible to avoid bogging the + * server down in swap. This packet may only be sent if + * DISTREN_REQUEST_FILE_POST_START has previously been sent. * * It is potential that if a server is DISTREN_SERVERTYPE_SUBMIT * but not also DISTREN_SERVERTYPE_DISTRIBUTE, that this request @@ -159,7 +182,18 @@ enum distren_request_type * * REQUIRED: DISTREN_SERVERTYPE_SUBMIT, DISTREN_SERVERTYPE_DISTRIBUTE */ - DISTREN_REQUEST_FILE_POST = 11, + DISTREN_REQUEST_FILE_POST = 12, + + /** + * Marks a post-id's file as having completely uploaded. Provides + * verification information so that the file's integrity may be + * verified. + * + * DATA: struct distren_request_file_post_finish + * + * REQUIRED: DISTREN_SERVERTYPE_SUBMIT, DISTREN_SERVERTYPE_DISTRIBUTE + */ + DISTREN_REQUEST_FILE_POST_FINISH = 13, /** * Request information about obtaining a file (such as a @@ -169,7 +203,7 @@ enum distren_request_type * * REQUIRED: DISTREN_SERVERTYPE_DISTRIBUTE */ - DISTREN_REQUEST_FILE_FIND = 12, + DISTREN_REQUEST_FILE_FIND = 14, /** * Provide information about obtaining a file (such as a URL). @@ -178,7 +212,7 @@ enum distren_request_type * * REQUIRED: DISTREN_SERVERTYPE_DISTRIBUTE */ - DISTREN_REQUEST_FILE = 13, + DISTREN_REQUEST_FILE = 15, }; struct distren_request @@ -202,6 +236,45 @@ struct distren_request_version char package_string[DISTREN_REQUEST_VERSION_PACKAGE_STRING_LEN + 1]; }; +#define DISTREN_REQUEST_FILE_POST_NAME_LEN (64) +struct distren_request_file_post_start +{ + /** + * Uniquely identify this file upload (per connection). + */ + uint32_t post_id; + /** + * The user-friendly filename + */ + char filename[DISTREN_REQUEST_FILE_POST_NAME_LEN]; +}; + +#define DISTREN_REQUEST_FILE_POST_DATA_LEN (1024*128) +struct distren_request_file_post +{ + /** + * Uniquely identify this file upload (per connection). + */ + uint32_t post_id; +}; + +struct distren_request_file_post_finish +{ + /** + * Uniquely identify this file upload (per connection). + */ + uint32_t post_id; + /** + * Marks this upload as failed/cancelled. + */ + uint32_t cancel; + /** + * An SHA1sum of the entire file. Only set if last_packet is + * nonzero. Should be otherwise ignored. + */ + unsigned char sha[EVP_MAX_MD_SIZE]; +}; + /** * initializes and allocates request */