libosdp 3.2.3__tar.gz → 3.2.6__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.3 → libosdp-3.2.6}/PKG-INFO +6 -6
- {libosdp-3.2.3 → libosdp-3.2.6}/README.md +4 -4
- {libosdp-3.2.3 → libosdp-3.2.6}/libosdp.egg-info/PKG-INFO +6 -6
- {libosdp-3.2.3 → libosdp-3.2.6}/setup.py +2 -2
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_common.h +5 -5
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_config.h +4 -4
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_cp.c +6 -4
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_diag.c +1 -1
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_file.c +22 -2
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_pd.c +28 -13
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_phy.c +27 -6
- {libosdp-3.2.3 → libosdp-3.2.6}/MANIFEST.in +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/libosdp.egg-info/SOURCES.txt +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/libosdp.egg-info/dependency_links.txt +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/libosdp.egg-info/top_level.txt +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/osdp/__init__.py +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/osdp/channel.py +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/osdp/constants.py +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/osdp/control_panel.py +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/osdp/helpers.py +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/osdp/key_store.py +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/osdp/peripheral_device.py +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/pyproject.toml +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/setup.cfg +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/include/osdp.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/include/osdp_export.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/python/osdp_sys/base.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/python/osdp_sys/cp.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/python/osdp_sys/data.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/python/osdp_sys/module.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/python/osdp_sys/module.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/python/osdp_sys/pd.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/python/osdp_sys/utils.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/crypto/tinyaes.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/crypto/tinyaes_src.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/crypto/tinyaes_src.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_common.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_diag.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_file.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/src/osdp_sc.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/assert.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/crc16.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/disjoint_set.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/list.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/logger.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/pcap_gen.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/queue.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/slab.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/include/utils/utils.h +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/src/crc16.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/src/disjoint_set.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/src/list.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/src/logger.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/src/pcap_gen.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/vendor/utils/src/queue.c +0 -0
- {libosdp-3.2.3 → libosdp-3.2.6}/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.6
|
|
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.6
|
|
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.6"
|
|
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",
|
|
@@ -492,9 +492,9 @@ void osdp_sc_teardown(struct osdp_pd *pd);
|
|
|
492
492
|
|
|
493
493
|
static inline uint16_t bread_u16_le(const uint8_t *buf, int *pos)
|
|
494
494
|
{
|
|
495
|
-
|
|
496
|
-
v |= (
|
|
497
|
-
return v;
|
|
495
|
+
uint32_t v = buf[(*pos)++];
|
|
496
|
+
v |= (uint32_t)buf[(*pos)++] << 8;
|
|
497
|
+
return (uint16_t)v;
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
static inline uint32_t bread_u24_le(const uint8_t *buf, int *pos)
|
|
@@ -546,9 +546,9 @@ static inline void bwrite_u32_le(uint32_t val, uint8_t *buf, int *len)
|
|
|
546
546
|
|
|
547
547
|
static inline uint16_t bread_u16_be(const uint8_t *buf, int *pos)
|
|
548
548
|
{
|
|
549
|
-
|
|
549
|
+
uint32_t v = (uint32_t)buf[(*pos)++] << 8;
|
|
550
550
|
v |= buf[(*pos)++];
|
|
551
|
-
return v;
|
|
551
|
+
return (uint16_t)v;
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
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.6"
|
|
15
15
|
#define PROJECT_NAME "libosdp"
|
|
16
|
-
#define GIT_BRANCH "
|
|
17
|
-
#define GIT_REV "
|
|
18
|
-
#define GIT_TAG ""
|
|
16
|
+
#define GIT_BRANCH "detached"
|
|
17
|
+
#define GIT_REV "v3.2.6-0-g9ff9013"
|
|
18
|
+
#define GIT_TAG "v3.2.6"
|
|
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 */
|
|
@@ -573,7 +573,8 @@ static int cp_decode_response(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
573
573
|
event.type = OSDP_EVENT_KEYPRESS;
|
|
574
574
|
event.keypress.reader_no = buf[pos++];
|
|
575
575
|
event.keypress.length = buf[pos++];
|
|
576
|
-
if ((len - REPLY_KEYPAD_DATA_LEN)
|
|
576
|
+
if (event.keypress.length != (len - REPLY_KEYPAD_DATA_LEN) ||
|
|
577
|
+
event.keypress.length > OSDP_EVENT_KEYPRESS_MAX_DATALEN) {
|
|
577
578
|
break;
|
|
578
579
|
}
|
|
579
580
|
memcpy(event.keypress.data, buf + pos, event.keypress.length);
|
|
@@ -591,7 +592,8 @@ static int cp_decode_response(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
591
592
|
event.cardread.length = bread_u16_le(buf, &pos);
|
|
592
593
|
event.cardread.direction = 0; /* un-specified */
|
|
593
594
|
t = (event.cardread.length + 7) / 8; /* len: bytes */
|
|
594
|
-
if (t != (len - REPLY_RAW_DATA_LEN)
|
|
595
|
+
if (t != (len - REPLY_RAW_DATA_LEN) ||
|
|
596
|
+
t > OSDP_EVENT_CARDREAD_MAX_DATALEN) {
|
|
595
597
|
break;
|
|
596
598
|
}
|
|
597
599
|
memcpy(event.cardread.data, buf + pos, t);
|
|
@@ -605,7 +607,7 @@ static int cp_decode_response(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
605
607
|
* for deprecation in v2.2.2. To avoid confusions, we will just
|
|
606
608
|
* ignore it here.
|
|
607
609
|
*
|
|
608
|
-
* See: https://github.com/
|
|
610
|
+
* See: https://github.com/osdp-dev/libosdp/issues/206
|
|
609
611
|
*/
|
|
610
612
|
LOG_WRN("Ignoring deprecated response osdp_FMT");
|
|
611
613
|
ret = OSDP_CP_ERR_NONE;
|
|
@@ -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)
|
|
@@ -218,7 +218,12 @@ int osdp_file_cmd_tx_decode(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
218
218
|
xfer.offset = bread_u32_le(buf, &pos);
|
|
219
219
|
xfer.length = bread_u16_le(buf, &pos);
|
|
220
220
|
assert(pos == sizeof(struct osdp_cmd_file_xfer));
|
|
221
|
-
|
|
221
|
+
|
|
222
|
+
if (xfer.length > (uint16_t)(len - FILE_TRANSFER_HEADER_SIZE)) {
|
|
223
|
+
LOG_ERR("TX_Decode: declared length %d exceeds %d bytes present",
|
|
224
|
+
xfer.length, len - FILE_TRANSFER_HEADER_SIZE);
|
|
225
|
+
return -1;
|
|
226
|
+
}
|
|
222
227
|
|
|
223
228
|
if (f->state == OSDP_FILE_IDLE || f->state == OSDP_FILE_DONE) {
|
|
224
229
|
if (pd->command_callback) {
|
|
@@ -253,6 +258,15 @@ int osdp_file_cmd_tx_decode(struct osdp_pd *pd, uint8_t *buf, int len)
|
|
|
253
258
|
return -1;
|
|
254
259
|
}
|
|
255
260
|
|
|
261
|
+
/* Bound the wire offset and length against the declared file size
|
|
262
|
+
* before handing them to the write handler, so a peer cannot make it
|
|
263
|
+
* write outside the file it announced. */
|
|
264
|
+
if ((uint64_t)xfer.offset + xfer.length > f->size) {
|
|
265
|
+
LOG_ERR("TX_Decode: chunk off:%d len:%d exceeds size:%d",
|
|
266
|
+
xfer.offset, xfer.length, f->size);
|
|
267
|
+
return -1;
|
|
268
|
+
}
|
|
269
|
+
|
|
256
270
|
f->length = f->ops.write(f->ops.arg, data, xfer.length, xfer.offset);
|
|
257
271
|
if (f->length != xfer.length) {
|
|
258
272
|
LOG_ERR("TX_Decode: user write failed! rc:%d len:%d off:%d",
|
|
@@ -296,7 +310,13 @@ int osdp_file_cmd_stat_build(struct osdp_pd *pd, uint8_t *buf, int max_len)
|
|
|
296
310
|
}
|
|
297
311
|
LOG_DBG("length: %d offset: %d size: %d", f->length, f->offset, f->size);
|
|
298
312
|
f->length = 0;
|
|
299
|
-
|
|
313
|
+
|
|
314
|
+
/*
|
|
315
|
+
* Don't assert f->offset:w <= f->size: a legitimately retransmitted
|
|
316
|
+
* chunk (lost FTSTAT) re-drives the running offset and can transiently
|
|
317
|
+
* overshoot. The write-side bound in tx_decode is the real guard.
|
|
318
|
+
*/
|
|
319
|
+
|
|
300
320
|
if (f->offset == f->size) { /* EOF */
|
|
301
321
|
if (f->ops.close(f->ops.arg) < 0) {
|
|
302
322
|
LOG_ERR("Stat_Build: Close failed!");
|
|
@@ -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;
|
|
@@ -421,7 +421,7 @@ static int phy_validate_header(struct osdp_pd *pd, uint8_t *buf,
|
|
|
421
421
|
return OSDP_ERR_PKT_FMT;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
-
pkt_len = (pkt->len_msb << 8) | pkt->len_lsb;
|
|
424
|
+
pkt_len = ((uint32_t)pkt->len_msb << 8) | pkt->len_lsb;
|
|
425
425
|
if (pkt_len > max_len ||
|
|
426
426
|
pkt_len < sizeof(struct osdp_packet_header) + 1 ||
|
|
427
427
|
(is_cp_mode(pd) && !(pkt->pd_address & 0x80)) ||
|
|
@@ -466,6 +466,7 @@ static bool phy_rescan_packet_buf(struct osdp_pd *pd)
|
|
|
466
466
|
static int phy_check_header(struct osdp_pd *pd)
|
|
467
467
|
{
|
|
468
468
|
int ret, len;
|
|
469
|
+
unsigned long need;
|
|
469
470
|
uint8_t cur_byte = 0, prev_byte = 0;
|
|
470
471
|
uint8_t *buf = pd->packet_buf;
|
|
471
472
|
|
|
@@ -491,10 +492,19 @@ static int phy_check_header(struct osdp_pd *pd)
|
|
|
491
492
|
prev_byte = cur_byte;
|
|
492
493
|
}
|
|
493
494
|
|
|
494
|
-
/*
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
495
|
+
/*
|
|
496
|
+
* Found start of a new packet; top up only the header bytes still
|
|
497
|
+
* missing. On re-entry with a partially collected header, popping a
|
|
498
|
+
* fixed sizeof(header)-1 bytes would overshoot packet_buf_len past the
|
|
499
|
+
* packet and wedge the framer (see osdp_phy_check_packet()).
|
|
500
|
+
*/
|
|
501
|
+
need = sizeof(struct osdp_packet_header) +
|
|
502
|
+
(buf[0] == OSDP_PKT_MARK ? 1 : 0);
|
|
503
|
+
if (pd->packet_buf_len < need) {
|
|
504
|
+
len = osdp_rb_pop_buf(pd->rx.rb, buf + pd->packet_buf_len,
|
|
505
|
+
need - pd->packet_buf_len);
|
|
506
|
+
pd->packet_buf_len += len;
|
|
507
|
+
}
|
|
498
508
|
|
|
499
509
|
/* Validate header using shared function */
|
|
500
510
|
ret = phy_validate_header(pd, buf, pd->packet_buf_len, OSDP_PACKET_BUF_SIZE);
|
|
@@ -530,7 +540,7 @@ static int phy_check_packet(struct osdp_pd *pd, uint8_t *buf, int pkt_len)
|
|
|
530
540
|
/* validate CRC/checksum */
|
|
531
541
|
if (pkt->control & PKT_CONTROL_CRC) {
|
|
532
542
|
pkt_len -= 2; /* consume CRC */
|
|
533
|
-
cur = (buf[pkt_len + 1] << 8) | buf[pkt_len];
|
|
543
|
+
cur = ((uint32_t)buf[pkt_len + 1] << 8) | buf[pkt_len];
|
|
534
544
|
comp = osdp_compute_crc16(buf, pkt_len);
|
|
535
545
|
if (comp != cur) {
|
|
536
546
|
LOG_ERR("Invalid crc 0x%04x/0x%04x", comp, cur);
|
|
@@ -672,6 +682,17 @@ int osdp_phy_check_packet(struct osdp_pd *pd)
|
|
|
672
682
|
}
|
|
673
683
|
|
|
674
684
|
if (!zero_copy) {
|
|
685
|
+
/*
|
|
686
|
+
* Guard the unsigned subtraction below: if we ever hold more
|
|
687
|
+
* bytes than the header declared, the wrap-around would ask for
|
|
688
|
+
* a huge (negative when cast to int) count and wedge the framer.
|
|
689
|
+
* Treat it as a malformed frame so the link resets and recovers.
|
|
690
|
+
*/
|
|
691
|
+
if (pd->packet_buf_len > pd->packet_len) {
|
|
692
|
+
LOG_ERR("Buffered %lu bytes exceeds packet length %lu",
|
|
693
|
+
pd->packet_buf_len, pd->packet_len);
|
|
694
|
+
return OSDP_ERR_PKT_FMT;
|
|
695
|
+
}
|
|
675
696
|
/* Traditional: collect remaining packet bytes from ring buffer */
|
|
676
697
|
ret = osdp_rb_pop_buf(pd->rx.rb,
|
|
677
698
|
pd->packet_buf + pd->packet_buf_len,
|
|
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
|