decodeReply function
Decode an ONC RPC reply message body (without the record marker).
Implementation
OncRpcReply decodeReply(List<int> body) {
final r = XdrReader(body);
final xid = r.readUint32();
final msgType = r.readUint32();
if (msgType != 1) {
throw OncRpcError('expected REPLY (msg_type=1), got $msgType');
}
final replyStat = r.readUint32();
if (replyStat == ReplyStatus.msgDenied) {
return OncRpcReply(
xid: xid, acceptStat: -1, denied: true,
resultBytes: Uint8List(0),
);
}
// msg_accepted: read verf + accept_stat.
r.readUint32(); // verf flavor
r.readOpaque(); // verf body (always empty for AUTH_NONE)
final acceptStat = r.readUint32();
final result = body.sublist(r.offset);
return OncRpcReply(
xid: xid, acceptStat: acceptStat, denied: false,
resultBytes: Uint8List.fromList(result),
);
}