1
2
3 """Remote Procedure Call."""
4 from __future__ import absolute_import
5
6 import struct
7
8 from . import dpkt
9
10
11 CALL = 0
12 REPLY = 1
13
14
15 AUTH_NONE = AUTH_NULL = 0
16 AUTH_UNIX = 1
17 AUTH_SHORT = 2
18 AUTH_DES = 3
19
20
21 MSG_ACCEPTED = 0
22 MSG_DENIED = 1
23
24
25 SUCCESS = 0
26 PROG_UNAVAIL = 1
27 PROG_MISMATCH = 2
28 PROC_UNAVAIL = 3
29 GARBAGE_ARGS = 4
30 SYSTEM_ERR = 5
31
32
33 RPC_MISMATCH = 0
34 AUTH_ERROR = 1
35
36
37 -class RPC(dpkt.Packet):
38 """Remote Procedure Call.
39
40 TODO: Longer class information....
41
42 Attributes:
43 __hdr__: Header fields of RPC.
44 TODO.
45 """
46
47 __hdr__ = (
48 ('xid', 'I', 0),
49 ('dir', 'I', CALL)
50 )
51
52 - class Auth(dpkt.Packet):
66
67 - class Call(dpkt.Packet):
68 __hdr__ = (
69 ('rpcvers', 'I', 2),
70 ('prog', 'I', 0),
71 ('vers', 'I', 0),
72 ('proc', 'I', 0)
73 )
74
80
83
89
90 - class Reply(dpkt.Packet):
148
155
156
158 l = []
159 while buf:
160 if buf.startswith(b'\x00\x00\x00\x01'):
161 p = cls(buf[4:])
162 l.append(p)
163 buf = p.data
164 elif buf.startswith(b'\x00\x00\x00\x00'):
165 break
166 else:
167 raise dpkt.UnpackError('invalid XDR list')
168 return l
169
170
172 return b'\x00\x00\x00\x01'.join(map(bytes, args)) + b'\x00\x00\x00\x00'
173