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

Revision:
176:7eb916c22084
Parent:
116:60521b29e4c9
Child:
183:ee809769bf89
--- a/ip4/ip4addr.c	Thu Dec 24 19:17:06 2020 +0000
+++ b/ip4/ip4addr.c	Sat Dec 26 17:07:02 2020 +0000
@@ -9,7 +9,7 @@
 #include "ntpclient.h"
 #include "tftp.h"
 
-int Ip4AddressToString(uint32_t ip, int size, char* text)
+int Ip4AddressToString(const uint32_t ip, const int size, char* text)
 {
     int a0 = (ip & 0xFF000000) >> 24;
     int a1 = (ip & 0x00FF0000) >> 16;
@@ -17,7 +17,7 @@
     int a3 = (ip & 0x000000FF);
     return snprintf(text, size, "%d.%d.%d.%d", a3, a2, a1, a0); 
 }
-int Ip4AddressLog(uint32_t ip)
+int Ip4AddressLog(const uint32_t ip)
 {
     int a0 = (ip & 0xFF000000) >> 24;
     int a1 = (ip & 0x00FF0000) >> 16;
@@ -25,7 +25,7 @@
     int a3 = (ip & 0x000000FF);
     return LogF("%d.%d.%d.%d", a3, a2, a1, a0); 
 }
-int Ip4AddressHttp(uint32_t ip)
+int Ip4AddressHttp(const uint32_t ip)
 {
     int a0 = (ip & 0xFF000000) >> 24;
     int a1 = (ip & 0x00FF0000) >> 16;
@@ -34,14 +34,14 @@
     return HttpAddF("%d.%d.%d.%d", a3, a2, a1, a0); 
 }
 
-uint32_t Ip4AddressParse(char* text)
+uint32_t Ip4AddressParse(const char* text)
 {
     int ints[4];
     sscanf(text, "%d.%d.%d.%d", &ints[3], &ints[2], &ints[1], &ints[0]);
     return (ints[0] << 24) + (ints[1] << 16) + (ints[2] << 8) + ints[3];
 }
 
-void Ip4AddressFromDest(int dest, uint32_t* pDstIp)
+void Ip4AddressFromDest(const int dest, uint32_t* pDstIp)
 {
     switch (dest)
     {