PCAP_INJECT(3PCAP)
hii bestie π welcome to the PCAP_INJECT(3PCAP) manual page β yes, the one about pcap_inject and pcap_sendpacket, aka the βtransmit a packetβ duo. this is your group-chat cheat sheet, and we are keeping every single technical crumb. no cap. β¨
π NAME π
pcap_inject, pcap_sendpacket β transmit a packet. thatβs the whole assignment, and they ate. π
β¨ SYNOPSIS β¨
#include <pcap/pcap.h>
int pcap_inject(pcap_t *p, const void *buf, size_t size);
int pcap_sendpacket(pcap_t *p, const u_char *buf, int size);
π¦ DESCRIPTION π¦
okay so pcap_inject() sends a raw packet through the network interface. buf points to the data of the packet, including the link-layer header, and size is the number of bytes in the packet. iconic behavior. π«Ά
π¨ heads up, bestie: even if you successfully open the network interface, you might not have permission to send packets on it, or it might not support sending packets. because pcap_open_live(3PCAP) doesnβt have a flag to indicate whether to open for capturing, sending, or capturing and sending, you cannot request an open that supports sending and be notified at open time whether sending will be possible. also note that some devices might not support sending packets. π
platform tea time: on some platforms, the link-layer header of the packet thatβs sent might not be the same as the link-layer header of the packet supplied to pcap_inject(). why? because the source link-layer address, if the header contains such an address, might be changed to be the address assigned to the interface on which the packet it sent, if the platform doesnβt support sending completely raw and unchanged packets. π and even worse: some drivers on some platforms might change the link-layer type field to whatever value libpcap used when attaching to the device, even on platforms that do nominally support sending completely raw and unchanged packets. π
pcap_sendpacket() is like pcap_inject(), but it returns 0 on success, rather than returning the number of bytes written. periodt. (pcap_inject() comes from OpenBSD; pcap_sendpacket() comes from WinPcap/Npcap. Both are provided for compatibility.) π
π RETURN VALUE π
pcap_inject()returns the number of bytes written on success,PCAP_ERROR_NOT_ACTIVATEDif called on a capture handle that has been created but not activated, andPCAP_ERRORon other errors. β¨pcap_sendpacket()returns0on success,PCAP_ERROR_NOT_ACTIVATEDif called on a capture handle that has been created but not activated, andPCAP_ERRORon other errors. π
if PCAP_ERROR is returned, pcap_geterr(3PCAP) or pcap_perror(3PCAP) may be called with p as an argument to fetch or display the error text. π«Ά
π₯ SEE ALSO π₯
pcap(3PCAP)π
mwah π this little masterpiece is from the PCAP_INJECT(3PCAP) source/version, dated 5 March 2022 β bye bestie, go send packets responsibly ππ
π¦ where this page comes from
- alpine 3.22: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- alpine 3.23: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- alpine 3.24: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- centos-stream 10: libpcap-devel 14:1.10.4-8.el10 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- debian bookworm: libpcap0.8-dev 1.10.3-1
- debian trixie: libpcap0.8-dev 1.10.5-2
- fedora 43: libpcap-devel 14:1.10.5-3.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.5-3.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.7-1.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.7-1.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.6-2.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.6-2.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.7-1.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.7-1.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- nixos 26.05: libpcap 1.10.7
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- ubuntu noble: libpcap0.8-dev 1.10.4-4.1ubuntu3
- ubuntu noble: libpcap0.8-dev 1.10.4-4.1ubuntu3.1
- ubuntu questing: libpcap0.8-dev 1.10.5-2ubuntu2
- ubuntu resolute: libpcap0.8-dev 1.10.6-1ubuntu1 Β· BSD-3-clause-var3
- ubuntu resolute: libpcap0.8-dev 1.10.6-1ubuntu1.1 Β· BSD-3-clause-var3
- ubuntu stonking: libpcap0.8-dev 1.10.7-1ubuntu1 Β· BSD-3-clause-var3
- Copyright (c) 1994, 1996, 1997 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms