| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a number of library-internal static global buffers which are
mainly used for various stringification functions. This worked as
all of the related Osmocom programs were strictly single-threaded.
Let's make those buffers at least thread-local. This way every thread
gets their own set of buffers, and it's safe for multiple threads to
execute the same functions once. They're of course still not
re-entrant. If you need re-entrancy, you will need to use the _c()
or _buf() suffix version of those functions and work with your own
(stack or heap) buffers.
Change-Id: I50eb2436a7c1261d79a9d2955584dce92780ca07
|
|
|
|
|
|
|
|
|
|
| |
Calling sizeof() on a pointer to dynamically allocated memory would
result in getting size of the pointer (usually 4 or 8 bytes) itself,
but not the size of allocated memory.
Change-Id: I8ffda4dea2b7f9b4b76dfeecad1fab6384c5a62c
Fixes: CID#197629, CID#197628, CID#197627
Fixes: CID#197626, CID#197625, CID#197624
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a habit of returning static buffers from some functions,
particularly when generating some kind of string values. This is
convenient in terms of memory management, but it comes at the expense
of not being thread-safe, and not allowing for two calls of the
related function within one printf() statement.
Let's introduce _c suffix versions of those functions where the
caller passes in a talloc context from which the output buffer shall
be allocated.
Change-Id: I8481c19b68ff67cfa22abb93c405ebcfcb0ab19b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a number of static buffers in use in libosmo*. This means
the related functions are not usable in a thread-safe way. While
we so far don't have many multi-threaded programs in the osmocom
universe, the static buffers also prevent us from calling the same
e.g. string-ify function twice within a single printf() call.
Let's make sure there's an alternative function in all those cases,
where the user can pass in a caller-allocated buffer + size, and make
the 'classic' function with the static buffer a wrapper around that
_buf() variant.
Change-Id: Ibf85f79e93244f53b2684ff6f1095c5b41203e05
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change fixes the following Doxygen warnings:
src/msgb.c:479: warning: argument 'msg' of command @param is not
found in the argument list of
msgb_printf(struct msgb *msgb, const char *format,...)
core/msgb.h:708: warning: The following parameters of
msgb_printf(struct msgb *msgb, const char *format,...)
are not documented:
parameter 'msgb'
parameter 'format'
As a bonus, it dot-terminates all sentences.
Change-Id: Ib708664336eef06f748d408ae02a13c754b6647a
|
|
|
|
|
|
|
|
| |
Since osmo_hexdump() use static buffers we can't re-use pointers to it
after subsequent osmo_hexdump() calls. Let's print data used for
comparison directly instead.
Change-Id: I24dc3fad6f64ef788da9b7d790f9d5f689190c42
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
An internal symbol '_talloc_zero' of talloc library was used
during a msgb allocation. This is not actually good because:
- it may be removed or modified by talloc developers;
- the behaviour may be changed by talloc developers;
- it's marked as internal using 'underscore';
- there is public API to do the same.
So, let's use the public API.
Change-Id: I1080c9071e997944cc0f9fc3716129e9395437ad
|
|
|
|
|
|
|
|
|
|
|
|
| |
Printing an error message when msgb allocation failed was initially
intended, but have been commented out for years. This would
facilitate the bug hunting process, especially on embedded
platforms with limited resources (e.g. amount of RAM).
The GLOBAL logging subsystem with FATAL level is used
for printing such messages.
Change-Id: I3e2d1beabd6936fc28a1ad664c083ff1698bb644
|
|
|
|
|
|
|
|
| |
The MSGB API is not a part of OpenBSC anymore, so let's remove
dead includes, which were probably left here during the
migration process.
Change-Id: Ief562a6e5b220a84902f95862d67279f953ee726
|
|
|
|
| |
Change-Id: I6b473aadaa22d95f2a8cc87580c638ccd7e531a4
|
|
|
|
|
|
|
|
| |
Let's fix some erroneous/accidential references to wrong license,
update copyright information where applicable and introduce a
SPDX-License-Identifier to all files.
Change-Id: I39af26c6aaaf5c926966391f6565fc5936be21af
|
|
|
|
|
|
|
|
|
|
|
| |
In ASCII string based protocols it a printf() version that prints
directly to the message buffer may be useful.
Add function msgb_printf(), make sure that msg buffer bounderies
are not exceeded. If the end of the tail buffer is hit, return
with an error code.
Change-Id: I15e1af68616309555d0ed9ac5da027c9833d42e3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Considering the various styles and implications found in the sources, edit
scores of files to follow the same API doc guidelines around the doxygen
grouping and the \file tag.
Many files now show a short description in the generated API doc that was so
far only available as C comment.
The guidelines and reasoning behind it is documented at
https://osmocom.org/projects/cellular-infrastructure/wiki/Guidelines_for_API_documentation
In some instances, remove file comments and add to the corresponding group
instead, to be shared among several files (e.g. bitvec).
Change-Id: Ifa70e77e90462b5eb2b0457c70fd25275910c72b
|
|
|
|
|
|
|
|
|
|
| |
Especially for short descriptions, it is annoying to have to type \brief for
every single API doc.
Drop all \brief and enable the AUTOBRIEF feature of doxygen, which always takes
the first sentence of an API doc as the brief description.
Change-Id: I11a8a821b065a128108641a2a63fb5a2b1916e87
|
|
|
|
|
|
|
|
|
| |
It's a pity that even with this patch we still are fare away from having
the whole API documented. However, at least we have a more solid
foundation. Updates not only extend the documentation, but also make
sure it is rendered properly in the doxygen HTML.
Change-Id: I1344bd1a6869fb00de7c1899a8db93bba9bafce3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
So far each and every main() scope creates a msgb talloc context and either
passes it to msgb_set_talloc_ctx() or sets tall_msgb_ctx directly (by defining
it extern first).
Remove some code duplication: add one central function that creates the "msgb"
talloc context for all.
Most users of msgb employ a talloc_named_const(), but osmo-bts uses a
talloc_pool() instead. Offer both ways by means of the pool_size argument, and
for both ways make sure the context is called "msgb".
Suggest that msgb users should move to this new function: deprecate
msgb_set_talloc_ctx(). To be able to do so, include core/defs.h in msgb.h.
There's a tradeoff between hiding the msgb talloc context behind API that tries
to guess all use cases versus avoiding code dup. This patch opts against code
dup and boldly assumes that all future use is covered.
Also, the new function suggests to not access tall_msgb_ctx directly, which can
be considered a style improvement.
It seems that not all main scopes that use msgb actually initialize the msgb
ctx. As a fallback for these, explicitly initialize tall_msgb_ctx to NULL.
Change-Id: I747fbbf977c4d2c868c8dead64cfc5fd86eb8d4c
|
|
|
|
| |
Change-Id: I06e9c5ba3e00c73a4e52d2583ce3492f236275ce
|
|
|
|
|
| |
This adds and improves doxygen API descriptions all over libosmocore,
reducing the 'white spots' that don't have any documentation.
|
|
|
|
|
| |
86ec311896dd5d4 adds compiler warnings on 64bit. The build is clean otherwise,
so let's keep it that way.
|
|
|
|
|
|
|
| |
This patch makes msgb_hexdump accept out of range lXh pointers and
shows info about them instead of aborting the dump entirely.
Sponsored-by: On-Waves ehf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These functions originate from openbsc/src/gprs but are generic
msgb helper functions.
msgb_copy: This function allocates a new msgb, copies the data
buffer of msg, and adjusts the pointers (incl. l1h-l4h)
accordingly.
msgb_resize_area:
This resizes a sub area of the msgb data and adjusts the
pointers (incl. l1h-l4h) accordingly.
Sponsored-by: On-Waves ehf
|
|
|
|
|
|
|
|
|
|
|
|
| |
This function works like osmo_hexdump() and returns a static buffer
containing hex bytes along with markers for the layers.
Note that it uses osmo_hexdump() internally, thus a call to
msgb_hexdump() invalidates the buffer that has been returned by an
earlier call to osmo_hexdump(). In short: don't mix them in a single
call printf().
Sponsored-by: On-Waves ehf
|
|
|
|
|
| |
Doxygen generates quite a lot of warnings on libosmocore. Some of them
are obvious typos - this patch aims to fix such low-hanging fruit.
|
|
|
|
| |
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
|
| |
|
| |
|
|
|
|
|
| |
We used this include for the u_int{8,16,32}_t types but we do
not need this anymore.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch moves all GSM-specific definitions to include/osmocom/gsm.
Moreover, the headers in include/osmocore/ have been moved to
include/osmocom/core.
This has been proposed by Harald Welte and Sylvain Munaunt.
Tested with `make distcheck'.
Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
|
|
|
|
|
|
| |
It is easier from languages that dlopen libosmocore to have a function
to access this data than to poke at the bytes of the struct directly. Add
copyright for this method and the reset method I did earlier this year.
|
| |
|
|
|
|
|
| |
This is a lot of GSM/GPRS specific stuff in struct msgb which we want
to avoid. The 'control buffer' will replace them.
|
| |
|
|
|
|
| |
Don't assign the same var twice & init all from the same source.
|
|
|