Move packet handling to firewall
This commit is contained in:
parent
929aaf39a3
commit
986b596b46
2 changed files with 11 additions and 12 deletions
|
@ -1,10 +1,6 @@
|
|||
#ifndef _LWIP_HOOKS_H_
|
||||
#define _LWIP_HOOKS_H_
|
||||
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip4.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
|
|
@ -11,14 +11,17 @@ fw::API *firewallApi;
|
|||
|
||||
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));
|
||||
Serial.print((u16_t)IPH_PROTO(iphdr));
|
||||
Serial.print(": ");
|
||||
Serial.println(ip_address);
|
||||
// Firewall is not setup yet
|
||||
if (firewall != NULL)
|
||||
{
|
||||
if (firewall->is_packet_allowed(pbuf))
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
pbuf_free(pbuf);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue