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

ip.cpp

Committer:
andrewboyson
Date:
2017-08-23
Revision:
33:714a0345e59b
Parent:
14:e75a59c1123d
Child:
47:73af5c0b0dc2

File content as of revision 33:714a0345e59b:

#include "mbed.h"
#include   "ip.h"

void IpProtocolToString(uint8_t protocol, int size, char* text)
{
    switch (protocol)
    {
        case   ICMP: strncpy(text, "ICMP"  , size);       break;
        case   IGMP: strncpy(text, "IGMP"  , size);       break;
        case  ICMP6: strncpy(text, "ICMP6" , size);       break;
        case    TCP: strncpy(text, "TCP"   , size);       break;
        case    UDP: strncpy(text, "UDP"   , size);       break;
        case IP6IN4: strncpy(text, "IP6IN4", size);       break;
        default:    snprintf(text, size, "%d", protocol); break;
    }
}