This is Library using WIZnet Hardware TCP/IP chip, W5500 and WIZnet TCP/IP Offload Engine, W7500.
Dependents: HTTP_SDcard_file_server_WIZwiki-W7500 SSD1306_smart_watch TCPEchoServer-WIZwiki-W7500 httpServer-WIZwiki-W7500 ... more
Fork of WIZnetInterface by
This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.
[Users » embeddist » Code » WIZnetInterface](https://developer.mbed.org/users/embeddist/code/WIZnetInterface/) -> WIZnetInterface Lib will be released on [Team WIZnet](https://developer.mbed.org/teams/WIZnet/)
- 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@20:bda61525ac71, 2015-07-22 (annotated)
- Committer:
- kaizen
- Date:
- Wed Jul 22 02:11:37 2015 +0000
- Revision:
- 20:bda61525ac71
- Parent:
- 0:6f28332c466f
Added init() function. This function is necessary when you want to HTTPServer library which release by mbed.; ; init() function is same with init(uint8_t *mac) function.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Soohwan Kim |
0:6f28332c466f | 1 | // dnsname.h 2013/8/27 |
Soohwan Kim |
0:6f28332c466f | 2 | #pragma once |
Soohwan Kim |
0:6f28332c466f | 3 | //#include <string> |
Soohwan Kim |
0:6f28332c466f | 4 | #include "pico_string.h" |
Soohwan Kim |
0:6f28332c466f | 5 | class dnsname { |
Soohwan Kim |
0:6f28332c466f | 6 | public: |
Soohwan Kim |
0:6f28332c466f | 7 | uint8_t *buf; |
Soohwan Kim |
0:6f28332c466f | 8 | pico_string str; |
Soohwan Kim |
0:6f28332c466f | 9 | dnsname(uint8_t *s) { |
Soohwan Kim |
0:6f28332c466f | 10 | buf = s; |
Soohwan Kim |
0:6f28332c466f | 11 | } |
Soohwan Kim |
0:6f28332c466f | 12 | int decode(int pos) { |
Soohwan Kim |
0:6f28332c466f | 13 | while(1) { |
Soohwan Kim |
0:6f28332c466f | 14 | int len = buf[pos++]; |
Soohwan Kim |
0:6f28332c466f | 15 | if (len == 0x00) { |
Soohwan Kim |
0:6f28332c466f | 16 | break; |
Soohwan Kim |
0:6f28332c466f | 17 | } |
Soohwan Kim |
0:6f28332c466f | 18 | if ((len&0xc0) == 0xc0) { //compress |
Soohwan Kim |
0:6f28332c466f | 19 | int offset = (len&0x3f)<<8|buf[pos]; |
Soohwan Kim |
0:6f28332c466f | 20 | decode(offset); |
Soohwan Kim |
0:6f28332c466f | 21 | return pos+1; |
Soohwan Kim |
0:6f28332c466f | 22 | } |
Soohwan Kim |
0:6f28332c466f | 23 | if (!str.empty()) { |
Soohwan Kim |
0:6f28332c466f | 24 | str.append("."); |
Soohwan Kim |
0:6f28332c466f | 25 | } |
Soohwan Kim |
0:6f28332c466f | 26 | str.append((const char*)(buf+pos), len); |
Soohwan Kim |
0:6f28332c466f | 27 | pos += len; |
Soohwan Kim |
0:6f28332c466f | 28 | } |
Soohwan Kim |
0:6f28332c466f | 29 | return pos; |
Soohwan Kim |
0:6f28332c466f | 30 | } |
Soohwan Kim |
0:6f28332c466f | 31 | |
Soohwan Kim |
0:6f28332c466f | 32 | int encode(int pos, char* s) { |
Soohwan Kim |
0:6f28332c466f | 33 | while(*s) { |
Soohwan Kim |
0:6f28332c466f | 34 | char *f = strchr(s, '.'); |
Soohwan Kim |
0:6f28332c466f | 35 | if (f == NULL) { |
Soohwan Kim |
0:6f28332c466f | 36 | int len = strlen(s); |
Soohwan Kim |
0:6f28332c466f | 37 | buf[pos++] = len; |
Soohwan Kim |
0:6f28332c466f | 38 | memcpy(buf+pos, s, len); |
Soohwan Kim |
0:6f28332c466f | 39 | pos += len; |
Soohwan Kim |
0:6f28332c466f | 40 | break; |
Soohwan Kim |
0:6f28332c466f | 41 | } |
Soohwan Kim |
0:6f28332c466f | 42 | int len = f - s; |
Soohwan Kim |
0:6f28332c466f | 43 | buf[pos++] = len; |
Soohwan Kim |
0:6f28332c466f | 44 | memcpy(buf+pos, s, len); |
Soohwan Kim |
0:6f28332c466f | 45 | s = f+1; |
Soohwan Kim |
0:6f28332c466f | 46 | pos += len; |
Soohwan Kim |
0:6f28332c466f | 47 | } |
Soohwan Kim |
0:6f28332c466f | 48 | buf[pos++] = 0x00; |
Soohwan Kim |
0:6f28332c466f | 49 | return pos; |
Soohwan Kim |
0:6f28332c466f | 50 | } |
Soohwan Kim |
0:6f28332c466f | 51 | }; |
Soohwan Kim |
0:6f28332c466f | 52 |