mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
A few more uint64_t -> int64_t changes for timestamps
This commit is contained in:
parent
4177a11522
commit
099bedd2e9
6 changed files with 17 additions and 17 deletions
|
@ -85,7 +85,7 @@ public:
|
||||||
* @param rules Network flow rules for this capability
|
* @param rules Network flow rules for this capability
|
||||||
* @param ruleCount Number of flow rules
|
* @param ruleCount Number of flow rules
|
||||||
*/
|
*/
|
||||||
Capability(uint32_t id,uint64_t nwid,uint64_t ts,unsigned int mccl,const ZT_VirtualNetworkRule *rules,unsigned int ruleCount)
|
Capability(uint32_t id,uint64_t nwid,int64_t ts,unsigned int mccl,const ZT_VirtualNetworkRule *rules,unsigned int ruleCount)
|
||||||
{
|
{
|
||||||
memset(this,0,sizeof(Capability));
|
memset(this,0,sizeof(Capability));
|
||||||
_nwid = nwid;
|
_nwid = nwid;
|
||||||
|
@ -120,7 +120,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @return Timestamp
|
* @return Timestamp
|
||||||
*/
|
*/
|
||||||
inline uint64_t timestamp() const { return _ts; }
|
inline int64_t timestamp() const { return _ts; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Last 'to' address in chain of custody
|
* @return Last 'to' address in chain of custody
|
||||||
|
@ -460,7 +460,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t _nwid;
|
uint64_t _nwid;
|
||||||
uint64_t _ts;
|
int64_t _ts;
|
||||||
uint32_t _id;
|
uint32_t _id;
|
||||||
|
|
||||||
unsigned int _maxCustodyChainLength;
|
unsigned int _maxCustodyChainLength;
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
memset(this,0,sizeof(CertificateOfOwnership));
|
memset(this,0,sizeof(CertificateOfOwnership));
|
||||||
}
|
}
|
||||||
|
|
||||||
CertificateOfOwnership(const uint64_t nwid,const uint64_t ts,const Address &issuedTo,const uint32_t id) :
|
CertificateOfOwnership(const uint64_t nwid,const int64_t ts,const Address &issuedTo,const uint32_t id) :
|
||||||
_networkId(nwid),
|
_networkId(nwid),
|
||||||
_ts(ts),
|
_ts(ts),
|
||||||
_flags(0),
|
_flags(0),
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint64_t networkId() const { return _networkId; }
|
inline uint64_t networkId() const { return _networkId; }
|
||||||
inline uint64_t timestamp() const { return _ts; }
|
inline int64_t timestamp() const { return _ts; }
|
||||||
inline uint32_t id() const { return _id; }
|
inline uint32_t id() const { return _id; }
|
||||||
inline unsigned int thingCount() const { return (unsigned int)_thingCount; }
|
inline unsigned int thingCount() const { return (unsigned int)_thingCount; }
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ private:
|
||||||
bool _owns(const Thing &t,const void *v,unsigned int l) const;
|
bool _owns(const Thing &t,const void *v,unsigned int l) const;
|
||||||
|
|
||||||
uint64_t _networkId;
|
uint64_t _networkId;
|
||||||
uint64_t _ts;
|
int64_t _ts;
|
||||||
uint64_t _flags;
|
uint64_t _flags;
|
||||||
uint32_t _id;
|
uint32_t _id;
|
||||||
uint16_t _thingCount;
|
uint16_t _thingCount;
|
||||||
|
|
|
@ -155,7 +155,7 @@ Membership::AddCredentialResult Membership::addCredential(const RuntimeEnvironme
|
||||||
|
|
||||||
// Template out addCredential() for many cred types to avoid copypasta
|
// Template out addCredential() for many cred types to avoid copypasta
|
||||||
template<typename C>
|
template<typename C>
|
||||||
static Membership::AddCredentialResult _addCredImpl(Hashtable<uint32_t,C> &remoteCreds,const Hashtable<uint64_t,uint64_t> &revocations,const RuntimeEnvironment *RR,void *tPtr,const NetworkConfig &nconf,const C &cred)
|
static Membership::AddCredentialResult _addCredImpl(Hashtable<uint32_t,C> &remoteCreds,const Hashtable<uint64_t,int64_t> &revocations,const RuntimeEnvironment *RR,void *tPtr,const NetworkConfig &nconf,const C &cred)
|
||||||
{
|
{
|
||||||
C *rc = remoteCreds.get(cred.id());
|
C *rc = remoteCreds.get(cred.id());
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
@ -167,7 +167,7 @@ static Membership::AddCredentialResult _addCredImpl(Hashtable<uint32_t,C> &remot
|
||||||
return Membership::ADD_ACCEPTED_REDUNDANT;
|
return Membership::ADD_ACCEPTED_REDUNDANT;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t *const rt = revocations.get(Membership::credentialKey(C::credentialType(),cred.id()));
|
const int64_t *const rt = revocations.get(Membership::credentialKey(C::credentialType(),cred.id()));
|
||||||
if ((rt)&&(*rt >= cred.timestamp())) {
|
if ((rt)&&(*rt >= cred.timestamp())) {
|
||||||
RR->t->credentialRejected(tPtr,cred,"revoked");
|
RR->t->credentialRejected(tPtr,cred,"revoked");
|
||||||
return Membership::ADD_REJECTED;
|
return Membership::ADD_REJECTED;
|
||||||
|
@ -193,7 +193,7 @@ Membership::AddCredentialResult Membership::addCredential(const RuntimeEnvironme
|
||||||
|
|
||||||
Membership::AddCredentialResult Membership::addCredential(const RuntimeEnvironment *RR,void *tPtr,const NetworkConfig &nconf,const Revocation &rev)
|
Membership::AddCredentialResult Membership::addCredential(const RuntimeEnvironment *RR,void *tPtr,const NetworkConfig &nconf,const Revocation &rev)
|
||||||
{
|
{
|
||||||
uint64_t *rt;
|
int64_t *rt;
|
||||||
switch(rev.verify(RR,tPtr)) {
|
switch(rev.verify(RR,tPtr)) {
|
||||||
default:
|
default:
|
||||||
RR->t->credentialRejected(tPtr,rev,"invalid");
|
RR->t->credentialRejected(tPtr,rev,"invalid");
|
||||||
|
|
|
@ -202,9 +202,9 @@ private:
|
||||||
template<typename C>
|
template<typename C>
|
||||||
inline bool _isCredentialTimestampValid(const NetworkConfig &nconf,const C &remoteCredential) const
|
inline bool _isCredentialTimestampValid(const NetworkConfig &nconf,const C &remoteCredential) const
|
||||||
{
|
{
|
||||||
const uint64_t ts = remoteCredential.timestamp();
|
const int64_t ts = remoteCredential.timestamp();
|
||||||
if (((ts >= nconf.timestamp) ? (ts - nconf.timestamp) : (nconf.timestamp - ts)) <= nconf.credentialTimeMaxDelta) {
|
if (((ts >= nconf.timestamp) ? (ts - nconf.timestamp) : (nconf.timestamp - ts)) <= nconf.credentialTimeMaxDelta) {
|
||||||
const uint64_t *threshold = _revocations.get(credentialKey(C::credentialType(),remoteCredential.id()));
|
const int64_t *threshold = _revocations.get(credentialKey(C::credentialType(),remoteCredential.id()));
|
||||||
return ((!threshold)||(ts > *threshold));
|
return ((!threshold)||(ts > *threshold));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -235,7 +235,7 @@ private:
|
||||||
CertificateOfMembership _com;
|
CertificateOfMembership _com;
|
||||||
|
|
||||||
// Revocations by credentialKey()
|
// Revocations by credentialKey()
|
||||||
Hashtable< uint64_t,uint64_t > _revocations;
|
Hashtable< uint64_t,int64_t > _revocations;
|
||||||
|
|
||||||
// Remote credentials that we have received from this member (and that are valid)
|
// Remote credentials that we have received from this member (and that are valid)
|
||||||
Hashtable< uint32_t,Tag > _remoteTags;
|
Hashtable< uint32_t,Tag > _remoteTags;
|
||||||
|
|
|
@ -418,12 +418,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Controller-side time of config generation/issue
|
* Controller-side time of config generation/issue
|
||||||
*/
|
*/
|
||||||
uint64_t timestamp;
|
int64_t timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Max difference between timestamp and tag/capability timestamp
|
* Max difference between timestamp and tag/capability timestamp
|
||||||
*/
|
*/
|
||||||
uint64_t credentialTimeMaxDelta;
|
int64_t credentialTimeMaxDelta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller-side revision counter for this configuration
|
* Controller-side revision counter for this configuration
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
* @param id Tag ID
|
* @param id Tag ID
|
||||||
* @param value Tag value
|
* @param value Tag value
|
||||||
*/
|
*/
|
||||||
Tag(const uint64_t nwid,const uint64_t ts,const Address &issuedTo,const uint32_t id,const uint32_t value) :
|
Tag(const uint64_t nwid,const int64_t ts,const Address &issuedTo,const uint32_t id,const uint32_t value) :
|
||||||
_id(id),
|
_id(id),
|
||||||
_value(value),
|
_value(value),
|
||||||
_networkId(nwid),
|
_networkId(nwid),
|
||||||
|
@ -90,7 +90,7 @@ public:
|
||||||
inline uint32_t id() const { return _id; }
|
inline uint32_t id() const { return _id; }
|
||||||
inline const uint32_t &value() const { return _value; }
|
inline const uint32_t &value() const { return _value; }
|
||||||
inline uint64_t networkId() const { return _networkId; }
|
inline uint64_t networkId() const { return _networkId; }
|
||||||
inline uint64_t timestamp() const { return _ts; }
|
inline int64_t timestamp() const { return _ts; }
|
||||||
inline const Address &issuedTo() const { return _issuedTo; }
|
inline const Address &issuedTo() const { return _issuedTo; }
|
||||||
inline const Address &signedBy() const { return _signedBy; }
|
inline const Address &signedBy() const { return _signedBy; }
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ private:
|
||||||
uint32_t _id;
|
uint32_t _id;
|
||||||
uint32_t _value;
|
uint32_t _value;
|
||||||
uint64_t _networkId;
|
uint64_t _networkId;
|
||||||
uint64_t _ts;
|
int64_t _ts;
|
||||||
Address _issuedTo;
|
Address _issuedTo;
|
||||||
Address _signedBy;
|
Address _signedBy;
|
||||||
C25519::Signature _signature;
|
C25519::Signature _signature;
|
||||||
|
|
Loading…
Add table
Reference in a new issue