Attention is currently required from: pespin.
neels has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27050 )
Change subject: add osmo_sockaddr_from/to_octets()
......................................................................
Patch Set 1:
(2 comments)
File src/socket.c:
https://gerrit.osmocom.org/c/libosmocore/+/27050/comment/6219a76d_73d46bb7
PS1, Line 1746: size_t l;
> use len if possible, my eyes hurt seeing number ones everywhere due to l and 1 looking similar :P
lol, right =)
https://gerrit.osmocom.org/c/libosmocore/+/27050/comment/2a9ad3b4_40990b28
PS1, Line 1747: switch (os->u.sin.sin_family) {
> os->u.sa. […]
i'm still confused with all the different sockaddrs, thx
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27050
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie9e33bfac525c59c30714663d2bfcc62ec9eeb81
Gerrit-Change-Number: 27050
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 07 Feb 2022 21:14:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27025 )
Change subject: add osmo_quote_str_buf3, osmo_escape_str_buf3
......................................................................
add osmo_quote_str_buf3, osmo_escape_str_buf3
There already are osmo_quote_str_buf() and osmo_quote_str_buf2(), same
for _escape_, but none of them return the snprintf() like string length.
A private function does, publish this in the API.
The returned chars_needed is required to accurately allocate sufficient
size in string functions that call osmo_quote_str/osmo_escape_str. I am
adding such in osmo-upf.git.
Related: SYS#5599
Change-Id: I05d75a40599e3133da099a11e8babaaad0e9493a
---
M include/osmocom/core/utils.h
M src/utils.c
2 files changed, 29 insertions(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
osmith: Looks good to me, but someone else must approve
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 327aa3d..eda0e39 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -157,10 +157,12 @@
char *osmo_quote_cstr_c(void *ctx, const char *str, int in_len);
const char *osmo_escape_str(const char *str, int len);
+int osmo_escape_str_buf3(char *buf, size_t bufsize, const char *str, int in_len);
char *osmo_escape_str_buf2(char *buf, size_t bufsize, const char *str, int in_len);
const char *osmo_escape_str_buf(const char *str, int in_len, char *buf, size_t bufsize);
char *osmo_escape_str_c(const void *ctx, const char *str, int in_len);
const char *osmo_quote_str(const char *str, int in_len);
+int osmo_quote_str_buf3(char *buf, size_t bufsize, const char *str, int in_len);
char *osmo_quote_str_buf2(char *buf, size_t bufsize, const char *str, int in_len);
const char *osmo_quote_str_buf(const char *str, int in_len, char *buf, size_t bufsize);
char *osmo_quote_str_c(const void *ctx, const char *str, int in_len);
diff --git a/src/utils.c b/src/utils.c
index 357ed53..2012b74 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -754,7 +754,7 @@
* the non-legacy format also escapes those as "\xNN" sequences.
* \return Number of characters that would be written if bufsize were large enough excluding '\0' (like snprintf()).
*/
-static size_t _osmo_escape_str_buf(char *buf, size_t bufsize, const char *str, int in_len, bool legacy_format)
+static int _osmo_escape_str_buf(char *buf, size_t bufsize, const char *str, int in_len, bool legacy_format)
{
struct osmo_strbuf sb = { .buf = buf, .len = bufsize };
int in_pos = 0;
@@ -826,6 +826,18 @@
* \param[in] bufsize sizeof(buf).
* \param[in] str A string that may contain any characters.
* \param[in] in_len Pass -1 to print until nul char, or >= 0 to force a length (also past nul chars).
+ * \return Number of characters that would be written if bufsize were large enough excluding '\0' (like snprintf()).
+ */
+int osmo_escape_str_buf3(char *buf, size_t bufsize, const char *str, int in_len)
+{
+ return _osmo_escape_str_buf(buf, bufsize, str, in_len, false);
+}
+
+/*! Return the string with all non-printable characters escaped.
+ * \param[out] buf string buffer to write escaped characters to.
+ * \param[in] bufsize sizeof(buf).
+ * \param[in] str A string that may contain any characters.
+ * \param[in] in_len Pass -1 to print until nul char, or >= 0 to force a length (also past nul chars).
* \return The output buffer (buf).
*/
char *osmo_escape_str_buf2(char *buf, size_t bufsize, const char *str, int in_len)
@@ -883,6 +895,20 @@
return sb.chars_needed;
}
+/*! Like osmo_escape_str_buf3(), but returns double-quotes around a string, or "NULL" for a NULL string.
+ * This allows passing any char* value and get its C representation as string.
+ * The function signature is suitable for OSMO_STRBUF_APPEND_NOLEN().
+ * \param[out] buf string buffer to write escaped characters to.
+ * \param[in] bufsize sizeof(buf).
+ * \param[in] str A string that may contain any characters.
+ * \param[in] in_len Pass -1 to print until nul char, or >= 0 to force a length.
+ * \return Number of characters that would be written if bufsize were large enough excluding '\0' (like snprintf()).
+ */
+int osmo_quote_str_buf3(char *buf, size_t bufsize, const char *str, int in_len)
+{
+ return _osmo_quote_str_buf(buf, bufsize, str, in_len, false);
+}
+
/*! Like osmo_escape_str_buf2(), but returns double-quotes around a string, or "NULL" for a NULL string.
* This allows passing any char* value and get its C representation as string.
* The function signature is suitable for OSMO_STRBUF_APPEND_NOLEN().
null--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27025
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I05d75a40599e3133da099a11e8babaaad0e9493a
Gerrit-Change-Number: 27025
Gerrit-PatchSet: 3
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27024 )
Change subject: log: socket.c: rather use the osmo_sockaddr_str _FMT
......................................................................
log: socket.c: rather use the osmo_sockaddr_str _FMT
The OSMO_SOCKADDR_STR_FMT() and _ARGS() macros properly place square
braces around IPv6 addresses, so that the port nr is clearly
distinguishable.
before: 1:2::3:4:5
after: [1:2::3:4]:5
When using a struct reference, the macro resolves to '(&sastr) ? .. : ..',
which the compiler complains about as "condition is always true". Shim
around that error with a pointer variable.
I considered using osmo_sockaddr_to_str_c() instead, but here in
socket.c we cannot assume that osmo_select_main_ctx() is being used and
hence can't just use OTC_SELECT for log string composition. The
struct osmo_sockaddr_str is a string representation in a local variable,
and hence doesn't need talloc for log strings.
I considered adding log_check_level() around the log string conversion,
but since all of these instances are on LOGL_ERROR, I didn't bother.
Related: SYS#5599
Change-Id: Idbe7582b2b7f14540919e911dad08af6d491f68f
---
M src/socket.c
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/socket.c b/src/socket.c
index 0ffa11d..2d19fdf 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -484,8 +484,8 @@
}
#define _SOCKADDR_TO_STR(dest, sockaddr) do { \
- if (osmo_sockaddr_str_from_sockaddr(&dest, &sockaddr->u.sas)) \
- osmo_strlcpy(dest.ip, "Invalid IP", 11); \
+ if (osmo_sockaddr_str_from_sockaddr(dest, &sockaddr->u.sas)) \
+ osmo_strlcpy((dest)->ip, "Invalid IP", 11); \
} while (0)
/*! Initialize a socket (including bind and/or connect)
@@ -520,7 +520,8 @@
unsigned int flags)
{
int sfd = -1, rc, on = 1;
- struct osmo_sockaddr_str sastr = {};
+ struct osmo_sockaddr_str _sastr = {};
+ struct osmo_sockaddr_str *sastr = &_sastr;
if ((flags & (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) == 0) {
LOGP(DLGLOBAL, LOGL_ERROR, "invalid: you have to specify either "
@@ -551,8 +552,8 @@
sfd = socket_helper_osa(local, type, proto, flags);
if (sfd < 0) {
_SOCKADDR_TO_STR(sastr, local);
- LOGP(DLGLOBAL, LOGL_ERROR, "no suitable local addr found for: %s:%u\n",
- sastr.ip, sastr.port);
+ LOGP(DLGLOBAL, LOGL_ERROR, "no suitable local addr found for: " OSMO_SOCKADDR_STR_FMT "\n",
+ OSMO_SOCKADDR_STR_FMT_ARGS(sastr));
return -ENODEV;
}
@@ -562,10 +563,8 @@
if (rc < 0) {
_SOCKADDR_TO_STR(sastr, local);
LOGP(DLGLOBAL, LOGL_ERROR,
- "cannot setsockopt socket:"
- " %s:%u: %s\n",
- sastr.ip, sastr.port,
- strerror(errno));
+ "cannot setsockopt socket: " OSMO_SOCKADDR_STR_FMT ": %s\n",
+ OSMO_SOCKADDR_STR_FMT_ARGS(sastr), strerror(errno));
close(sfd);
return rc;
}
@@ -573,8 +572,8 @@
if (bind(sfd, &local->u.sa, sizeof(struct osmo_sockaddr)) == -1) {
_SOCKADDR_TO_STR(sastr, local);
- LOGP(DLGLOBAL, LOGL_ERROR, "unable to bind socket: %s:%u: %s\n",
- sastr.ip, sastr.port, strerror(errno));
+ LOGP(DLGLOBAL, LOGL_ERROR, "unable to bind socket: " OSMO_SOCKADDR_STR_FMT ": %s\n",
+ OSMO_SOCKADDR_STR_FMT_ARGS(sastr), strerror(errno));
close(sfd);
return -1;
}
@@ -596,8 +595,8 @@
rc = connect(sfd, &remote->u.sa, sizeof(struct osmo_sockaddr));
if (rc != 0 && errno != EINPROGRESS) {
_SOCKADDR_TO_STR(sastr, remote);
- LOGP(DLGLOBAL, LOGL_ERROR, "unable to connect socket: %s:%u: %s\n",
- sastr.ip, sastr.port, strerror(errno));
+ LOGP(DLGLOBAL, LOGL_ERROR, "unable to connect socket: " OSMO_SOCKADDR_STR_FMT ": %s\n",
+ OSMO_SOCKADDR_STR_FMT_ARGS(sastr), strerror(errno));
close(sfd);
return rc;
}
null--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27024
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Idbe7582b2b7f14540919e911dad08af6d491f68f
Gerrit-Change-Number: 27024
Gerrit-PatchSet: 3
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Hello Jenkins Builder, laforge, dexter,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/27050
to look at the new patch set (#2).
Change subject: add osmo_sockaddr_from/to_octets()
......................................................................
add osmo_sockaddr_from/to_octets()
Shorthand for the INET/INET6 switch() to get/put the addr part, useful
for encoding and decoding message buffers.
Related: OS#5599
Change-Id: Ie9e33bfac525c59c30714663d2bfcc62ec9eeb81
---
M include/osmocom/core/socket.h
M src/socket.c
2 files changed, 62 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/50/27050/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27050
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie9e33bfac525c59c30714663d2bfcc62ec9eeb81
Gerrit-Change-Number: 27050
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: laforge, pespin.
neels has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27024 )
Change subject: log: socket.c: rather use the osmo_sockaddr_str _FMT
......................................................................
Patch Set 2:
(1 comment)
File src/socket.c:
https://gerrit.osmocom.org/c/libosmocore/+/27024/comment/82f1caca_fe5571ff
PS1, Line 488: osmo_strlcpy(dest->ip, "Invalid IP", 11); \
> yes, this is criticial to fix before merge.
i think not critical at all, since the use of this macro is limited to this c file, and before this patch the macro also had no such parens. but ok
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27024
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Idbe7582b2b7f14540919e911dad08af6d491f68f
Gerrit-Change-Number: 27024
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 07 Feb 2022 21:10:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: fixeria, dexter.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/27084 )
Change subject: gsm_network_T_defs: add T4, so it becomes configurable
......................................................................
Patch Set 3:
(1 comment)
Commit Message:
https://gerrit.osmocom.org/c/osmo-bsc/+/27084/comment/0620c922_76309421
PS3, Line 12: 5 seconds (see bssmap_reset_fsm_state_chg()).
Then, since it's now available, it probably makes sense to default to -1 since it should always find it, correct?
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/27084
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Id844dab1abffd6efbe7767585f127b29c0ee710c
Gerrit-Change-Number: 27084
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 07 Feb 2022 18:31:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: pespin, dexter.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/27084 )
Change subject: gsm_network_T_defs: add T4, so it becomes configurable
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS2:
> I don't see this newly added timer being user anywhere in the patch?
Answering in the commit message.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/27084
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Id844dab1abffd6efbe7767585f127b29c0ee710c
Gerrit-Change-Number: 27084
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 07 Feb 2022 18:23:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: fixeria, dexter.
Hello Jenkins Builder, laforge, dexter,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-bsc/+/27084
to look at the new patch set (#3).
Change subject: gsm_network_T_defs: add T4, so it becomes configurable
......................................................................
gsm_network_T_defs: add T4, so it becomes configurable
This timer is referenced in 'src/osmo-bsc/bssmap_reset.c', see
bssmap_reset_timeouts[]. However, it is not present in the
gsm_network_T_defs[], so we fall-back to hard-coded value of
5 seconds (see bssmap_reset_fsm_state_chg()).
Change-Id: Id844dab1abffd6efbe7767585f127b29c0ee710c
Related: SYS#5796
---
M src/osmo-bsc/net_init.c
M tests/timer.vty
2 files changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/84/27084/3
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/27084
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Id844dab1abffd6efbe7767585f127b29c0ee710c
Gerrit-Change-Number: 27084
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: fixeria, dexter.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/27084 )
Change subject: gsm_network_T_defs: add T4, so it becomes configurable
......................................................................
Patch Set 2:
(1 comment)
Patchset:
PS2:
I don't see this newly added timer being user anywhere in the patch?
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/27084
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Id844dab1abffd6efbe7767585f127b29c0ee710c
Gerrit-Change-Number: 27084
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 07 Feb 2022 17:56:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment