summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* contrib: add script to find unterminated value_string arraysNeels Hofmeyr2017-03-161-0/+33
| | | | | | | | | | | | | | | Unterminated value_string arrays are dangerous since get_value_string() and get_string_value() need to know where the struct ends. If the terminator is missing, they might run through and return arbitrary memory locations. Employ some regexes to find such unterminated value string arrays and return nonzero if any are found. This can be used in our jenkins build jobs to avoid committing unterminated value_string arrays. In fact I've found one in current libosmocore: gsm0808_bssap_names in gsm/gsm0808.c, fixed in a separate patch. Change-Id: I2bc93ab4781487e7685cfb63091a489cd126b1a8
* auth_milenage: fix check against too large indNeels Hofmeyr2017-03-161-1/+1
| | | | | | | To ensure that the IND index appended to SEQ does not affect the SEQ, the check should read '>= seq_1', not '>'. Change-Id: Ib1251159eee02aa07fae1b429ffec2e4604bf6a8
* fix OSMO_VALUE_STRING macro: don't use OSMO_STRINGIFY()Neels Hofmeyr2017-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | To be able to use OSMO_VALUE_STRING() on a #defined constant, don't use OSMO_STRINGIFY(): the second indirection resolves the #define to its value, so for example OSMO_VALUE_STRING(GSM48_PDISC_MM) would resolve to { 0x05, "0x05" } When using '#x' directly, this becomes the desired { 0x05, "GSM48_PDISC_MM" } With enum values as we've used until now, this problem does not appear, because enum values are not resolved by the preprocessor. Keep OSMO_STRINGIFY() because it is used directly in openbsc (composing FSM state names). Change-Id: I91ecfcef61be8cf73d59ea821cc4fd9d2ad5c9c7
* ctrl_type_vals: explicitly terminateNeels Hofmeyr2017-03-153-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't use CTRL_TYPE_UNKNOWN as value_string[] terminator, use an explicit, more obvious { 0, NULL } termination. Set an explicit string for CTRL_TYPE_UNKNOWN. No other value_string[]s to date have such a "hidden" terminator. BTW, a { 0, "string" } item is not a terminator, only { 0, NULL } is, so we can set a string for CTRL_TYPE_UNKNOWN == 0. Also, having a string value for CTRL_TYPE_UNKNOWN is not harmful because all code paths explicitly check for the CTRL_TYPE_*s that are valid. Adjust the test expectation. From the ctrl_type_vals enum, remove the = 0, because it is implicitly 0 anyway. One motivation to press this fixup: I am trying to add a script that checks whether all value_string[]s are terminated to our jenkins jobs, and to find that this one is terminated, it would need to interpret the CTRL_TYPE_UNKNOWN constant, which would make things far more complex. At this point, all of the value_string[]s have an explicit termination, and I would like to enforce this from now on -- for readable code and to not spend more time on the validator. The patch adding ctrl_type_vals (Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28) was accepted by another reviewer before I could reconfirm my -1, so this is a fixup to enable the termination checking script patches. Related: I2bc93ab4781487e7685cfb63091a489cd126b1a8 (adds script to libosmocore) I7fe3678b524d602fc6aa14bc0ed06308df809a3e (uses in jenkins.sh) Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28 (adds ctrl_type_vals) Change-Id: Ia99f37464c7b36b587da2cc78f52c82725f02cbc
* milenage_test: cosmetic: verify AUTS in commentsNeels Hofmeyr2017-03-151-0/+56
| | | | | | | | In a comment and by code #if'd away, illustrate that the AUTS used in the unit test is accurate. Related: OS#1968 Change-Id: Iefeaaf33570f8e40245fdf9b810390ec61cfc7e0
* fix wrong return codeThorsten Alteholz2017-03-151-1/+1
| | | | | | | | | | | | In case we are a daemon, we do not need to daemonize again. On the other hand everything is fine and we also do not need to bail out with an error. The daemonize template at [1] does the same. [1] http://www.itp.uzh.ch/~dpotter/howto/daemonize Change-Id: Ia4dcf7344bd65934faa3d7d46563f6e0532c232e
* linuxlist.h: add llist_first/last_entry macrosNeels Hofmeyr2017-03-151-0/+30
| | | | | | | | | | | Copy list_first_entry, list_first_entry_or_null and list_last_entry from current linux kernel's tools/include/linux/list.h and rename to llist_*. Slightly adjust API doc but stay as close to the source as possible. This can replace similar implementations in osmo-bts-octphy's l1_if.c, in openbsc's gtphub.c and in osmo-hlr's gsup_server.c. Change-Id: I4eac5be0c0b2cede04464c4c3a0873102d952453
* milenage_test: enhance to verify new SQN incrementsNeels Hofmeyr2017-03-152-0/+31
| | | | | | | | | After the legacy mode incrementing with ind_bitlen == 0 is through, do another AUTS run with sensible ind_bitlen and ind, and then two more normal vector generations to verify proper SQN increments. Related: OS#1968 Change-Id: Id6947899ff7b1c82b939f969e163e51ce282bce2
* osmo_auth_gen_vec: UMTS auth: fix SQN as SEQ || INDNeels Hofmeyr2017-03-153-1/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | So far we incremented SQN by 1, which doesn't match the procedures described in 3GPP TS 33.102. An IND (index) denotes a non-significant part of SQN, and the significant SEQ part needs to be incremented. In OsmoHLR we furthermore want to use the "exception" suggested in annex C.3.4, so that each HLR's client has a fixed IND index. In other words, we will not assign IND cyclically, but keep IND unchanged per auth vector consumer. Add 'ind_bitlen' and 'ind' to the osmo_sub_auth_data.u.umts structure and increment SQN accordingly. Add a comment explaining the details. Because 'ind_bitlen' is still passed as zero, the milenage_test does not change its behavior, which is a feature I want to clearly show in this patch. The test will be expanded for the newly implemented SQN scheme in a subsequent patch. Adjust osmo-auc-gen.c to still show the right SQN and SQN.MS -- because it is passing ind_bitlen == 0, osmo-auc-gen can rely on single increments and know SQN.MS is sqn - 1. Note that osmo-auc-gen_test output remains unchanged. Related: OS#1968 Change-Id: Ibc97e1736a797ffcbf8c1f7d41c5c4518f4e41bf
* osmo_auth_gen_vec: UMTS auth: store last used SQN, not nextNeels Hofmeyr2017-03-154-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prepare for the implementation of splitting SQN increments in SEQ and an IND part; particularly to clearly show where the changes in auth/milenage_test's expectations originate. Rationale: the source of UMTS auth vectors, for us usually OsmoHLR, typically stores the last used SQN, not the next one to be used. Particularly with the upcoming fix of the SQN scheme, this change is important: the next SQN will depend on which entity asks for it, because each auth consumer may have a particular slot in the IND part of SQN. It does not make sense to store the next SQN, because we will not know which consumer that will be for. The milenage_test has always calculated a tuple for SQN == 34. To account for the increment now happening before calculating a tuple, lower the test_aud->sqn by one to 0x21 == 33, so that it is still calculating for SQN == 34. Because we are no longer incrementing SQN after the tuple is generated, milenage_test's expected output after doing an AUTS resync to 31 changes to the next SQN = 32, the SQN used for the generated tuple. (BTW, a subsequent patch will illustrate AUTS in detail.) osmo-auc-gen now needs to pass the user requested SQN less one, because the SQN will be incremented befor generating the auth vector. Also the SQN remains the same after generating, so SQN output needs less decrementing. Note that the expected output for osmo-auc-gen_test remains unchanged, hence the same input arguments (particularly -s <sqn> and -A <auts>) still produce the same results. Note: osmo-hlr regression tests will require adjustments when this patch is merged, because it must now pass desired_sqn - 1 instead of just desired_sqn. See osmo-hlr change-id I4ec5a578537acb1d9e1ebfe00a72417fc3ca5894 . Related: OS#1968 Change-Id: Iadf43f21e0605e9e85f7e8026c40985f7ceff1a3
* osmo-auc-gen: clarify SQN output, prepare for SQN changesNeels Hofmeyr2017-03-152-16/+18
| | | | | | | | | | | | | | | | Upcoming patches will change the way SQN are incremented. Change the SQN related output by osmo-auc-gen so that it also makes sense after these changes, and so that its output is proven to remain unchanged for the same arguments: Always show the SQN used for vector generation when a UMTS vector was generated. Don't show the next SQN, it will not make sense anymore (see later patches). The adjustments of expected output of osmo-auc-gen_test illustrates how the output changes. Related: OS#1968 Change-Id: I35d9c669002ff3e8570e07b444cca34ce57c3b0c
* add osmo-auc-gen_testNeels Hofmeyr2017-03-156-2/+134
| | | | | | | | | | | | | | | | | | Add test for osmo-auc-gen invocations to ensure stability across upcoming SQN increment scheme changes. The test comprises of a shell script that invokes the osmo-auc-gen binary with various milenage parameters, of which the stdout/stderr are verified. More osmo-auc-gen invocations could be added, but my main focus is on the SEQ changes. Instead of manually testing that it still works for each SQN patch, I want this test to do it for me. To make sure that osmo-auc-gen is build before the tests are launched, place 'utils' before 'tests' in the root Makefile.am. Related: OS#1968 Change-Id: Ib4af34201cd2e7d76037bcd31dd89ef18c1a9aec
* milenage_test: cosmetic fix: shown value is not SEQ.MSNeels Hofmeyr2017-03-152-2/+4
| | | | | | | | | | | | | | | In the milenage_test, the console output printed "SEQ.MS = 33", but 33 is a) the SQN, not SEQ; b) the SQN *after* the next auth generation, i.e. SQN.MS would have been 31. While at it also use the proper PRIu64 from inttypes.h to output the sqn value. This prepares for upcoming sparation of SQN incrementing by SEQ and IND, particularly to clearly show where the changes in auth/milenage_test's expectations originate. Related: OS#1968 Change-Id: Ie83201f1362f3d793ada774f3fc5f89cc0b3fbb7
* lapd_core: Use 'struct value_string' for LAPD state namesHarald Welte2017-03-151-28/+33
| | | | | | | | | We don't really use state numbers without bounds check into string tables since March 2010, when value_string became part of libosmocore. It's time to catch up, 7 years later... Change-Id: I1dac7b4cb441a1119cc167112521e8b8aae62e63
* Doxygen: exclude osmocom/core/gsm/protocol/*Harald Welte2017-03-151-1/+1
| | | | | | | | | We don't document the header files that define structs/enums/types that are taken 1:1 from the relevant GSM specifications. So let's avoid having doxygen generate tons of warnings for related undocumented members. Change-Id: I231f78972a015902e4085aa80fcbc04009ae9f13
* gsm_04_08: add _NUM_CHREQ_T to enumAlexander Couzens2017-03-141-0/+1
| | | | | | _NUM_CHREQ_T defines the last element of the enum Change-Id: Id67ba8de89dd6288e449197438e9e1c5d7f5a134
* gsm0408: add chreq_type for CHREQ_T_PDCH_ONE_PHASE and CHREQ_T_PDCH_TWO_PHASEAlexander Couzens2017-03-141-0/+2
| | | | | | | | | | The previous version of this commit got reverted to avoid a breakage in openbsc. The problem is openbsc use an array of chreq_type with a manual defined size. This array is using enums as index which breaks if any elements got added into the middle, because the size of the array can't hold elements greater or equal than the size. Change-Id: I6676105507fe4e5627f740dfe4c2770f766ad068
* build: cosmetic: coding: break a CPPFLAGS lineNeels Hofmeyr2017-03-131-1/+3
| | | | | | Matches our general scheme and helps readability of an upcoming patch. Change-Id: I174086a988b51b6e80f3661609069b69a3d41cc7
* libosmocoding: fix .deb buildingMax2017-03-073-0/+9
| | | | | | | dpkg-buildpackage fails due to missing file descriptions - add necessary .install and .doc-base files to fix it. Change-Id: I5fb7e813c0860a3b5037e805deb84f9bf649ffa3
* libosmocoding: migrate transcoding routines from OsmoBTSVadim Yanitskiy2017-03-0725-7/+8111
| | | | | | | | | | | | | | | | | | | | | | | | | There are some projects, such as GR-GSM and OsmocomBB, which would benefit from using one shared implementation of GSM 05.03 code. So, this commit introduces a new sub-library called libosmocoding, which (for now) provides GSM, GPRS and EDGE transcoding routines, migrated from OsmoBTS. The original GSM 05.03 code from OsmoBTS was relicensed under GPLv2-or-later with permission of copyright holders (Andreas Eversberg, Alexander Chemeris and Tom Tsou). The following data types are currently supported: - xCCH - PDTCH (CS 1-4 and MCS 1-9) - TCH/FR - TCH/HR - TCH/AFS - RCH/AHS - RACH - SCH Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1
* tests/conv: separate test logicVadim Yanitskiy2017-03-064-153/+169
| | | | | | | | To be able to add some more tests, related to convolutional coding, without duplication of code, the test logic was separated from the conv_test.c into conv.c and conv.h. Change-Id: Idbdc7e19cb9b9a36cd1fccd621cd858e87530d98
* gsm0503.h: generate header automaticallyVadim Yanitskiy2017-03-063-174/+7
| | | | | | | Since we have automatic header generation, implemented in the utils/conv_gen.py, it's time to use this feature! Change-Id: I21caa4e433b2cc1861611e35350a9671da444c2a
* utils/conv_gen.py: add header generation featureVadim Yanitskiy2017-03-061-5/+44
| | | | Change-Id: Iae830d716f01810972edbef14fc5383ac647d0ea
* utils/conv_gen.py: add test vectors generation featureVadim Yanitskiy2017-03-061-2/+76
| | | | Change-Id: Ie10c47ee952f253b1ba77ecf6e79f2c033545bc1
* ctrl_type_vals: fix range checkNeels Hofmeyr2017-03-061-1/+1
| | | | | | | | In ctrl_cmd_parse(), fix missing check for not parseable ctrl type. Fixup for Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28. Change-Id: I7f8055225e3ee04b2a723bae07b12c42618963a0
* Check for proper lapdm_datalink entityMax2017-03-021-2/+8
| | | | | | | | | | Previously lapdm_datalink->entity->mode was dereferenced without checking if correct entity is present. This might lead to segfault. Check it explicitly before dereferencing, log error and gracefully return if necessary. Change-Id: I0361e3731e86712b415a370cab1128d611988f56 Related: OS#1898
* fix: gsm0808.c: unterminated value_string array gsm0808_bssap_namesNeels Hofmeyr2017-03-021-0/+1
| | | | Change-Id: Ie38bae32372dc41e1902a8f6f0bc550ae515cfb8
* fsm: convenience: add inline osmo_fsm_inst_state_name()Neels Hofmeyr2017-03-011-0/+4
| | | | Change-Id: If9a6ecc4d6e2beaf716569e9a6053d73488e860b
* Handle replies in ctrl_cmd_handle()Max2017-03-011-0/+17
| | | | | | | | | | | | Previously *_REPLY and ERROR messages were not explicitly handled which would lead to sending error in response to them which in turn would prompt other party to send error as well which would result in infinite cycle. Handle it explicitly by logging message id and other relevant data. Change-Id: Id96f3a2fc81fa4549f49556d83f062c6b2f59e28 Related: OS#1615
* Use value_string for ctrl_typeMax2017-03-017-37/+74
| | | | | | | | Use value_string for enum ctrl_type instead of custom code. Add corresponding unit tests. Related: OS#1615 Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28
* Fix client-side ctrl interface helpersMax2017-03-011-40/+1
| | | | | | | | * remove unused ctrl_interface_connect() which is not part of public API * add default read callback to osmo_ctrl_conn_alloc() Change-Id: Iaa209e34a849ce0dfe2e29b482c3208ade1a32a4 Related: OS#1615
* Export comp128 v2 and v3 routines as wellHolger Hans Peter Freyther2017-02-271-0/+2
| | | | | | | It is in the public header file and allows to easily bind it from other languages (without having to go through the abstraction). Change-Id: I0128d529c52ec030cfb87b0aff3c69cadf2c59d2
* ports.h: rename CSCN to MSCNeels Hofmeyr2017-02-242-2/+2
| | | | | | See OS#1958 Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d
* libosmoctrl: Fix typo in ctrl_interface_connect()Harald Welte2017-02-231-1/+1
| | | | | | it's osmo_sock_init_ofd(), not osmo_sock_init_ifd() Change-Id: Ia6a82031a691403f641815862613d99b31a3a159
* Expand and expose ctrl connection allocationMax2017-02-232-6/+52
| | | | | | | | | | | | Add function for allocating CTRL connection to public headers and replace call to previous static function with it. Add doxygen docs for this function. It's useful if we need to allocate ctrl connection but don't need to bind to any interfaces: when we act as ctrl client. Related: OS#1615 Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32
* logging.h: fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*Neels Hofmeyr2017-02-238-59/+61
| | | | | | | | | | | | | | | My recent logging patch was merged to master a bit too soon. Accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING". libosmocore will not be backwards-compatible with the few commits from change-id I5c343630020f4b108099696fd96c2111614c8067 up to this one. This and following commits are backwards compatible with those before that short window. See also: * openbsc change-id Ib2ec5e4884aa90f48051ee2f832af557aa525991 * osmo-pcu change-id I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93
* logging.h: fixup: add API doc for logging enums recently addedNeels Hofmeyr2017-02-231-0/+5
| | | | Change-Id: Ic459b04219abe70171c8f80ed09df53d412dcfb2
* logging.h: fix backwards compat broken by recent commitNeels Hofmeyr2017-02-231-0/+7
| | | | | | | | | | | | | | Commit 812ba6dc63a75c39678dd3fe652768e76bf63183 "logging: centrally define ctx and filter indexes" Removed definitions, which causes older e.g. openbsc and osmo-pcu code trees to fail to build against a newer libosmocore. Re-introduce the legacy definitions to redirect to the new ones and re-establish backwards compatibility. The GPRS_* constants used to be defined in gprs_msgb.h, but since that header also includes logging.h, rather place the legacy shims in logging.h next to the other ones. Change-Id: I455bb1bb474d758af0fd5b6397f7e57260ad739d
* gsm_04_08.h: add R99 MSCR and CBQ3 to SI3 Ctrl Chan DescrNeels Hofmeyr2017-02-231-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | MSCR and CBQ3 are Release 1999 additions to the Control Channel Description IE of SI3. Assuming that no-one is using the spare bits, this will not cause any code conflicts. In the R99 struct, spare1 and spare2 are in different places, so rather rename them to spare_1 and spare_2 to make sure we get a compiler barf *if* anyone tries to use them with the wrong structure. Adjust the spec reference to TS 44.018; TS 04.08 Figure 10.5.33 is replaced by TS 44.018 Figure 10.5.2.11.1 which is right there in the named Section 10.5.2.11, so drop the explicit reference. Motivation: the R99 Control Channel Description defines MSCR to indicate whether the MSC is R99+ or not. To use UMTS AKA on GSM networks, we want to indicate that our libmsc is capable of R99, like OsmoSGSN already does. CBQ3 is merely added for completeness, no particular use case in mind. Related: OS#1593 Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608
* logging: centrally define ctx and filter indexesNeels Hofmeyr2017-02-2210-54/+66
| | | | | | | | | | | | | | | | | | | | | | | It is too easy for calling code to use the same filter and context indexes for different filters and structs. For example, openbsc's IMSI filter and libgb's GPRS_BVC filter both fall on index 1 even though there are plenty more indexes to choose from. To alleviate this, have one central definition here, sort of like ports.h does for VTY and CTRL port numbers. Add static asserts to make sure the indexes fit in the available array and bit mask space. Calling code like openbsc.git and osmo-pcu need adjustments and/or should move to using these enum values instead of their local definitions. Taking this opportunity to also prepare for a split of struct gsm_subscriber in openbsc into bsc_subsciber and vlr_subscriber with appropriate separate filter index constants for both subscriber types. Include previous LOG_FILTER_ALL in the LOGGING_FILTER_* enum, and replace its use by (1 << LOGGING_FILTER_ALL). Change-Id: I5c343630020f4b108099696fd96c2111614c8067
* gsup_test: also check stderrNeels Hofmeyr2017-02-224-8/+89
| | | | | | | | | Configure logging to be deterministic and add stderr checking to testuite.at. However, exclude the thousands of message modification log lines from the log to not have a huge test expectation file. Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb
* gsup test: add decoding test for UMTS IEsNeels Hofmeyr2017-02-222-1/+61
| | | | | | | | | | This would have caught the wrong expectation of AUTS' length fixed recently (3a5ca647c531b7761dc6c555e5e0cabc972bd3ac). Besides AUTS, add AUTN, RES, CK, IK which were also not tested yet. Change-Id: I6fddf8d7ce97137b0a585d365807bcaf90a319d0 Related: OS#1593
* fix osmo_auth_gen_vec_auts: copy rand to auth vectorNeels Hofmeyr2017-02-221-1/+8
| | | | | Related: OS#1593 Change-Id: If943731a78089f0aac3d55245de80596d01314a4
* gsup decode: fix expectation of AUTS length, should be 14Neels Hofmeyr2017-02-211-2/+2
| | | | | | The wrong expectation caused OsmoHLR to fail on Auth Sync. Change-Id: I277fb3d407396dffa5c07a9c5454d87a415d393f
* Document ctrl_interface_setup_dynip() functionMax2017-02-191-0/+8
| | | | Change-Id: Ie1d5881dda7a9b797d15e9e1eead8281a994d91e
* fix: gprs_bssgp_vty: logging filter: wrong constantNeels Hofmeyr2017-02-171-1/+1
| | | | | | | Setting the BVC log filter to NULL worked only if the NSVC filter was set, use the proper constant instead. Change-Id: Ic1cc268ed20700698c93d3ff8bf85cc0f01d3b1b
* gsup: add osmo_gsup_message_type_name()Neels Hofmeyr2017-02-153-0/+35
| | | | Change-Id: Ic29b588b72893821d73fe90ecc16c6bf78d5a360
* OAP:remove design doc. osmocom-authn-protocol.txtikostov2017-02-152-251/+1
| | | | | | | | | | | Osmocom Authentication Protocol design document is removed from libosmocore project as this information has been included in the User Manual. It is present in SGSN User Manual. relates to OS#1874 Change-Id: I2d4dc608622a7484e67b15f930efc76e28285045
* osmo_hexparse: allow whitespace in parsed string, add ws testNeels Hofmeyr2017-02-143-9/+51
| | | | | | | | This is particularly useful for hex dumps containing spaces found in a log (e.g. osmo-nitb authentication rand token), which can now be passed in quotes to osmo-auc-gen without having to edit the spaces away. Change-Id: Ib7af07f674a2d26c8569acdee98835fb3e626c45
* utils: add hexparse testNeels Hofmeyr2017-02-142-0/+117
| | | | Change-Id: Ic95ab00b57d54905a235109561c00419161cf4bc