More Packet Parsing

This commit is contained in:
Florian Märkl 2019-03-17 22:53:53 +01:00
commit c82ff6259b
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
3 changed files with 15 additions and 7 deletions

View file

@ -31,7 +31,7 @@ extern "C" {
typedef void (*ChiakiTakionDataCallback)(uint8_t *buf, size_t buf_size, void *user);
typedef void (*ChiakiTakionAVCallback)(uint8_t *buf, size_t buf_size, uint32_t key_pos, void *user);
typedef void (*ChiakiTakionAVCallback)(uint8_t *buf, size_t buf_size, uint8_t base_type, uint32_t key_pos, void *user);
typedef struct chiaki_takion_connect_info_t

View file

@ -58,7 +58,7 @@ static ChiakiErrorCode nagare_send_disconnect(ChiakiNagare *nagare);
static void nagare_takion_data_expect_bang(ChiakiNagare *nagare, uint8_t *buf, size_t buf_size);
static void nagare_takion_data_expect_streaminfo(ChiakiNagare *nagare, uint8_t *buf, size_t buf_size);
static ChiakiErrorCode nagare_send_streaminfo_ack(ChiakiNagare *nagare);
static void nagare_takion_av(uint8_t *buf, size_t buf_size, uint32_t key_pos, void *user);
static void nagare_takion_av(uint8_t *buf, size_t buf_size, uint8_t base_type, uint32_t key_pos, void *user);
CHIAKI_EXPORT ChiakiErrorCode chiaki_nagare_run(ChiakiSession *session)
@ -493,7 +493,7 @@ static ChiakiErrorCode nagare_send_disconnect(ChiakiNagare *nagare)
}
static void nagare_takion_av(uint8_t *buf, size_t buf_size, uint32_t key_pos, void *user)
static void nagare_takion_av(uint8_t *buf, size_t buf_size, uint8_t base_type, uint32_t key_pos, void *user)
{
ChiakiNagare *nagare = user;
@ -503,6 +503,10 @@ static void nagare_takion_av(uint8_t *buf, size_t buf_size, uint32_t key_pos, vo
{
chiaki_audio_receiver_frame_packet(nagare->session->audio_receiver, buf, 0x50);
}
else if(base_type == 2 && buf[0] != 0xf4)
{
CHIAKI_LOGD(nagare->log, "av frame 2, which is not audio\n");
}
//CHIAKI_LOGD(nagare->log, "Nagare AV %lu\n", buf_size);
//chiaki_log_hexdump(nagare->log, CHIAKI_LOG_DEBUG, buf, buf_size);

View file

@ -646,7 +646,7 @@ static ChiakiErrorCode takion_recv_message_cookie_ack(ChiakiTakion *takion)
static void takion_handle_packet_av(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size)
{
// HHIxxxxxIx
// HHIxIIx
if(buf_size < AV_HEADER_SIZE + 1)
{
@ -654,15 +654,19 @@ static void takion_handle_packet_av(ChiakiTakion *takion, uint8_t base_type, uin
return;
}
uint16_t word_0 = ntohs(*((uint16_t *)(buf + 0)));
uint16_t word_1 = ntohs(*((uint16_t *)(buf + 2)));
uint16_t packet_index = ntohs(*((uint16_t *)(buf + 0)));
uint16_t frame_index = ntohs(*((uint16_t *)(buf + 2)));
uint32_t dword_2 = ntohl(*((uint32_t *)(buf + 4)));
uint8_t *gmac = buf + 9; // uint8_t[4]
uint32_t key_pos = ntohl(*((uint32_t *)(buf + 0xd)));
uint8_t unknown_1 = buf[0x11];
CHIAKI_LOGD(takion->log, "packet index %u, frame index %u\n", packet_index, frame_index);
chiaki_log_hexdump(takion->log, CHIAKI_LOG_DEBUG, buf, buf_size);
uint8_t *data = buf + AV_HEADER_SIZE;
size_t data_size = buf_size - AV_HEADER_SIZE;
if(takion->av_cb)
takion->av_cb(data, data_size, key_pos, takion->av_cb_user);
takion->av_cb(data, data_size, base_type, key_pos, takion->av_cb_user);
}