Skip to content

Commit

Permalink
Pass packet ID to custom packet handlers.
Browse files Browse the repository at this point in the history
We don't expose this to the user code, yet, because it would break the
API, but this is useful for future internal code.
  • Loading branch information
iphydf committed Mar 7, 2020
1 parent 7b3d2ed commit 6b26d03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ static int m_handle_lossy_packet(void *object, int friend_num, const uint8_t *pa
}

if (m->lossy_packethandler) {
m->lossy_packethandler(m, friend_num, packet, length, userdata);
m->lossy_packethandler(m, friend_num, packet[0], packet, length, userdata);
}

return 1;
Expand Down Expand Up @@ -1900,7 +1900,7 @@ static int handle_custom_lossless_packet(void *object, int friend_num, const uin
}

if (m->lossless_packethandler) {
m->lossless_packethandler(m, friend_num, packet, length, userdata);
m->lossless_packethandler(m, friend_num, packet[0], packet, length, userdata);
}

return 1;
Expand Down
6 changes: 2 additions & 4 deletions toxcore/Messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,8 @@ typedef void m_file_chunk_request_cb(Messenger *m, uint32_t friend_number, uint3
size_t length, void *user_data);
typedef void m_file_recv_chunk_cb(Messenger *m, uint32_t friend_number, uint32_t file_number, uint64_t position,
const uint8_t *data, size_t length, void *user_data);
typedef void m_friend_lossy_packet_cb(Messenger *m, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data);
typedef void m_friend_lossless_packet_cb(Messenger *m, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data);
typedef void m_friend_lossy_packet_cb(Messenger *m, uint32_t friend_number, uint8_t packet_id, const uint8_t *data, size_t length, void *user_data);
typedef void m_friend_lossless_packet_cb(Messenger *m, uint32_t friend_number, uint8_t packet_id, const uint8_t *data, size_t length, void *user_data);
typedef void m_friend_connectionstatuschange_internal_cb(Messenger *m, uint32_t friend_number,
uint8_t connection_status, void *user_data);
typedef void m_conference_invite_cb(Messenger *m, uint32_t friend_number, const uint8_t *cookie, uint16_t length,
Expand Down
6 changes: 2 additions & 4 deletions toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ static void tox_conference_peer_list_changed_handler(Messenger *m, uint32_t conf
}
}

static void tox_friend_lossy_packet_handler(Messenger *m, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data)
static void tox_friend_lossy_packet_handler(Messenger *m, uint32_t friend_number, uint8_t packet_id, const uint8_t *data, size_t length, void *user_data)
{
struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data;

Expand All @@ -312,8 +311,7 @@ static void tox_friend_lossy_packet_handler(Messenger *m, uint32_t friend_number
}
}

static void tox_friend_lossless_packet_handler(Messenger *m, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data)
static void tox_friend_lossless_packet_handler(Messenger *m, uint32_t friend_number, uint8_t packet_id, const uint8_t *data, size_t length, void *user_data)
{
struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data;

Expand Down

0 comments on commit 6b26d03

Please sign in to comment.