res_pjsip: Log IPv6 addresses correctly

Both pjsip_tx_data.tp_info.dst_name and pjsip_rx_data.pkt_info.src_name
store IPv6 addresses without enclosing brackets. This causes some log
output to be confusing because it is difficult to separate the IPv6
address from a port specification.

* Use pj_sockaddr_print() along with pjsip_tx_data.tp_info.dst_addr and
  pjsip_rx_data.pkt_info.src_addr where possible for consistent IPv6
  output.

* When a pj_sockaddr is not available, explicitly wrap IPv6 addresses
  in brackets.

* When assigning pjsip_rx_data.pkt_info.src_name ourselves, make sure
  to also set pjsip_rx_data.pkt_info.src_addr.

Change-Id: I5cfe997ced7883862a12b9c7d8551d76ae02fcf8
This commit is contained in:
Sean Bright
2018-09-07 10:40:05 -04:00
parent 3f9544c1f5
commit 887a315e17
7 changed files with 62 additions and 23 deletions

View File

@@ -31,6 +31,18 @@ extern "C" {
#include <netinet/in.h>
/*
* String buffer size that can accommodate a fully stringified representation of a
* supported IP address & port:
*
* - 45 bytes for an IPv6 address
* - 2 bytes for brackets around an IPv6 address
* - 1 byte for the port separator (a colon)
* - 5 bytes for the port
* - 1 byte for the zero-terminator
*/
#define AST_SOCKADDR_BUFLEN (45 + 2 + 1 + 5 + 1)
/*!
* Values for address families that we support. This is reproduced from socket.h
* because we do not want users to include that file. Only netsock2.c should