Find the answer to your Linux question:
Results 1 to 2 of 2
Hi All! Already posted this to another forum, unfortunately nobody could help until now What I am trying to do is send and receive at the same time through RAW ...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    2

    Question configuring RAW sockets not to receive sent frames

    Hi All!

    Already posted this to another forum, unfortunately nobody could help until now

    What I am trying to do is send and receive at the same time through RAW sockets on the same NIC. The problem I am facing is that I am always receiving the frames I sent through another socket, but on the same NIC.
    Using different NICs everything works fine!
    This is the normal behaviour for NICs in promiscious mode, though I have not activated this mode explicitely. If this is happening implicitely, is there a way to deactivte promiscious mode and receive all incoming frames anyway?

    Here are my approaches:
    Code:
    //Creating RAW Ethernet Socket
    int SOCKET_ID = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
    //int SOCKET_ID = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
    
    //socket config
    struct sockaddr_ll socket_address;
    socket_address.sll_family = AF_PACKET;
    socket_address.sll_protocol = htons(ETH_P_ALL);
    socket_address.sll_ifindex = IF_INDEX;
    //configuring the packet type makes no difference
    socket_address.sll_pkttype = PACKET_OTHERHOST|PACKET_BROADCAST|PACKET_MULTICAST|PACKET_HOST;
    //socket_address.sll_pkttype = PACKET_HOST;
    socket_address.sll_halen = ETH_ALEN;
    socket_address.sll_hatype = 0x0000; 
    
    //bind socket to NIC by IF_INDEX
    int bind_res = bind(SOCKET_ID,(struct sockaddr* )&socket_address,sizeof(socket_address));
    
    //configure promiscious mode
    struct packet_mreq pmreq;
    pmreq.mr_ifindex = IF_INDEX;
    //setting promisc or other makes no difference
    //pmreq.mr_type = PACKET_MR_PROMISC;
    pmreq.mr_type = PACKET_MR_ALLMULTI;
    pmreq.mr_alen = ETH_ALEN;
    //pmreq.mr_address[8] = (unsigned long) 0x010ECF000000;
    int sock_opt_res = setsockopt(SOCKET_ID,SOL_PACKET,PACKET_ADD_MEMBERSHIP,(struct packet_mreq*)&pmreq,sizeof(pmreq));
    Anyone ever reached this problem? There should be more people having this problem, should´t there?
    Please help...

  2. #2
    Just Joined!
    Join Date
    May 2008
    Posts
    2

    Thumbs down Workaround

    Implemented a filter, that "manually" filtered out the sent frames.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...