aboutsummaryrefslogtreecommitdiffstats
path: root/include
AgeCommit message (Collapse)AuthorFilesLines
2020-05-09stats: Support regular stats flushAlexander Chemeris1-1/+4
Reliable monitoring requires regular flush of all stat values, even if they have not changed. Otherwise (1) the monitoring app has to maintain state and (2) can go out of sync if it's restarted while the app is still running. Change-Id: I04f1e7bdf0d6f20e4f15571e94191de61c47ddad
2020-05-05sim: When decoding SW, take application specific SW into accountHarald Welte1-8/+7
So far we only looked at SW definitions of the card profile. However, if we have a currently selected application, we also must check that application for SW definitions. This breaks ABI and API all over the place, but as there are no known users beyond osmo-sim-test, this is acceptable. Change-Id: I3a1d60898529c173f73587e34c155660ba5f5fb1
2020-05-02gsm_29_118.h: Fix compilation with gcc-10Harald Welte1-1/+1
this causes problems when compiling user applications /usr/bin/ld: ../../src/libvlr/libvlr.a(vlr_lu_fsm.o):/usr/local/include/osmocom/gsm/protocol/gsm_29_118.h:184: multiple definition of `sgsap_ie_tlvdef'; msc_main.o:/usr/local/include/osmocom/gsm/protocol/gsm_29_118.h:184: first defined here Change-Id: Iaa1d36c7a9bb64aa84ee85fa3e40f6b3560fe693
2020-04-28gsm_04_06.h: Remove repeated egprs header struct definitionsPau Espin Pedrol1-153/+0
Each struct already contains different definition based on endianess, so there's no reason to re-define all of them again based on endianess. Probably at some point somebody run the script ./contrib/struct_endianess.py on those structures but forgot to remove the old way of supporting differnet endianess. Change-Id: Ibd002e52979950e09013767fa643b2a3c52dfea9
2020-04-20gsm0503_parity: Fix compilation with gcc-10Harald Welte1-10/+10
/usr/bin/ld: .libs/gsm0503_coding.o:/home/laforge/projects/git/libosmocore/src/coding/../../include/osmocom/coding/gsm0503_parity.h:16: multiple definition of `gsm0503_mcs_crc12'; .libs/gsm0503_parity.o:/home/laforge/projects/git/libosmocore/src/coding/../../include/osmocom/coding/gsm0503_parity.h:16: first defined here Change-Id: I15945bbf59c873e50154c40fed0ba3d6b4d7c399
2020-04-18select.c: Introduce support for signalfdHarald Welte1-0/+18
The signalfd(2) mechanism of Linux allows signals to be delivered and processed via normal file descriptor I/O. This avoids any of the usual problems about re-entrancy of signal processing, as signals can be processed from the osmocom select() loop abstraction just like any other event. Change-Id: If8d89dd1f6989e1cd9b9367fad954d65f91ada30
2020-04-18exec: Introduce osmo_system_nowait2() to allow specify a userHarald Welte1-0/+1
For a process running as root, it may be desirable to drop privileges down to a normal user before executing an external command. Let's add a new API function for that. Change-Id: If1431f930f72a8d6c1d102426874a11b7a2debd9
2020-04-17ports.h: Add 4268 for UECUPS VTYHarald Welte1-0/+1
Change-Id: I6c53654f06fac6b6b196be88178a918d38e91e46
2020-04-14dtx: add decoding for AMR-DTX framesPhilipp Maier3-0/+47
gsm0503_coding contains AMR decoder functions for HR and FR. Those can only decode AMR payload frames but not amr DTX frames. Lets add functionality to detect DTX frames. Also lets add decoding for SID_UPDATE frames as well as error checking for the SID frame recognition patterns. Related: OS#2978 Change-Id: I2bbdb39ea20461ca08b2e6f1a33532cb55cd5195
2020-03-21sim: re-structure how we support cards + applicationsHarald Welte1-0/+47
Before this change, a card application (USIM, ISIM, ...) didn't exist as a separate concept from a card profile. This meant, we had a manual combination of UICC card profile with USIM application, and another one of UICC card profile and ISIM application. But what if there's a combined USIM+ISIM? In reality, applications exist as separate objects, on top of an ETSI UICC. Lets therefore register all known applications to the osim library core, and add code to osmo-sim-test which dynamically detects all applications present on a given card (by reading EF.DIR). Change-Id: Ic4b4ac433a9976842b30a017fb0fc347d87201cd
2020-03-21sim: add osim_file_desc_find_aid()Harald Welte1-0/+3
Change-Id: I80468c8c4f4590c262019f42285e8d8fd3444f7f
2020-03-10socket: Add osmo_sock_mcast_iface_set() to bind multicast to deviceHarald Welte1-0/+1
Change-Id: Ib52d22710020b56965aefcef09bde8247ace4a9c Related: OS#2966
2020-03-09parity: add amr crc14 definitionPhilipp Maier1-0/+1
AMR not only specifies a 6 bit CRC for regular voice information. It also specifies a 14 bit CRC to protect the comfort noise updates contained in the SID_UPDATE frames. Change-Id: I5cfd8ca806aba8d42cb9787f69605cea7de6e900 Related: OS#2978
2020-03-08fixup depreciation warningHarald Welte1-2/+2
Change-Id: Id2d016939c3a6185cc3cfa8631da0c8d187a8c5a
2020-03-08gsmtap: Solve TCH / FACCH confusion once and for allHarald Welte2-3/+10
* What we used to call TCH/F and TCH/H in gsmtap are actually only FACCH/F and FACCH/H, i.e. the signaling part of Bm/Lm channels * Give them proper names with backwards compatibility #define * Split VOICE into VOICE_F and VOICE_H. If we don't differentiate this, a receiver is not able to determine the RSL channel ID of a frame without looking at external state/context. That in turn has been a design feature of GSMTAP Um format so far, and programs like osmo-bts-virtual rely on it. Change-Id: I952044a17334f35712e087dc41781805000aebc1 Related: OS#2557
2020-03-08Add CTRL port number for osmo-mgwHarald Welte1-0/+2
Related: OS#4441 Change-Id: I70ae237ea27972f6819fd217c3d5059dda009486
2020-03-05gsmtap.h: Add definitions for voice inside GSMTAPHarald Welte1-2/+26
We so far are only able to transmit signalling data inside GSMTAP, but not actual voice / user plane payload data. we cannot use the existing TCHF/TCHH sub-types, as those are already used [without further discrimination] for FACCH + SACCH Data on those channels. Instead, we will introduce a new GSMTAP_CHANNEL_VOICE sub-type, which then will have the first byte for a sub-sub-type specifying the payload format in detail. Change-Id: If223020933b083fe359a2e8ff5fab1ce64a363d8 Related: OS#2557
2020-02-15osmo-sim-test: Fall-back to classic SIMHarald Welte1-0/+1
If selection of ADF_USIM fails, let's fall-back to reading/dumping a classic TS 11.11 (51.011) SIM card. Change-Id: I5a986fc65de76c24c5af52ce7e8c699cf302fda9
2020-02-06tdef_vty: do not enforce enum 'node_type' in osmo_tdef_vty_groups_init()Vadim Yanitskiy1-1/+1
Some osmo-* applications may need to use their own VTY node as a parent for the timer configuration commands. Therefore it makes more sense to use 'unsigned int' instead of 'enum node_type'. Let's also clarify that osmo_tdef_vty_groups_init() accepts parent node for configuration commands only: 'parent_node' -> 'parent_cfg_node'. Change-Id: Ifb4c406c85d76a25fc53fc235484599aa87dc77c
2020-02-04value_string: Switch val from unsigned to intPau Espin Pedrol1-1/+1
There's nothing really preventing a user from user negative values. Otherwise if we keep it like this then g++ is not happy when passing eg. { -2, "foobar" } when initializing a value_string array. Change-Id: I754fa7e054cb89801ef82edc82199dcfbe59c6ab
2020-01-12usb: Add osmo_libusb_find_matching_dev_{path,serial}Harald Welte1-0/+8
Thise two helper functions allow the user application to find a unique match among the existing USB devices, using either a user- provided iSerial string, or a user-provided physical USB path. Change-Id: I8ff3fb3e1a77e10cb313473480ce5e7673749a93
2020-01-07l1sap: add measurement related struct membersPhilipp Maier1-0/+3
In order to dissolve info_meas_ind_param in ph_data_param and ph_tch_param we need to add the measurement related struct members to ph_data_param and ph_tch_param as well so that those indications can also carry measurement data. Change-Id: I2c34b02d329f9df190c5035c396403ca0a4f9c42 Related: OS#2977
2019-12-17Introduce helper functions for safe fork+exec of processesHarald Welte2-0/+29
In some situations, we want to execute an external shell command in a non-blocking way. Similar to 'system', but without waiting for the child to complete. We also want to close all file descriptors ahead of the exec() and filter + modify the environment. Change-Id: Ib24ac8a083db32e55402ce496a5eabd8749cc888 Related: OS#4332
2019-12-16usb: Import a variety of libusb utility functions from simtraceHarald Welte1-0/+75
Those functions were originally developed as part of simtrace; let's import them to libosmousb as they are truly generic. Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a Related: OS#4299
2019-12-16libosmocore libusb integrationHarald Welte2-0/+11
Osmocom applications typically use libosmocore select.[ch] event loop code as their main event dispatch mechanism. When they want to deal with libusb in a non-blocking/asynchronous way, they need to integrate libusb into that select(). The new libosmousb is doing exactly that: Providing a shared utility library for Osmocom programs that wish to use libusb. This is useful for example in simtrace2 host utilitie as well as osmo-e1d. Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3 Closes: OS#4299
2019-12-12debian, utils: switch to python 3Oliver Smith1-1/+1
Make build and external tests work with python3, so we can drop the python2 dependency. This should be merged shortly after osmo-python-tests was migrated to python3, and the jenkins build slaves were (automatically) updated to have the new osmo-python-tests installed. Related: OS#2819 Depends: osmo-python-tests I3ffc3519bf6c22536a49dad7a966188ddad351a7 Change-Id: I84ef43f700e125c7a65f92347f12844e07e65655
2019-12-11core/defs.h: introduce and use OSMO_DEPRECATED_OUTSIDEVadim Yanitskiy3-3/+7
The new OSMO_DEPRECATED_OUTSIDE macro is similar to the existing OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE, but allows to override the deprecation message. Let's use it to suspend deprecation warnings related to: - gsm48_decode_bcd_number(), - osmo_ecu_fr_conceal(), - osmo_ecu_fr_reset(), as they're intentionally used in scope of the library. Change-Id: I1b0eff1396776900c1286e41da3aee3ff78b326e
2019-12-09gsup: Introduce OSMO_GSUP_NUM_VECTORS_REQ_IEHarald Welte1-0/+1
This is a bit of a hack, as we want to maintain binary compatibility without breaking existing users of libosmocore. To do so, we use the 'num_auth_vectors' field in two ways now: * In the existing use case as part of SEND_AUTH_INFO_RESPONSE, it indicates the number of vectors stored in the 'auth_vectors' field * In the new use case as part of SEND_AUTH_INFO_REQUEST, it indicates the number of vectors actually requested by the MSC/SGSN/MME. Change-Id: Iaecc47280f8ce54f3e3a888c1cfc160735483d0f
2019-11-28add all missing OSMO_GSUP_TO_MSGT_*() macrosNeels Hofmeyr1-0/+3
OSMO_GSUP_TO_MSGT_RESULT() is needed by osmo-hlr for osmo_gsup_req. The others are added for completeness' sake. Related: I3a8dff3d4a1cbe10d6ab08257a0138d6b2a082d9 Change-Id: I6e38a3bb8447f8f212f8d6f5b10a5d0df59323d7
2019-11-27Introduce fields related to DTAP DLCIPau Espin Pedrol1-1/+28
Change-Id: Iec448af02d28e6c5c573e68a0b4a86067ec7e561
2019-11-24add osmo_escape_cstr and osmo_quote_cstrNeels Hofmeyr1-0/+5
Provide string escaping that - returns the required buffer size, so it can be used with OSMO_STRBUF_APPEND(). - uses C compatible string constant escaping sequences. This is intended as a replacement for all previous osmo_escape_str* and osmo_quote_str* API. It pains me that I didn't get them right the first nor the second time: - The buffer functions do not return the chars needed, which is required for allocating sufficient memory in the *_c versions of the functions. - Because of that, these functions are accurately usable for OSMO_STRBUF_APPEND(), producing truncated strings, for example when dumping a GSUP message. - They do not use the C equivalent string constant escaping: for some reason I thought "\15" would be valid, but it should be "\x0f". If I could, I would completely drop those mislead implementations ... but backwards compat prohibits that. A previous patch already provided internal static functions that accurately return the required buffer size. Enhance these to also support C compatible string escaping, and use them as implementation of the new functions: osmo_escape_cstr_buf() osmo_escape_cstr_c() osmo_quote_cstr_buf() osmo_quote_cstr_c() In the tests for these, also test C string equivalence. Naming: from API versions, it would be kind of logical to call them osmo_escape_str_buf3() and osmo_escape_str_c2(). Since these anyway return a different escaping, it makes sense to me to have distinct names instead. Quasi missing are variants of the non-C-compatible weird legacy escaping that return the required buffer size, but I refrain from adding those, because we have enough API cruft as it is. Just always use these new cstr variants. Change-Id: I3dfb892036e01000033dd8e7e4a6a0c32a3caa9b
2019-11-24vty_app_info.is_config_node: add OSMO_DEPRECATEDNeels Hofmeyr1-1/+4
Although this OSMO_DEPRECATED doesn't seem to generate a warning when compiling code that sets .is_config_node = foo, it seems a good idea to add the deprecation tag. It is deprecated since commit "vty: track parent nodes also for telnet sessions" I2b32b4fe20732728db6e9cdac7e484d96ab86dc5 Change-Id: I800507b27cb0d536c1a4c203d7f7b90eec05a69c
2019-11-24vty: track parent nodes also for telnet sessionsNeels Hofmeyr1-2/+7
Keep track of parent nodes and go back hierarchically, not only for .cfg file reading, but also for telnet VTY sessions. A long time ago cfg file parsing was made strictly hierarchical: node exits go back to parent nodes exactly as they were entered. However, live telnet VTY sessions still lacked this and depended on the go_parent_cb(). From this commit on, implementing a go_parent_cb() is completely optional. The go_parent_cb() no longer has the task to determine the correct parent node, neither for cfg files (as already the case before this patch) nor for telnet VTY sessions (added by this patch). Instead, a go_parent_cb() implementation can merely take actions it requires on node exits, for example applying some config when leaving a specific node. The node value that is returned by the go_parent_cb() and the vty->node and vty->index values that might be set are completely ignored; instead the implicit parent node tracking determines the parent and node object. As a side effect, the is_config_node() callback is no longer needed, since the VTY now always implicitly knows when to exit back to the CONFIG_NODE. For example, osmo_ss7_is_config_node() could now be dropped, and the osmo_ss7_vty_go_parent() could be shortened by five switch cases, does no longer need to set vty->node nor vty->index and could thus be shortened to: int osmo_ss7_vty_go_parent(struct vty *vty) { struct osmo_ss7_asp *asp; struct osmo_xua_server *oxs; switch (vty->node) { case L_CS7_ASP_NODE: asp = vty->index; /* If no local addr was set */ if (!asp->cfg.local.host_cnt) { asp->cfg.local.host[0] = NULL; asp->cfg.local.host_cnt = 1; } osmo_ss7_asp_restart(asp); break; case L_CS7_XUA_NODE: oxs = vty->index; /* If no local addr was set, or erased after _create(): */ if (!oxs->cfg.local.host_cnt) osmo_ss7_xua_server_set_local_host(oxs, NULL); if (osmo_ss7_xua_server_bind(oxs) < 0) vty_out(vty, "%% Unable to bind xUA server to IP(s)%s", VTY_NEWLINE); break; } return 0; } Before parent tracking, every program was required to write a go_parent_cb() which has to return every node's parent node, basically a switch() statement that manually traces the way back out of child nodes. If the go_parent_cb() has errors, we may wildly jump around the node tree: a common error is to jump right out to the top config node with one exit, even though we were N levels deep. This kind of error has been eliminated for cfg files long ago, but still exists for telnet VTY sessions, which this patch fixes. This came up when I was adding multi-level config nodes to osmo-hlr to support Distributed GSM / remote MS lookup: the config file worked fine, while vty node tests failed to exit to the correct nodes. Change-Id: I2b32b4fe20732728db6e9cdac7e484d96ab86dc5
2019-11-24osmo_sockaddr_str: deprecate osmo_sockaddr_str_*_32n()Neels Hofmeyr1-2/+8
Follow up for patch I3cf150cc0cc06dd36039fbde091bc71b01697322 osmo_sockaddr_str_{from,to}_32n actually use host byte order. Deprecate these and introduce a more accurately named version ending in h. Change-Id: Ic7fc279bf3c741811cfc002538e28e8f8560e338
2019-11-24utils: add osmo_strnchr()Neels Hofmeyr1-0/+1
When finding a char in a string, I want to be able to limit the search area by size, not only by nul terminator. Change-Id: I48f8ace9f51f8a06796648883afcabe3b4e8b537
2019-11-24msgb_put: more elaborate logging of head/tailroom failureNeels Hofmeyr1-3/+12
Change-Id: I55b68098e1037c74ebe5faa86e34bd4494f5b726
2019-11-24fsm.h: add missing include of logging.hNeels Hofmeyr1-0/+1
Change-Id: I783bf0eb40b674fb6a77f7673563fdf156975f5a
2019-11-24GSUP: rename E_ROUTING_ERROR to ROUTING_ERRORNeels Hofmeyr1-1/+3
GSUP routing was introduced when adding the E interface. Hence that was the first realm where routing errors could occur. I did notice back then that this message type was special: it does not convey a response to a particular message kind -- it does not make sense, for example, to return an Updating Location Error cause, and do that for all conceivable message types. Instead, this tells the sender that a deeper error exists, i.e. that the desired peer is completely gone and unreachable. I did not foresee though that for D-GSM, there would also be arbitrary GSUP proxy routing, and that this error is not limited to E interface semantics. From today's point of view, adding the "_E_" in the name was a mistake. Remove that "_E_" to yield OSMO_GSUP_MSGT_ROUTING_ERROR (with unchanged message type discriminator), but provide a #define linking the old name OSMO_GSUP_MSGT_E_ROUTING_ERROR to the new one. The only visible change should be that osmo_gsup_message_type_names[] now returns the new name without "_E_". I am not aware of any regression test fallout from that. Change-Id: Ic8e8bd11522d6c51ac7aaf946516cbce26bc6e1e
2019-11-23utils.h: add OSMO_NAME_C_IMPL() macroNeels Hofmeyr1-0/+56
Provide a common implementation for foo_name_c() functions that base on foo_name_buf() functions. char *foo_name_c(void *ctx, example_t arg) { OSMO_NAME_C_IMPL(ctx, 64, "ERROR", foo_name_buf, arg) } Rationale: the most efficient way of composing strings that have optional parts or require loops for composition is by writing to a ready char[], and this in turn is easiest done by using OSMO_STRBUF_* API. Using such a basic name string implementation which typically returns a length, I often want a more convenient version that returns a char*, which can just be inlined in a "%s" string format -- crucially: skipping string composition when inlined in a LOGP(). This common implementation allows saving code dup, only the function signature is needed. Why not include the function signature in the macro? The two sets of varargs (1: signature args, 2: function call args) are hard to do. Also, having an explicit signature is good for readability and code grepping / ctags. Upcoming uses: in libosmocore in the mslookup (D-GSM) implementation (osmo_mslookup_result_name_c()), and in osmo_msc's codec negotiation implementation (sdp_audio_codecs_name_c(), sdp_msg_name_c(), ...). I54b6c0810f181259da307078977d9ef3d90458c9 (libosmocore) If3ce23cd5bab15e2ab4c52ef3e4c75979dffe931 (osmo-msc) Change-Id: Ida5ba8d9640ea641aafef0236800f6d489d3d322
2019-11-23cosmetic: logging.h: fix comment s/levels/subsystemsNeels Hofmeyr1-1/+1
Change-Id: I242a4a44649bc4dac055985ba8fd63b2f784ee6d
2019-11-23logging.h: define ansi color constantsNeels Hofmeyr1-0/+19
It's hard to figure out what color logging categories have with those ANSI color code strings. Instead, define these OSMO_LOGCOLOR_* constants. Naming: commonly, the logging.h header has the "LOG" prefix in the name, but it seems saner to include the OSMO_ prefix: it seems too likely that some libosmocore user somewhere already has defined "LOGCOLOR_RED" somewhere. Change-Id: I03b6b1f73ae7ee61d37ff921e071a3d0881d3e9a
2019-11-21add osmo_sockaddr_str_cmp()Neels Hofmeyr2-0/+3
Currently planned user: for Distributed GSM in osmo-hlr: setting per-MSC service addresses in VTY: replace/remove existing entries. osmo_sockaddr_str_cmp() is useful to catch identical resulting IP addresses, regardless of differing strings (e.g. '0::' and '::' are equal but differ in strings). Change-Id: I0dbc1cf707098dcda75f8e07c1b936951f9f9501
2019-11-11fix OSMO_SOCKADDR_STR_FMT for IPv6Neels Hofmeyr1-2/+6
The format prints IP:port separated by a colon, which of course is confusing when the IPv6 address itself contains mostly colons. The new format adds square braces. cafe:face::1:42 -> [cafe:face::1]:42 The IPv4 format remains unchanged: 1.2.3.4:42 Change-Id: I161f8427729ae31be0eac719b7a4a9290715e37f
2019-11-09GPRS/BSSGP: introduce bssgp_bvc_ctx_free()Vadim Yanitskiy1-0/+2
So far we had a function to allocate a new bssgp_bvc_ctx, but not the opposite one. Let's finally introduce it, so it will be used at least in OsmoPCU. Please note that the new symbol has 'bssgp_' prefix, not 'btsctx_'. Change-Id: Ia78979379dbdccd6e4628c16f00d0c06d9212172
2019-11-07select: Make file descriptor lists per-threadHarald Welte1-0/+1
In a multi-threaded environemnt, it's likely that each thread will have its own, distinct set of file descriptors that it wants to watch. Hence, let's make the osmo_fd_* functions configure not one global list of file descriptors, but a thread-local list of file descriptors. Change-Id: I5082ed3e500ad1a7516e1785bc57e008da2fac9a
2019-11-04gsm: gsm_04_08.h: Allow accessing classmark2 as struct instead of uint32_tPau Espin Pedrol1-5/+28
New fields are put inside a union to keep backward compatibility with potential older users of the struct. Change-Id: I235635800c0de47b1e2b9ec9c7191418f6003554
2019-11-04gsm: gsm_utils: Fix return type of API ms_class_gmsk_dbm() and add unit testsPau Espin Pedrol1-2/+1
Only known user of API is in osmocom-bb and it compiles fine after the change. Related: OS#4244 Change-Id: Ia10345008b3aca50b30482ef3b852b03eca71995
2019-11-04gsm: Fix compilation error under some compilersPau Espin Pedrol2-2/+2
Some compilers don't like declaration of enums in header files like we do sometimes for structs: enum gsm_band; void foobar(enum gsm_band band); triggers: error: use of enum 'gsm_band' without previous declaration Fixes: b99f4ca2d8517d99cdf8aa183dbfda7b233bb781 Related: OS#4244 Change-Id: I6c2102c763f565bbe3c8dd7e5b4e04c4a45fff67
2019-11-03gsm_04_08.h: Introduce API osmo_gsm48_rfpowercap2powerclass()Pau Espin Pedrol1-1/+2
Related: OS#4244 Change-Id: I32e9cc1c2397b44f0d48db2acdf782a821365b63
2019-11-01add osmo_sockaddr_str_is_nonzero()Neels Hofmeyr1-0/+1
Often, an IP address of 0.0.0.0 is considered an unset value (for clients requiring a server address; not for listening on "any"). osmo_sockaddr_str_is_set() does return false when the port is 0, but there is no simple way to tell whether the IP address is actually set to a server address. Add osmo_sockaddr_str_is_nonzero() to return false if: - the port is zero, or - the IP address is zero (0.0.0.0 or ::0), or - the IP address cannot be parsed. A practical use example: osmo-msc so far accepts an RTP IP address of 0.0.0.0 as valid. I noticed when trying to trigger error handling from a ttcn3 test. osmo-msc can use this function to reject invalid addresses from MGCP messages. Related: I53ddb19a70fda3deb906464e1b89c12d9b4c7cbd (osmo-msc) Change-Id: I73cbcab90cffcdc9a5f8d5281c57c1f87b2c3550