For mbed OS-5 version for WIZnet Ethernet Interface, this is Library using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.
Warning
- If you want to use existing codes, you need to change the class used as EthernetInterface to WIZnetInterface.
This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.
- WIZwiki_W7500 : /platforms/WIZwiki-W7500/
- WIZwiki_W7500P : /platforms/WIZwiki-W7500P/
- WIZwiki_W7500ECO : /platforms/WIZwiki-W7500ECO/
- W5500 Ethernet Shield : /components/W5500-Ethernet-Kit-for-IoT/
This library is an Ethernet Interface library port-based on [EthernetInterface](https://developer.mbed.org/users/mbed_official/code/EthernetInterface/docs/tip/).
For more detail, visit http://embeddist.blogspot.kr/2015/06/wiznetinterface-for-armmbed.html
Socket/dnsname.h@0:d4c8fe4d9b29, 2017-09-04 (annotated)
- Committer:
- justinkim
- Date:
- Mon Sep 04 00:23:04 2017 +0000
- Revision:
- 0:d4c8fe4d9b29
mbed OS 5 version migration...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
justinkim | 0:d4c8fe4d9b29 | 1 | // dnsname.h 2013/8/27 |
justinkim | 0:d4c8fe4d9b29 | 2 | #pragma once |
justinkim | 0:d4c8fe4d9b29 | 3 | //#include <string> |
justinkim | 0:d4c8fe4d9b29 | 4 | #include "pico_string.h" |
justinkim | 0:d4c8fe4d9b29 | 5 | class dnsname { |
justinkim | 0:d4c8fe4d9b29 | 6 | public: |
justinkim | 0:d4c8fe4d9b29 | 7 | uint8_t *buf; |
justinkim | 0:d4c8fe4d9b29 | 8 | pico_string str; |
justinkim | 0:d4c8fe4d9b29 | 9 | dnsname(uint8_t *s) { |
justinkim | 0:d4c8fe4d9b29 | 10 | buf = s; |
justinkim | 0:d4c8fe4d9b29 | 11 | } |
justinkim | 0:d4c8fe4d9b29 | 12 | int decode(int pos) { |
justinkim | 0:d4c8fe4d9b29 | 13 | while(1) { |
justinkim | 0:d4c8fe4d9b29 | 14 | int len = buf[pos++]; |
justinkim | 0:d4c8fe4d9b29 | 15 | if (len == 0x00) { |
justinkim | 0:d4c8fe4d9b29 | 16 | break; |
justinkim | 0:d4c8fe4d9b29 | 17 | } |
justinkim | 0:d4c8fe4d9b29 | 18 | if ((len&0xc0) == 0xc0) { //compress |
justinkim | 0:d4c8fe4d9b29 | 19 | int offset = (len&0x3f)<<8|buf[pos]; |
justinkim | 0:d4c8fe4d9b29 | 20 | decode(offset); |
justinkim | 0:d4c8fe4d9b29 | 21 | return pos+1; |
justinkim | 0:d4c8fe4d9b29 | 22 | } |
justinkim | 0:d4c8fe4d9b29 | 23 | if (!str.empty()) { |
justinkim | 0:d4c8fe4d9b29 | 24 | str.append("."); |
justinkim | 0:d4c8fe4d9b29 | 25 | } |
justinkim | 0:d4c8fe4d9b29 | 26 | str.append((const char*)(buf+pos), len); |
justinkim | 0:d4c8fe4d9b29 | 27 | pos += len; |
justinkim | 0:d4c8fe4d9b29 | 28 | } |
justinkim | 0:d4c8fe4d9b29 | 29 | return pos; |
justinkim | 0:d4c8fe4d9b29 | 30 | } |
justinkim | 0:d4c8fe4d9b29 | 31 | |
justinkim | 0:d4c8fe4d9b29 | 32 | int encode(int pos, char* s) { |
justinkim | 0:d4c8fe4d9b29 | 33 | while(*s) { |
justinkim | 0:d4c8fe4d9b29 | 34 | char *f = strchr(s, '.'); |
justinkim | 0:d4c8fe4d9b29 | 35 | if (f == NULL) { |
justinkim | 0:d4c8fe4d9b29 | 36 | int len = strlen(s); |
justinkim | 0:d4c8fe4d9b29 | 37 | buf[pos++] = len; |
justinkim | 0:d4c8fe4d9b29 | 38 | memcpy(buf+pos, s, len); |
justinkim | 0:d4c8fe4d9b29 | 39 | pos += len; |
justinkim | 0:d4c8fe4d9b29 | 40 | break; |
justinkim | 0:d4c8fe4d9b29 | 41 | } |
justinkim | 0:d4c8fe4d9b29 | 42 | int len = f - s; |
justinkim | 0:d4c8fe4d9b29 | 43 | buf[pos++] = len; |
justinkim | 0:d4c8fe4d9b29 | 44 | memcpy(buf+pos, s, len); |
justinkim | 0:d4c8fe4d9b29 | 45 | s = f+1; |
justinkim | 0:d4c8fe4d9b29 | 46 | pos += len; |
justinkim | 0:d4c8fe4d9b29 | 47 | } |
justinkim | 0:d4c8fe4d9b29 | 48 | buf[pos++] = 0x00; |
justinkim | 0:d4c8fe4d9b29 | 49 | return pos; |
justinkim | 0:d4c8fe4d9b29 | 50 | } |
justinkim | 0:d4c8fe4d9b29 | 51 | }; |