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 "RPCCall.h"
11
12#include <debug.h>
13#include <util/kernel_cpp.h>
14
15#include "RPCDefs.h"
16
17
18using namespace RPC;
19
20
21Call::Call()
22{
23}
24
25
26Call*
27Call::Create(uint32 proc, const Auth* creds, const Auth* ver)
28{
29	ASSERT(creds != NULL);
30	ASSERT(ver != NULL);
31
32	Call* call = new(std::nothrow) Call;
33	if (call == NULL)
34		return NULL;
35
36	// XID will be determined and set by RPC::Server
37	call->fXIDPosition = call->fStream.Current();
38	call->fStream.AddUInt(0);
39
40	call->fStream.AddInt(CALL);
41	call->fStream.AddUInt(VERSION);
42	call->fStream.AddUInt(PROGRAM_NFS);
43	call->fStream.AddUInt(NFS_VERSION);
44	call->fStream.AddUInt(proc);
45
46	call->fStream.Append(creds->Stream());
47	delete creds;
48
49	call->fStream.Append(ver->Stream());
50	delete ver;
51
52	if (call->fStream.Error() != B_OK) {
53		delete call;
54		return NULL;
55	}
56
57	return call;
58}
59
60
61Call::~Call()
62{
63}
64
65
66void
67Call::SetXID(uint32 xid)
68{
69	fStream.InsertUInt(fXIDPosition, xid);
70}
71
72