Help with PF_PACKET sockets

Help with PF_PACKET sockets

Post by Jose Antonio Ant » Thu, 27 Apr 2000 04:00:00



Hi all,

I want to setup a LAN over several point-to-point connections, based on
USB-USB connectors and USB-Ethernet adapters. Since I dont need any L3
or L4 protocol, and what I need is the less possible overhead, I've
thought about using packet sockets (PF_PACKET). What I want is a way of
sending raw stuff into the data portion of ethernet packets. I'd like to
use Packet Datagram sockets, because I'm lazy and don't want to worry
about headers, and if using Packet Raw sockets, I would have to
(wouldn't I? Please see question below).

When creating/binding a packet socket (packet(7), packet(4)), I'm told
to choose a protocol for sending, from if_ether.h .

Now, some cuestions (sorry if trivial):
- What happens if I register a packet Raw socket and don't send correct
headers? Will my packets get discarded? For example, think I create a
socket(PF_PACKET,SOCK_RAW, ETH_P_IP) and when I send packets I don't
build a proper IP header.
- Can I make a packet socket for a protocol number not included in
ether.h?
- If not, what do I need to do in order to be able to send packets for a
user defined protocol? Adding a line in if_ether.h and recompile? I only
need a dummy protocol, just for sending raw data over ethernet packets.

Any help will be appreciated. I'm totally lost...
Thank you for your time.

Cheers,

JAA

 
 
 

1. PF_PACKETS socket protocol family

Hi!

I need to adapt a program from linux to solaris. It uses sockets with
protocol family PF_PACKETS which is defined under linux but not under
solaris. It also uses sockaddr_ll structure to initialize the socket.
Does anyone know what this protocol is and how to adapt it to solaris
(if it's possible at all)?
The structure sockaddr_ll looks like this in linux:

struct sockaddr_ll
{
        unsigned short  sll_family;
        unsigned short  sll_protocol;
        int             sll_ifindex;
        unsigned short  sll_hatype;
        unsigned char   sll_pkttype;
        unsigned char   sll_halen;
        unsigned char   sll_addr[8];

Thanks.
Przemek

2. cannot compile, no groff

3. Raw socket PF_PACKET questions

4. Can't link exception code (Using SunPro CC 4.0.1)

5. atomicity / thread-safety: PF_PACKET socket and tap file descriptor

6. fdisk and disklabel don't quite agree..

7. New in Linux kernel internals searching for help about touch PF_PACKET family

8. ppp0

9. Help Apache - getsockname: Socket operation on non-socket

10. socket help and other sockets problems !?!?

11. help: close(socket) leaves socket bound ?

12. HELP: ftpd: socket operation on non-socket?

13. PF_PACKET question...