Andi Kleen wrote:

> First you pass the wrong address to PF_PACKET sendto() -- it gets a
> sockaddr_ll, not a old style spkt address.
> It is not clear from your snippet where fromlen comes from, but it is
> probably not correctly initialized (it should be sizeof(struct sockaddr_ll)
> Also sendto really gets a ``to'' not a ``from'', maybe you should fix
> the confusing naming.

I looked at af_packet.c and figured out that sockaddr_ll was what was needed
(thanks for the well commented code :))

Also, it looks like after I bind, I can pass NULL in to sendto for
the 'to' address.

Right now, it looks like the code is putting it on the right interface
(according to debug I put in the kernel), but I'm still not seeing it on
the wire...  I'll keep digging down...

One thing that bothers me a little bit.  I have 2 4-port NICs and a
single...  The single is the one I'm trying to send messages over.
No matter which slot I put it in (there are only 3 PCI slots in the MB),
that interface shows up as eth8.  Is that normal?  I thought they probed
based on PCI slots, so that changing the slot would change the ifname it
showed up on...

One final question..  If I create the socket like:
   int s = socket(PF_PACKET, SOCK_RAW, htons(ether_type));

bind like this:
   struct sockaddr_ll myaddr;

   memset(&myaddr, '\0', sizeof(myaddr));
   myaddr.sll_family = AF_PACKET;
   myaddr.sll_protocol = htons(ether_type);
   myaddr.sll_ifindex = dev_idx;

   r = bind(s, (struct sockaddr*)(&myaddr), sizeof(myaddr));

and send like this:
 r = sendto(dev_socket, msg, msg_len, 0, NULL, 0);

Should I expect to see this method in af_packet.cc called?
static int packet_sendmsg(struct socket *sock, struct msghdr *msg, int len,
                          struct scm_cookie *scm)

I was expecting to see packet_sendmsg_spkt, but it is using the one above...

Thanks,
Ben

-- 
Ben Greear ([EMAIL PROTECTED])  http://www.candelatech.com
Author of ScryMUD:  scry.wanfear.com 4444        (Released under GPL)
http://scry.wanfear.com               http://scry.wanfear.com/~greear
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to