Skip to main content
TAlex.11
Visitor II
December 3, 2018
Question

can't create RAW SOCKET FeeRTOS+LWIP

  • December 3, 2018
  • 5 replies
  • 2534 views

I'm trying to create a project on the Nucleo-STM32H743ZI, in which I want to implement the ICMP protocol on remote hosts. I took the example of LWIP contrib-2.0.1. The problem is that when creating a RAW SOCKET, it always returns -1.

 socket = lwip_socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);

In this case, if you create a SOCK_DGRAM or SOCK_STREAM, then everything is successfully created.

What am I doing wrong?

This topic has been closed for replies.

5 replies

Hoang_Tran
Associate III
May 14, 2019

I have a similar situation!

Ivan Pletnev
Associate II
December 26, 2019

I have a same problem. TAlex.1, did you find some solution?

December 26, 2019

You need to rebuild LWIP with LWIP_RAW defined in lwipopts.h in order to include RAW socket support. It seems it is not defined by default.

Regards,

Alexander

Ivan Pletnev
Associate II
December 26, 2019

LWIP_RAW is defined in my code. It's looks like thread freezing, diagnostic messages and Socket Debug messages are not displaying in this case. Howewer, if type of socket are SOCK_DGRAM or SOCK_STREAM, everything is OK

if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) {
		puts("PING socket error");
		return;
	}
	printf("Socket No %u created\r\n", s);

Piranha
Principal III
December 28, 2019

You can't expect higher layers and APIs (especially thread-safe ones) to work, while lower layers are flawed and blatantly violating multithreading and other requirements.

https://community.st.com/s/question/0D50X0000BOtfhnSQB/how-to-make-ethernet-and-lwip-working-on-stm32