<p>Neels Hofmeyr <strong>uploaded patch set #3</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/12268">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add to osmo_sock_get_name*() API<br><br>Basically, I am applying code review that I would have given had I not been on<br>vacation when the last osmo_sock_get_name* stuff was merged.<br><br>osmo_sock_get_name2() is so far a static internal function. However, it is<br>nothing like osmo_sock_get_name(), so instead rename it to<br>osmo_sock_get_ip_and_port(). Also make it public API, no need to hide it.  I'm<br>adding an "and" in the name to hopefully clarify: "ip_port" vs. "ip_and_port"<br>-- there already are _get_X_ip_port() functions that only return the port<br>string, despite "ip" in the name.<br><br>Add new public osmo_sock_get_name2(), which is like osmo_sock_get_name(),<br>except it uses a static string instead of talloc, and omits the braces. This<br>is most convenient for log statement formats, avoiding dyn allocations.<br><br>Add new osmo_sock_get_name_buf(), which is like osmo_sock_get_name2() but<br>writes to a caller provided char buffer.<br><br>Use osmo_sock_get_name_buf() in the implementation of osmo_sock_get_name(),<br>but use another (non-static) local string buffer, because adding braces is too<br>complex without talloc_snprintf().<br><br>Rationale:<br><br>I want to improve the logging of socket errors, e.g. change<br><br>  DLMGCP ERROR Failed to read: 111/Connection refused (mgcp_client.c:720)<br><br>to<br><br>  DLMGCP ERROR Failed to read: r=10.0.99.2:2427<->l=10.0.99.2:2728: 111='Connection refused' (mgcp_client.c:721)<br><br>but it is just not handy to compose logging with the current API:<br><br>- osmo_sock_get_name() requires a talloc_free().<br>- all the others require output buffers.<br>- the only way to conveniently compose a logging string and,<br>- notably, the only trivial way to skip the string composition if the logging<br>  level is currently muted, is to have a function that returns a static string:<br>  the new osmo_sock_get_name2().<br>- (I think the osmo_sock_get_{local,remote}_* convenience wrappers should never<br>  have been added, because they encourage the caller to invoke the same code<br>  twice, for IP addr and port, and throw away one half each time.)<br><br>Related: Iae728192f499330d16836d9435648f6b8ed213b6 (osmo-mgw)<br>Change-Id: I8ad89ac447c9c582742e70d082072bdd40a5a398<br>---<br>M include/osmocom/core/socket.h<br>M src/socket.c<br>2 files changed, 50 insertions(+), 17 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/68/12268/3</pre><p>To view, visit <a href="https://gerrit.osmocom.org/12268">change 12268</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12268"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>
<div style="display:none"> Gerrit-Change-Id: I8ad89ac447c9c582742e70d082072bdd40a5a398 </div>
<div style="display:none"> Gerrit-Change-Number: 12268 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: Stefan Sperling <stsp@stsp.name> </div>