Exemple #1
0
/* Allocate a new Npfcall to "receive" raw data from fc->pkt.
 */
static Npfcall *
_rcv_buf (Npfcall *fc, int type, const char *fun)
{
    Npfcall *fc2;
    char s[256];

    printf ("%s(%d): %d\n", fun, type, fc->size);
    np_set_tag (fc, 42);

    /* see conn.c:np_conn_new_incall () */
    if (!(fc2 = malloc (sizeof (*fc2) + TEST_MSIZE)))
        msg_exit ("out of memory");
    fc2->pkt = (u8 *)fc2 + sizeof (*fc2);

    /* see conn.c::np_conn_read_proc */
    memcpy (fc2->pkt, fc->pkt, fc->size);
    if (!np_deserialize (fc2))
        msg_exit ("np_deserialize error in %s", fun);

    /* check a few things */
    if (fc->type != type)
        msg_exit ("incorrect type in %s", fun);
    if (fc->size != fc2->size)
        msg_exit ("size mismatch in %s", fun);
    if (fc->type != fc2->type)
        msg_exit ("type mismatch in %s", fun);

    np_snprintfcall (s, sizeof (s), fc);
    printf ("%s\n", s);

    return fc2;
}
Exemple #2
0
static void
_debug_trace (Npsrv *srv, Npfcall *fc)
{
	char s[512];

	np_snprintfcall(s, sizeof (s), fc);
	np_logmsg(srv, "%s", s);
}
Exemple #3
0
static char *
_get_one_request (char **sp, int *lp, Npreq *req)
{
	char *uname = req->fid ? req->fid->user->uname : "-";
	char *aname = req->fid && req->fid->aname ? req->fid->aname : "-";
	char reqstr[40];

	np_snprintfcall (reqstr, sizeof (reqstr), req->tcall);
	if (aspf (sp, lp, "%-10.10s %-10.10s %-10.10s %s...\n",
		 			np_conn_get_client_id (req->conn),
					aname, uname, reqstr) < 0) {
		np_uerror (ENOMEM);
		return NULL;
	}
	return *sp;
}
Exemple #4
0
static void
_debug_trace (Npsrv *srv, Npfcall *fc)
{
    if ((srv->flags & SRV_FLAGS_DEBUG_9PTRACE)) {
        char s[512];
        static struct timeval b = { 0, 0 };
        struct timeval a, c;

        np_snprintfcall(s, sizeof (s), fc);
        if ((srv->flags & SRV_FLAGS_DEBUG_TIMES)) {
            if (b.tv_sec == 0)
                (void)gettimeofday(&b, NULL);
            (void)gettimeofday(&a, NULL);
            timersub(&a, &b, &c);
            np_logmsg(srv, "[%lu.%-3lu] %s",
                      c.tv_sec, c.tv_usec/1000, s);
        } else
            np_logmsg(srv, "%s", s);
    }
}