tcpdump mailing list archives
Re: sending raw packet using pcap
From: "Chris sun" <lei_sun () comcast net>
Date: Wed, 12 Nov 2003 17:42:29 -0500
Here is the function I added for sending packet through pcap :
int pcap_write_linux(pcap_t *pd, unsigned char *buf, int count)
{
int i;
struct sockaddr_ll sa;
sa.sll_family = PF_PACKET;
sa.sll_protocol = htons(ETH_P_ALL);
sa.sll_ifindex = iface_get_id(pd->fd, pd->md.device, pd->errbuf);
i = sendto(pd->fd, buf, count, 0, &sa, (socklen_t)sizeof(struct
sockaddr_ll));
if (i != count){
perror(pd->errbuf);
return -1;
}
return i;
}
It did worked if i send packet slowly. But if i keep sending it without
putting some sleep code, error occured,
the error message is :
No Buffer space available.
The man page of sendto() tells me that linux will never return ENOBUFS ,
packets are just
silently dropped when a device queue overflows.
Besides, I think the pd-> fd is a blocking socket, it will block if buffer
is full instead of returnning error, right ?
Any idea ?
Thank you
chris
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe
Current thread:
- sending raw packet using pcap Chris sun (Nov 10)
- Message not available
- Re: sending raw packet using pcap Chris sun (Nov 10)
- Message not available
- Re: sending raw packet using pcap Guy Harris (Nov 10)
- Re: sending raw packet using pcap Chris sun (Nov 12)
- Re: sending raw packet using pcap Chris sun (Nov 12)
