version_2.0
Dependents: cc3000_ping_demo_try_2
Fork of cc3000_hostdriver_mbedsocket by
Diff: cc3000_socket.cpp
- Revision:
- 42:bd2c631a031a
- Parent:
- 20:30b6ed7bf8fd
- Child:
- 45:50ab13d8f2dc
--- a/cc3000_socket.cpp Sat Oct 12 21:03:45 2013 +0000 +++ b/cc3000_socket.cpp Sat Oct 12 21:53:28 2013 +0000 @@ -600,4 +600,39 @@ #endif +char * cc3000_socket::inet_ntoa_r(uint32_t s_addr, char *buf, int buflen) +{ + char inv[3]; + char *rp; + uint8_t *ap; + uint8_t rem; + uint8_t n; + uint8_t i; + int len = 0; + + rp = buf; + ap = (uint8_t *)&s_addr; + for(n = 0; n < 4; n++) { + i = 0; + do { + rem = *ap % (uint8_t)10; + *ap /= (uint8_t)10; + inv[i++] = '0' + rem; + } while(*ap); + while(i--) { + if (len++ >= buflen) { + return NULL; + } + *rp++ = inv[i]; + } + if (len++ >= buflen) { + return NULL; + } + *rp++ = '.'; + ap++; + } + *--rp = 0; + return buf; +} + } /* end of cc3000 namespace */