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

Committer:
andrewboyson
Date:
Thu Apr 02 19:08:25 2020 +0000
Revision:
167:3ba4e3c49631
Parent:
61:aad055f1b0d1
Modified resolution cache ajaxs to include the index

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 61:aad055f1b0d1 1 #include <stdint.h>
andrewboyson 61:aad055f1b0d1 2 #include <string.h>
andrewboyson 61:aad055f1b0d1 3 #include <stdio.h>
andrewboyson 61:aad055f1b0d1 4
andrewboyson 47:73af5c0b0dc2 5 #include "log.h"
andrewboyson 14:e75a59c1123d 6 #include "ip.h"
andrewboyson 14:e75a59c1123d 7
andrewboyson 47:73af5c0b0dc2 8 void IpProtocolString(uint8_t protocol, int size, char* text)
andrewboyson 14:e75a59c1123d 9 {
andrewboyson 14:e75a59c1123d 10 switch (protocol)
andrewboyson 14:e75a59c1123d 11 {
andrewboyson 33:714a0345e59b 12 case ICMP: strncpy(text, "ICMP" , size); break;
andrewboyson 33:714a0345e59b 13 case IGMP: strncpy(text, "IGMP" , size); break;
andrewboyson 33:714a0345e59b 14 case ICMP6: strncpy(text, "ICMP6" , size); break;
andrewboyson 33:714a0345e59b 15 case TCP: strncpy(text, "TCP" , size); break;
andrewboyson 33:714a0345e59b 16 case UDP: strncpy(text, "UDP" , size); break;
andrewboyson 33:714a0345e59b 17 case IP6IN4: strncpy(text, "IP6IN4", size); break;
andrewboyson 14:e75a59c1123d 18 default: snprintf(text, size, "%d", protocol); break;
andrewboyson 14:e75a59c1123d 19 }
andrewboyson 14:e75a59c1123d 20 }
andrewboyson 47:73af5c0b0dc2 21 void IpProtocolLog(uint8_t protocol)
andrewboyson 47:73af5c0b0dc2 22 {
andrewboyson 47:73af5c0b0dc2 23 switch (protocol)
andrewboyson 47:73af5c0b0dc2 24 {
andrewboyson 47:73af5c0b0dc2 25 case ICMP: Log("ICMP" ); break;
andrewboyson 47:73af5c0b0dc2 26 case IGMP: Log("IGMP" ); break;
andrewboyson 47:73af5c0b0dc2 27 case ICMP6: Log("ICMP6" ); break;
andrewboyson 47:73af5c0b0dc2 28 case TCP: Log("TCP" ); break;
andrewboyson 47:73af5c0b0dc2 29 case UDP: Log("UDP" ); break;
andrewboyson 47:73af5c0b0dc2 30 case IP6IN4: Log("IP6IN4"); break;
andrewboyson 47:73af5c0b0dc2 31 default: LogF("%d", protocol); break;
andrewboyson 47:73af5c0b0dc2 32 }
andrewboyson 47:73af5c0b0dc2 33 }