X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcfg%2Fmacros.h;h=4af10246f2ad6e646a44f242259cf8d920b12b3e;hb=refs%2Fheads%2Fmaster;hp=ff682fe214d3cdb22f2e4ab5242ba07ada65e510;hpb=4a71fb58e067d3dc00fe1c29927f945bd34be49a;p=bertos.git diff --git a/bertos/cfg/macros.h b/bertos/cfg/macros.h index ff682fe2..4af10246 100644 --- a/bertos/cfg/macros.h +++ b/bertos/cfg/macros.h @@ -446,5 +446,22 @@ INLINE bool is_aligned(const void *addr, size_t size) /** \} */ //defgroup macros + +/** + * Macro to unpack the ip addres from lwip format in 4 int + * \param addr is struct ip_addr ip_addr; + * \return for int variable separated from comma + * + * \code + * //Upack into 4 int the lwip ip address + * LOG_INFO("dhcp ok: ip = %d.%d.%d.%d\n", IP_ADDR_TO_INT_TUPLE(netif.ip_addr.addr)); + * \endcode + */ +#define IP_ADDR_TO_INT_TUPLE(addr) \ + (int)((addr) >> 0 & 0xff), \ + (int)((addr) >> 8 & 0xff), \ + (int)((addr) >> 16 & 0xff), \ + (int)((addr) >> 24 & 0xff) + #endif /* MACROS_H */