libosdp 3.2.5__tar.gz → 3.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {libosdp-3.2.5 → libosdp-3.2.7}/PKG-INFO +6 -6
- {libosdp-3.2.5 → libosdp-3.2.7}/README.md +4 -4
- {libosdp-3.2.5 → libosdp-3.2.7}/libosdp.egg-info/PKG-INFO +6 -6
- {libosdp-3.2.5 → libosdp-3.2.7}/setup.py +2 -2
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_common.c +5 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_common.h +7 -5
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_config.h +3 -3
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_cp.c +23 -3
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_diag.c +1 -1
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_pd.c +28 -13
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_phy.c +26 -4
- {libosdp-3.2.5 → libosdp-3.2.7}/MANIFEST.in +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/libosdp.egg-info/SOURCES.txt +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/libosdp.egg-info/dependency_links.txt +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/libosdp.egg-info/top_level.txt +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/osdp/__init__.py +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/osdp/channel.py +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/osdp/constants.py +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/osdp/control_panel.py +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/osdp/helpers.py +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/osdp/key_store.py +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/osdp/peripheral_device.py +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/pyproject.toml +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/setup.cfg +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/include/osdp.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/include/osdp_export.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/python/osdp_sys/base.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/python/osdp_sys/cp.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/python/osdp_sys/data.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/python/osdp_sys/module.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/python/osdp_sys/module.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/python/osdp_sys/pd.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/python/osdp_sys/utils.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/crypto/tinyaes.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/crypto/tinyaes_src.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/crypto/tinyaes_src.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_diag.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_file.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_file.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/src/osdp_sc.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/assert.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/crc16.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/disjoint_set.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/list.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/logger.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/pcap_gen.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/queue.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/slab.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/include/utils/utils.h +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/src/crc16.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/src/disjoint_set.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/src/list.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/src/logger.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/src/pcap_gen.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/src/queue.c +0 -0
- {libosdp-3.2.5 → libosdp-3.2.7}/vendor/utils/src/utils.c +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libosdp
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.7
|
|
4
4
|
Summary: Library implementation of IEC 60839-11-5 OSDP (Open Supervised Device Protocol)
|
|
5
|
-
Home-page: https://github.com/
|
|
5
|
+
Home-page: https://github.com/osdp-dev/libosdp
|
|
6
6
|
Author: Siddharth Chandrasekaran
|
|
7
7
|
Author-email: sidcha.dev@gmail.com
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -42,13 +42,13 @@ pip install libosdp
|
|
|
42
42
|
Or, from github,
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
|
-
pip install -e "git+https://github.com/
|
|
45
|
+
pip install -e "git+https://github.com/osdp-dev/libosdp#egg=libosdp&subdirectory=python"
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Or, from source using,
|
|
49
49
|
|
|
50
50
|
```sh
|
|
51
|
-
git clone https://github.com/
|
|
51
|
+
git clone https://github.com/osdp-dev/libosdp --recurse-submodules
|
|
52
52
|
cd libosdp/python
|
|
53
53
|
python3 setup.py install
|
|
54
54
|
```
|
|
@@ -141,5 +141,5 @@ pd.set_event_completion_handler(on_event_complete)
|
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
[1]: https://doc.osdp.dev/api/
|
|
144
|
-
[2]: https://github.com/
|
|
145
|
-
[3]: https://github.com/
|
|
144
|
+
[2]: https://github.com/osdp-dev/libosdp/blob/master/examples/python/cp_app.py
|
|
145
|
+
[3]: https://github.com/osdp-dev/libosdp/blob/master/examples/python/pd_app.py
|
|
@@ -21,13 +21,13 @@ pip install libosdp
|
|
|
21
21
|
Or, from github,
|
|
22
22
|
|
|
23
23
|
```sh
|
|
24
|
-
pip install -e "git+https://github.com/
|
|
24
|
+
pip install -e "git+https://github.com/osdp-dev/libosdp#egg=libosdp&subdirectory=python"
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Or, from source using,
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
|
-
git clone https://github.com/
|
|
30
|
+
git clone https://github.com/osdp-dev/libosdp --recurse-submodules
|
|
31
31
|
cd libosdp/python
|
|
32
32
|
python3 setup.py install
|
|
33
33
|
```
|
|
@@ -120,5 +120,5 @@ pd.set_event_completion_handler(on_event_complete)
|
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
[1]: https://doc.osdp.dev/api/
|
|
123
|
-
[2]: https://github.com/
|
|
124
|
-
[3]: https://github.com/
|
|
123
|
+
[2]: https://github.com/osdp-dev/libosdp/blob/master/examples/python/cp_app.py
|
|
124
|
+
[3]: https://github.com/osdp-dev/libosdp/blob/master/examples/python/pd_app.py
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libosdp
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.7
|
|
4
4
|
Summary: Library implementation of IEC 60839-11-5 OSDP (Open Supervised Device Protocol)
|
|
5
|
-
Home-page: https://github.com/
|
|
5
|
+
Home-page: https://github.com/osdp-dev/libosdp
|
|
6
6
|
Author: Siddharth Chandrasekaran
|
|
7
7
|
Author-email: sidcha.dev@gmail.com
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -42,13 +42,13 @@ pip install libosdp
|
|
|
42
42
|
Or, from github,
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
|
-
pip install -e "git+https://github.com/
|
|
45
|
+
pip install -e "git+https://github.com/osdp-dev/libosdp#egg=libosdp&subdirectory=python"
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Or, from source using,
|
|
49
49
|
|
|
50
50
|
```sh
|
|
51
|
-
git clone https://github.com/
|
|
51
|
+
git clone https://github.com/osdp-dev/libosdp --recurse-submodules
|
|
52
52
|
cd libosdp/python
|
|
53
53
|
python3 setup.py install
|
|
54
54
|
```
|
|
@@ -141,5 +141,5 @@ pd.set_event_completion_handler(on_event_complete)
|
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
[1]: https://doc.osdp.dev/api/
|
|
144
|
-
[2]: https://github.com/
|
|
145
|
-
[3]: https://github.com/
|
|
144
|
+
[2]: https://github.com/osdp-dev/libosdp/blob/master/examples/python/cp_app.py
|
|
145
|
+
[3]: https://github.com/osdp-dev/libosdp/blob/master/examples/python/pd_app.py
|
|
@@ -12,7 +12,7 @@ import shutil
|
|
|
12
12
|
import subprocess
|
|
13
13
|
|
|
14
14
|
project_name = "libosdp"
|
|
15
|
-
project_version = "3.2.
|
|
15
|
+
project_version = "3.2.7"
|
|
16
16
|
current_dir = os.path.dirname(os.path.realpath(__file__))
|
|
17
17
|
repo_root = os.path.realpath(os.path.join(current_dir, ".."))
|
|
18
18
|
|
|
@@ -229,7 +229,7 @@ setup(
|
|
|
229
229
|
author = "Siddharth Chandrasekaran",
|
|
230
230
|
author_email = "sidcha.dev@gmail.com",
|
|
231
231
|
description = "Library implementation of IEC 60839-11-5 OSDP (Open Supervised Device Protocol)",
|
|
232
|
-
url = "https://github.com/
|
|
232
|
+
url = "https://github.com/osdp-dev/libosdp",
|
|
233
233
|
ext_modules = [
|
|
234
234
|
Extension(
|
|
235
235
|
name = "osdp_sys",
|
|
@@ -174,6 +174,11 @@ int osdp_rb_pop_buf(struct osdp_rb *p, uint8_t *buf, int max_len)
|
|
|
174
174
|
return i;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
void osdp_rb_reset(struct osdp_rb *p)
|
|
178
|
+
{
|
|
179
|
+
p->head = p->tail = 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
177
182
|
/* --- Exported Methods --- */
|
|
178
183
|
|
|
179
184
|
void osdp_logger_init(const char *name, int log_level,
|
|
@@ -372,6 +372,7 @@ struct osdp_pd {
|
|
|
372
372
|
int state; /* FSM state (CP mode only) */
|
|
373
373
|
int phy_state; /* phy layer FSM state (CP mode only) */
|
|
374
374
|
int phy_retry_count; /* command retry counter */
|
|
375
|
+
int phy_tx_seq; /* seq number embedded in last TX packet */
|
|
375
376
|
uint32_t wait_ms; /* wait time in MS to retry communication */
|
|
376
377
|
int64_t tstamp; /* Last POLL command issued time in ticks */
|
|
377
378
|
int64_t sc_tstamp; /* Last received secure reply time in ticks */
|
|
@@ -466,6 +467,7 @@ int osdp_rb_push(struct osdp_rb *p, uint8_t data);
|
|
|
466
467
|
int osdp_rb_push_buf(struct osdp_rb *p, uint8_t *buf, int len);
|
|
467
468
|
int osdp_rb_pop(struct osdp_rb *p, uint8_t *data);
|
|
468
469
|
int osdp_rb_pop_buf(struct osdp_rb *p, uint8_t *buf, int max_len);
|
|
470
|
+
void osdp_rb_reset(struct osdp_rb *p);
|
|
469
471
|
|
|
470
472
|
void osdp_crypt_setup();
|
|
471
473
|
void osdp_encrypt(uint8_t *key, uint8_t *iv, uint8_t *data, int len);
|
|
@@ -492,9 +494,9 @@ void osdp_sc_teardown(struct osdp_pd *pd);
|
|
|
492
494
|
|
|
493
495
|
static inline uint16_t bread_u16_le(const uint8_t *buf, int *pos)
|
|
494
496
|
{
|
|
495
|
-
|
|
496
|
-
v |= (
|
|
497
|
-
return v;
|
|
497
|
+
uint32_t v = buf[(*pos)++];
|
|
498
|
+
v |= (uint32_t)buf[(*pos)++] << 8;
|
|
499
|
+
return (uint16_t)v;
|
|
498
500
|
}
|
|
499
501
|
|
|
500
502
|
static inline uint32_t bread_u24_le(const uint8_t *buf, int *pos)
|
|
@@ -546,9 +548,9 @@ static inline void bwrite_u32_le(uint32_t val, uint8_t *buf, int *len)
|
|
|
546
548
|
|
|
547
549
|
static inline uint16_t bread_u16_be(const uint8_t *buf, int *pos)
|
|
548
550
|
{
|
|
549
|
-
|
|
551
|
+
uint32_t v = (uint32_t)buf[(*pos)++] << 8;
|
|
550
552
|
v |= buf[(*pos)++];
|
|
551
|
-
return v;
|
|
553
|
+
return (uint16_t)v;
|
|
552
554
|
}
|
|
553
555
|
|
|
554
556
|
static inline uint32_t bread_u24_be(const uint8_t *buf, int *pos)
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
* @brief The following macros are defined defined from the variable in cmake
|
|
12
12
|
* files. All @XXX@ are replaced by the value of XXX as resolved by cmake.
|
|
13
13
|
*/
|
|
14
|
-
#define PROJECT_VERSION "3.2.
|
|
14
|
+
#define PROJECT_VERSION "3.2.7"
|
|
15
15
|
#define PROJECT_NAME "libosdp"
|
|
16
16
|
#define GIT_BRANCH "detached"
|
|
17
|
-
#define GIT_REV "v3.2.
|
|
18
|
-
#define GIT_TAG "v3.2.
|
|
17
|
+
#define GIT_REV "v3.2.7-0-gb284aa2"
|
|
18
|
+
#define GIT_TAG "v3.2.7"
|
|
19
19
|
#define GIT_DIFF ""
|
|
20
20
|
#define REPO_ROOT "/home/runner/work/libosdp/libosdp"
|
|
21
21
|
|
|
@@ -473,7 +473,7 @@ static int cp_decode_response(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
473
473
|
t = OSDP_PD_CAP_RECEIVE_BUFFERSIZE;
|
|
474
474
|
if (pd->cap[t].function_code == t) {
|
|
475
475
|
pd->peer_rx_size = pd->cap[t].compliance_level;
|
|
476
|
-
pd->peer_rx_size |= pd->cap[t].num_items << 8;
|
|
476
|
+
pd->peer_rx_size |= (uint32_t)pd->cap[t].num_items << 8;
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
/* post-capabilities hooks */
|
|
@@ -607,7 +607,7 @@ static int cp_decode_response(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
607
607
|
* for deprecation in v2.2.2. To avoid confusions, we will just
|
|
608
608
|
* ignore it here.
|
|
609
609
|
*
|
|
610
|
-
* See: https://github.com/
|
|
610
|
+
* See: https://github.com/osdp-dev/libosdp/issues/206
|
|
611
611
|
*/
|
|
612
612
|
LOG_WRN("Ignoring deprecated response osdp_FMT");
|
|
613
613
|
ret = OSDP_CP_ERR_NONE;
|
|
@@ -744,6 +744,21 @@ static int cp_process_reply(struct osdp_pd *pd)
|
|
|
744
744
|
return OSDP_CP_ERR_NO_DATA;
|
|
745
745
|
case OSDP_ERR_PKT_BUSY:
|
|
746
746
|
return OSDP_CP_ERR_RETRY_CMD;
|
|
747
|
+
case OSDP_ERR_PKT_SKIP: {
|
|
748
|
+
/*
|
|
749
|
+
* A command-direction frame reached us: either a second CP is
|
|
750
|
+
* contending for the bus or we heard our own transmission echo
|
|
751
|
+
* back. Drop the frame and keep waiting for the real reply.
|
|
752
|
+
* The buffered header must be discarded or phy_check_header()
|
|
753
|
+
* re-validates it forever, but osdp_phy_state_reset() also
|
|
754
|
+
* clears phy_state, which the CP owns; preserve it.
|
|
755
|
+
*/
|
|
756
|
+
int saved_phy_state = pd->phy_state;
|
|
757
|
+
|
|
758
|
+
osdp_phy_state_reset(pd, false);
|
|
759
|
+
pd->phy_state = saved_phy_state;
|
|
760
|
+
return OSDP_CP_ERR_NO_DATA;
|
|
761
|
+
}
|
|
747
762
|
case OSDP_ERR_PKT_NACK:
|
|
748
763
|
if (pd->ephemeral_data[0] == OSDP_PD_NAK_SEQ_NUM) {
|
|
749
764
|
LOG_WRN("NAK(SEQ_NUM); restarting communication");
|
|
@@ -878,7 +893,12 @@ static int cp_phy_state_update(struct osdp_pd *pd)
|
|
|
878
893
|
pd->phy_state = OSDP_CP_PHY_STATE_SEND_CMD;
|
|
879
894
|
__fallthrough;
|
|
880
895
|
case OSDP_CP_PHY_STATE_SEND_CMD:
|
|
881
|
-
|
|
896
|
+
if (pd->phy_retry_count > 0) {
|
|
897
|
+
struct osdp_channel *channel = &pd->channel;
|
|
898
|
+
if (channel->flush)
|
|
899
|
+
channel->flush(channel->data);
|
|
900
|
+
pd->seq_number = pd->phy_tx_seq - 1;
|
|
901
|
+
}
|
|
882
902
|
if (cp_build_and_send_packet(pd)) {
|
|
883
903
|
LOG_ERR("Failed to build/send packet for CMD: %s(%02x)",
|
|
884
904
|
osdp_cmd_name(pd->cmd_id), pd->cmd_id);
|
|
@@ -52,7 +52,7 @@ void osdp_packet_capture_finish(struct osdp_pd *pd)
|
|
|
52
52
|
LOG_ERR("Unable to stop capture (flush/close failed)");
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
LOG_INF("Captured %
|
|
55
|
+
LOG_INF("Captured %zu packets", num_packets);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
void osdp_capture_packet(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
@@ -170,7 +170,7 @@ static int pd_translate_event(struct osdp_pd *pd, const struct osdp_event *event
|
|
|
170
170
|
* osdp_FMT was underspecified by SIA from get-go. It
|
|
171
171
|
* was marked for deprecation in v2.2.2.
|
|
172
172
|
*
|
|
173
|
-
* See: https://github.com/
|
|
173
|
+
* See: https://github.com/osdp-dev/libosdp/issues/206
|
|
174
174
|
*/
|
|
175
175
|
LOG_WRN("Event CardRead::format::OSDP_CARD_FMT_ASCII"
|
|
176
176
|
" is deprecated. Ignoring");
|
|
@@ -474,12 +474,14 @@ static int pd_decode_command(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
474
474
|
pd->reply_id = REPLY_PDCAP;
|
|
475
475
|
ret = OSDP_PD_ERR_NONE;
|
|
476
476
|
break;
|
|
477
|
-
case CMD_OUT:
|
|
477
|
+
case CMD_OUT: {
|
|
478
|
+
int count;
|
|
478
479
|
if ((len % CMD_OUT_DATA_LEN) != 0) {
|
|
479
480
|
break;
|
|
480
481
|
}
|
|
482
|
+
count = len / CMD_OUT_DATA_LEN;
|
|
481
483
|
ret = OSDP_PD_ERR_REPLY;
|
|
482
|
-
for (i = 0; i <
|
|
484
|
+
for (i = 0; i < count; i++) {
|
|
483
485
|
cmd.id = OSDP_CMD_OUTPUT;
|
|
484
486
|
cmd.output.output_no = buf[pos++];
|
|
485
487
|
cmd.output.control_code = buf[pos++];
|
|
@@ -491,15 +493,20 @@ static int pd_decode_command(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
491
493
|
break;
|
|
492
494
|
}
|
|
493
495
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
+
if (i == count) {
|
|
497
|
+
pd->reply_id = REPLY_ACK;
|
|
498
|
+
ret = OSDP_PD_ERR_NONE;
|
|
499
|
+
}
|
|
496
500
|
break;
|
|
497
|
-
|
|
501
|
+
}
|
|
502
|
+
case CMD_LED: {
|
|
503
|
+
int count;
|
|
498
504
|
if ((len % CMD_LED_DATA_LEN) != 0) {
|
|
499
505
|
break;
|
|
500
506
|
}
|
|
507
|
+
count = len / CMD_LED_DATA_LEN;
|
|
501
508
|
ret = OSDP_PD_ERR_REPLY;
|
|
502
|
-
for (i = 0; i <
|
|
509
|
+
for (i = 0; i < count; i++) {
|
|
503
510
|
cmd.id = OSDP_CMD_LED;
|
|
504
511
|
cmd.led.reader = buf[pos++];
|
|
505
512
|
cmd.led.led_number = buf[pos++];
|
|
@@ -523,15 +530,20 @@ static int pd_decode_command(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
523
530
|
break;
|
|
524
531
|
}
|
|
525
532
|
}
|
|
526
|
-
|
|
527
|
-
|
|
533
|
+
if (i == count) {
|
|
534
|
+
pd->reply_id = REPLY_ACK;
|
|
535
|
+
ret = OSDP_PD_ERR_NONE;
|
|
536
|
+
}
|
|
528
537
|
break;
|
|
529
|
-
|
|
538
|
+
}
|
|
539
|
+
case CMD_BUZ: {
|
|
540
|
+
int count;
|
|
530
541
|
if ((len % CMD_BUZ_DATA_LEN) != 0) {
|
|
531
542
|
break;
|
|
532
543
|
}
|
|
544
|
+
count = len / CMD_BUZ_DATA_LEN;
|
|
533
545
|
ret = OSDP_PD_ERR_REPLY;
|
|
534
|
-
for (i = 0; i <
|
|
546
|
+
for (i = 0; i < count; i++) {
|
|
535
547
|
cmd.id = OSDP_CMD_BUZZER;
|
|
536
548
|
cmd.buzzer.reader = buf[pos++];
|
|
537
549
|
cmd.buzzer.control_code = buf[pos++];
|
|
@@ -545,9 +557,12 @@ static int pd_decode_command(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
545
557
|
break;
|
|
546
558
|
}
|
|
547
559
|
}
|
|
548
|
-
|
|
549
|
-
|
|
560
|
+
if (i == count) {
|
|
561
|
+
pd->reply_id = REPLY_ACK;
|
|
562
|
+
ret = OSDP_PD_ERR_NONE;
|
|
563
|
+
}
|
|
550
564
|
break;
|
|
565
|
+
}
|
|
551
566
|
case CMD_TEXT:
|
|
552
567
|
if (len < CMD_TEXT_DATA_LEN) {
|
|
553
568
|
break;
|
|
@@ -230,6 +230,7 @@ int osdp_phy_packet_init(struct osdp_pd *pd, uint8_t *buf, int max_len)
|
|
|
230
230
|
id = pd->cmd_id;
|
|
231
231
|
}
|
|
232
232
|
pkt->control = phy_get_next_seq_number(pd);
|
|
233
|
+
pd->phy_tx_seq = pkt->control & PKT_CONTROL_SQN;
|
|
233
234
|
if (is_pd_mode(pd) ||
|
|
234
235
|
(is_cp_mode(pd) && ISSET_FLAG(pd, PD_FLAG_CP_USE_CRC))) {
|
|
235
236
|
pkt->control |= PKT_CONTROL_CRC;
|
|
@@ -421,14 +422,31 @@ static int phy_validate_header(struct osdp_pd *pd, uint8_t *buf,
|
|
|
421
422
|
return OSDP_ERR_PKT_FMT;
|
|
422
423
|
}
|
|
423
424
|
|
|
424
|
-
pkt_len = (pkt->len_msb << 8) | pkt->len_lsb;
|
|
425
|
-
|
|
425
|
+
pkt_len = ((uint32_t)pkt->len_msb << 8) | pkt->len_lsb;
|
|
426
|
+
/**
|
|
427
|
+
* The mark byte is not counted in the packet's length field but it is
|
|
428
|
+
* buffered along with the packet, so it must be charged against the
|
|
429
|
+
* space the packet has to fit into. Validating pkt_len alone lets a
|
|
430
|
+
* peer declare a full-capacity packet behind a mark byte and overrun
|
|
431
|
+
* the buffer by one byte.
|
|
432
|
+
*/
|
|
433
|
+
if (pkt_len + mark > max_len ||
|
|
426
434
|
pkt_len < sizeof(struct osdp_packet_header) + 1 ||
|
|
427
435
|
(is_cp_mode(pd) && !(pkt->pd_address & 0x80)) ||
|
|
428
|
-
(is_pd_mode(pd) &&
|
|
436
|
+
(is_pd_mode(pd) && (pkt->pd_address & 0x80))) {
|
|
429
437
|
return OSDP_ERR_PKT_FMT;
|
|
430
438
|
}
|
|
431
439
|
|
|
440
|
+
/**
|
|
441
|
+
* Wrong-direction packets must be silently skipped; on a multi-drop
|
|
442
|
+
* bus, every PD sees every other PD's replies (along with commands to
|
|
443
|
+
* other PDs).
|
|
444
|
+
*/
|
|
445
|
+
if ((is_cp_mode(pd) && !(pkt->pd_address & 0x80)) ||
|
|
446
|
+
(is_pd_mode(pd) && (pkt->pd_address & 0x80))) {
|
|
447
|
+
return OSDP_ERR_PKT_SKIP;
|
|
448
|
+
}
|
|
449
|
+
|
|
432
450
|
return (int)(pkt_len + mark);
|
|
433
451
|
}
|
|
434
452
|
|
|
@@ -540,7 +558,7 @@ static int phy_check_packet(struct osdp_pd *pd, uint8_t *buf, int pkt_len)
|
|
|
540
558
|
/* validate CRC/checksum */
|
|
541
559
|
if (pkt->control & PKT_CONTROL_CRC) {
|
|
542
560
|
pkt_len -= 2; /* consume CRC */
|
|
543
|
-
cur = (buf[pkt_len + 1] << 8) | buf[pkt_len];
|
|
561
|
+
cur = ((uint32_t)buf[pkt_len + 1] << 8) | buf[pkt_len];
|
|
544
562
|
comp = osdp_compute_crc16(buf, pkt_len);
|
|
545
563
|
if (comp != cur) {
|
|
546
564
|
LOG_ERR("Invalid crc 0x%04x/0x%04x", comp, cur);
|
|
@@ -898,10 +916,14 @@ void osdp_phy_state_reset(struct osdp_pd *pd, bool is_error)
|
|
|
898
916
|
pd->packet_buf = pd->packet_buf_store;
|
|
899
917
|
if (is_error) {
|
|
900
918
|
pd->phy_retry_count = 0;
|
|
919
|
+
pd->phy_tx_seq = 0;
|
|
901
920
|
phy_reset_seq_number(pd);
|
|
902
921
|
if (pd->channel.flush) {
|
|
903
922
|
pd->channel.flush(pd->channel.data);
|
|
904
923
|
}
|
|
924
|
+
#ifndef OPT_OSDP_RX_ZERO_COPY
|
|
925
|
+
osdp_rb_reset(pd->rx.rb);
|
|
926
|
+
#endif
|
|
905
927
|
}
|
|
906
928
|
}
|
|
907
929
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|