commit - e8774f897331c13b183eab230279bad62d8068eb
commit + 83f6b305b66bda08e569781940a4098cdd60c0a0
blob - cad31417325f16acb78e589d5e3d209c5b1c8b56
blob + 4f9cfff38480a133a81294c411288fe1396eb26d
--- client.c
+++ client.c
#include "sandbox.h"
#include "utils.h"
-#define DEBUG_PACKETS 0
+#define DEBUG_PACKETS 1
STAILQ_HEAD(qidhead, qid) qids;
struct qid {
static void parse_message(const uint8_t *, size_t,
struct np_msg_header *, uint8_t **);
+static void np_write16(uint16_t);
static void np_header(uint32_t, uint8_t, uint16_t);
static void np_string(uint16_t, const char *);
static void np_qid(struct qid *);
err:
/* TODO: send a proper message to terminate the connection. */
fatalx("got invalid message");
+}
+
+static void
+np_write16(uint16_t x)
+{
+ x = htole16(x);
+ evbuffer_add(evb, &x, sizeof(x));
}
static void
{
int i;
- np_header(QIDSIZE * nwqid, Rwalk, tag);
-
+ /* two bytes for the counter */
+ np_header(2 + QIDSIZE * nwqid, Rwalk, tag);
+ np_write16(nwqid);
for (i = 0; i < nwqid; ++i)
np_qid(wqid + i);
*/
if (nf == NULL) {
- if ((nf = new_fid(f->qid, newfid)))
- fatal("new_fid");
+ if ((nf = new_fid(f->qid, newfid)) == NULL)
+ fatal("new_fid duplication");
}
np_walk(hdr->tag, 1, f->qid);