aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2018-12-26wipneels/rat_typesNeels Hofmeyr6-7/+59
Change-Id: If4df92abd5f98c388a51f085a24bbc1928f721ca
2018-12-21add LOGPFSMSL(), LOGPFSMSLSRC()neels/logpfsmNeels Hofmeyr1-6/+30
Using an FSM instace's logging context is very useful. Sometimes it makes sense to log something on a different logging category than the FSM definition's default category. For example, an MSC conn has aspects concerning MM, CC, RR, MGCP, ..., and currently all of those log on DMM. This came up in I358cfbaf0f44f25148e8b9bafcb9257b1952b35a, where I want to log an MGCP event using a ran_conn context, and used the conn->fi->id. That of course omits context like the current conn FSM state... I remember at least one other place where I recently added logging using some fi->id as context, so it might turn out useful in various places. Change-Id: I11b182a03f5ecb6df7cd8f260757d3626c8e945d
2018-12-21LOGPFSM*: guard against fi == NULLNeels Hofmeyr1-4/+4
The LOGPFSM macros are in such wide use that they should guard against a NULL fi pointer. In case of NULL, default to subsys = DLGLOBAL, loglevel = LOGL_ERROR and state = "fi=NULL". Change-Id: I9eaf8b7e2cf1e450ae626cb2fc928862008f6233
2018-12-21add API doc for LOGPFSM* macrosNeels Hofmeyr1-0/+31
Change-Id: I3bf6500889aa58195f50a726dec0876c0c2baec3
2018-12-21define LOGPFSM fmt only once, in LOGPFSMLSRCNeels Hofmeyr1-7/+4
Instead of duplicating the fmt and args in LOGPFSML and LOGPFSMLSRC, rather make LOGPFSML invoke LOGPFSMLSRC with __FILE__ and __LINE__. This is a cosmetic preparation for more tweaks coming up. Change-Id: I2f23c57ebfdb5355919c06ac5ded7732e3b17a97
2018-12-21tests/gsm0808: use new msgb comparison APIVadim Yanitskiy1-12/+4
Since I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5, we have some helpers to compare certain msgb layer to a given buffer. Let's change 'VERIFY' macro to use msgb_eq_l3_data_print(). Change-Id: Ib6be778236eff8f2153f3113f9379ecfbec9052b
2018-12-21GSUP: add CHECK-IMEI messageOliver Smith5-0/+93
Implement necessary messages for Procedure Check_IMEI_VLR (TS 23.018 Chapter 7.1.2.9). This lets the VLR ask the EIR to check if an IMEI is valid. In the Osmocom stack, we don't have an EIR and this request will be handled by the HLR. We will be able to store the IMEI in the HLR as side-effect (OS#2541). This is roughly based on TS 29.002 8.7.1 MAP_CHECK_IMEI service, but only implements the bare minimum required IEs (imei and imei_result). Related: OS#3733 Change-Id: I085819df0ea7f3bfeb0cabebb5fd1942a23c6155
2018-12-21GSUP: add end marker to enum osmo_gsup_ieiOliver Smith2-5/+3
Simplify gsup_test.c by defining an end marker in gsup.h. No need to manually update the last element every time anymore. The C standard guarantees, that the end marker will have the last value plus one: "Each subsequent enumerator with no = defines its enumeration constant as the value of the constant expression obtained by adding 1 to the value of the previous enumeration constant." (From C99: 6.7.2.2 Enumeration specifiers) Change-Id: I2aab7245e209f0ebd2f33a83d4d181dd3339cb17
2018-12-21GSUP: fix missing osmo_gsup_get_err_msg_type()sOliver Smith1-0/+8
Add missing mappings of request to error message types in osmo_gsup_get_error_msg_type(): * PROC_SS_REQUEST * MO_FORWARD_SM_REQUEST * MT_FORWARD_SM_REQUEST * READY_FOR_SM_REQUEST Change-Id: I801a0d6ffe09cfc75b77ab602bd25b3dc40f19c0
2018-12-20TLV: add convenience function for 1-byte valuesMax1-0/+16
Similar to existing 16 and 32 bit value helpers but simpler because we don't have to worry about alingment and endianness. Change-Id: Ic0a148bd04b8860e321f509fdcd913f688c8e920
2018-12-20TLV: fix doc copy-paste errorMax1-1/+1
Change-Id: I8aa79cab7505585de00ee2aaae125462108906e8
2018-12-20Use define for key buffersMax3-6/+9
Add corresponding spec. references and comments where appropriate. Change-Id: If5e2aad86eaecd8eada667b3488ba415d81c6312
2018-12-19rename CELL_IDENT_LAI_AND_LAC to CELL_IDENT_LAIStefan Sperling1-2/+3
The name "LAI AND LAC" makes no sense because a LAC is part of a LAI. Keep the old name available for API backwards compatibility. Change-Id: I2749cf75b7b45de0cd43cf4c696a6b6984f5a065 Related: OS#3124
2018-12-19add/clean big-endian packed structs (struct_endianess.py)Neels Hofmeyr9-45/+647
This is 1:1 the result of doing cd libosmocore ./contrib/struct_endianess.py git commit -a Running struct_endianess.py again should result in no changes. That means we could include such a check in the gerrit verification job now. Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2
2018-12-19LCLC: fix doc to match type signatureMax1-2/+1
Change-Id: I8f7b3dca080ef0e632d47a907154f8404b0ec523
2018-12-19Fix typos in SS opcode namesMax1-2/+2
Change-Id: I8fa1961c85b3fd714bc8df56fe4af6be4060c208
2018-12-19add to osmo_sock_get_name*() APINeels Hofmeyr2-17/+50
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-18GSUP/SMS: introduce READY-FOR-SM messageVadim Yanitskiy6-1/+46
According to 3GPP TS 29.002, section 12.4, MAP-READY-FOR-SM is used between the MSC and VLR as well as between the VLR and the HLR to indicate that a subscriber has memory available for SMS. This change replicates this service in GSUP as READY_FOR_SM_*. The only mandatory IE for this service (excluding Invoke ID) is 'Alert Reason' that is replicated by OSMO_GSUP_SM_ALERT_RSN_IE. Change-Id: Ic37f3b2114b8095cfce22977e67133b9103942e3 Related Change-Id: (docs) I549b6c8840a1e86caac09e77fb8bc5042d939e62 Related Change-Id: (TTCN) If2256607527ecfcb10285583332fb8b0515d7c78 Related: OS#3587
2018-12-18GSUP/SMS: introduce MO-/MT-FORWARD-SM messagesVadim Yanitskiy11-15/+527
According to 3GPP TS 29.002, there are two services: - MAP-MO-FORWARD-SHORT-MESSAGE (see 12.2), - MAP-MT-FORWARD-SHORT-MESSAGE (see 12.9), which are used to forward MO/MT short messages. This change replicates both services as GSUP messages: - OSMO_GSUP_MSGT_MO_FORWARD_SM_*, - OSMO_GSUP_MSGT_MT_FORWARD_SM_*. Please note, that only the 'must-have' IEs are introduced by this change, in particular the following: - OSMO_GSUP_SM_RP_MR_IE (see note below), - OSMO_GSUP_SM_RP_DA_IE (see 7.6.8.1), - OSMO_GSUP_SM_RP_OA_IE (see 7.6.8.2), - OSMO_GSUP_SM_RP_UI_IE (see 7.6.8.4), - OSMO_GSUP_SM_RP_MMS_IE (see 7.6.8.7), - OSMO_GSUP_SM_RP_CAUSE_IE (see GSM TS 04.11, 8.2.5.4), where both SM_RP_DA and SM_RP_OA IEs basically contain a single nested TV of the following format: - T: identity type (see 'osmo_gsup_sms_sm_rp_oda_t'), - V: encoded identity itself (optional). According to GSM TS 04.11, every single message on the SM-RL has an unique message reference (see 8.2.3), that is used to link an RP-ACK or RP-ERROR message to the associated (preceding) RP-DATA or RP-SMMA message transfer attempt. In case of TCAP/MAP, this message reference is being mapped to the Invoke ID. But since GSUP has no 'Invoke ID' IE, and it is not required for other applications (other than SMS), this change introduces a special 'SM_RP_MR' IE that doesn't exist in MAP. Change-Id: Ibe325c64ae2d6c626b232533bb4cbc65fc2b5d71 Related Change-Id: (docs) Ie0150756c33c1352bc4eb49421824542c711175c Related Change-Id: (TTCN) Ibf49474a81235096c032ea21f217170f523bd94e Related: OS#3587
2018-12-14LCLS: add gsm0808_create_ass2()Max5-6/+133
It allows setting additional assignment parameters explicitly. Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba Related: OS#2487
2018-12-14LCLS, TS 48.008: add GCR IE encoding/decodingMax5-0/+123
* add functions to encode Global Call. Ref. from TS 29.205 as 3GPP TS 48.008 ยง3.2.2.115 information element * add corresponding tests Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
2018-12-14LCLS, TS 29.205: add GCR routinesMax10-4/+263
Add functions to encode and decode Global Call Reference as per 3GPP TS 29.205 Table B 2.1.9.1 add corresponding tests. Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf Related: OS#2487
2018-12-14gsm0480: fix copy-pasted note for gsm0480_gen_return_error()Vadim Yanitskiy1-3/+0
InvokeID is mandatory for ReturnError component. Change-Id: Ie1c7116d368c2029b9f524cb74ffa316e282ec83
2018-12-13stats.h: Fix build on MacOSPau Espin Pedrol1-2/+2
Otherwise struct osmo_stats_config is not defined and compiler fails. Related: OS#3722 Change-Id: I037c3ca141ecee2d457e0a881a56e32ee24cec4d
2018-12-12msgb: add test helpersMax2-0/+231
It's often handy to compare certain msgb layer to a given array and print the position where they differ. Add simple pretty-printer and corresponding L* wrappers. Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
2018-12-11fix api doc for osmo_bcd2str()Neels Hofmeyr1-1/+1
Change-Id: I504ea849fc9daeb34a1b3c5343371161deba743e
2018-12-10gsm48_mi_to_string(): do not read from zero length input bufferNeels Hofmeyr1-1/+1
Change-Id: I12cada7c2c5187146ca5a33d1ebfefb4cad65632
2018-12-10gsm48_mi_to_string(): guard against zero length output bufferNeels Hofmeyr2-13/+13
All successful cases already return from the switch(), so simply handle all errors below it by returning an empty string (if there is enough string buffer). Change-Id: I709ac3b9efb7b4258d8660715b10312e11b9b571
2018-12-10gsm48_generate_mid(): mask out ODD flag from mi_typeNeels Hofmeyr3-8/+6
For MI encoding, see 3GPP TS 24.008, 10.5.1.4 Mobile Identity. The 'odd' flag indicates whether the last BCD nibble is used. Of course that flag should be made sure to reflect the actual length. Change-Id: Id6e695ebf9f86b295eaa7e2c6228989256f37e68
2018-12-10gsm48_mi_to_string: use osmo_bcd2str(), fix some corner casesNeels Hofmeyr3-29/+24
By using osmo_bcd2str(), ensure that the resulting string is always nul terminated, and always return strlen()+1 whether truncated or not. Still keep up the previous return value style, even if that isn't consistent at all. The difference between IMSI/IMEI and TMSI return values remains and is not part of this patch. Change-Id: I1b51b72a721e1cc9d69796b804ebda741ff0f36b
2018-12-10add osmo_bcd2str()Neels Hofmeyr4-0/+186
Add a standalone bcd-to-string conversion function with generic parameters. Add a regression test in utils_test.c. So far there is no single universal implementation that converts a BCD to a string. I could only find gsm48_mi_to_string(), which also interprets surrounding bytes, MI type and TMSI as non-BCD value. The idea is to use this function from gsm48_mi_to_string() and similar implementations in subsequent commits. Root cause: in osmo-msc, I want to have an alternative MI-to-string function for composing an FSM name, which needs the BCD part of gsm48_mi_to_string() but not the TMSI part. Change-Id: I86b09d37ceef33331c1a56046a5443127d6c6be0
2018-12-10Constify llist_count() parameterMax1-1/+1
Counting list entires should not alter the list content: let's make this obvious from type signature. Change-Id: I414e67a3de733fab407161b3264d3b89070ba537
2018-12-10api doc: gsm48_mi_to_string(): warn of return value implementationNeels Hofmeyr1-1/+4
Change-Id: If5e7abd15dddf39cdfad8071f4cd5ca8244eabe0
2018-12-10gsm0408_test: test encoding and decoding Mobile IdentityNeels Hofmeyr2-0/+358
One would think by now we would solidly encode and decode Mobile Identities. Well, guess again. - rc is sometimes the amount of bytes written, sometimes actual strlen(). - on string truncation, rc is sometimes strlen() (assuming nul terminated), and sometimes snprintf()-style would-be strlen(). - returned string, when truncated by not enough buffer size, is sometimes nul terminated, sometimes not. - gsm48_mi_to_string() happily reads a byte from zero-length input buffer. - gsm48_mi_to_string() happily writes to zero length output buffer. - gsm48_mi_to_string() returns nonempty string for empty input. - encoding a MI type that still has the GSM_MI_ODD flag set results in encoding an even-length MI as odd-length (hence appending a stray 'F'). I am going to tweak the implementation of gsm48 mobile identity encoding / decoding, so first pinpoint the current behavior in a unit test, and show how perforated even such a seemingly trivial API can be. Change-Id: Iaae3af87f82f1a8f2e6273984c011b2813038cf7
2018-12-10timer: Fix clockid_t undefined on MacOS < 10.12Pau Espin Pedrol2-0/+5
Related: OS#3722 Change-Id: If466a64bd44dcb8ae8a9b7f82bc9c9435ba3e640
2018-12-08gsm0808: add encoder for cause codes and use itPhilipp Maier6-19/+75
At the moment the all gsm0808 cause codes are encoded directly using the tlv API directly to put a one byte TLV field. This works ok for most situations where the cause code consists of a single byte. However, gsm0808 specifies a two byte cause code model where cause codes may be extended up to two bytes. Instead of implementing the encoding over and over and again, let's rather have an encoder function we can call. - Add an encoder function that can generate single byte and extended cause codeds and makes the length decision automatically. - Use only this function to append cause codes Change-Id: I71d58fad89502a43532f60717ca022c15c73f8bb
2018-12-07gsm29118: add generator functions for GSM29118 messagesPhilipp Maier5-0/+363
We already have some GSM29118 related definitions and functions in libosmocore. Lets also add some functions to generate GSM29118 messages (similar to those we have for GSM0808). Change-Id: Ic87f8a771b87b52215d0a7451b67794557b80b8a Related: OS#3615
2018-12-07gsm_29_118.h: Add constant for default portPhilipp Maier1-0/+3
The specification defines a default port where the SGs interface should be reachable. Lets add a define-constant for it. Change-Id: Ia4b9f547dd980411d15b2691b7f535fa0463f0f1 Related: OS#3615
2018-12-07cosmetic apn: correct whitespace errorPhilipp Maier2-2/+2
there is a whitespace between the * and osmo_apn_to_str(). Lets remove this. Change-Id: I094e6eb08eacf2d6459c47a7370837601aa92925
2018-12-07Add osmo_sockaddr_in_to_str_and_uint()Max2-5/+23
It's similar to osmo_sockaddr_to_str_and_uint() but does not require odd typecasting for AF_INET case. Make osmo_sockaddr_to_str_and_uint() into wrapper around new function and make sure to check for address family before typecasting. Also use proper return type. Change-Id: Ie384483124d407a960ab6732e6a7fd90554389d2
2018-12-06Allow log_init() with NULL log_infoMax1-10/+15
Since we have library-internal categories we don't have to force application to supply its own categories. This is especially useful for testing code inside libosmocore which only use internal categories anyway. Change-Id: I42159780b57684bff225789f036f28a4b25fc7b8
2018-12-05gsm_29_118: add missing extern for struct value_string decl.Philipp Maier1-8/+8
The value string arrays in the header file (gsm_29_118.h) are not declared as extern. Lets add it now. Change-Id: Ib6c4cbea649f790fa4db1ed2fe2b7e76a60291b4 Related: OS#3615
2018-12-04LCLS: update osmo_lcls structMax1-4/+4
* use pointer to proper struct type for GCR * update comments to be useful for doxygen Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
2018-12-04Add msgb_tl_put() helperMax1-0/+12
When adding complex TLV structures where length of V is not known in advance it's handy to be able to simply add Tag and save the pointer to the Length field so it can be updated once entire Value is added and its length is known. Change-Id: I8dc1e4880352833a0a49c1dd0d7cb4148ac43aff
2018-12-03ctrl: use #define for TRAP idMax2-1/+2
We always use id = 0 when sending TRAP messages. Let's make this more obvious by introducing appropriate define. Change-Id: I33d7d4c6a1885a75a85d6f2f017430e0860b4126
2018-12-03Update msgb Lx helpersMax1-1/+17
* add missing L1 and L4 hexdump * add msgb_l4() for consistency and convert msgb_sms() into simple alias Those will be used in follow-up patches for msgb debug/test helpers. Change-Id: I8d6dd1b1ff3aa98a452711c692ca7dee0449203b
2018-12-03gsm0808: add message generator for BSSMAP HANDOVER PERFORMEDPhilipp Maier3-0/+71
We currently have no generator function that can generate BSSMAP HANDOVER PERFORMED messages. Lets add function for this. Change-Id: I825106858bd89afc9837811b8fed2e8accc82441 Related: OS#3645
2018-12-03configure.ac: check clock_gettime for glib < 2.17Alexander Couzens2-1/+5
glib < 2.17 doesn't support clock_gettime directly, it is available via librt. Change-Id: Ice853d85ffe859b1d4df48b91b050c24d85c861b
2018-11-30Move BSSMAP_MSG_* defines to header fileMax2-3/+3
This will be reused be several tests related to TS 48.008 and TS 29.205 in follow-up commits. Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
2018-11-26ctrl: print textual error on IPA parsing failureMax1-1/+1
Change-Id: I49bb613b416d549f554fd9d23cd37b63954324db