EtherLib/eth_interface.c
Wiesner András ac5fc9c529 -IP reassembler added
-PcktSieve special return functionality added
-ARP multicast learning bug fixed
-include guards have been refactored
-Doxygen style tweaked
2023-02-04 11:04:26 +01:00

49 lines
1.3 KiB
C

//
// Created by epagris on 2022.10.20..
//
#include "eth_interface.h"
#include "dynmem.h"
#include "utils.h"
#include "etherlib_options.h"
#include "etherlib/prefab/conn_blocks/ethernet_info.h"
static int ethintf_llrecv(EthIODef * io, const RawPckt * pckt) {
ethinf_receive((EthInterface *) io->tag, pckt);
return 0;
}
static void ethintf_register(EthInterface * intf) {
intf->ioDef->tag = intf;
intf->ioDef->llRxDone = ethintf_llrecv;
}
EthInterface *ethintf_new(EthIODef * io) {
EthInterface * ethIntf = (EthInterface *)dynmem_alloc(sizeof(EthInterface));
ASSERT_NULL(ethIntf);
memset(&ethIntf->sieve.layer0, 0, sizeof(PcktSieveLayer));
ethIntf->sieve.intf = ethIntf;
ethIntf->sieve.layer0.connBReportFn = ethernet_print_report;
ethIntf->ioDef = io;
ethIntf->ip = 0;
ethIntf->arpc = arpc_new(ethIntf, ETHLIB_ARPCACHE_SIZE);
ASSERT_NULL(ethIntf->arpc);
ethintf_register(ethIntf);
ethIntf->txQ = mq_create(ETHLIB_DEF_MQ_SIZE);
ethIntf->ipra = ipra_new();
return ethIntf;
}
void ethinf_receive(EthInterface *intf, const RawPckt *rawPckt) {
packsieve_input(&intf->sieve, rawPckt);
}
void ethinf_transmit(EthInterface *intf, const RawPckt *rawPckt) {
mq_push(intf->txQ, rawPckt); // push packet onto the message queue
intf->ioDef->llTxTrigger(intf->ioDef, intf->txQ);
}