Problems using iqp_read
Hello,
Hi. I am quite new into Linux programming and I am having some difficulties trying to develop a userspace program that should intercept packets that are for the QUEUE target of the iptables. I've created a program using the socket netlink, and libipq, but it fails to receive correct packets: ipq_message_type(packet) returns NLMSG_ERROR, and ipq_errstr() returns Unknown error. Does anybody know why this could be hapenning?
Any hint will be very appreciated!!
The code I have is the following: ________________________________________________________
int main(void)
{ struct ipq_handle *h=NULL;
int rval=0;
unsigned char packet[65536];
memset(packet, 0, 65536);
if ((h = ipq_create_handle(0, PF_INET)) == NULL) exit(1);
rval = ipq_set_mode(h, IPQ_COPY_META, 0);
if (rval < 0) goto die;
while (rval >= 0)
{
int mType = 0;
rval = ipq_read(h, packet, sizeof(packet), 0);
switch (mType = ipq_message_type(packet))
{
case IPQM_PACKET:
{
ipq_packet_msg_t *m =
ipq_get_packet(packet);
int verdict = NF_ACCEPT;
if (m->data_len == 200) verdict = NF_DROP;
ipq_set_verdict(h, m->packet_id, verdict,
m->data_len, m->payload);
break;
}
case NLMSG_ERROR:
{
fprintf(stderr, "Received error message: %s,
messageType = %d\n", ipq_errstr(), mType);
rval = -1;
break;
}
default:
rval = -1;
fprintf(stderr, "Unknown message type %d!\n",
mType);
break;
}
}
die:
printf("Die\n");
ipq_destroy_handle(h);
exit(1);
}______________________________ End of code
Thanks,
Raquel
_________________________________________________________________
Charla con tus amigos en línea mediante MSN Messenger: http://messenger.microsoft.com/es
Quoted 1 line · raquel toribio
Does anybody know why this could be hapenning?
Not really... what kernel is this with?
Signature · 2 lines
James Morris <[email protected]>