#include "lwip_hooks.h"
const char *get_protocol(u16_t type)
{
switch (type)
case 1:
return "ICMP";
case 6:
return "TCP";
case 17:
return "UDP";
default:
return "-";
}
int lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif)
const struct ip_hdr *iphdr;
char ip_address[IP_HLEN];
iphdr = (struct ip_hdr *)pbuf->payload;
sprintf(ip_address, "%d.%d.%d.%d", ip4_addr1_16_val(iphdr->src), ip4_addr2_16_val(iphdr->src), ip4_addr3_16_val(iphdr->src), ip4_addr4_16_val(iphdr->src));
ESP_LOGI("HOOK", "%s: %s",
get_protocol((u16_t)IPH_PROTO(iphdr)), ip_address);
return ESP_OK;