@@ -113,14 +113,15 @@ microtime (void)
113
113
114
114
115
115
void
116
- send_error (double timestamp , struct sockaddr_in * reader_addr , char * error_msg , uint32_t error_code )
116
+ send_error (double timestamp , struct sockaddr_in * reader_addr , uint16_t reader_id , char * error_msg , uint32_t error_code )
117
117
{
118
118
int i = 0 ;
119
119
120
120
i += sprintf (buf + i , "{" );
121
121
122
- i += sprintf (buf + i , "\"reader\": {\"ip\":\"%s\",\"t\":%d}," ,
122
+ i += sprintf (buf + i , "\"reader\": {\"ip\":\"%s\",\"id\":%d,\" t\":%d}," ,
123
123
inet_ntoa (reader_addr -> sin_addr ),
124
+ reader_id ,
124
125
(uint32_t ) timestamp );
125
126
126
127
i += sprintf (buf + i , "\"error\": \"%s (%d)\"" , error_msg , error_code );
@@ -217,30 +218,30 @@ parse_packet (double timestamp, struct sockaddr_in *reader_addr, const void *dat
217
218
pkt = (const TBeaconLogSighting * )data ;
218
219
if (pkt -> hdr .protocol != BEACONLOG_SIGHTING )
219
220
{
220
- send_error (timestamp , reader_addr , "Invalid protocol" , pkt -> hdr .protocol );
221
+ send_error (timestamp , reader_addr , ntohs ( pkt -> hdr . reader_id ), "Invalid protocol" , pkt -> hdr .protocol );
221
222
//fprintf(stderr, " Invalid protocol [0x%02X]\n\r", pkt->hdr.protocol);
222
223
return len ;
223
224
}
224
225
225
226
t = ntohs (pkt -> hdr .size );
226
227
if (ntohs (t != sizeof (TBeaconLogSighting )))
227
228
{
228
- send_error (timestamp , reader_addr , "Invalid packet size" , t );
229
+ send_error (timestamp , reader_addr , ntohs ( pkt -> hdr . reader_id ), "Invalid packet size" , t );
229
230
//fprintf(stderr, " Invalid packet size (%u)\n\r", t);
230
231
return len ;
231
232
}
232
233
233
234
if (ntohs (pkt -> hdr .icrc16 ) != icrc16 (& pkt -> hdr .protocol , (sizeof (TBeaconLogSighting )- sizeof (pkt -> hdr .icrc16 ))))
234
235
{
235
- send_error (timestamp , reader_addr , "Invalid packet CRC" , 0 );
236
+ send_error (timestamp , reader_addr , ntohs ( pkt -> hdr . reader_id ), "Invalid packet CRC" , 0 );
236
237
//fprintf(stderr, " Invalid packet CRC\n\r");
237
238
return len ;
238
239
}
239
240
240
241
/* decrypt valid packet */
241
242
if ((t = aes_decr (& pkt -> log , & track , sizeof (track ), CONFIG_SIGNATURE_SIZE ))!= 0 )
242
243
{
243
- send_error (timestamp , reader_addr , "Packet decryption error" , t );
244
+ send_error (timestamp , reader_addr , ntohs ( pkt -> hdr . reader_id ), "Packet decryption error" , t );
244
245
//fprintf(stderr, " Failed decrypting packet with error [%i]\n\r", t);
245
246
return len ;
246
247
}
@@ -249,7 +250,7 @@ parse_packet (double timestamp, struct sockaddr_in *reader_addr, const void *dat
249
250
if (!((track .proto == RFBPROTO_BEACON_NG_SIGHTING )||
250
251
(track .proto == RFBPROTO_BEACON_NG_STATUS )))
251
252
{
252
- send_error (timestamp , reader_addr , "Unkown packet protocol" , track .proto );
253
+ send_error (timestamp , reader_addr , ntohs ( pkt -> hdr . reader_id ), "Unkown packet protocol" , track .proto );
253
254
//fprintf(stderr, " Unknown protocol [%i]\n\r", track.proto);
254
255
return len ;
255
256
}
0 commit comments