Commit graph

75 commits

Author SHA1 Message Date
Siddharth Chandrasekaran
a871f00726 mgmt/osdp: Fix coverity identified off-by-one
Fix a coverity identified, off-by-one, out-of-bound array access at
pd->cap[].

CID: 215379
Fixes: #33095
Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2021-03-10 10:15:48 -05:00
Kumar Gala
4ff6061b09 mgmt/osdp: Fix build issue
When building the osdsp control_panel sample we get the following
compile error:

subsys/mgmt/osdp/src/osdp_cp.c:993:10: error: implicit declaration of
function 'osdp_cp_send_command_keyset'

Fix by adding ifdef protection around the call to
osdp_cp_send_command_keyset

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-11-03 13:00:11 -06:00
Siddharth Chandrasekaran
4640bafca6 mgmt/osdp: Fix early check of no-data that holds PD online
When waiting for data from CP, the data timeout check must happen before
no-data check. If not, a partial packet may endlessly hold PD in
"wait-for-data" state, while the PD keeps reporting status as online
till another packet is received.

Fix this my moving no-data check below the timeout check.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
8d012aace9 mgmt/osdp: CP: Reset channel before sending a command
Flush channel of any existing partial packets before sending a new
command.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
23c0c77049 mgmt/osdp: Skip all incoming bytes till start of new packet
All OSDP packets must start with a mark byte (0xFF) followed by a Start
of Message byte (0x53). Skip all bytes received until such a sequence is
seen to to avoid waking up the refresh thread needlessly.

Also, refactor osdp_uart_isr() to reduce number of local variables.

Fixes: #28168 Coverity-ID: 214218

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
d6437c1aa1 mgmt/osdp: CP: Unify osdp_cp_send_cmd_*() as osdp_cp_send_command()
Minimize number of exported methods by unifying all osdp_cp_send_cmd_*()
as osdp_cp_send_command().

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
f0b43a4dfa mgmt/osdp: CP: Add COMSET command
Add osdp_COMSET command to set PD communication parameters.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Flavio Ceolin
619dcef498 mgmt: osdp: Fix a warning about an unused variable
tmp variable is only used when osdp sc is enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-10-13 10:58:02 +02:00
Flavio Ceolin
aa23af14b6 mgmt: osdp: Fix build when osdp sc is not enabled
osdp was unconditionally referencing symbols that are defined only if
osdp sc is enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-10-13 10:58:02 +02:00
Flavio Ceolin
6f7f9dfe7b mgmt: osdp: Make osdp sc requires on CSPRING_ENABLED
OSDP secure channel require a truly random number generator
source. Make this dependency explicit.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-10-13 10:58:02 +02:00
Siddharth Chandrasekaran
7f4d2c741b mgmt/osdp: Add support for Secure Channel
This patch adds Secure Channel capabilities to osdp Control Panel and
Peripheral Device modes.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-09 11:45:58 +02:00
Xavier Chapron
824f423e54 misc: Replace assert include and calls by sys/__assert.h equivalent
Replace all calls to the assert macro that comes from libc by calls to
__ASSERT_NO_MSG(). This is usefull as the former might be different
depending on the libc used and the later can be customized to reduce
flash footprint.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-10-02 11:42:40 +02:00
Siddharth Chandrasekaran
2b4ca51c85 mgmt/osdp: Fix osdp_build_ctx(); Add NULL check on ctx
osdp_build_ctx() was returning fixed NULL and the subsequent code did
not check if ctx was NULL due to osdp_build_ctx() failures. Fix both
these issues.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-18 17:36:02 +02:00
Siddharth Chandrasekaran
a3d07cda9b mgmt/osdp: Make CP/PD mode selection as first entry in Kconfig
CP/PD mode selection is the most frequently looked-for/changed key in
Kconfig. Making that as the first entry for ease of use.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-14 16:00:45 -05:00
Siddharth Chandrasekaran
e6789a82ca mgmt/osdp: Change select SERIAL to imply SERIAL_SUPPORT_INTERRUPT
OSDP subsys was doing a `select SERIAL` in its Kconfig. But this has
other unintended side effects. Change this to
`imply SERIAL_SUPPORT_INTERRUPT`.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-14 16:00:45 -05:00
Siddharth Chandrasekaran
ee99c34fb6 mgmt/osdp: Refactor struct osdp_cmd members for readability
Some of the names used in `struct osdp_cmd` where directly as in the
specification. Initially it appealed to keep them like that but with
time, a little more consistent naming of members helps if you haven't
read the specification document very recently.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-04 10:58:13 +02:00
Siddharth Chandrasekaran
4c9b0ae928 samples: mgmt/osdp: Add CP Sample
Add a OSDP CP mode sample that sends out a periocic command to a
connected PD. It also demosnstrates key press and card read callback
registration.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-04 10:58:13 +02:00
Siddharth Chandrasekaran
ea03c9c304 mgmt/osdp: Add support for CP mode of operation
Following the PD mode implementation (9a91b4ad), this patch adds support
for CP mode of operation in OSDP.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-04 10:58:13 +02:00
Siddharth Chandrasekaran
31d2b991e0 mgmt/osdp: Refactor PD for upcomming CP changes
Some PD init sequence and other methods are useful in CP mode as well.
This patch refactors those methods to osdp_*(), moves them to common
source files and and exposes them from osdp_common.h.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-04 10:58:13 +02:00
Flavio Ceolin
86d8475850 osdp: Remove invald serial option
SERIAL_HAS_DRIVER and UART_INTERRUPT_DRIVEN should be selected by the
driver. If something needs is should dependson these options.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-02 13:45:26 -04:00
Flavio Ceolin
2fde557e14 osdp: Do not select ENTROPY_GENERATOR
Entropy generator is not used in this subsystem so there is no need to
select it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-02 13:45:26 -04:00
Flavio Ceolin
61b2cdd0dd osdp: Do not use TEST_RANDOM_GENERATOR
TEST_RANDOM_GENERATOR should not be used in subsystems because it does
not generate truly random numbers. This is indented to be used only
for tests purpose.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-02 13:45:26 -04:00
Tomasz Bursztyka
e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Flavio Ceolin
0aaae4a039 guideline: Make explicit fallthrough cases
-Wimplicit-fallthrough=2 requires a fallthrough comment or a compiler
to tells gcc that this happens intentionally.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-24 20:28:47 -04:00
Siddharth Chandrasekaran
9a91b4adf9 mgmt/osdp: Add support for OSDP in PD mode of operation
Open Supervised Device Protocol (OSDP) describes the communication
protocol for interfacing one or more Peripheral Devices (PD) to a
Control Panel (CP). The PDs are slave devices that waits for commands
from a CP. The communication happens over a RS485 multi-drop connection
with specification for a secure channel communication.

This patch adds initial support for OSDP in PD mode without secure
channel.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-08-13 11:48:28 +02:00