Re: [PATCH] add nfq_snprintf_xml() to output a packet in XML format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jan Engelhardt wrote:
> On Wednesday 2010-05-26 14:39, Pablo Neira Ayuso wrote:
> 
>> This patch adds a new function to output the packet in XML format.
> 
>> +int nfq_snprintf_xml(char *buf, int len, struct nfq_data *tb, int flags)
>> +{
>> +	struct nfqnl_msg_packet_hdr *ph;
>> +	struct nfqnl_msg_packet_hw *hwph;
>> +	u_int32_t mark, ifi;
>> +	int size, offset = 0, ret;
>> +	char *data;
>> +
>> +	size = snprintf(buf + offset, len, "<pkt>");
>> +	SNPRINTF_FAILURE(size, len, offset);
>> +
>> +	ph = nfq_get_msg_packet_hdr(tb);
>> +	if (ph) {
>> +		size = snprintf(buf + offset, len,
>> +				"<hook>%u</hook><id>%u</id>",
>> +				ph->hook, ntohl(ph->packet_id));
>> +		SNPRINTF_FAILURE(size, len, offset);
> 
> Couldn't libxml be used to generate the XML?

Adding such a dependency is overkill. One of the good things of these
libraries is that they are small and they have small dependencies.

>> +	ret = nfq_get_payload(tb, &data);
>> +	if (ret >= 0 && (flags & NFQ_XML_PAYLOAD)) {
>> +		int i;
>> +
>> +		size = snprintf(buf + offset, len, "<payload>");
>> +		SNPRINTF_FAILURE(size, len, offset);
>> +
>> +		for (i=0; i<ret; i++) {
>> +			size = snprintf(buf + offset, len, "x%02x",
> 
> What's the leading x for? It seems to add no value.

We can remove that or include a backslash before the 'x'.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux