how to set lwip interface to promiscuous mode by raw socket

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to set lwip interface to promiscuous mode by raw socket

ソリューションへジャンプ
659件の閲覧回数
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 解決策
632件の閲覧回数
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 返答(返信)
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 件の賞賛
返信
624件の閲覧回数
Changhawn
Contributor III

Thank u for your support.

0 件の賞賛
返信