32 Commits

Author SHA1 Message Date
Konrad Dybcio
daf7f4cc32 treewide: Include libqrtr.h as a global header
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
2024-05-21 11:10:11 +02:00
Arnaud Ferraris
b6b586f3d0 lib: meson.build: restore libqrtr SONAME
The previous version of `libqrtr` had `libqrtr.so.1` as their SONAME,
while the current version have only `libqrtr.so`. This is problematic as
previously built binaries using this lib will have to be rebuilt for
this new version (or rather, re-linked, which is practically
equivalent).

This change ensures the SONAME is kept by setting the project version
in the top-level `meson.build` and uses this string as the shared
library version.

In practice, the generated library filename is now `libqrtr.so.1.1` with
SONAME still being `libqrtr.so.1`.
2024-04-30 23:51:42 +02:00
Konrad Dybcio
baee896ad0 qmi: fix format warnings 2024-04-09 13:14:34 +02:00
Konrad Dybcio
ed513e627b lib: generate pkgconfig 2024-04-09 13:14:34 +02:00
Konrad Dybcio
dece9315ea treewide: meson
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
2024-04-09 13:14:34 +02:00
Bjorn Andersson
9dc7a88548 libqrtr: Zero-initialize sockaddr_qrtr
Valgrind complains that sockaddr_qrtr isn't properly initialized, even
though all fields are initialized. So explicitly clear the
sockaddr_qrtrs.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-12-07 08:44:31 -08:00
Adam Serbinski
33bf949e4f Clang: fix for arithmetic disallowed on void pointers 2020-09-28 10:21:21 -05:00
Alex Khouderchah
fef484babd libqrtr: Use size_t for offsets
Currently, offsetof produces an unsigned long, while qmi_elem_info's
offset member is a uint32_t. Since this is not the same type on all
platforms, this change uses a size_t for both. stddef.h is also
included for the standard offsetof definition, which also produces a
size_t.

This change also makes similar modifications to list.h.
2020-09-28 10:18:59 -05:00
Eric Caruso
c1bdfb37db logging: add min priority and other cleanup
The dprintf macro shadows a real libc symbol which is called
differently, so we should change it to something else (in this
case LOGD) and change it to use the libqrtr logging facilities.
This also means we should add a minimum priority to the logging
library so we don't log DEBUG-level messages by default.

Additionally there were some warn/warnx calls left over that
have been changed to PLOGW/LOGW respectively.
2018-12-10 16:03:04 -08:00
Bjorn Andersson
a1694a1c93 libqrtr: Correct "instance" composition
The "instance" id of a service is a composition of the instance id and
the version. In some plaeces in the library I made this two half words
instead of the actually expected 8 bits version + 24 bit instance. Fix
this in the library.

