| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/** |
| 2 |
|
|
* This file is part of the CernVM File System. |
| 3 |
|
|
* |
| 4 |
|
|
* Client side of the NFSv4.0 callback program (RFC 7530 section 16.2), used |
| 5 |
|
|
* to recall delegations. |
| 6 |
|
|
*/ |
| 7 |
|
|
|
| 8 |
|
|
#ifndef CVMFS_NFS4_CALLBACK_H_ |
| 9 |
|
|
#define CVMFS_NFS4_CALLBACK_H_ |
| 10 |
|
|
|
| 11 |
|
|
#include <stdint.h> |
| 12 |
|
|
|
| 13 |
|
|
#include <mutex> |
| 14 |
|
|
#include <string> |
| 15 |
|
|
|
| 16 |
|
|
namespace nfs4 { |
| 17 |
|
|
|
| 18 |
|
|
class CallbackClient { |
| 19 |
|
|
public: |
| 20 |
|
|
/** |
| 21 |
|
|
* netid and address as sent by the client in SETCLIENTID, e.g. "tcp" and |
| 22 |
|
|
* "127.0.0.1.3.28" (universal address: host, then port high and low byte). |
| 23 |
|
|
*/ |
| 24 |
|
|
CallbackClient(uint32_t program, uint32_t ident, const std::string &netid, |
| 25 |
|
|
const std::string &address); |
| 26 |
|
|
~CallbackClient(); |
| 27 |
|
|
|
| 28 |
|
|
/** Whether the address could be parsed; only IPv4 over TCP is supported */ |
| 29 |
|
39 |
bool valid() const { return port_ != 0; } |
| 30 |
|
|
|
| 31 |
|
|
/** CB_NULL, i.e. checks that the callback path works */ |
| 32 |
|
|
bool Null(unsigned timeout_ms); |
| 33 |
|
|
/** |
| 34 |
|
|
* CB_RECALL of a delegation. Returns the NFS status of the client's reply, |
| 35 |
|
|
* or -1 if the client did not answer. |
| 36 |
|
|
*/ |
| 37 |
|
|
int Recall(uint32_t stateid_seqid, const std::string &stateid_other, |
| 38 |
|
|
const std::string &fh, unsigned timeout_ms); |
| 39 |
|
|
|
| 40 |
|
|
private: |
| 41 |
|
|
bool Call(uint32_t procedure, const std::string &args, std::string *result, |
| 42 |
|
|
unsigned timeout_ms); |
| 43 |
|
|
bool Connect(unsigned timeout_ms); |
| 44 |
|
|
void Disconnect(); |
| 45 |
|
|
|
| 46 |
|
|
uint32_t program_; |
| 47 |
|
|
uint32_t ident_; |
| 48 |
|
|
std::string host_; |
| 49 |
|
|
uint16_t port_; |
| 50 |
|
|
std::mutex lock_; |
| 51 |
|
|
int fd_; |
| 52 |
|
|
uint32_t next_xid_; |
| 53 |
|
|
}; |
| 54 |
|
|
|
| 55 |
|
|
} // namespace nfs4 |
| 56 |
|
|
|
| 57 |
|
|
#endif // CVMFS_NFS4_CALLBACK_H_ |
| 58 |
|
|
|