I referenced that sample code at http://www.kohala.com/start/writepcap.txt
and use "write" to send the ethernet frame. But the call returns ENOTCONN,
which means "Transport endpoint is not connected". I have no idea why it
happens since I use "pd->fd" as the socket. Here're some related source
code:
in main():
if (pcap_loop(pd, cnt, fwd_ethframe, pcap_userdata) < 0) {
printf("pcap_loop: %s\n",pcap_geterr(pd));
exit(1);
}
in fwd_ethframe():
if(write(pd->fd, data, len)!=len){
...
}
Thanks in advance.
----- Original Message -----
From: "Ryan Mooney" <[EMAIL PROTECTED]>
To: "mini" <[EMAIL PROTECTED]>
Sent: Friday, December 21, 2001 10:54 AM
Subject: Re: [tcpdump-workers] how to send an ethernet frame?
>
> See:
> http://www.kohala.com/start/writepcap.txt
> for an eample. You can't use sendto to write a raw frame, pcap lets you
> do that. You'll have to hack your pcap library to support write (easy)
> as described here... FYI, the pcap file has headers you'll need to strip
> off. When building custom frames, a binary hex editor will be your best
> freind. Find one you like, learn it, love it.
>
> > I implement to capture the ethernet packets by using libpcap. Now I want
to send the captured packet to a certain computer. But I'm not sure what
routine I should call to send the packets. If I call "sendto", I should
specify the destination IP address and port. But I just want to send the
captured ethernet packets out which already contains the ethernet frame
header.
> >
> > Any help will be appreciated.
> >
> > -
> > This is the TCPDUMP workers list. It is archived at
> > http://www.tcpdump.org/lists/workers/index.html
> > To unsubscribe use
mailto:[EMAIL PROTECTED]?bodysubscribe
> --
> >-=-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-=-<
> Ryan Mooney [EMAIL PROTECTED]
> <-=-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-=->
>
>
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe