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: net.cpp
- Revision:
- 9:91dae5300a4d
- Parent:
- 7:b794780e33b4
- Child:
- 10:f0854784e960
--- a/net.cpp Tue Mar 14 19:26:24 2017 +0000 +++ b/net.cpp Tue Apr 04 10:41:25 2017 +0000 @@ -3,9 +3,10 @@ #include "net.h" #include "tcp.h" #include "dhcp.h" -#include "arp.h" +#include "ar.h" #include "dns.h" #include "slaac.h" +#include "ndp.h" static void addHexNibble(bool* pAdded, int number, int index, char** pp) { @@ -53,16 +54,17 @@ } int NetMacToString(char* mac, int size, char* text) { - return snprintf(text, size, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + return snprintf(text, size, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } -void NetProtocolToString(uint16_t protocol, int size, char* text) +void NetProtocolToString(uint8_t protocol, int size, char* text) { switch (protocol) { - case ICMP6_PROTOCOL: strncpy (text, "ICMP6", size); break; - case TCP_PROTOCOL: strncpy (text, "TCP" , size); break; - case UDP_PROTOCOL: strncpy (text, "UDP" , size); break; - default: snprintf(text, size, "%d", protocol); break; + case ICMP: strncpy (text, "ICMP4", size); break; + case ICMP6: strncpy (text, "ICMP6", size); break; + case TCP: strncpy (text, "TCP" , size); break; + case UDP: strncpy (text, "UDP" , size); break; + default: snprintf(text, size, "%d", protocol); break; } } @@ -148,19 +150,20 @@ { PhyInit(); TcpInit(); - ArpInit(); + ArInit(); SlaacInit(); return 0; } int NetMain() { PhyMain(); - ArpMain(); + ArMain(); if (ticked()) { DhcpTick(); - ArpTick(); + ArTick(); DnsTick(); + NdpTick(); } return 0; } \ No newline at end of file