This was not spotted previously because all prior work has dealt with
instance id 0, but with the QRTR support in Diag this is now an issue.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-08-03 22:01:48 -07:00
Ben Chan
f9b5b38b50 qmi: pass `const struct qrtr_packet' to qmi_decode_header()
Similar to qmi_decode_message(), qmi_decode_header() doesn't modify the
`struct qrtr_packet' argument. This patch makes qmi_decode_header() to
take a `const struct qrtr_packet' argument like qmi_decode_message()
does.

Contributed by Jacob Rutherford <jruthe@chromium.org>
2018-07-26 06:15:57 -07:00
Arun Kumar Neelakantam
4c4987ba7d libqrtr : Add support for signed one byte enum.
Add support to encode/decode one BYTE signed enum data type.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-07-16 09:03:29 -07:00
Ben Chan
0ba75091ab libqrtr: add extern "C" guard in libqrtr.h
This patch adds an extern "C" guard in libqrtr.h, so that it can be
included in both C and C++ projects.

Signed-off-by: Ben Chan <benchan@chromium.org>
2018-06-29 12:32:29 -07:00
Eric Caruso
de5ee77b00 logging: add use_syslog to qlog_setup
This causes qlog to log to syslog instead of logging to stderr.

Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
2018-05-08 17:16:33 -07:00
Eric Caruso
f64c25c8af Unify logging into one function
This prepares us to add log-to-syslog functionality by passing
all logging through one place.

Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
2018-05-08 17:16:33 -07:00
Eric Caruso
b0f8857615 qmi: remove unused include
This include provides err, errx, etc. but it looks like all
error logging in qmi.c is done with fprintf, so there's no
reason to include it.

Change-Id: I4f4a71323a55fca981ef8df994fe624a590e3802
2018-04-27 16:28:19 -07:00
Ben Chan
539c83dc5b libqrtr: define AF_QIPCRTR if it isn't defined in libc header
Definition of AF_QIPCRTR was introduced in glibc in the following
commit and is only available since glibc 2.25 or later.

https://sourceware.org/git/?p=glibc.git;a=commit;h=acaff9b658720e4c887f4e44e6f28962d6f372d3

This patch modifies libqrtr.h to define AF_QIPCRTR if it isn't defined
in libc header, which allows compilation of libqrtr on a system with an
older version of glibc. The compiled libqrtr can still be used on a
system with kernel 4.7 or later with the QIPCRTR support.

Signed-off-by: Ben Chan <benchan@chromium.org>
2018-03-29 08:48:55 -07:00
Bjorn Andersson
dbffdd0193 libqrtr: Remove depricated functions
Post-QMI clean up of old interfaces and some duplicated definitions.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-02-01 02:06:57 +00:00
Bjorn Andersson
183d33d238 libqrtr: Rename libqrtr.c for the purpose of symmetry
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-02-01 01:51:39 +00:00
Bjorn Andersson
70b6f4900d qmi: Introduce QMI encoder/decoder helpers
The QMI functions can be used to deal with QMI-encoded data in
qrtr_packet objects. The structure-description is the same element-info
arrays as is used in the upstream Linux kernel.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-31 21:07:45 +00:00
Bjorn Andersson
17c4c1038e qrtr: Drop container.h
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-31 21:07:39 +00:00
Bjorn Andersson
99390f90ae libqrtr: Add qrtr_decode() operation
The qrtr_decode() takes a buffer of data and returns a decoded qrtr
packet object, this will either contain control data or a reference to
the message data.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-31 21:07:39 +00:00
Bjorn Andersson
0ec649d4e6 qrtr: Backport future qrtr.h uapi
The uapi qrtr.h is extended with additional types and constants. Drop
the local qrtr.h to use the one from linux-headers and extend it
conditionally while we're waiting for the updated file.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-31 05:53:49 +00:00
Bjorn Andersson
b65e63045f libqrtr: Don't enforce server port to be bound
When sending a new_server message to the qrtr-ns the node and port in
the packet is ignored (to not allow clients spoofing the information),
so there's no reason to have this artificial check in the
qrtr_new_server() implementation either.

The socket will be bound to a port automatically when the new_server
message is sent out.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-11-09 10:22:28 -08:00
Bjorn Andersson
dfae11b03a libqrtr: Don't require socket to be bound for lookup
There's no reason to require that the socket to be bound to a specific
port in order to register a lookup, the transmission of the lookup
request will autobind the socket to a port for us.

Also drop the node and port from the payload, as qrtr-ns will register
the lookup on the source sq, rather than the passed port.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-30 21:38:47 -07:00
Bjorn Andersson
ba500a4d3d lib: Fix endian handling and add new/del server
Fix up the handling of endian translation and add support for decoding
new and del server messages.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-07 10:00:28 -07:00
Bjorn Andersson
577328a8ab lib: Add helpers for handling control messages
The two added functions can be used by an application to check if a
sockaddr is from the control port and for parsing the control messages
that is passed to registered clients.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-07 10:00:28 -07:00
Bjorn Andersson
0bc03abb43 ns: Remove the ns service
Now that we have moved all operations to the control socket we can
remove the ns handler. The query function in the library is racy, as
there might be non-response messages in our incoming buffer when we
start reading, so this is dropped too - rather than just being
translated to the new interface.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-06 21:50:54 -07:00
Bjorn Andersson
326aad23ae ns: Introduce lookup registration
Introduce a subscription based lookup model, in order for a client to be
able to listen to a future spawning service. The client can register any
number of queries with the ns and the ns will post lookup-results as
services are registred.

As a special case the list of lookup-results that is sent out as a
result of the registration of a new lookup will be finished by an empty
lookup response, allowing tools like qrtr-lookup to terminate as the
entire list of currently registed services is received.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-06 21:49:30 -07:00
Bjorn Andersson
e377bc8e84 lib: Replace qrtr_publish() and qrtr_bye() implementations
Replace the implementation of the two library functions with calls to
the new APIs, so that we can remove the server-side implementation of
the previous messages.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-06 21:47:00 -07:00
Bjorn Andersson
ff29fb17a3 lib: Provide new API for clients to register services
Add a new set of operations to libqrtr for sending registration events
to the control service, rather than using the nameservice port.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-06 21:16:54 -07:00
Bjorn Andersson
18fc98b858 libqrtr: Extract the lib from the src directory
Extract the libqrtr source and header file to a separate directory,
making it more convinient to include the header file from other
projects.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-02-07 22:01:57 -08:00