diff --git a/libretroshare/src/serialiser/rsdistribitems.cc b/libretroshare/src/serialiser/rsdistribitems.cc index 80ee58e46..c7b7f8e95 100644 --- a/libretroshare/src/serialiser/rsdistribitems.cc +++ b/libretroshare/src/serialiser/rsdistribitems.cc @@ -331,7 +331,7 @@ RsDistribGrp *RsDistribSerialiser::deserialiseGrp(void *data, uint32_t *pktsize) if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || - (RS_SERVICE_TYPE_DISTRIB != getRsItemService(rstype)) || + (SERVICE_TYPE != getRsItemService(rstype)) || (RS_PKT_SUBTYPE_DISTRIB_GRP != getRsItemSubType(rstype))) { #ifdef RSSERIAL_DEBUG @@ -491,7 +491,7 @@ RsDistribGrpKey *RsDistribSerialiser::deserialiseGrpKey(void *data, uint32_t *pk if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || - (RS_SERVICE_TYPE_DISTRIB != getRsItemService(rstype)) || + (SERVICE_TYPE != getRsItemService(rstype)) || (RS_PKT_SUBTYPE_DISTRIB_GRP_KEY != getRsItemSubType(rstype))) { #ifdef RSSERIAL_DEBUG @@ -633,7 +633,7 @@ RsDistribSignedMsg *RsDistribSerialiser::deserialiseSignedMsg(void *data, uint32 if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || - (RS_SERVICE_TYPE_DISTRIB != getRsItemService(rstype)) || + (SERVICE_TYPE != getRsItemService(rstype)) || (RS_PKT_SUBTYPE_DISTRIB_SIGNED_MSG != getRsItemSubType(rstype))) { #ifdef RSSERIAL_DEBUG @@ -755,7 +755,7 @@ RsItem *RsDistribSerialiser::deserialise(void *data, uint32_t *pktsize) uint32_t rstype = getRsItemId(data); if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || - (RS_SERVICE_TYPE_DISTRIB != getRsItemService(rstype))) + (SERVICE_TYPE != getRsItemService(rstype))) { return NULL; /* wrong type */ } diff --git a/libretroshare/src/serialiser/rsdistribitems.h b/libretroshare/src/serialiser/rsdistribitems.h index 7dc1e6013..02e34a367 100644 --- a/libretroshare/src/serialiser/rsdistribitems.h +++ b/libretroshare/src/serialiser/rsdistribitems.h @@ -127,9 +127,13 @@ class RsDistribGrpKey: public RsItem { public: + RsDistribGrpKey(uint16_t service_type) + :RsItem(RS_PKT_VERSION_SERVICE, service_type, RS_PKT_SUBTYPE_DISTRIB_GRP_KEY) + { return; } + RsDistribGrpKey() :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DISTRIB, RS_PKT_SUBTYPE_DISTRIB_GRP_KEY) - { return; } + { return; } virtual ~RsDistribGrpKey() { return; } @@ -144,9 +148,12 @@ virtual std::ostream& print(std::ostream &out, uint16_t indent = 0); class RsDistribSerialiser: public RsSerialType { public: - RsDistribSerialiser() - :RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DISTRIB) + + // optional to allow use in p3service/sockets + RsDistribSerialiser(uint16_t service_type = RS_SERVICE_TYPE_DISTRIB) + : RsSerialType(RS_PKT_VERSION_SERVICE, service_type), SERVICE_TYPE(service_type) { return; } + virtual ~RsDistribSerialiser() { return; } @@ -171,6 +178,8 @@ virtual uint32_t sizeSignedMsg(RsDistribSignedMsg *); virtual bool serialiseSignedMsg (RsDistribSignedMsg *item, void *data, uint32_t *size); virtual RsDistribSignedMsg *deserialiseSignedMsg(void *data, uint32_t *size); +const uint16_t SERVICE_TYPE; + }; /**************************************************************************/ diff --git a/libretroshare/src/services/p3distrib.cc b/libretroshare/src/services/p3distrib.cc index 09c538d42..4ff45f4a7 100644 --- a/libretroshare/src/services/p3distrib.cc +++ b/libretroshare/src/services/p3distrib.cc @@ -72,7 +72,7 @@ p3GroupDistrib::p3GroupDistrib(uint16_t subtype, mOwnId = AuthSSL::getAuthSSL()->OwnId(); - addSerialType(new RsDistribSerialiser()); + addSerialType(new RsDistribSerialiser(getRsItemService(getType()))); return; } @@ -1883,7 +1883,7 @@ void p3GroupDistrib::locked_sharePubKey(){ if(std::find(peersOnline.begin(), peersOnline.end(), *lit) != peersOnline.end()){ /* create Key for sharing */ - RsDistribGrpKey* pubKey = new RsDistribGrpKey(); + RsDistribGrpKey* pubKey = new RsDistribGrpKey(getRsItemService(getType())); pubKey->clear(); @@ -1935,13 +1935,13 @@ void p3GroupDistrib::locked_receivePubKeys(){ if(key_item != NULL){ -#ifdef STATUS_DEBUG +#ifdef DISTRIB_DEBUG std::cerr << "p3GroupDistrib::locked_receiveKeys()" << std::endl; std::cerr << "PeerId : " << key_item->PeerId() << std::endl; std::cerr << "GrpId: " << key_item->grpId << std::endl; std::cerr << "Got key Item" << std::endl; #endif - if(key_item->key.keyFlags == RSTLV_KEY_TYPE_FULL){ + if(key_item->key.keyFlags & RSTLV_KEY_TYPE_FULL){ mRecvdPubKeys[key_item->grpId] = key_item; } else{ @@ -1984,8 +1984,6 @@ void p3GroupDistrib::locked_loadRecvdPubKeys(){ if(locked_updateGroupPublishKey(*gi, mit->second)){ toDelete.push_back(mit->first); - gi->flags |= RS_DISTRIB_SUBSCRIBED; - locked_notifyGroupChanged(*gi, GRP_SUBSCRIBED); ok |= true; } else @@ -2841,7 +2839,7 @@ bool p3GroupDistrib::locked_validateDistribSignedMsg( /* now verify Personal signature */ - if (signOk == 1 && ((info.grpFlags & RS_DISTRIB_AUTHEN_MASK) & RS_DISTRIB_AUTHEN_REQ)) + if ((signOk == 1) && ((info.grpFlags & RS_DISTRIB_AUTHEN_MASK) & RS_DISTRIB_AUTHEN_REQ)) { #ifdef DISTRIB_DEBUG std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Personal Signature. sslCert : " << newMsg->personalSignature.sslCert << std::endl;