Classified ads
protocol.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Järvinen 2013-2016.
3 
4  This file is part of Classified Ads.
5 
6  Classified Ads is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with Classified Ads; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef CA_PROTOCOL_H
22 #define CA_PROTOCOL_H
23 #include "../util/hash.h" // for Hash
24 
41 // node greeting has following fields, each is unsigned
42 // 8-bit if not otherwise stated, 32-bit integers are
43 // in network byte order:
44 // 1. protocol version for this node. Note that identifies
45 // both this message and the protocol version. Later we
46 // may invent protocol version xyz that will then
47 // identify node and its protocol with some other
48 // number.
49 static const unsigned char KProtocolVersion (1) ;
50 // 2. number of bytes that follows for the whole message
51 // 3. node greeting as qCompress()ed JSon
52 //
53 // ok, next thing to define is our easiest message type, random numbers.
54 // idea for this is this: upon connect node sends node greeting.
55 // node greeting contains hash and outside ip addr. suppose someone
56 // is eavesdropping the tsl tcp connection she already has some known
57 // plaintext in there, in the very first real datapacket transmitted,
58 // in known offset so .. say, the original tsl key was done using bad
59 // random number and in addition the listener knows some plaintext
60 // inside it might be possible to brute-force the key.
61 //
62 // lets make her job a bit more interesting by first transmitting
63 // short random sequence of random length in the beginning.
64 static const unsigned char KRandomNumbersPacket (100) ;
65 // rest of the packet is msg len and then the bytes that are supposed
66 // to be discarded (or written into your weekly lottery ticket
67 // if you consider yourself a lucky jerk :)
68 
69 // then have packet for requesting nodes that might be held liable
70 // for keeping alive content with given hash
71 // the packet consists of the identifier and a 160 bit hash. nothing else.
72 
73 // following items are for requesting various things from peer:
74 static const unsigned char KNodesAroundHash (101) ;
75 static const unsigned char KProfileAtHash (103) ;
76 static const unsigned char KBinaryFileAtHash (104) ;
77 static const unsigned char KClassifiedAdAtHash (109) ;
79 static const unsigned char KProfilePublish (102) ;
80 static const unsigned char KBinaryFilePublish (105) ;
81 static const unsigned char KBinaryFileSend (106) ;
82 static const unsigned char KClassifiedAdPublish (107) ;
83 static const unsigned char KProfileSend (108) ;
84 static const unsigned char KClassifiedAdSend (110) ;
85 static const unsigned char KAdsClassifiedAtHash (111) ;
86 static const unsigned char KListOfAdsClassifiedAtHash (112) ;
87 static const unsigned char KPrivMessagePublish (113) ;
88 static const unsigned char KPrivMessageSend (114) ;
89 static const unsigned char KPrivMessagesAtHash (115) ;
90 static const unsigned char KPrivMessagesForProfile (116) ;
91 static const unsigned char KProfileCommentPublish (117) ;
92 static const unsigned char KProfileCommentSend (118) ;
98 static const unsigned char KProfileCommentAtHash (119) ;
102 static const unsigned char KSingleProfileCommentAtHash (120) ;
106 static const unsigned char KSearchRequest (121) ;
110 static const unsigned char KSearchResults (122) ;
114 static const unsigned char KVoiceCallStart (123) ;
118 static const unsigned char KVoiceCallEnd (124) ;
127 static const unsigned char KRealtimeData (125) ;
131 static const unsigned char KDbRecordPublish ( 126 ) ;
132 static const unsigned char KDbRecordSend ( 127 ) ;
133 static const unsigned char KDbRecordSearch ( 128 ) ;
134 
138 static const unsigned char KFutureUse4 (129) ;
139 static const unsigned char KFutureUse5 (130) ;
140 static const unsigned char KFutureUse6 (131) ;
141 
142 
146 static const unsigned char KRTDataAudioSubtype (1) ;
150 static const unsigned char KRTDataControlSubtype (2) ;
151 
188 };
198 } ;
206 struct PublishItem {
210  QList<quint32> iAlreadyPushedHosts ;
212 } ;
213 
217 static const int KMaxOpenConnections( 100 );
223 static const int KNumberOfNodesToSendToEachPeer ( 300 ) ;
228 static const int KNumberOfClassifiedAdsToSendToEachPeer ( 300 ) ;
232 static const quint32 KMaxProtocolItemSize ( 1024*1024*2 ) ;
233 
238 static const quint16 KBroadCastAdvertismentPort ( 23432 ) ;
239 #endif /* CA_PROTOCOL_H */
static const unsigned char KClassifiedAdAtHash(109)
Definition: protocol.h:169
Definition: protocol.h:174
static const unsigned char KBinaryFilePublish(105)
static const unsigned char KSearchResults(122)
static const unsigned char KDbRecordPublish(126)
static const unsigned char KVoiceCallStart(123)
Definition: protocol.h:164
static const unsigned char KProfilePublish(102)
Definition: protocol.h:180
static const unsigned char KVoiceCallEnd(124)
static const unsigned char KBinaryFileSend(106)
static const unsigned char KProtocolVersion(1)
static const unsigned char KFutureUse6(131)
Hash i2NdAddr
Definition: protocol.h:211
Definition: protocol.h:170
static const unsigned char KNodesAroundHash(101)
static const unsigned char KAdsClassifiedAtHash(111)
Definition: protocol.h:186
static const unsigned char KListOfAdsClassifiedAtHash(112)
Definition: protocol.h:177
Definition: protocol.h:173
Definition: protocol.h:172
Definition: protocol.h:167
static const quint32 KMaxProtocolItemSize(1024 *1024 *2)
Definition: protocol.h:176
Hash is class that carries 160-bit digest.
Definition: hash.h:38
Definition: protocol.h:161
static const unsigned char KSearchRequest(121)
ProtocolItemType
Definition: protocol.h:157
Definition: protocol.h:160
Definition: protocol.h:181
static const unsigned char KPrivMessagePublish(113)
Definition: protocol.h:185
static const unsigned char KRealtimeData(125)
ProtocolItemType iItemType
Definition: protocol.h:196
Definition: protocol.h:178
static const int KNumberOfNodesToSendToEachPeer(300)
Definition: protocol.h:166
static const unsigned char KPrivMessagesAtHash(115)
static const quint16 KBroadCastAdvertismentPort(23432)
Definition: protocol.h:162
static const unsigned char KClassifiedAdPublish(107)
static const unsigned char KProfileCommentAtHash(119)
static const unsigned char KSingleProfileCommentAtHash(120)
Hash iObjectHash
Definition: protocol.h:208
Definition: protocol.h:175
static const unsigned char KRTDataAudioSubtype(1)
static const unsigned char KDbRecordSearch(128)
static const unsigned char KFutureUse4(129)
static const unsigned char KProfileCommentSend(118)
static const unsigned char KPrivMessagesForProfile(116)
Definition: protocol.h:163
Definition: protocol.h:179
send-queue item.
Definition: protocol.h:195
Definition: protocol.h:184
static const unsigned char KRTDataControlSubtype(2)
static const unsigned char KPrivMessageSend(114)
Definition: protocol.h:183
static const unsigned char KClassifiedAdSend(110)
static const unsigned char KProfileSend(108)
Definition: protocol.h:182
static const int KNumberOfClassifiedAdsToSendToEachPeer(300)
Carrier for keeping state of item about to be published.
Definition: protocol.h:206
Definition: protocol.h:159
static const unsigned char KProfileAtHash(103)
static const int KMaxOpenConnections(100)
static const unsigned char KProfileCommentPublish(117)
static const unsigned char KBinaryFileAtHash(104)
Definition: protocol.h:165
ProtocolItemType iObjectType
Definition: protocol.h:207
static const unsigned char KFutureUse5(130)
Hash iHash
Definition: protocol.h:197
Definition: protocol.h:168
Definition: protocol.h:158
static const unsigned char KDbRecordSend(127)
static const unsigned char KRandomNumbersPacket(100)
Definition: protocol.h:171
Definition: protocol.h:187
QList< quint32 > iAlreadyPushedHosts
Definition: protocol.h:210