@@ -44,12 +44,12 @@ static void remove_announces(GC_Announces_List *gc_announces_list, GC_Announces
44
44
* Returns null if no announce is found.
45
45
*/
46
46
non_null ()
47
- static GC_Announces * get_announces_by_chat_id (const GC_Announces_List * gc_announces_list , const uint8_t * chat_id )
47
+ static GC_Announces * get_announces_by_chat_id (const GC_Announces_List * gc_announces_list , const Public_Key * chat_id )
48
48
{
49
49
GC_Announces * announces = gc_announces_list -> root_announces ;
50
50
51
51
while (announces != nullptr ) {
52
- if (memcmp (announces -> chat_id , chat_id , CHAT_ID_SIZE ) == 0 ) {
52
+ if (memcmp (& announces -> chat_id , chat_id , CHAT_ID_SIZE ) == 0 ) {
53
53
return announces ;
54
54
}
55
55
@@ -60,7 +60,7 @@ static GC_Announces *get_announces_by_chat_id(const GC_Announces_List *gc_announ
60
60
}
61
61
62
62
int gca_get_announces (const GC_Announces_List * gc_announces_list , GC_Announce * gc_announces , uint8_t max_nodes ,
63
- const uint8_t * chat_id , const uint8_t * except_public_key )
63
+ const Public_Key * chat_id , const Public_Key * except_public_key )
64
64
{
65
65
if (gc_announces == nullptr || gc_announces_list == nullptr || chat_id == nullptr || max_nodes == 0
66
66
|| except_public_key == nullptr ) {
@@ -78,15 +78,15 @@ int gca_get_announces(const GC_Announces_List *gc_announces_list, GC_Announce *g
78
78
for (size_t i = 0 ; i < announces -> index && i < GCA_MAX_SAVED_ANNOUNCES_PER_GC && added_count < max_nodes ; ++ i ) {
79
79
const size_t index = i % GCA_MAX_SAVED_ANNOUNCES_PER_GC ;
80
80
81
- if (memcmp (except_public_key , announces -> peer_announces [index ].base_announce .peer_public_key ,
81
+ if (memcmp (except_public_key , & announces -> peer_announces [index ].base_announce .peer_public_key ,
82
82
ENC_PUBLIC_KEY_SIZE ) == 0 ) {
83
83
continue ;
84
84
}
85
85
86
86
bool already_added = false;
87
87
88
88
for (size_t j = 0 ; j < added_count ; ++ j ) {
89
- if (memcmp (gc_announces [j ].peer_public_key , announces -> peer_announces [index ].base_announce .peer_public_key ,
89
+ if (memcmp (& gc_announces [j ].peer_public_key , & announces -> peer_announces [index ].base_announce .peer_public_key ,
90
90
ENC_PUBLIC_KEY_SIZE ) == 0 ) {
91
91
already_added = true;
92
92
break ;
@@ -125,7 +125,7 @@ int gca_pack_announce(const Logger *log, uint8_t *data, uint16_t length, const G
125
125
}
126
126
127
127
uint16_t offset = 0 ;
128
- memcpy (data + offset , announce -> peer_public_key , ENC_PUBLIC_KEY_SIZE );
128
+ memcpy (data + offset , announce -> peer_public_key . data , ENC_PUBLIC_KEY_SIZE );
129
129
offset += ENC_PUBLIC_KEY_SIZE ;
130
130
131
131
data [offset ] = announce -> ip_port_is_set ? 1 : 0 ;
@@ -186,7 +186,7 @@ static int gca_unpack_announce(const Logger *log, const uint8_t *data, uint16_t
186
186
}
187
187
188
188
uint16_t offset = 0 ;
189
- memcpy (announce -> peer_public_key , data + offset , ENC_PUBLIC_KEY_SIZE );
189
+ memcpy (announce -> peer_public_key . data , data + offset , ENC_PUBLIC_KEY_SIZE );
190
190
offset += ENC_PUBLIC_KEY_SIZE ;
191
191
192
192
net_unpack_bool (& data [offset ], & announce -> ip_port_is_set );
@@ -233,7 +233,7 @@ int gca_pack_public_announce(const Logger *log, uint8_t *data, uint16_t length,
233
233
return -1 ;
234
234
}
235
235
236
- memcpy (data , public_announce -> chat_public_key , CHAT_ID_SIZE );
236
+ memcpy (data , public_announce -> chat_public_key . data , CHAT_ID_SIZE );
237
237
238
238
const int packed_size = gca_pack_announce (log , data + CHAT_ID_SIZE , length - CHAT_ID_SIZE ,
239
239
& public_announce -> base_announce );
@@ -264,7 +264,7 @@ int gca_unpack_public_announce(const Logger *log, const uint8_t *data, uint16_t
264
264
return -1 ;
265
265
}
266
266
267
- memcpy (public_announce -> chat_public_key , data , CHAT_ID_SIZE );
267
+ memcpy (public_announce -> chat_public_key . data , data , CHAT_ID_SIZE );
268
268
269
269
const int base_announce_size = gca_unpack_announce (log , data + ENC_PUBLIC_KEY_SIZE , length - ENC_PUBLIC_KEY_SIZE ,
270
270
& public_announce -> base_announce );
@@ -361,7 +361,7 @@ static GC_Announces *gca_new_announces(
361
361
362
362
announces -> next_announce = gc_announces_list -> root_announces ;
363
363
gc_announces_list -> root_announces = announces ;
364
- memcpy ( announces -> chat_id , public_announce -> chat_public_key , CHAT_ID_SIZE ) ;
364
+ announces -> chat_id = public_announce -> chat_public_key ;
365
365
366
366
return announces ;
367
367
}
@@ -373,7 +373,7 @@ GC_Peer_Announce *gca_add_announce(const Mono_Time *mono_time, GC_Announces_List
373
373
return nullptr ;
374
374
}
375
375
376
- GC_Announces * announces = get_announces_by_chat_id (gc_announces_list , public_announce -> chat_public_key );
376
+ GC_Announces * announces = get_announces_by_chat_id (gc_announces_list , & public_announce -> chat_public_key );
377
377
378
378
// No entry for this chat_id exists so we create one
379
379
if (announces == nullptr ) {
@@ -464,7 +464,7 @@ void do_gca(const Mono_Time *mono_time, GC_Announces_List *gc_announces_list)
464
464
}
465
465
}
466
466
467
- void cleanup_gca (GC_Announces_List * gc_announces_list , const uint8_t * chat_id )
467
+ void cleanup_gca (GC_Announces_List * gc_announces_list , const Public_Key * chat_id )
468
468
{
469
469
if (gc_announces_list == nullptr || chat_id == nullptr ) {
470
470
return ;
0 commit comments