1PCAP_INJECT(3PCAP)                                          PCAP_INJECT(3PCAP)
2
3
4

NAME

6       pcap_inject, pcap_sendpacket - transmit a packet
7

SYNOPSIS

9       #include <pcap/pcap.h>
10
11       int pcap_inject(pcap_t *p, const void *buf, size_t size);
12       int pcap_sendpacket(pcap_t *p, const u_char *buf, int size);
13

DESCRIPTION

15       pcap_inject()  sends  a  raw  packet through the network interface; buf
16       points to the data of the packet, including the link-layer header,  and
17       size is the number of bytes in the packet.
18
19       Note  that,  even  if  you successfully open the network interface, you
20       might not have permission to send packets on it, or it might  not  sup‐
21       port  sending packets; as pcap_open_live() doesn't have a flag to indi‐
22       cate whether to open for capturing, sending, or capturing and  sending,
23       you  cannot  request  an  open that supports sending and be notified at
24       open time whether sending  will  be  possible.   Note  also  that  some
25       devices might not support sending packets.
26
27       Note  that,  on  some  platforms,  the  link-layer header of the packet
28       that's sent might not be the same  as  the  link-layer  header  of  the
29       packet  supplied to pcap_inject(), as the source link-layer address, if
30       the header contains such an address, might be changed to be the address
31       assigned  to the interface on which the packet it sent, if the platform
32       doesn't support sending completely raw  and  unchanged  packets.   Even
33       worse,  some drivers on some platforms might change the link-layer type
34       field to whatever value libpcap used when attaching to the device, even
35       on  platforms  that  do  nominally  support  sending completely raw and
36       unchanged packets.
37
38       pcap_sendpacket() is like pcap_inject(), but it returns 0  on  success,
39       rather  than  returning  the  number  of bytes written.  (pcap_inject()
40       comes from OpenBSD; pcap_sendpacket() comes  from  WinPcap.   Both  are
41       provided for compatibility.)
42

RETURN VALUE

44       pcap_inject()  returns the number of bytes written on success and -1 on
45       failure.
46
47       pcap_sendpacket() returns 0 on success and -1 on failure.
48
49       If -1 is returned, pcap_geterr() or pcap_perror() may be called with  p
50       as an argument to fetch or display the error text.
51

SEE ALSO

53       pcap(3PCAP), pcap_geterr(3PCAP)
54
55
56
57                                 5 April 2008               PCAP_INJECT(3PCAP)
Impressum