/*
*-----------------------------------------------------------------------------
*
- * HgfsServerGetRequestHeaderSize --
+ * HgfsServerGetHeaderSize --
*
- * Takes the Hgfs request input and finds the size of the header component.
+ * Takes the Hgfs input and finds the size of the header component.
*
* Results:
- * Size of the HGFS protocol header used by this request and reply.
+ * Size of the HGFS protocol header used by this request or reply.
*
* Side effects:
* None
*/
static HgfsInternalStatus
-HgfsServerGetRequestHeaderSize(HgfsInputParam *input) // IN: parameters
+HgfsServerGetHeaderSize(Bool sessionEnabled, // IN: session based request
+ HgfsOp op, // IN: operation
+ Bool request) // IN: TRUE for request, FALSE for reply
{
size_t headerSize;
/*
* If the HGFS request is session enabled we must have the new header.
+ * Any V4 operation always must have the new header too.
* Otherwise, starting from HGFS V3 the header is not included in the
- * request itself, so we must return the size of the separate HgfsReply
- * structure. Prior to V3 (so V1 and V2) there was no separate header
- * from the request result structure so a zero size is returned for these
- * operations.
+ * request itself, so we must return the size of the separate header
+ * structure, for requests this will be HgfsRequest and replies will be HgfsReply.
+ * Prior to V3 (so V1 and V2) there was no separate header from the request
+ * or reply structure for any given operation, so a zero size is returned for these.
*/
- if (input->sessionEnabled) {
+ if (sessionEnabled) {
headerSize = sizeof (HgfsHeader);
- } else if (input->op >= HGFS_OP_OPEN_V3) {
- headerSize = sizeof (HgfsReply);
+ } else if (op < HGFS_OP_CREATE_SESSION_V4 &&
+ op >= HGFS_OP_OPEN_V3) {
+ headerSize = (request ? sizeof (HgfsRequest) : sizeof (HgfsReply));
} else {
headerSize = 0;
}
}
+#if defined HGFS_SERVER_UNUSED
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsServerGetRequestHeaderSize --
+ *
+ * Takes the Hgfs request input and finds the size of the header component.
+ *
+ * Results:
+ * Size of the HGFS protocol header used by this request and reply.
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static HgfsInternalStatus
+HgfsServerGetRequestHeaderSize(Bool sessionEnabled, // IN: session based request
+ HgfsOp op) // IN: operation
+{
+ return HgfsServerGetHeaderSize(sessionEnabled, op, TRUE);
+}
+#endif
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsServerGetReplyHeaderSize --
+ *
+ * Takes the Hgfs reply input and finds the size of the header component.
+ *
+ * Results:
+ * Size of the HGFS protocol header used by this reply.
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static HgfsInternalStatus
+HgfsServerGetReplyHeaderSize(Bool sessionEnabled, // IN: session based request
+ HgfsOp op) // IN: operation
+{
+ return HgfsServerGetHeaderSize(sessionEnabled, op, FALSE);
+}
+
+
/*
*-----------------------------------------------------------------------------
*
replySessionId = (NULL != input->session) ? input->session->sessionId
: HGFS_INVALID_SESSION_ID;
- replyHeaderSize = HgfsServerGetRequestHeaderSize(input);
+ replyHeaderSize = HgfsServerGetReplyHeaderSize(input->sessionEnabled,
+ input->op);
if (replyHeaderSize != 0) {
replySize = replyHeaderSize + replyPayloadSize;
void *replyData;
/*
- * XXX - this should be modified to use the common HgfsServerGetRequestHeaderSize
+ * XXX - this should be modified to use the common HgfsServerGetReplyHeaderSize
* so that all requests and replies are handled consistently.
*/
if (HGFS_OP_NEW_HEADER == request->op) {
Bool useMappedBuffer;
useMappedBuffer = (input->transportSession->channelCbTable->getWriteVa != NULL);
- replyReadHeaderSize = HgfsServerGetRequestHeaderSize(input);
+ replyReadHeaderSize = HgfsServerGetReplyHeaderSize(input->sessionEnabled,
+ input->op);
switch (input->op) {
case HGFS_OP_READ_FAST_V4:
/* Data is packed into a separate buffer from the read results. */