A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
Diff: eth/ar4.c
- Revision:
- 74:c3756bfa960e
- Parent:
- 71:736a5747ade1
- Child:
- 93:580fc113d9e9
--- a/eth/ar4.c Tue Oct 23 06:46:50 2018 +0000 +++ b/eth/ar4.c Mon Oct 29 09:33:44 2018 +0000 @@ -91,7 +91,7 @@ records[i].elapsed = elapsed; MacClear(records[i].mac); } -uint32_t* Ar4AddIpRecord(void (*traceback)(void), char* mac, uint32_t ip) +int Ar4AddIpRecord(void (*traceback)(void), char* mac, uint32_t ip) { //Don't treat non ips if (!ip) @@ -101,7 +101,7 @@ LogTime("Ar4AddIpRecord had blank ip\r\n"); if (NetTraceStack) traceback(); } - return NULL; + return -1; } if (MacIsEmpty(mac)) { @@ -110,7 +110,7 @@ LogTime("Ar4AddIpRecord had blank mac\r\n"); if (NetTraceStack) traceback(); } - return NULL; + return -1; } int i; @@ -121,7 +121,7 @@ records[i].elapsed = elapsed; records[i].state = STATE_VALID; MacCopy(records[i].mac, mac); - return &records[i].ip; + return i; } //Otherwise find the first empty slot and add the IP, MAC, and date @@ -130,7 +130,7 @@ records[i].elapsed = elapsed; records[i].state = STATE_VALID; MacCopy(records[i].mac, mac); - return &records[i].ip; + return i; } void Ar4IpToMac(uint32_t ip, char* mac) { @@ -144,6 +144,10 @@ } MacClear(mac); } +uint32_t Ar4IndexToIp(int i) +{ + return records[i].ip; +} void Ar4SendHttp() { for (int i = 0; i < RECORDS_COUNT; i++)