1 /* 2 * Copyright 2012 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Paweł Dziepak, pdziepak@quarnos.org 7 */ 8 9 10 #include "RPCCallbackRequest.h" 11 12 #include <stdlib.h> 13 14 #include <debug.h> 15 16 #include "NFS4Defs.h" 17 #include "RPCDefs.h" 18 19 20 using namespace RPC; 21 22 23 CallbackRequest::CallbackRequest(void* buffer, int size) 24 : 25 fError(B_BAD_VALUE), 26 fRPCError(GARBAGE_ARGS), 27 fStream(buffer, size), 28 fBuffer(buffer) 29 { 30 ASSERT(buffer != NULL); 31 32 fXID = fStream.GetUInt(); 33 34 if (fStream.GetUInt() != CALL) 35 return; 36 37 if (fStream.GetUInt() != VERSION) 38 return; 39 40 if (fStream.GetUInt() != PROGRAM_NFS_CB) { 41 fRPCError = PROG_UNAVAIL; 42 return; 43 } 44 45 if (fStream.GetUInt() != NFS_CB_VERSION) { 46 fRPCError = PROG_MISMATCH; 47 return; 48 } 49 50 fProcedure = fStream.GetUInt(); 51 52 fStream.GetUInt(); 53 fStream.GetOpaque(NULL); 54 55 fStream.GetUInt(); 56 fStream.GetOpaque(NULL); 57 58 if (fProcedure == CallbackProcCompound) { 59 fStream.GetOpaque(NULL); // TODO: tag may be important 60 if (fStream.GetUInt() != 0) 61 return; 62 63 fID = fStream.GetUInt(); 64 65 fRPCError = SUCCESS; 66 fError = B_OK; 67 } else if (fProcedure == CallbackProcNull) { 68 fRPCError = SUCCESS; 69 fError = B_OK; 70 } else 71 fRPCError = PROC_UNAVAIL; 72 } 73 74 75 CallbackRequest::~CallbackRequest() 76 { 77 free(fBuffer); 78 } 79 80 81