28 lines
916 B
C
28 lines
916 B
C
//
|
|
// Created by epagris on 2022.11.07..
|
|
//
|
|
|
|
#include "ipv4_connblock.h"
|
|
|
|
#include "../packet_parsers/packet_parsers.h"
|
|
#include "../../utils.h"
|
|
|
|
static bool filtIPv4(const PcktSieveFilterCondition * filtCond, const PcktProps * contProps, const PcktProps * ownProps) {
|
|
EthernetProps * etherProps = (EthernetProps *) contProps;
|
|
IPv4Props * ipProps = (IPv4Props *) ownProps;
|
|
|
|
return etherProps->length_type == ETH_IPv4_PACKET_CLASS && filtCond->u[0] == ipProps->DestIPAddr;
|
|
}
|
|
|
|
ConnBlock ipv4_new_connblock(EthInterface *intf, ip4_addr ipAddr, SieveCallBackFn cbFn) {
|
|
ConnBlock connb;
|
|
PcktSieveFilterCondition filtCond;
|
|
packfiltcond_zero(&filtCond);
|
|
filtCond.u[0] = ipAddr;
|
|
PcktSieveLayerTag tag;
|
|
tag.u = 0;
|
|
connb.sieveLayer = packsieve_new_layer(&intf->sieve.layer0, &filtCond, filtIPv4, cbFn, tag, ETH_IPv4_PACKET_CLASS);
|
|
ASSERT_NULL(connb.sieveLayer);
|
|
return connb;
|
|
}
|