mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 20:04:20 -04:00
Major improvements to the serialiser to make it work with retroshare.
This is still a first draft - the message types will surely change. -corrected ids and added service classes. -Added disc/msg/chat/cache/file messages -Extended serialiser to handle service extensions. -corrected IpAddrPort code. -More debugging code. -Added some tests. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@270 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9f76b1a313
commit
e8ccb0b427
22 changed files with 3101 additions and 333 deletions
|
@ -59,14 +59,17 @@
|
|||
******************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include "util/rsnet.h"
|
||||
|
||||
/* 0b 0000 0000 0001 XXXX UInt8 */
|
||||
/* 0b 0000 0000 0010 XXXX UInt16 */
|
||||
/* 0b 0000 0000 0011 XXXX UInt32 */
|
||||
/* 0b 0000 0000 0100 XXXX UInt64 */
|
||||
/* 0b 0000 0000 0101 XXXX String */
|
||||
/* 0b 0000 0000 0110 XXXX IP:Port V4 */
|
||||
/* 0b 0000 0000 0111 XXXX ?????? */
|
||||
|
||||
/* 0b 0000 0000 0001 XXXX UInt32 */
|
||||
/* 0b 0000 0000 0010 XXXX String */
|
||||
/* 0b 0000 0000 0011 XXXX IP:Port V4 */
|
||||
/* 0b 0000 0000 0011 XXXX IP:Port V4 */
|
||||
|
||||
/******* BINARY TYPES ****************/
|
||||
/******* BINARY TYPES *****************/
|
||||
/* 0b 0000 0000 1000 XXXX CERT */
|
||||
/* 0b 0000 0000 1001 XXXX Priv Key */
|
||||
/* 0b 0000 0000 1010 XXXX Pub Key */
|
||||
|
@ -74,29 +77,37 @@
|
|||
|
||||
/* 0b 0001 XXXX XXXX XXXX Compound */
|
||||
|
||||
const uint16_t TLV_TYPE_UINT32_SIZE = 0x0010;
|
||||
const uint16_t TLV_TYPE_UINT32_POP = 0x0011;
|
||||
const uint16_t TLV_TYPE_UINT32_AGE = 0x0012;
|
||||
const uint16_t TLV_TYPE_UINT32_OFFSET = 0x0013;
|
||||
const uint16_t TLV_TYPE_UINT32_SERID = 0x0014;
|
||||
const uint16_t TLV_TYPE_UINT8_SERID = 0x0010;
|
||||
|
||||
const uint16_t TLV_TYPE_STR_HASH = 0x0020;
|
||||
const uint16_t TLV_TYPE_STR_NAME = 0x0021;
|
||||
const uint16_t TLV_TYPE_STR_PATH = 0x0022;
|
||||
const uint16_t TLV_TYPE_STR_PEERID = 0x0023;
|
||||
const uint16_t TLV_TYPE_STR_KEY = 0x0024;
|
||||
const uint16_t TLV_TYPE_STR_VALUE = 0x0025;
|
||||
const uint16_t TLV_TYPE_STR_COMMENT = 0x0026;
|
||||
const uint16_t TLV_TYPE_STR_TITLE = 0x0027;
|
||||
const uint16_t TLV_TYPE_UINT16_SERID = 0x0020;
|
||||
|
||||
const uint16_t TLV_TYPE_UINT8_SERID = 0x0028;
|
||||
const uint16_t TLV_TYPE_UINT32_SIZE = 0x0030;
|
||||
const uint16_t TLV_TYPE_UINT32_POP = 0x0031;
|
||||
const uint16_t TLV_TYPE_UINT32_AGE = 0x0032;
|
||||
const uint16_t TLV_TYPE_UINT32_OFFSET = 0x0033;
|
||||
const uint16_t TLV_TYPE_UINT32_SERID = 0x0034;
|
||||
|
||||
const uint16_t TLV_TYPE_IPV4_LOCAL = 0x0030;
|
||||
const uint16_t TLV_TYPE_IPV4_SERVER = 0x0031;
|
||||
const uint16_t TLV_TYPE_IPV4_LAST = 0x0032;
|
||||
const uint16_t TLV_TYPE_UINT64_SIZE = 0x0040;
|
||||
const uint16_t TLV_TYPE_UINT64_OFFSET = 0x0041;
|
||||
|
||||
const uint16_t TLV_TYPE_STR_HASH = 0x0050;
|
||||
const uint16_t TLV_TYPE_STR_NAME = 0x0051;
|
||||
const uint16_t TLV_TYPE_STR_PATH = 0x0052;
|
||||
const uint16_t TLV_TYPE_STR_PEERID = 0x0053;
|
||||
const uint16_t TLV_TYPE_STR_KEY = 0x0054;
|
||||
const uint16_t TLV_TYPE_STR_VALUE = 0x0055;
|
||||
const uint16_t TLV_TYPE_STR_COMMENT = 0x0056;
|
||||
const uint16_t TLV_TYPE_STR_TITLE = 0x0057;
|
||||
const uint16_t TLV_TYPE_STR_MSG = 0x0058;
|
||||
const uint16_t TLV_TYPE_STR_SUBJECT = 0x0059;
|
||||
|
||||
|
||||
const uint16_t TLV_TYPE_IPV4_LOCAL = 0x0060;
|
||||
const uint16_t TLV_TYPE_IPV4_SERVER = 0x0061;
|
||||
const uint16_t TLV_TYPE_IPV4_LAST = 0x0062;
|
||||
|
||||
/**** Binary Types ****/
|
||||
const uint16_t TLV_TYPE_CERT_XPGP = 0x0080;
|
||||
const uint16_t TLV_TYPE_CERT_XPGP_DER = 0x0080;
|
||||
const uint16_t TLV_TYPE_CERT_X509 = 0x0081;
|
||||
const uint16_t TLV_TYPE_CERT_OPENPGP = 0x0082;
|
||||
|
||||
|
@ -133,18 +144,22 @@ bool SetTlvSize(void *data, uint32_t size, uint16_t len);
|
|||
* so we include a type parameter in the arguments
|
||||
*/
|
||||
|
||||
bool SetTlvUInt8(void *data, uint32_t size, uint32_t *offset, uint16_t type, uint8_t out);
|
||||
bool GetTlvUInt8(void *data, uint32_t size, uint32_t *offset, uint16_t type, uint8_t *in);
|
||||
|
||||
bool SetTlvUInt16(void *data, uint32_t size, uint32_t *offset, uint16_t type, uint16_t out);
|
||||
bool GetTlvUInt16(void *data, uint32_t size, uint32_t *offset, uint16_t type, uint16_t *in);
|
||||
|
||||
bool SetTlvUInt32(void *data, uint32_t size, uint32_t *offset, uint16_t type, uint32_t out);
|
||||
bool GetTlvUInt32(void *data, uint32_t size, uint32_t *offset, uint16_t type, uint32_t *in);
|
||||
uint32_t GetTlvUInt32Size();
|
||||
uint32_t GetTlvUInt16Size();
|
||||
uint32_t GetTlvUInt8Size();
|
||||
/* additiona numerical set and Get Routine to be added
|
||||
|
||||
bool SetTlvUInt16(...)
|
||||
bool SetTlvUInt8(...)
|
||||
bool GetTlvUInt16(...)
|
||||
bool GetTlvUInt8(...)
|
||||
............................could above just be templated? */
|
||||
bool SetTlvUInt64(void *data, uint32_t size, uint32_t *offset, uint16_t type, uint64_t out);
|
||||
bool GetTlvUInt64(void *data, uint32_t size, uint32_t *offset, uint16_t type, uint64_t *in);
|
||||
|
||||
uint32_t GetTlvUInt8Size();
|
||||
uint32_t GetTlvUInt16Size();
|
||||
uint32_t GetTlvUInt32Size();
|
||||
uint32_t GetTlvUInt64Size();
|
||||
|
||||
|
||||
bool SetTlvString(void *data, uint32_t size, uint32_t *offset, uint16_t type, std::string out);
|
||||
|
@ -153,7 +168,7 @@ uint32_t GetTlvStringSize(std::string &in);
|
|||
|
||||
bool SetTlvIpAddrPortV4(void *data, uint32_t size, uint32_t *offset, uint16_t type, struct sockaddr_in *out);
|
||||
bool GetTlvIpAddrPortV4(void *data, uint32_t size, uint32_t *offset, uint16_t type, struct sockaddr_in *in);
|
||||
bool GetTlvIpAddrPortV4Size();
|
||||
uint32_t GetTlvIpAddrPortV4Size();
|
||||
|
||||
/* additional function to be added
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue