diff options
author | Peter Delevoryas <pdel@fb.com> | 2022-05-13 20:12:35 -0700 |
---|---|---|
committer | Peter Delevoryas <pdel@fb.com> | 2022-05-18 21:14:14 -0700 |
commit | ec7f20e8b634d4957258969ec82c7b3fe3802705 (patch) | |
tree | aa73bb49a56aef4c899f1d7311510df8e5d5cee3 /src | |
parent | da3afd3ccdde4f2317f3a73e31c879c0a2847a25 (diff) | |
download | slirp-ec7f20e8b634d4957258969ec82c7b3fe3802705.zip slirp-ec7f20e8b634d4957258969ec82c7b3fe3802705.tar.gz slirp-ec7f20e8b634d4957258969ec82c7b3fe3802705.tar.bz2 |
ncsi: Use response header for payload length
In the Linux NC-SI driver[1], each response's length is validated with a
statically declared payload length, _unless_ it's an OEM command or some
more complicated NC-SI packet that you can't determine the length of just
from the "type" field, in which case it just uses the length provided by the
response's header.
To support OEM response handlers without requiring too many modifications we
can make the default payload length use the value specified in the handler
table, and then allow OEM handlers to override the length by modifying the
"length" in the response header within the handler implementation.
[1] https://github.com/torvalds/linux/blob/ec7f49619d8ee13e108740c82f942cd401b989e9/net/ncsi/ncsi-rsp.c#L1215-L1220
Signed-off-by: Peter Delevoryas <pdel@fb.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/ncsi.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -195,7 +195,7 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) if (handler->handler) { handler->handler(slirp, nh, rnh); } - ncsi_rsp_len += handler->payload; + ncsi_rsp_len += ntohs(rnh->common.length); } else { rnh->common.length = 0; rnh->code = htons(NCSI_PKT_RSP_C_UNAVAILABLE); |