search for: be16toh

Displaying 20 results from an estimated 75 matches for "be16toh".

Did you mean: le16toh
2023 Jun 20
1
[libnbd PATCH v4 4/4] internal: Refactor layout of replies in sbuf
...tates-reply-chunk.c b/generator/states-reply-chunk.c > index 94f3a8ae..c42741fb 100644 > --- a/generator/states-reply-chunk.c > +++ b/generator/states-reply-chunk.c > @@ -50,9 +50,9 @@ REPLY.CHUNK_REPLY.START: > uint16_t flags, type; > uint32_t length; > > - flags = be16toh (h->sbuf.sr.structured_reply.flags); > - type = be16toh (h->sbuf.sr.structured_reply.type); > - length = be32toh (h->sbuf.sr.structured_reply.length); > + flags = be16toh (h->sbuf.reply.hdr.structured.flags); > + type = be16toh (h->sbuf.reply.hdr.structured.type); &gt...
2019 Jun 18
0
[libnbd PATCH 1/8] states: Add state for structured reply completion
...@@ -225,7 +225,6 @@ REPLY.STRUCTURED_REPLY.RECV_ERROR_TAIL: struct command_in_flight *cmd; - uint16_t flags; uint64_t handle; uint32_t error; uint64_t offset; @@ -234,7 +233,6 @@ switch (recv_into_rbuf (h)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; case 0: - flags = be16toh (h->sbuf.sr.structured_reply.flags); handle = be64toh (h->sbuf.sr.structured_reply.handle); error = be32toh (h->sbuf.sr.payload.error.error.error); type = be16toh (h->sbuf.sr.structured_reply.type); @@ -264,10 +262,7 @@ if (cmd->error == 0) cmd->error =...
2019 May 23
0
[PATCH libnbd 1/3] states: Factor out common code for setting export size and eflags.
...b6c9e 100644 --- a/generator/states-newstyle-opt-export-name.c +++ b/generator/states-newstyle-opt-export-name.c @@ -58,13 +58,13 @@ return 0; NEWSTYLE.OPT_EXPORT_NAME.CHECK_REPLY: - conn->h->exportsize = be64toh (conn->sbuf.export_name_reply.exportsize); - conn->h->eflags = be16toh (conn->sbuf.export_name_reply.eflags); - debug (conn->h, "exportsize: %" PRIu64 " eflags: 0x%" PRIx16, - conn->h->exportsize, conn->h->eflags); - if (conn->h->eflags == 0) { + uint64_t exportsize; + uint16_t eflags; + + exportsize = be64toh (...
2019 Jun 14
1
[libnbd PATCH] states: Validate error message size
...generator/states-reply-structured.c @@ -149,21 +149,69 @@ } REPLY.STRUCTURED_REPLY.RECV_ERROR: + uint32_t length, msglen; + switch (recv_into_rbuf (h)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; case 0: + length = be32toh (h->sbuf.sr.structured_reply.length); + msglen = be16toh (h->sbuf.sr.payload.error.len); + if (msglen > length - sizeof h->sbuf.sr.payload.error) { + SET_NEXT_STATE (%.DEAD); + set_error (0, "error message length too large"); + return -1; + } + /* We skip the human readable error for now. XXX */ h->rbu...
2019 Sep 16
1
[libnbd PATCH] states: Avoid magic number for h->tls
...quire' (2)"); return 0; } diff --git a/generator/states-newstyle.c b/generator/states-newstyle.c index c8f817e..b4f2b80 100644 --- a/generator/states-newstyle.c +++ b/generator/states-newstyle.c @@ -129,10 +129,10 @@ handle_reply_error (struct nbd_handle *h) h->gflags = be16toh (h->gflags); if ((h->gflags & NBD_FLAG_FIXED_NEWSTYLE) == 0 && - h->tls == 2) { + h->tls == LIBNBD_TLS_REQUIRE) { SET_NEXT_STATE (%.DEAD); set_error (ENOTSUP, "handshake: server is not fixed newstyle, " - "but handle TLS se...
2019 Aug 14
2
[libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...eply-structured.c index 2e327ce..58e83d4 100644 --- a/generator/states-reply-structured.c +++ b/generator/states-reply-structured.c @@ -295,7 +295,6 @@ } if (cmd->type == NBD_CMD_READ && cmd->cb.fn.chunk.callback) { int scratch = error; - uint16_t flags = be16toh (h->sbuf.sr.structured_reply.flags); /* Different from successful reads: inform the callback about the * current error rather than any earlier one. If the callback fails @@ -307,8 +306,6 @@ &scratch) == -1) if (cmd->error == 0)...
2023 Jun 09
4
[libnbd PATCH v4 0/4] Saner reply header layout
This was v3 patch 2/22, reworked to address the confusion about how a structured reply header is read in two pieces before getting to the payload portion. I'm still working on rebasing the rest of my v3 series (patches 1, 3-22) from other comments given, but this seemed independent enough that it's worth posting now rather than holding it up for the rest of the series. Eric Blake (4):
2012 Dec 06
2
[PATCH 0/2] Two build fixes for libldm
Two simple build fixes for libldm. Well, the first isn't a build fix as such, but a code improvement. Rich.
2019 Aug 15
0
Re: [libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...e83d4 100644 > --- a/generator/states-reply-structured.c > +++ b/generator/states-reply-structured.c > @@ -295,7 +295,6 @@ > } > if (cmd->type == NBD_CMD_READ && cmd->cb.fn.chunk.callback) { > int scratch = error; > - uint16_t flags = be16toh (h->sbuf.sr.structured_reply.flags); > > /* Different from successful reads: inform the callback about the > * current error rather than any earlier one. If the callback fails > @@ -307,8 +306,6 @@ > &scratch) == -1) >...
2019 May 23
5
[PATCH libnbd 0/3] Prevent some misuse of multi-conn.
Per recent discussion here: https://www.redhat.com/archives/libguestfs/2019-May/thread.html#00175
2019 Apr 23
0
[nbdkit PATCH 6/7] nbd: Implement NBD_OPT_GO client request
...se NBD_REP_INFO: + /* Parse payload, but ignore all except NBD_INFO_EXPORT */ + if (reply.replylen < 2) { + nbdkit_error ("NBD_REP_INFO reply too short"); + free (buffer); + return -1; + } + memcpy (&info, buffer, sizeof info); + info = be16toh (info); + switch (info) { + case NBD_INFO_EXPORT: + if (reply.replylen != sizeof reply_export) { + nbdkit_error ("NBD_INFO_EXPORT reply wrong size"); + free (buffer); + return -1; + } + memcpy (&reply_export, buffer, sizeof rep...
2019 Aug 13
0
[PATCH libnbd 4/4] lib: Add CALL_CALLBACK macro.
...0, offset, LIBNBD_READ_ERROR, + &scratch) == -1) if (cmd->error == 0) cmd->error = scratch; if (flags & NBD_REPLY_FLAG_DONE) @@ -392,10 +392,9 @@ int error = cmd->error; uint16_t flags = be16toh (h->sbuf.sr.structured_reply.flags); - if (cmd->cb.fn.chunk.callback (cmd->cb.fn.chunk.user_data, - cmd->data + (offset - cmd->offset), - length - sizeof offset, offset, -...
2019 May 23
2
[PATCH libnbd] api: Get rid of nbd_connection.
This isn't quite finished because not all of the tests or examples have been updated, but it demonstrates an idea: Should we forget about the concept of having multiple connections managed under a single handle? In this patch there is a single ‘struct nbd_handle *’ which manages a single state machine and connection (and therefore no nbd_connection). To connect to a multi-conn server you must
2019 Apr 23
12
[nbdkit PATCH 0/7] Implement structured replies in nbd plugin
I'm hoping to implement .extents for the nbd plugin; this is a prerequisite. I'm not sure about patch 3 - if we like it, I'll squash it to 2, if we don't, I think we are okay just dropping it. I'm also wondering if we have to worry about malicious plugins that don't populate the entire .pread buffer in an effort to get nbdkit to expose portions of the heap; my patch 7 loses
2018 Aug 06
3
[PATCH nbdkit v2] protocol: Implement NBD_OPT_GO.
There's no substantial difference over v1, I simply fixed a few whitespace issues, moved one struct around and tidied up the comments. Rich.
2019 May 30
0
[nbdkit PATCH 3/4] nbd: Use libnbd 0.1
...nbdkit_error ("structured response without negotiation"); - return nbdplug_mark_dead (h); - } - if (read_full (h->fd, sizeof rep.simple + (char *) &rep, - sizeof rep - sizeof rep.simple)) - return nbdplug_mark_dead (h); - rep.structured.flags = be16toh (rep.structured.flags); - rep.structured.type = be16toh (rep.structured.type); - rep.structured.length = be32toh (rep.structured.length); - nbdkit_debug ("received structured reply %s for cookie %#" PRIx64 - ", payload length %" PRId32, -...
2019 Jun 25
0
Re: [libnbd PATCH] states: Never block state machine inside REPLY
...> switch (recv_into_rbuf (h)) { > case -1: SET_NEXT_STATE (%.DEAD); return -1; > + case 1: > + save_reply_state (h); > + SET_NEXT_STATE (%.READY); > + return 0; > case 0: > length = be32toh (h->sbuf.sr.structured_reply.length); > msglen = be16toh (h->sbuf.sr.payload.error.error.len); > @@ -176,6 +184,10 @@ > > switch (recv_into_rbuf (h)) { > case -1: SET_NEXT_STATE (%.DEAD); return -1; > + case 1: > + save_reply_state (h); > + SET_NEXT_STATE (%.READY); > + return 0; > case 0: > lengt...
2019 Apr 23
1
Re: [nbdkit PATCH 7/7] nbd: Implement structured replies
...tructured response without negotiation"); > + return nbd_mark_dead (h); > + } > + if (read_full (h->fd, sizeof rep.simple + (char *) &rep, > + sizeof rep - sizeof rep.simple)) > + return nbd_mark_dead (h); > + rep.structured.flags = be16toh (rep.structured.flags); > + rep.structured.type = be16toh (rep.structured.type); > + rep.structured.length = be32toh (rep.structured.length); > + nbdkit_debug ("received structured reply %s for cookie %#" PRIx64 > + ", payload length %" PRId...
2019 Jun 12
0
[nbdkit PATCH v3 3/5] nbd: Use libnbd 0.1.3+
...nbdkit_error ("structured response without negotiation"); - return nbdplug_mark_dead (h); - } - if (read_full (h->fd, sizeof rep.simple + (char *) &rep, - sizeof rep - sizeof rep.simple)) - return nbdplug_mark_dead (h); - rep.structured.flags = be16toh (rep.structured.flags); - rep.structured.type = be16toh (rep.structured.type); - rep.structured.length = be32toh (rep.structured.length); - nbdkit_debug ("received structured reply %s for cookie %#" PRIx64 - ", payload length %" PRId32, -...
2020 Mar 19
1
[nbdkit PATCH] nbd: Drop nbd-standalone fallback
...{ - nbdkit_error ("structured response without negotiation"); - return nbd_mark_dead (h); - } - if (read_full (h->fd, sizeof rep.simple + (char *) &rep, - sizeof rep - sizeof rep.simple)) - return nbd_mark_dead (h); - rep.structured.flags = be16toh (rep.structured.flags); - rep.structured.type = be16toh (rep.structured.type); - rep.structured.length = be32toh (rep.structured.length); - nbdkit_debug ("received structured reply %s for cookie %#" PRIx64 - ", payload length %" PRId32, -...