Hi Heinrich,

On Tue, 22 Apr 2025 at 05:13, Heinrich Schuchardt <xypron.g...@gmx.de> wrote:
>
> Hello Jerome,
>
> I am trying to compile with CONFIG_LOG_SYSLOG=y and CONFIG_NET_LWIP=y
> and get:
>
> common/log_syslog.c: In function ‘log_syslog_emit’:
> common/log_syslog.c:59:24: error: implicit declaration of function
> ‘net_set_ether’; did you mean ‘env_set_hex’?
> [-Wimplicit-function-declaration]
>     59 |         eth_hdr_size = net_set_ether((uchar *)ptr,
> net_bcast_ethaddr, PROT_IP);
>        |                        ^~~~~~~~~~~~~
>        |                        env_set_hex
> common/log_syslog.c:102:9: error: implicit declaration of function
> ‘net_set_udp_header’ [-Wimplicit-function-declaration]
>    102 |         net_set_udp_header((uchar *)iphdr, bcast_ip, 514, 514,
> ptr - log_msg);
>        |         ^~~~~~~~~~~~~~~~~~
>
> As these function just prepare packet buffers, should they be moved to
> common code used both for the legacy and the new network stack?

Doing so may not be the best option, since it will be pulling a few more globals
we don't have (and don't want) with NET_LWIP: net_our_vlan, net_native_vlan,
net_ethaddr... I believe the best course of action is to rewrite
log_syslog_emit()
to use the lwIP UDP API when NET_LWIP is enabled. It should not be too hard.
Something like that:

struct pbuf *p;
struct netif *netif;

netif = net_lwip_new_netif(eth_get_dev());
pcb = udp_new();
udp_bind_netif(pcb, netif);
udp_bind(pcb, ip, src_port); /* maybe not needed if src_port doesn't matter */
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
memcpy(p->payload, data, len);
udp_sendto_if(pcb, dst_ip, dst_port, netif);
pbuf_free(p);
udp_remove(pcb);
net_lwip_remove_netif(netif);

See also lib/lwip/lwip/src/apps/tftp/tftp.c for usage of the UDP API.

HTH,
-- 
Jerome

>
> Best regards
>
> Heinrich

Reply via email to