Esempio n. 1
0
bool
_input_nmsg_filter(nmsg_input_t input, unsigned idx, Nmsg__NmsgPayload *np) {
	assert(input->stream->nmsg != NULL);

	/* payload crc */
	if (input->stream->nmsg->n_payload_crcs >= (idx + 1)) {
		uint32_t wire_crc = input->stream->nmsg->payload_crcs[idx];
		uint32_t calc_crc = my_crc32c(np->payload.data, np->payload.len);
		if (ntohl(wire_crc) != calc_crc) {
			_nmsg_dprintf(1, "libnmsg: WARNING: crc mismatch (%x != %x) [%s]\n",
				      calc_crc, wire_crc, __func__);
			return (false);
		}
	}

	/* (vid, msgtype) */
	if (input->do_filter == true &&
	    (input->filter_vid != np->vid ||
	     input->filter_msgtype != np->msgtype))
	{
		return (false);
	}

	/* source */
	if (input->stream->source > 0 &&
	    input->stream->source != np->source)
	{
		return (false);
	}

	/* operator */
	if (input->stream->operator > 0 &&
	    input->stream->operator != np->operator_)
	{
		return (false);
	}

	/* group */
	if (input->stream->group > 0 &&
	    input->stream->group != np->group)
	{
		return (false);
	}

	/* all passed */
	return (true);
}
Esempio n. 2
0
uint32_t
mtbl_crc32c(const uint8_t *buf, size_t size)
{
    return (my_crc32c(buf, size));
}