Ethereal-dev: [Ethereal-dev] sendto with PF_PACKET and SOCK_RAW

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Kilimanjaro Robbs <killa@xxxxxxxxxxx>
Date: Wed, 15 Aug 2001 19:27:39 -0400 (EDT)
I am a newbie,
	I have been reading past post to the mailing list regarding the 
topics of reading and writing messages via the PF_PACKET options with
the linux 2.2.x kernels. But I have run into a road block, because information
is limited to this topic.

	So if any one can help in leading in a right direction, many thanks
in advance. 

This is what I am seeing:

Currently I can grab the packets from the interface with setup up the socket call:

	network_fd = socket (PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))

then some setup for the sockaddr_ll struct :

	network_socket_addr.sll_family   = AF_PACKET;
	network_socket_addr.sll_protocol = htons(ETH_P_ALL);
	network_socket_addr.sll_ifindex  = 0;


I to the bind to the socket after turning on PROMISC mode on the controller:

    if (bind(network_fd, (struct sockaddr *) &network_socket_addr, sizeof( struct sockaddr_ll)) < 0) {
        show_netinfo(("bind() failure on device %s\n", this_network_device_name));
        show_netinfo(("error = %d %d %s\n", network_fd, errno, strerror(errno) ));
        return XFALSE;
    }
	
now later on in the code I am trying to do a write to via sendto:

 
        if ( sendto( network_fd, xnb->np_buffer.data_start,
                  xnb->np_buffer.data_size, 0,
                  (struct sockaddr *) &network_socket_addr, fromlen) < 0 )
 
            {
            /* Write failed.  Since I don't know why at this point
             *  we'll call it an abort.
             */
            printf("Write_network failed errno = %s \n", strerror(errno) );
            inc_enet_stat_cnt( STAT_PACK_ABORT, 1);
            }

The code builds and upon execution I get the error number 22 which translates to
	" Device not configured"

Is there something that I am missing, or should I be doing. 


If it helps I am converting from the SOCK_PACKET implemnentation.

Kilimanjaro