search for: be32toh

Displaying 20 results from an estimated 121 matches for "be32toh".

Did you mean: le32toh
2019 Jun 14
0
[libnbd PATCH 5/7] states: Factor out NBD_REP payload prep
...- const size_t maxpayload = sizeof h->sbuf.or.payload; - switch (recv_into_rbuf (h)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; case 0: - /* Read the following payload if it is short enough to fit in the - * static buffer. If it's too long, skip it. - */ - len = be32toh (h->sbuf.or.option_reply.replylen); - if (len <= maxpayload) - h->rbuf = &h->sbuf.or.payload; - else - h->rbuf = NULL; - h->rlen = len; + if (prepare_for_reply_payload (h, NBD_OPT_GO) == -1) { + SET_NEXT_STATE (%.DEAD); + return -1; + }...
2023 Jun 20
1
[libnbd PATCH v4 4/4] internal: Refactor layout of replies in sbuf
...ply.hdr; > + h->rlen = sizeof h->sbuf.reply.hdr.simple; > > r = h->sock->ops->recv (h, h->sock, h->rbuf, h->rlen); > if (r == -1) { > @@ -122,22 +125,22 @@ REPLY.CHECK_REPLY_MAGIC: > uint32_t magic; > uint64_t cookie; > > - magic = be32toh (h->sbuf.simple_reply.magic); > + magic = be32toh (h->sbuf.reply.hdr.magic); > if (magic == NBD_SIMPLE_REPLY_MAGIC) { > SET_NEXT_STATE (%SIMPLE_REPLY.START); > } > else if (magic == NBD_STRUCTURED_REPLY_MAGIC) { > - /* We've only read the bytes that fil...
2019 Jun 14
10
[libnbd PATCH 0/7] state machine refactoring
I'm still playing with ideas on how to split rstate from wstate (so that we can send a request without waiting for POLLIN to complete a pending reply), but this is some preliminary refactoring I found useful. I also fixed a couple of bugs while in the area (already pushed). There's a question of whether we want nbd_handle to be nearly 5k, or if we should instead keep it small and add one
2015 Feb 12
0
Re: [PATCH 1/3] macosx: Includes/defines for byteswap operations
...3 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/src/inspect-apps.c b/src/inspect-apps.c > index 20cf00a..8fbae9c 100644 > --- a/src/inspect-apps.c > +++ b/src/inspect-apps.c > @@ -35,11 +35,22 @@ > #include <sys/endian.h> > #endif > > -/* be32toh is usually a macro definend in <endian.h>, but it might be > +/* be32toh is usually a macro defined in <endian.h>, but it might be > * a function in some system so check both, and if neither is defined > * then define be32toh for RHEL 5. > */ > #if !defined(HAVE_BE...
2015 Feb 12
8
[PATCH 1/3] macosx: Includes/defines for byteswap operations
...c | 6 ++++++ src/journal.c | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/inspect-apps.c b/src/inspect-apps.c index 20cf00a..8fbae9c 100644 --- a/src/inspect-apps.c +++ b/src/inspect-apps.c @@ -35,11 +35,22 @@ #include <sys/endian.h> #endif -/* be32toh is usually a macro definend in <endian.h>, but it might be +/* be32toh is usually a macro defined in <endian.h>, but it might be * a function in some system so check both, and if neither is defined * then define be32toh for RHEL 5. */ #if !defined(HAVE_BE32TOH) && !define...
2019 Apr 23
0
[nbdkit PATCH 7/7] nbd: Implement structured replies
...= false; /* Whether to read or memset on structured read */ *fd = -1; - if (read_full (h->fd, &rep, sizeof rep) < 0) + /* magic and handle overlap between simple and structured replies */ + if (read_full (h->fd, &rep, sizeof rep.simple)) return nbd_mark_dead (h); - if (be32toh (rep.magic) != NBD_SIMPLE_REPLY_MAGIC) + switch (be32toh (rep.simple.magic)) { + case NBD_SIMPLE_REPLY_MAGIC: + nbdkit_debug ("received simple reply for cookie %#" PRIx64 ", status %s", + rep.simple.handle, + name_of_nbd_error(be32toh (rep....
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):
2019 Jun 18
0
[libnbd PATCH 2/8] states: Consolidate search for current reply's command
...12536e0 100644 --- a/generator/states-reply-simple.c +++ b/generator/states-reply-simple.c @@ -20,24 +20,15 @@ /* STATE MACHINE */ { REPLY.SIMPLE_REPLY.START: - struct command_in_flight *cmd; + struct command_in_flight *cmd = h->reply_cmd; uint32_t error; uint64_t handle; error = be32toh (h->sbuf.simple_reply.error); handle = be64toh (h->sbuf.simple_reply.handle); - /* Find the command amongst the commands in flight. */ - for (cmd = h->cmds_in_flight; cmd != NULL; cmd = cmd->next) { - if (cmd->handle == handle) - break; - } - if (cmd == NULL) { - S...
2012 Oct 29
1
[PATCH] lib: update inspect_list_applications to return all installed RPMs (RHBZ#859885)
...; + + /* This function parses the RPM header structure to pull out various + * tag strings (version, release, arch, etc.). For more detail on the + * header format, see: + * http://www.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html#S2-RPM-FILE-FORMAT-HEADER + */ + + num_fields = be32toh (*(uint32_t *) header_start); + store = header_start + 8 + (16 * num_fields); + + while (cursor < store && cursor < header_start + header_len) { + if (be32toh (*(uint32_t *) cursor) == tag){ + offset = be32toh(*(uint32_t *) (cursor + 8)); + return safe_strdup(g, store +...
2019 Mar 08
1
[PATCH nbdkit] server: Implement minimal implementation of set/list metadata contexts.
...optname, what); + + if (send_newstyle_option_reply (conn, option, NBD_REP_ERR_INVALID) + == -1) + return -1; + continue; + } + + /* Discard the export name. */ + memcpy (&exportnamelen, &data[0], 4); + exportnamelen = be32toh (exportnamelen); + opt_index = 4 + exportnamelen; + + /* Read the number of queries. */ + what = "reading number of queries"; + if (opt_index+4 > optlen) + goto opt_meta_invalid_option_len; + memcpy (&nr_queries, &data[opt_index], 4);...
2019 Jun 25
0
Re: [libnbd PATCH] states: Never block state machine inside REPLY
...(%CHECK); > } > return 0; > @@ -154,6 +158,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: > 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_...
2019 Apr 25
6
[nbdkit PATCH v2 0/5] structured replies/.extents for nbd plugin
Updated based on other changes that have happened in the meantime: - rely more on cleanup.h (throughout) - split structured read for easier review (patch 2 and 3 were combined in v1) - rely on nbdkit not leaking a server's partial answer (patch 3) - add tests (patch 5) - other bug fixes I found while testing it - drop EOVERFLOW patch for now; it will be separate once upstream NBD protocol
2019 Jun 19
4
[libnbd PATCH] states: Never block state machine inside REPLY
..._STATE (%.READY); + return 0; case 0: SET_NEXT_STATE (%CHECK); } return 0; @@ -154,6 +158,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: 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...
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
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 Jun 18
0
[libnbd PATCH 1/8] states: Add state for structured reply completion
...4_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 = nbd_internal_errno_of_nbd_error (error); - if (flags & NBD_REPLY_FLAG_DONE) - SET_NEXT_STATE (%^FINISH_COMMAND)...
2019 Jun 14
1
[libnbd PATCH] states: Validate error message size
...6d58742 100644 --- a/generator/states-reply-structured.c +++ b/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; + } + /*...
2019 May 30
0
[nbdkit PATCH 3/4] nbd: Use libnbd 0.1
...unk */ - bool zero = false; /* if len, whether to read or memset */ - uint16_t errlen; - - *trans_out = NULL; - /* magic and handle overlap between simple and structured replies */ - if (read_full (h->fd, &rep, sizeof rep.simple)) - return nbdplug_mark_dead (h); - rep.simple.magic = be32toh (rep.simple.magic); - switch (rep.simple.magic) { - case NBD_SIMPLE_REPLY_MAGIC: - nbdkit_debug ("received simple reply for cookie %#" PRIx64 ", status %s", - rep.simple.handle, - name_of_nbd_error (be32toh (rep.simple.error))); - error...
2019 Mar 08
0
Re: [PATCH nbdkit] Minimal implementation of NBD Structured Replies.
...struct simple_reply rep; > struct transaction *trans; > void *buf; > uint32_t count; > @@ -353,7 +353,7 @@ nbd_reply_raw (struct handle *h, int *fd) > *fd = -1; > if (read_full (h->fd, &rep, sizeof rep) < 0) > return nbd_mark_dead (h); > - if (be32toh (rep.magic) != NBD_REPLY_MAGIC) > + if (be32toh (rep.magic) != NBD_SIMPLE_REPLY_MAGIC) > return nbd_mark_dead (h); > nbdkit_debug ("received reply for cookie %#" PRIx64 ", status %s", > rep.handle, name_of_nbd_error(be32toh (rep.error))); T...
2019 Jun 12
0
[nbdkit PATCH v3 3/5] nbd: Use libnbd 0.1.3+
...unk */ - bool zero = false; /* if len, whether to read or memset */ - uint16_t errlen; - - *trans_out = NULL; - /* magic and handle overlap between simple and structured replies */ - if (read_full (h->fd, &rep, sizeof rep.simple)) - return nbdplug_mark_dead (h); - rep.simple.magic = be32toh (rep.simple.magic); - switch (rep.simple.magic) { - case NBD_SIMPLE_REPLY_MAGIC: - nbdkit_debug ("received simple reply for cookie %#" PRIx64 ", status %s", - rep.simple.handle, - name_of_nbd_error (be32toh (rep.simple.error))); - error...