// // 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(ðIntf->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); }