how to set lwip interface to promiscuous mode by raw socket

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to set lwip interface to promiscuous mode by raw socket

Jump to solution
197 Views
Changhawn
Contributor I

Hi

I am using S32K3 Design studio with FreeRTOS, LWIP component.

Question) By raw socket , can I make promiscuous mode like below?

PF_PACKET, SIOCGIFFLAGS, IFF_PROMISC is not defined.

But SW32K3_TCPIP_STACK_1_0_4 / 1_0_3 doesn't support it.

Is there any other method?

~~~~

/* Open PF_PACKET socket, listening for EtherType ETHER_TYPE */
if ((sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETHER_TYPE))) == -1)
{
perror("listener: socket");
return -1;
}
 
/* Set interface to promiscuous mode - do we need to do this every time? */
strncpy(ifopts.ifr_name, ifName, IFNAMSIZ - 1);
ioctl(sockfd, SIOCGIFFLAGS, &ifopts);
ifopts.ifr_flags |= IFF_PROMISC;
ioctl(sockfd, SIOCSIFFLAGS, &ifopts);
/* Allow the socket to be reused - incase connection is closed prematurely */
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof sockopt) == -1)
~~~
0 Kudos
1 Solution
170 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Changhawn,

You can set promiscuous mode by writing a 1 to MAC_Packet_Filter[PR]:

Julin_AragnM_0-1716247251134.png

See chapter 76.17.4 (MAC_Packet_Filter) from the reference manual.

Also, promiscuous mode is set as

    GMAC_PKT_FILTER_PROMISCUOUS_MODE = GMAC_MAC_PACKET_FILTER_PR_MASK,               /*!< Passes all incoming packets irrespective of the destination or source address. */

In the Gmac_Ip_Types.h file from the RTD include directory.

Best regards,
Julián

View solution in original post

0 Kudos
2 Replies
171 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Changhawn,

You can set promiscuous mode by writing a 1 to MAC_Packet_Filter[PR]:

Julin_AragnM_0-1716247251134.png

See chapter 76.17.4 (MAC_Packet_Filter) from the reference manual.

Also, promiscuous mode is set as

    GMAC_PKT_FILTER_PROMISCUOUS_MODE = GMAC_MAC_PACKET_FILTER_PR_MASK,               /*!< Passes all incoming packets irrespective of the destination or source address. */

In the Gmac_Ip_Types.h file from the RTD include directory.

Best regards,
Julián

0 Kudos
162 Views
Changhawn
Contributor I

Thank u for your support.

0 Kudos