-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
176 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @file arp_cache.cpp | ||
* | ||
*/ | ||
/* Copyright (C) 2018-2023 by Arjan van Vught mailto:[email protected] | ||
/* Copyright (C) 2018-2024 by Arjan van Vught mailto:[email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -23,6 +23,10 @@ | |
* THE SOFTWARE. | ||
*/ | ||
|
||
#pragma GCC push_options | ||
#pragma GCC optimize ("O2") | ||
#pragma GCC optimize ("no-tree-loop-distribute-patterns") | ||
|
||
#include <cstdint> | ||
#include <cstring> | ||
#include <cassert> | ||
|
@@ -47,17 +51,12 @@ struct ArpRecord { | |
uint8_t mac_address[ETH_ADDR_LEN]; | ||
}; | ||
|
||
typedef union pcast32 { | ||
uint32_t u32; | ||
uint8_t u8[4]; | ||
} _pcast32; | ||
|
||
static ArpRecord s_ArpRecords[MAX_RECORDS] SECTION_NETWORK ALIGNED; | ||
static uint16_t s_Entries SECTION_NETWORK ALIGNED; | ||
|
||
#ifndef NDEBUG | ||
# define TICKER_COUNT 100 ///< 10 seconds | ||
static volatile uint32_t s_ticker ; | ||
static uint32_t s_ticker ; | ||
#endif | ||
|
||
void __attribute__((cold)) arp_cache_init() { | ||
|
@@ -100,16 +99,14 @@ uint32_t arp_cache_lookup(uint32_t nIp, uint8_t *pMacAddress) { | |
DEBUG_ENTRY | ||
DEBUG_PRINTF(IPSTR " " MACSTR, IP2STR(nIp), MAC2STR(pMacAddress)); | ||
|
||
uint32_t i; | ||
|
||
for (i = 0; i < MAX_RECORDS; i++) { | ||
if (s_ArpRecords[i].nIp == nIp) { | ||
memcpy(pMacAddress, s_ArpRecords[i].mac_address, ETH_ADDR_LEN); | ||
for (auto& record : s_ArpRecords) { | ||
if (record.nIp == nIp) { | ||
memcpy(pMacAddress, record.mac_address, ETH_ADDR_LEN); | ||
DEBUG_EXIT | ||
return nIp; | ||
} | ||
|
||
if (s_ArpRecords[i].nIp == 0) { | ||
if (record.nIp == 0) { | ||
break; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @file igmp.cpp | ||
* | ||
*/ | ||
/* Copyright (C) 2018-2023 by Arjan van Vught mailto:[email protected] | ||
/* Copyright (C) 2018-2024 by Arjan van Vught mailto:[email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -23,11 +23,16 @@ | |
* THE SOFTWARE. | ||
*/ | ||
|
||
#pragma GCC push_options | ||
#pragma GCC optimize ("O2") | ||
#pragma GCC optimize ("no-tree-loop-distribute-patterns") | ||
|
||
#include <cstdint> | ||
#include <cstdio> | ||
#include <cstring> | ||
|
||
#include "net.h" | ||
#include "net_memcpy.h" | ||
#include "net_private.h" | ||
|
||
#include "../../config/net_config.h" | ||
|
@@ -68,12 +73,8 @@ extern uint8_t macAddress[ETH_ADDR_LEN]; | |
static void _send_report(uint32_t nGroupAddress); | ||
|
||
void igmp_set_ip() { | ||
_pcast32 src; | ||
|
||
src.u32 = net::globals::ipInfo.ip.addr; | ||
|
||
memcpy(s_report.ip4.src, src.u8, IPv4_ADDR_LEN); | ||
memcpy(s_leave.ip4.src, src.u8, IPv4_ADDR_LEN); | ||
net::memcpy_ip(s_report.ip4.src, net::globals::ipInfo.ip.addr); | ||
net::memcpy_ip(s_leave.ip4.src, net::globals::ipInfo.ip.addr); | ||
} | ||
|
||
void __attribute__((cold)) igmp_init() { | ||
|
@@ -186,10 +187,6 @@ static void _send_report(const uint32_t nGroupAddress) { | |
|
||
static void _send_leave(const uint32_t nGroupAddress) { | ||
DEBUG_ENTRY | ||
_pcast32 multicast_ip; | ||
|
||
multicast_ip.u32 = nGroupAddress; | ||
|
||
DEBUG_PRINTF(IPSTR " " MACSTR, IP2STR(nGroupAddress), MAC2STR(s_multicast_mac)); | ||
|
||
// IPv4 | ||
|
@@ -199,7 +196,7 @@ static void _send_leave(const uint32_t nGroupAddress) { | |
s_leave.ip4.chksum = net_chksum(reinterpret_cast<void *>(&s_leave.ip4), 24); //TODO | ||
#endif | ||
// IGMP | ||
memcpy(s_leave.igmp.report.igmp.group_address, multicast_ip.u8, IPv4_ADDR_LEN); | ||
net::memcpy_ip(s_leave.igmp.report.igmp.group_address, nGroupAddress); | ||
s_leave.igmp.report.igmp.checksum = 0; | ||
#if !defined (CHECKSUM_BY_HARDWARE) | ||
s_leave.igmp.report.igmp.checksum = net_chksum(reinterpret_cast<void *>(&s_leave.ip4), IPv4_IGMP_REPORT_HEADERS_SIZE); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @file ip.cpp | ||
* | ||
*/ | ||
/* Copyright (C) 2018-2023 by Arjan van Vught mailto:[email protected] | ||
/* Copyright (C) 2018-2024 by Arjan van Vught mailto:[email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -23,6 +23,10 @@ | |
* THE SOFTWARE. | ||
*/ | ||
|
||
#pragma GCC push_options | ||
#pragma GCC optimize ("O2") | ||
#pragma GCC optimize ("no-tree-loop-distribute-patterns") | ||
|
||
#include <cstdint> | ||
|
||
#include "net.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.