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@47:73af5c0b0dc2, 2017-10-26 (annotated)
- Committer:
- andrewboyson
- Date:
- Thu Oct 26 14:50:24 2017 +0000
- Revision:
- 47:73af5c0b0dc2
- Parent:
- 33:714a0345e59b
Replaced a number of temporary buffers with direct writes to the Log or HTTP.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 14:e75a59c1123d | 1 | #include "mbed.h" |
andrewboyson | 47:73af5c0b0dc2 | 2 | #include "log.h" |
andrewboyson | 14:e75a59c1123d | 3 | #include "ip.h" |
andrewboyson | 14:e75a59c1123d | 4 | |
andrewboyson | 47:73af5c0b0dc2 | 5 | void IpProtocolString(uint8_t protocol, int size, char* text) |
andrewboyson | 14:e75a59c1123d | 6 | { |
andrewboyson | 14:e75a59c1123d | 7 | switch (protocol) |
andrewboyson | 14:e75a59c1123d | 8 | { |
andrewboyson | 33:714a0345e59b | 9 | case ICMP: strncpy(text, "ICMP" , size); break; |
andrewboyson | 33:714a0345e59b | 10 | case IGMP: strncpy(text, "IGMP" , size); break; |
andrewboyson | 33:714a0345e59b | 11 | case ICMP6: strncpy(text, "ICMP6" , size); break; |
andrewboyson | 33:714a0345e59b | 12 | case TCP: strncpy(text, "TCP" , size); break; |
andrewboyson | 33:714a0345e59b | 13 | case UDP: strncpy(text, "UDP" , size); break; |
andrewboyson | 33:714a0345e59b | 14 | case IP6IN4: strncpy(text, "IP6IN4", size); break; |
andrewboyson | 14:e75a59c1123d | 15 | default: snprintf(text, size, "%d", protocol); break; |
andrewboyson | 14:e75a59c1123d | 16 | } |
andrewboyson | 14:e75a59c1123d | 17 | } |
andrewboyson | 47:73af5c0b0dc2 | 18 | void IpProtocolLog(uint8_t protocol) |
andrewboyson | 47:73af5c0b0dc2 | 19 | { |
andrewboyson | 47:73af5c0b0dc2 | 20 | switch (protocol) |
andrewboyson | 47:73af5c0b0dc2 | 21 | { |
andrewboyson | 47:73af5c0b0dc2 | 22 | case ICMP: Log("ICMP" ); break; |
andrewboyson | 47:73af5c0b0dc2 | 23 | case IGMP: Log("IGMP" ); break; |
andrewboyson | 47:73af5c0b0dc2 | 24 | case ICMP6: Log("ICMP6" ); break; |
andrewboyson | 47:73af5c0b0dc2 | 25 | case TCP: Log("TCP" ); break; |
andrewboyson | 47:73af5c0b0dc2 | 26 | case UDP: Log("UDP" ); break; |
andrewboyson | 47:73af5c0b0dc2 | 27 | case IP6IN4: Log("IP6IN4"); break; |
andrewboyson | 47:73af5c0b0dc2 | 28 | default: LogF("%d", protocol); break; |
andrewboyson | 47:73af5c0b0dc2 | 29 | } |
andrewboyson | 47:73af5c0b0dc2 | 30 | } |