how to set lwip interface to promiscuous mode by raw socket

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

how to set lwip interface to promiscuous mode by raw socket

跳至解决方案
660 次查看
Changhawn
Contributor III

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 项奖励
回复
1 解答
633 次查看
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 项奖励
回复
2 回复数
634 次查看
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 项奖励
回复
625 次查看
Changhawn
Contributor III

Thank u for your support.

0 项奖励
回复