libosmocore/src
Neels Hofmeyr 0145751a97 add to osmo_sock_get_name*() API
Basically, I am applying code review that I would have given had I not been on
vacation when the last osmo_sock_get_name* stuff was merged.

osmo_sock_get_name2() is so far a static internal function. However, it is
nothing like osmo_sock_get_name(), so instead rename it to
osmo_sock_get_ip_and_port(). Also make it public API, no need to hide it.  I'm
adding an "and" in the name to hopefully clarify: "ip_port" vs. "ip_and_port"
-- there already are _get_X_ip_port() functions that only return the port
string, despite "ip" in the name.

Add new public osmo_sock_get_name2(), which is like osmo_sock_get_name(),
except it uses a static string instead of talloc, and omits the braces. This
is most convenient for log statement formats, avoiding dyn allocations.

Add new osmo_sock_get_name_buf(), which is like osmo_sock_get_name2() but
writes to a caller provided char buffer.

Use osmo_sock_get_name_buf() in the implementation of osmo_sock_get_name(),
but use another (non-static) local string buffer, because adding braces is too
complex without talloc_snprintf().

Rationale:

I want to improve the logging of socket errors, e.g. change

  DLMGCP ERROR Failed to read: 111/Connection refused (mgcp_client.c:720)

to

  DLMGCP ERROR Failed to read: r=10.0.99.2:2427<->l=10.0.99.2:2728: 111='Connection refused' (mgcp_client.c:721)

but it is just not handy to compose logging with the current API:

- osmo_sock_get_name() requires a talloc_free().
- all the others require output buffers.
- the only way to conveniently compose a logging string and,
- notably, the only trivial way to skip the string composition if the logging
  level is currently muted, is to have a function that returns a static string:
  the new osmo_sock_get_name2().
- (I think the osmo_sock_get_{local,remote}_* convenience wrappers should never
  have been added, because they encourage the caller to invoke the same code
  twice, for IP addr and port, and throw away one half each time.)

Related: Iae728192f499330d16836d9435648f6b8ed213b6 (osmo-mgw)
Change-Id: I8ad89ac447c9c582742e70d082072bdd40a5a398
2018-12-19 03:25:55 +01:00
..
codec Bump version: 0.11.0.91-9d4a3-dirty → 0.12.0 2018-07-27 17:31:47 +02:00
coding coding: Always initialize bit counters in gsm0503_pdtch_egprs_decode(). 2018-09-05 16:08:34 +03:00
ctrl ctrl: use #define for TRAP id 2018-12-03 21:42:51 +00:00
gb document unblock-ack vs. signalling in gprs_ns_process_msg() 2018-11-20 11:06:05 +01:00
gsm GSUP/SMS: introduce READY-FOR-SM message 2018-12-18 21:52:06 +07:00
pseudotalloc Fix embedded (arm-none-eabi) builds 2018-06-28 10:30:34 +02:00
sim Bump version: 0.10.2.284-bc47-dirty → 0.11.0 2018-05-03 15:47:11 +02:00
vty make 'show rate-counters' show group index 2018-10-29 17:50:30 +01:00
Makefile.am configure.ac: check clock_gettime for glib < 2.17 2018-12-03 13:52:29 +00:00
application.c fix logging talloc ctx: add osmo_init_logging2() 2018-03-28 19:06:16 +02:00
backtrace.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
bitcomp.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
bits.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
bitvec.c Don't call abort() directly, always use osmo_panic() 2018-06-28 10:57:42 +02:00
conv.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
conv_acc.c conv_acc: Our code requires SSSE3, not just SSE3 2017-11-17 11:44:22 +01:00
conv_acc_generic.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
conv_acc_sse.c conv_acc: Our code requires SSSE3, not just SSE3 2017-11-17 11:44:22 +01:00
conv_acc_sse_avx.c conv_acc: Our code requires SSSE3, not just SSE3 2017-11-17 11:44:22 +01:00
conv_acc_sse_impl.h Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
counter.c counters: add osmo_counters_count() returns the amount of counters 2017-12-05 16:06:27 +01:00
crc16.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
crcXXgen.c.tpl Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
fsm.c fsm: fix apidoc of osmo_fsm_state_name() 2018-11-16 17:45:40 +01:00
gsmtap_util.c gsmtap_util: make sure SO_REUSEADDR is applied for GSMTAP 2018-08-24 10:31:18 +00:00
isdnhdlc.c isdnhdlc: Port from kernel to userspace 2018-05-11 21:57:46 +02:00
logging.c Allow log_init() with NULL log_info 2018-12-06 15:52:28 +01:00
logging_gsmtap.c memleak: _gsmtap_raw_output(): free msg in case of vsnprintf failure 2018-02-16 01:35:08 +01:00
logging_syslog.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
loggingrb.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
macaddr.c osmo_get_macaddr: Fix buffer read out of bounds 2018-04-18 08:57:56 +00:00
msgb.c msgb: add test helpers 2018-12-12 09:34:12 +00:00
msgfile.c memleak: osmo_config_list_parse: getline() needs free also on error 2017-11-18 10:30:57 +00:00
panic.c osmo_panic(): Annotate as __attribute__ ((noreturn)) 2018-06-29 20:32:57 +02:00
plugin.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
prbs.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
prim.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
rate_ctr.c rate_ctr: Improve logging 2018-07-21 08:22:57 +00:00
rbtree.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
select.c timerfd_create(): Fix error handling of osmo_fd_register() 2018-10-21 13:46:07 +02:00
sercomm.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
serial.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
signal.c signal: Introduce API osmo_signal_talloc_ctx_init 2018-08-16 21:03:32 +02:00
socket.c add to osmo_sock_get_name*() API 2018-12-19 03:25:55 +01:00
stat_item.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
stats.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
stats_statsd.c stats_statsd: Send all stat_items as gauges 2018-10-24 16:37:05 +02:00
strrb.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
timer.c timer: fixup whitespace issues 2017-12-22 16:48:14 +01:00
timer_clockgettime.c Fix embedded (arm-none-eabi) builds 2018-06-28 10:30:34 +02:00
timer_gettimeofday.c timer: Document osmo_gettimeofday API 2018-03-01 12:33:03 +00:00
utils.c fix api doc for osmo_bcd2str() 2018-12-11 02:14:20 +01:00
write_queue.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00