Пример #1
0
struct sk_buff *tipc_log_dump(void)
{
    struct sk_buff *reply;

    spin_lock_bh(&print_lock);
    if (!TIPC_LOG->buf) {
        spin_unlock_bh(&print_lock);
        reply = tipc_cfg_reply_ultra_string("log not activated\n");
    } else if (tipc_printbuf_empty(TIPC_LOG)) {
        spin_unlock_bh(&print_lock);
        reply = tipc_cfg_reply_ultra_string("log is empty\n");
    }
    else {
        struct tlv_desc *rep_tlv;
        struct print_buf pb;
        int str_len;

        str_len = min(TIPC_LOG->size, 32768u);
        spin_unlock_bh(&print_lock);
        reply = tipc_cfg_reply_alloc(TLV_SPACE(str_len));
        if (reply) {
            rep_tlv = (struct tlv_desc *)reply->data;
            tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), str_len);
            spin_lock_bh(&print_lock);
            tipc_printbuf_move(&pb, TIPC_LOG);
            spin_unlock_bh(&print_lock);
            str_len = strlen(TLV_DATA(rep_tlv)) + 1;
            skb_put(reply, TLV_SPACE(str_len));
            TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
        }
    }
    return reply;
}
Пример #2
0
static struct sk_buff *tipc_show_stats(void)
{
	struct sk_buff *buf;
	struct tlv_desc *rep_tlv;
	char *pb;
	int pb_len;
	int str_len;
	u32 value;

	if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

	value = ntohl(*(u32 *)TLV_DATA(req_tlv_area));
	if (value != 0)
		return tipc_cfg_reply_error_string("unsupported argument");

	buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN));
	if (buf == NULL)
		return NULL;

	rep_tlv = (struct tlv_desc *)buf->data;
	pb = TLV_DATA(rep_tlv);
	pb_len = ULTRA_STRING_MAX_LEN;

	str_len = tipc_snprintf(pb, pb_len, "TIPC version " TIPC_MOD_VER "\n");
	str_len += 1;	/* for "\0" */
	skb_put(buf, TLV_SPACE(str_len));
	TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);

	return buf;
}
Пример #3
0
static struct sk_buff *tipc_show_stats(void)
{
	struct sk_buff *buf;
	struct tlv_desc *rep_tlv;
	struct print_buf pb;
	int str_len;
	u32 value;

	if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

	value = ntohl(*(u32 *)TLV_DATA(req_tlv_area));
	if (value != 0)
		return tipc_cfg_reply_error_string("unsupported argument");

	buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_STATS_INFO));
	if (buf == NULL)
		return NULL;

	rep_tlv = (struct tlv_desc *)buf->data;
	tipc_printbuf_init(&pb, (char *)TLV_DATA(rep_tlv), MAX_STATS_INFO);

	tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n");

	/* Use additional tipc_printf()'s to return more info ... */

	str_len = tipc_printbuf_validate(&pb);
	skb_put(buf, TLV_SPACE(str_len));
	TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);

	return buf;
}