Networking Forums

Networking Forums > Computer Networking > Linux Networking > Raw socket PF_PACKET questions

Reply
Thread Tools Display Modes

Raw socket PF_PACKET questions

 
 
manolinux
Guest
Posts: n/a

 
      08-31-2006, 10:40 AM
Hi,

I'm working with raw-ethernet sockets, and there are some questions
that have arisen to me during my work. Hope someone knows the answers !

1) Bind step is always necessary when opening PF_PACKET sockets? Only
in sending, in receiving, in both?

2) Is there any patch that solves problem of getting repeated packets
when using loopback interface + multicast?

3) I cannot receive broadcast messages from a raw ethernet socket which
i open this way:

sk = socket (PF_PACKET,SOCK_RAW,0);

do i need to pass any kind of option to the socket to enable broadcast
receiving?


Thanx a lot in advance,
Manuel Cotallo.

 
Reply With Quote
 
 
 
 
sunil.maryala@gmail.com
Guest
Posts: n/a

 
      09-08-2006, 05:54 PM
Hi,

Answers to your questions are below

1. Bind is only needed when you need to receive packets from a specefic
interface.

2. Please give me some more info on this.

3. I have collected some info from man page for receving broadcast
which will help you in receving broadcast packets

ADDRESS TYPES
The sockaddr_ll is a device independent physical layer address.


struct sockaddr_ll {
unsigned short sll_family; /* Always AF_PACKET */
unsigned short sll_protocol; /* Physical layer protocol */
int sll_ifindex; /* Interface number */
unsigned short sll_hatype; /* Header type */
unsigned char sll_pkttype; /* Packet type */
unsigned char sll_halen; /* Length of address */
unsigned char sll_addr[8]; /* Physical layer address */
};


sll_protocol is the standard ethernet protocol type in network order as
defined in the linux/if_ether.h include file. It defaults to the
socket's protocol. sll_ifindex is the interface index of the interface
(see netdevice(7)); 0 matches any interface (only legal for binding).
sll_hatype is a ARP type as defined in the linux/if_arp.h include file.
sll_pkttype contains the packet type. Valid types are PACKET_HOST for a
packet addressed to the local host, PACKET_BROADCAST for a physical
layer broadcast packet, PACKET_MULTICAST for a packet sent to a
physical layer multicast address, PACKET_OTHERHOST for a packet to some
other host that has been caught by a device driver in promiscuous mode,
and PACKET_OUTGOING for a packet originated from the local host that is
looped back to a packet socket. These types make only sense for
receiving. sll_addr and sll_halen contain the physical layer (e.g. IEEE
802.3) address and its length. The exact interpretation depends on the
device.

When you send packets it is enough to specify sll_family, sll_addr,
sll_halen, sll_ifindex. The other fields should be 0. sll_hatype and
sll_pkttype are set on received packets for your information. For bind
only sll_protocol and sll_ifindex are used.

Please feel free to contact if you need any more info.

Thanks,
Sunil

manolinux wrote:
> Hi,
>
> I'm working with raw-ethernet sockets, and there are some questions
> that have arisen to me during my work. Hope someone knows the answers !
>
> 1) Bind step is always necessary when opening PF_PACKET sockets? Only
> in sending, in receiving, in both?
>
> 2) Is there any patch that solves problem of getting repeated packets
> when using loopback interface + multicast?
>
> 3) I cannot receive broadcast messages from a raw ethernet socket which
> i open this way:
>
> sk = socket (PF_PACKET,SOCK_RAW,0);
>
> do i need to pass any kind of option to the socket to enable broadcast
> receiving?
>
>
> Thanx a lot in advance,
> Manuel Cotallo.


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stumped on IPv6 ping in c language with PF_PACKET/SOCK_DGRAM pdbuchan@yahoo.com Linux Networking 10 11-03-2011 03:00 PM
atomicity / thread-safety: PF_PACKET socket and tap file descriptor Max Schmied Linux Networking 0 02-28-2007 10:31 AM
send and receive raw packets with PF_PACKET and bypassing the kernel nehavrce@yahoo.co.in Linux Networking 0 01-06-2005 07:37 AM
Re: Question on sendto with PF_PACKET and SOCK_RAW. nehavrce@yahoo.co.in Linux Networking 0 01-06-2005 07:09 AM
WLAN Monitor 10038 Socket operation on non-socket Bill Windows Networking 1 03-01-2004 10:34 PM



1 2 3 4 5 6 7 8 9 10 11