本文整理汇总了C++中PacketReader::read7BitEncoded方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketReader::read7BitEncoded方法的具体用法?C++ PacketReader::read7BitEncoded怎么用?C++ PacketReader::read7BitEncoded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader::read7BitEncoded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handshakeHandler
//.........这里部分代码省略.........
break;
}
if(it3!=it2->second.end())
break;
}
return 0x71;
}
if(edges().size()>0)
WARN("After %u hello attempts, impossible to connect to edges. Edges are busy? or unreachable?",_invoker.edgesAttemptsBeforeFallback);
// New Cookie
createCookie(response,attempt,tag,epd);
// instance id (certificat in the middle)
response.writeRaw(_certificat,sizeof(_certificat));
return 0x70;
} else
ERROR("Unkown handshake first way with '%02x' type",type);
break;
}
case 0x39:
case 0x38: {
(UInt32&)farId = request.read32();
if(request.read7BitLongValue()!=COOKIE_SIZE) {
ERROR("Bad handshake cookie '%s': its size should be 64 bytes",Util::FormatHex(request.current(),COOKIE_SIZE).c_str());
return 0;
}
map<const UInt8*,Cookie*,CompareCookies>::iterator itCookie = _cookies.find(request.current());
if(itCookie==_cookies.end()) {
if(id!=0x39) {
ERROR("Handshake cookie '%s' unknown",Util::FormatHex(request.current(),COOKIE_SIZE).c_str());
return 0;
}
Cookie* pCookie = new Cookie();
UInt32 pos = request.position();
request.readRaw((UInt8*)pCookie->value,COOKIE_SIZE);
request >> (string&)pCookie->queryUrl;
request.reset(pos);
itCookie = _cookies.insert(pair<const UInt8*,Cookie*>(pCookie->value,pCookie)).first;
}
Cookie& cookie(*itCookie->second);
if(cookie.id==0) {
UInt8 decryptKey[AES_KEY_SIZE];UInt8* pDecryptKey=&decryptKey[0];
UInt8 encryptKey[AES_KEY_SIZE];UInt8* pEncryptKey=&encryptKey[0];
if(id==0x38) {
request.next(COOKIE_SIZE);
size_t size = (size_t)request.read7BitLongValue();
// peerId = SHA256(farPubKey)
EVP_Digest(request.current(),size,(UInt8*)peer.id,NULL,EVP_sha256(),NULL);
vector<UInt8> publicKey(request.read7BitValue()-2);
request.next(2); // unknown
request.readRaw(&publicKey[0],publicKey.size());
size = request.read7BitValue();
cookie.computeKeys(&publicKey[0],publicKey.size(),request.current(),(UInt16)size,decryptKey,encryptKey);
} else {
// edge
pDecryptKey=NULL;
pEncryptKey=NULL;
memcpy((UInt8*)peer.id,request.current(),ID_SIZE);
request.next(COOKIE_SIZE);
request.next(request.read7BitEncoded());
}
// Fill peer infos
Util::UnpackUrl(cookie.queryUrl,(string&)peer.path,(map<string,string>&)peer.properties);
// RESPONSE
Session& session = _gateway.createSession(farId,peer,pDecryptKey,pEncryptKey,cookie);
(UInt32&)cookie.id = session.id;
string address;
if(id==0x39) {
// Session by edge
session.flags |= SESSION_BY_EDGE;
Edge* pEdge = _invoker.edges(peer.address);
if(!pEdge)
ERROR("Edge session creation by an unknown server edge %s",peer.address.toString().c_str())
else
pEdge->addSession(session);
request >> address;
} else // Session direct
address = session.peer.address.toString();
session.peer.addresses.clear();
session.peer.addresses.push_back(address);
cookie.write();
} else