File: sunrpc.h

package info (click to toggle)
yaird 0.0.12-18etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 1,432 kB
  • ctags: 725
  • sloc: perl: 4,161; xml: 3,233; ansic: 3,105; sh: 876; makefile: 150
file content (100 lines) | stat: -rw-r--r-- 1,682 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * sunrpc.h - open-coded SunRPC structures
 */
#include <sys/types.h>
#include <linux/types.h>	/* for __u32 */

#define SUNRPC_PORT	111
#define MOUNT_PORT	627

#define RPC_CALL	0
#define RPC_REPLY	1

#define PORTMAP_PROGRAM	100000
#define NLM_PROGRAM	100021

#define RPC_PMAP_PROGRAM	100000
#define RPC_PMAP_VERSION	2
#define RPC_PMAP_PORT		111

#define PMAP_PROC_NULL		0
#define PMAP_PROC_SET		1
#define PMAP_PROC_UNSET		2
#define PMAP_PROC_GETPORT	3
#define PMAP_PROC_DUMP		4

#define LAST_FRAG	0x80000000

#define REPLY_OK	0
#define REPLY_DENIED    1

#define SUCCESS		0
#define PROG_UNAVAIL	1
#define PROG_MISMATCH	2
#define PROC_UNAVAIL	3
#define GARBAGE_ARGS	4
#define SYSTEM_ERR	5

struct rpc_udp_header
{
	__u32 xid;
	__u32 msg_type;
};

struct rpc_header
{
	__u32 frag_hdr;
	struct rpc_udp_header udp;
};

struct rpc_call
{
	struct rpc_header hdr;
	__u32 rpc_vers;

	__u32 program;
	__u32 prog_vers;
	__u32 proc;
	__u32 cred_flavor;

	__u32 cred_len;
	__u32 vrf_flavor;
	__u32 vrf_len;
};

struct rpc_reply 
{
	struct rpc_header hdr;
	__u32 reply_state;
	__u32 vrf_flavor;
	__u32 vrf_len;
	__u32 state;
};

struct rpc
{
	struct rpc_call *call;
	size_t call_len;
	struct rpc_reply *reply;
	size_t reply_len;
};

struct client;

typedef int (*call_stub)(struct client *, struct rpc *);

struct client
{
	int sock;
	call_stub call_stub;
};

#define CLI_RESVPORT	00000001

struct client *tcp_client(__u32 server, __u16 port, __u32 flags);
struct client *udp_client(__u32 server, __u16 port, __u32 flags);
void client_free(struct client *client);

int rpc_call(struct client *client, struct rpc *rpc);

__u32 portmap(__u32 server, __u32 program, __u32 version, __u32 proto);