diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2024-04-13 14:12:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 14:12:20 +0200 |
commit | 8edb2f133c2df808e5fa65052bc6734bdca655c1 (patch) | |
tree | 474339398f8b01377c9e4202136f8512e100bec0 /src/lib/protocols/stun.c | |
parent | f51dfc69730a2e123b9a48d378d4685b981324a4 (diff) |
STUN: add support for ipv6 in some metadata (#2389)
Diffstat (limited to 'src/lib/protocols/stun.c')
-rw-r--r-- | src/lib/protocols/stun.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/protocols/stun.c b/src/lib/protocols/stun.c index a58e6202c..7ab6bc6f6 100644 --- a/src/lib/protocols/stun.c +++ b/src/lib/protocols/stun.c @@ -217,7 +217,17 @@ static void parse_ip_port_attribute(const u_int8_t *payload, u_int16_t payload_l ap->is_ipv6 = 0; } else if(protocol_family == 0x02 /* IPv6 */ && real_len == 20) { - /* TODO */ + u_int16_t port = ntohs(*((u_int16_t*)&payload[off+6])); + u_int32_t ip[4]; + + ip[0] = *((u_int32_t *)&payload[off + 8]); + ip[1] = *((u_int32_t *)&payload[off + 12]); + ip[2] = *((u_int32_t *)&payload[off + 16]); + ip[3] = *((u_int32_t *)&payload[off + 20]); + + ap->port = port; + memcpy(&ap->address, &ip, 16); + ap->is_ipv6 = 1; } } } |