As pespin point out, the kernel coding style says:
Do not unnecessarily use braces where a single statement will do.
[...]
This does not apply if only one branch of a conditional statement is a single
statement; in the latter case use braces in both branches:
Change-Id: Ia23c4bd018db141ff0afe77fe25678a9b2a395f0
The DEC_ERR() macro has a check for a missing type, but when used on the uint
h.type variable, emits a warning about an always-true statement. Try to work
around that warning with a cast to (int).
Related: CID#214888 CID#214890 CID#214891
Change-Id: Ic5fa87d23a6f0ce872de9c1dcfe36023981f70de
Fixes following ASan runtime errors while running vty tests:
src/vty/command.c:3088:27: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
src/vty/command.c:3136:23: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
Change-Id: Ie11ff18d6fd9f6e1e91a51b6156fb6b0b7d3a9a8
NS_ALIVE can't create new NS-VC. Those NS-VC can be only created
by SNS or by vty.
Also fixes a crash because the TLV parser tried to retrieve NSEI TLV
which doesn't exist on NS_ALIVE PDUs.
Related: OS#4792
Change-Id: I16b9d7b2eb7544a83ce871d894887c4b30605b34
It's more clear which part of the address is returned.
In preparation to add a gprs_ns2_ip_vc_local.
Change-Id: I6110ff573362961c713a990da7ef3f3dbedf6c57
The sockaddr should not be changed.
free and create the bind/nsvc if the address should be changed.
Change-Id: I371ac2361b569e36722b02fc9cd82ec8da2fa9e3
Those messages were printed without any prefix because
LOGPC was used. LOGPC means continue a log line.
This must happened while copying this part of code over
from ns1 where has been a LOGP in this function.
Related: OS#4792
Change-Id: I2672ea0e34d19ea6172cb3458b8ff98d9700b2d0
The remote must be initialized because the osmo_sockaddr_cmp is using a memcmp() and might fail
on spare bytes in the struct. The same was already done for IPv6.
Related: OS#4792
Change-Id: Iefeef969bb2b5ae4d5db6a6358293ef9eeda858a
Using the 'const' qualifier allows the compiler to spot some
programming errors and further optimize the code.
Change-Id: I0df6a00ac1830bd64a10b9336b827e113fa772bb
When we use strtoll(), the return type is "long long" and we cannot
compare against LONG_MAX and LONG_MIN but must compare against LLONG_MAX
and LLONG_MIN.
Change-Id: I9c18ac237b4aacd56639d1faffa6841c8ad7b8da
Closes: OS#4787
Otherwise we get (valid!) format string warnings like these on 32bit
targets:
[ 372s] bssmap_le/bssmap_le_test.c: In function 'test_bssmap_le_enc_dec':
[ 372s] bssmap_le/bssmap_le_test.c:141:15: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
[ 372s] printf("[%ld] %s: ERROR: failed to encode pdu\n", (pdu - bssmap_le_test_pdus),
[ 372s] ^
Closes: OS#4786
Change-Id: Ib1c16b8adc5c8c0a2b418db51d12089f9b49a844
3GPP TS 48.018 is quite clear: The RA-ID must only be included
when a PTP-BVCI is being reset [and only if the sender is the BSS].
Before this patch, osmo-pcu is including the RA-ID in BVC-RESET
for BVCI=0.
Change-Id: Ie87820537d6d616da4fd4bbf73eab06e28fda5e1
BSSLAP: there are APDUs transferred in BSSMAP-LE Connection Oriented
Information messages on Lb between BSC and SMLC.
Add BSSLAP coding for these APDU messages:
- TA Layer3
- TA Request
- TA Response, possibly containing Location Estimate coded in GAD
- Reject
- Reset (for intra-BSS handover during TA Request)
- Abort (for inter-BSS handover)
Add encoding and decoding tests.
Change-Id: I6409c4bcac402dc7626a3afce9081c59cd715fe8
GAD, Universal Geographical Area Description:
- raw coding for all GAD elements.
- SI-units encoding and decoding for Ellipsoid point with uncertainty circle,
which I presume is the typical "at most N meters away from cell tower located
at X,Y", which corresponds to the TA positioning currently being implemented.
- other SI-units GAD element encodings are so far not implemented.
Add encoding and decoding tests.
In gsm/protocol/gsm_23_032.h are the raw coding structs as defined in 3GPP TS
23.032.
In gsm/gad.h are structs carrying consistent units based on meters and degrees,
for convenient / less error prone handling of GAD data, and for human readable
representations of the GAD data.
The separation of the two is desirable because OsmoBSC will receive GAD data
from OsmoSMLC on the Lb interface, and pass on this data to the MSC via the A
interface. It is better to pass the GAD data as-is without de/encoding.
Change-Id: I7a9dd805a91b1ebb6353bde0cd169218acbf223c
This will be useful to handle latitude and longitude numbers for GAD, which is
the location estimate representation used for LCS (Location Services).
The OsmoSMLC VTY user interface will provide floating-point strings like
"23.456" while GAD stores them as micro-degress 23456000. The osmo_gad_to_str*
will also convert latitude and longitude to floating-point string.
There was code review concerns against adding this API, upon which I tried to
use floating point string formats. But I encountered various problems with
accuracy and trailing zeros. For global positioning data (latitude and
longitude), even inaccuracy on the sixth significant decimal digit causes
noticeable positional shift. To achieve sufficient accuracy on the least
significant end, I need to use double instead of float. To remove trailing
zeros, the idea was to use '%.6g' format, but that can cause rounding. '%.6f'
on a double looks ok, but always includes trailing zeros. A test program shows:
%.6g of ((double)(int32_t)23230100)/1e6 = "23.2301" <-- good
%.6g of ((double)(int32_t)42419993)/1e6 = "42.42" <-- bad rounding
%.6g of ((double)(int32_t)23230199)/1e6 = "23.2302" <-- bad rounding
%.6f of ((double)(int32_t)23230100)/1e6 = "23.230100" <-- trailing zeros
%.6f of ((double)(int32_t)42419993)/1e6 = "42.419993" <-- good
%.6f of ((double)(int32_t)23230199)/1e6 = "23.230199" <-- good
It looks like when accepting that there will be trailing zeros, using double
with '%.6f' would work out, but in the end I am not certain enough that there
aren't more hidden rounding / precision glitches. Hence I decided to reinforce
the need to add this API: it is glitch free in sufficient precision for
latitude and longitude data, because it is based on integer arithmetic.
The need for this precision is particular to the (new) OsmoSMLC vty
configuration, where reading and writing back user config must not modify the
values the user entered. Considering to add these functions to osmo-smlc.git,
we might as well add them here to libosmocore utils, and also use them in
osmo_gad_to_str_*() functions.
Change-Id: Ib9aee749cd331712a4dcdadfb6a2dfa4c26da957
The bind pointer can't be NULL because gprs_ns2_ip_bind()
is either return 0 and bind is valid or != 0 and returning.
Found-by: Coverity
Fixes: CID#214854
Change-Id: I11d86c9cb36226701e51942f14d7a6412c3eff26
Some attributes like CMD_ATTR_LIB_COMMAND are not being printed
to the XML VTY reference (despite being set), so we should not
print empty "<attributes scope='global'></attributes>".
Change-Id: Ie7e53b080c10564bfef6f0e8ddeb470e46fad387
Related: SYS#4937
Here is an example:
OsmoAPP(config-foo)# list with-flags
... help
... list
... show running-config
... exit
..F lib-command foo (one|two|three)
ZB. lib-command bar [zoo]
.bf app-command foo-bar
z.. app-command zoo .TEXT
... app-command nope
A dot indicates that the associated attribute is not set.
Note that there is no strict relation between rows and index values
of the attributes. In the example above there could be one or more
hidden flag rows corresponding to attributes that are not assigned
to any of the commands within 'config-foo' node.
If neither of the commands belonging to the current node (where
'list' command is executed) has attributes, the output would
not contain empty dot-rows.
Global attributes (such as CMD_ATTR_IMMEDIATE) are not yet displayed
because we still have not agreed on what kind of symbols to assign
them. This will be implemented later.
Change-Id: I71cef3ec0fab44c7e11fc353b8bc42268a4ee8f0
Related: SYS#4937
Here is an example of listing all attributes:
OsmoBSC# show vty-attributes
Global attributes:
. This command is deprecated
. This command is hidden
. This command applies immediately
. This command applies on VTY node exit
Library specific attributes:
(no attributes)
Application specific attributes:
o This command applies on A-bis OML link (re)establishment
r This command applies on A-bis RSL link (re)establishment
or only a specific kind of attributes:
OsmoBSC# show vty-attributes application
Application specific attributes:
o This command applies on A-bis OML link (re)establishment
r This command applies on A-bis RSL link (re)establishment
Change-Id: I561114d7416e30cc06b7d49c0bc1217a76039c99
Related: SYS#4937