コード例 #1
0
ファイル: packets.c プロジェクト: throckmortonsign/lightning
static void queue_raw_pkt(struct peer *peer, Pkt *pkt)
{
	size_t n = tal_count(peer->outpkt);
	tal_resize(&peer->outpkt, n+1);
	peer->outpkt[n] = pkt;

	log_debug(peer->log, "Queued pkt %s", pkt_name(pkt->pkt_case));

	/* In case it was waiting for output. */
	io_wake(peer);
}
コード例 #2
0
ファイル: print.c プロジェクト: NeuronRobotics/c-bowler-pc
/*
 * Query and display information about the namespaces.
 */
void dyio_print_namespaces(dyio_t *d)
{
    int query_type, resp_type, num_args, num_resp;
    int num_spaces, ns, num_methods, m;
    uint8_t query[2], *args, *resp;
    char rpc[5];

    /* Query the number of namespaces. */
    dyio_call(d, PKT_GET, ID_BCS_CORE, "_nms", 0, 0);
    if (d->reply_len < 1) {
        printf("dyio-info: incorrect _nms reply: length %u bytes\n", d->reply_len);
        exit(-1);
    }
    num_spaces = d->reply[0];

    /* Print info about every namespace. */
    for (ns=0; ns<num_spaces; ns++) {
        query[0] = ns;
        dyio_call(d, PKT_GET, ID_BCS_CORE, "_nms", query, 1);
        if (d->reply_len < 1) {
            printf("dyio-info: incorrect _nms[%u] reply\n", ns);
            exit(-1);
        }
        printf("Namespace %u: %s\n", ns, d->reply);

        /* Print available methods. */
        num_methods = 1;
        for (m=0; m<num_methods; m++) {
            /* Get method name (RPC). */
            query[0] = ns;
            query[1] = m;
            dyio_call(d, PKT_GET, ID_BCS_RPC, "_rpc", query, 2);
            if (d->reply_len < 7) {
                printf("dyio-info: incorrect _rpc[%u] reply\n", ns);
                exit(-1);
            }
            num_methods = d->reply[2];
            rpc[0] = d->reply[3];
            rpc[1] = d->reply[4];
            rpc[2] = d->reply[5];
            rpc[3] = d->reply[6];
            rpc[4] = 0;

            /* Get method args. */
            query[0] = ns;
            query[1] = m;
            dyio_call(d, PKT_GET, ID_BCS_RPC, "args", query, 2);
            if (d->reply_len < 6) {
                printf("dyio-info: incorrect args[%u] reply\n", ns);
                exit(-1);
            }
            query_type = d->reply[2];
            num_args = d->reply[3];
            args = &d->reply[4];
            resp_type = d->reply[4 + num_args];
            num_resp = d->reply[5 + num_args];
            resp = &d->reply[6 + num_args];

            printf("    %s %s(", rpc, pkt_name(query_type));
            print_args(num_args, args);
            printf(") -> %s(", pkt_name(resp_type));
            print_args(num_resp, resp);
            printf(")\n");
        }
    }
}
コード例 #3
0
ファイル: packets.c プロジェクト: throckmortonsign/lightning
Pkt *pkt_err_unexpected(struct peer *peer, const Pkt *pkt)
{
	return pkt_err(peer, "Unexpected packet %s", pkt_name(pkt->pkt_case));
}