mirror of https://github.com/mkerrisk/man-pages
![]() The manpage packet(7) currently states that: "When you send packets it is enough to specify sll_family, sll_addr, sll_halen, sll_ifindex." This is incorrect: you also need to specify sll_protocol. (The protocol specified when the socket is created is used for filtering inbound packets, but not for constructing outbound packets.) I encountered this while researching a page for my website: http://www.microhowto.info/howto/send_an_arbitrary_ethernet_frame_using_an_af_packet_socket_in_c.html To empirically verify the behaviour I took my test code from the above page then changed it to use different values for the third argument to socket() and the sll_protocol field: - socket created with ETH_P_ARP, packet sent with ETH_P_ARP: packet sent with EtherType of ETH_P_ARP - socket created with ETH_P_ARP, sll_protocol==0: packet sent with EtherType of 0 - socket created with 0x88b5, sll_protocol==htons(ETH_P_ARP): packet sent with EtherType of ETH_P_ARP - socket created with ETH_P_ARP, sll_protocol==htons(0x88b5): packet sent with EtherType of 0x88b5 This shows that leaving sll_protocol set to zero does not have the desired effect and that it needs to be set to the desired link-layer protocol. There is code in the relevant kernel source file (net/packet/af_packet.c) which appears to inspect the value of the sll_protocol field and use it as the link-layer protocol number, however I am not sufficiently familiar with this subsystem to be fully confident of what is happening. The line in question is: proto = saddr->sll_protocol; In version 3.4 of the kernel this can be found in the functions packet_snd and tpacket_snd. In version 2.6.26 it is in packet_sendmsg. Below is a patch that adds sll_protocol to the list of required fields. This may not be the whole truth, since it is not clear what role if any sll_protocol, sll_halen or sll_addr would play when the socket type is SOCK_RAW, however I'm confident it is more accurate than the page as it stands at present. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com> |
||
---|---|---|
man1 | ||
man2 | ||
man3 | ||
man4 | ||
man5 | ||
man6 | ||
man7 | ||
man8 | ||
scripts | ||
Changes | ||
Changes.old | ||
Makefile | ||
README | ||
man-pages-4.00.Announce | ||
man-pages-4.00.lsm |
README
This package contains Linux man pages for sections 2, 3, 4, 5, and 7. Some more information is given in the `Announce' file. Install by copying to your favourite location. "make install" will just copy them to /usr/share/man/man[1-8]. To install to a path different from /usr use "make install prefix=/install/path". "make" will move the pages from this package that are older than the already installed ones to a subdirectory `not_installed', then remove old versions (compressed or not), compress the pages, and copy them to /usr/share/man/man[1-8]. Note that you may have to remove preformatted pages. Note that sometimes these pages are duplicates of pages also distributed in other packages. This has been reported about dlclose.3, dlerror.3, dlopen.3, dlsym.3 (found in ld.so), about resolver.3, resolv.conf.5 (found in bind-utils), and about passwd.5, and mailaddr.7. Be careful not to overwrite more up-to-date versions. Reports on further duplicates are welcome. Formerly present and now removed duplicates: exports.5 (found in nfs-server-2.2*), fstab.5, nfs.5 (found in util-linux-2.12*), lilo.8, lilo.conf.5 (found in lilo-21.6*). Copyrights: These man pages come under various copyrights. All pages are freely distributable when the nroff source is included. If you have corrections and additions to suggest, see http://www.kernel.org/doc/man-pages/contributing.html