Skip to content

tport_logging: copy IPv6 addresses correctly in HEP capture - #354

Open
KaranGauswami wants to merge 1 commit into
freeswitch:masterfrom
KaranGauswami:fix-hep-ipv6-address
Open

KaranGauswami wants to merge 1 commit into
freeswitch:masterfrom
KaranGauswami:fix-hep-ipv6-address

Conversation

@KaranGauswami

Copy link
Copy Markdown

Fixes #353

Problem

For IPv6 transports, the HEP capture sends :: as the source and destination address. The port, IP family, protocol and timestamp fields are correct.

Root cause

In libsofia-sip-ua/tport/tport_logging.c, the IPv6 branches copy the address from the IPv4 member of the su_sockaddr_t union (su_sin.sin_addr.s_addr, 4 bytes).

For an IPv6 socket address, su_sin.sin_addr is at offset 4. In struct sockaddr_in6, offset 4 is sin6_flowinfo, not the address:

offset 0  sin6_family    (2)
offset 2  sin6_port      (2)   <- same offset as sin_port, so ports are correct
offset 4  sin6_flowinfo  (4)   <- the code reads this as "sin_addr"
offset 8  sin6_addr      (16)  <- the real address, never read

The code thus copies 4 bytes of sin6_flowinfo (usually 0) into a 16-byte field that was set to zero before. The result is always ::.

The same problem is in:

  • tport_capt_msg_hepv3(): the source and destination IPv6 chunks (0x0005, 0x0006)
  • tport_capt_msg_hepv2(): hep_ip6header.hp6_src and hp6_dst

Change

Copy su_sin6.sin6_addr with its full size (16 bytes) in the IPv6 branches of HEPv2 and HEPv3. The IPv4 branches do not change.

Test

  • Built commit 3cc785eeb1 with this change and loaded it into FreeSWITCH 1.11.3 (Debian 13, amd64).
  • Enabled HEPv3 capture on an IPv6 SIP profile and sent HEP to sngrep and to Homer (heplify-server).
  • Sent SIP over UDP and TLS (OPTIONS, REGISTER, INVITE, BYE).

Before the change:

src_ipv6 = ::               src_port = 5099
dst_ipv6 = ::               dst_port = 5060

After the change (documentation addresses shown):

src_ipv6 = 2001:db8:1::10   src_port = 5099
dst_ipv6 = 2001:db8:2::1    dst_port = 5060

The replies show the reverse direction correctly. Homer stores the correct srcIp and dstIp.

I did not test the HEPv2 change separately. It is the same correction.

The IPv6 branches of tport_capt_msg_hepv2() and tport_capt_msg_hepv3()
copied the address from su_sin.sin_addr.s_addr. For an IPv6 socket
address this reads 4 bytes of sin6_flowinfo, so the HEP source and
destination addresses were always "::".

Copy su_sin6.sin6_addr with its full size instead.

Fixes freeswitch#353
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HEP capture: source and destination IPv6 addresses are always ::

1 participant