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? >+ 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. >+ data[i] & 0xff); >+ SNPRINTF_FAILURE(size, len, offset); >+ } >+ >+ size = snprintf(buf + offset, len, "</payload>"); >+ SNPRINTF_FAILURE(size, len, offset); >+ } >+ >+ size = snprintf(buf + offset, len, "</pkt>"); >+ SNPRINTF_FAILURE(size, len, offset); >+ >+ return size; >+} >+ -- 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