many changes :Py
This commit is contained in:
31
net/IP.h
31
net/IP.h
@@ -5,21 +5,40 @@
|
||||
|
||||
struct IP {
|
||||
|
||||
uint32_t val;
|
||||
//uint32_t val;
|
||||
ip_addr addr;
|
||||
|
||||
/** empty ctor */
|
||||
IP() : val(0) {
|
||||
;
|
||||
explicit IP() {
|
||||
addr.addr = 0;
|
||||
}
|
||||
|
||||
/** ctor with IP-string */
|
||||
IP(const char* ipStr) {
|
||||
explicit IP(const char* ipStr) {
|
||||
set(ipStr);
|
||||
}
|
||||
|
||||
/** set the IP */
|
||||
/** ctor with ip_addr_t */
|
||||
explicit IP(ip_addr addr) : addr(addr) {
|
||||
;
|
||||
}
|
||||
|
||||
/** set the IP by string: x.x.x.x */
|
||||
void set(const char* ipStr) {
|
||||
val = ipaddr_addr(ipStr);
|
||||
addr.addr = ipaddr_addr(ipStr);
|
||||
}
|
||||
|
||||
/** convert to ip_addr/ip_addr_t */
|
||||
const ip_addr* getPtr() const {
|
||||
return &addr;
|
||||
}
|
||||
|
||||
/** convert to string */
|
||||
const char* toString() const {
|
||||
//static char str[16];
|
||||
//ipaddr_aton(str, (ip_addr*)&addr);
|
||||
//return str;
|
||||
return ipaddr_ntoa(&addr);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user