35 #ifndef __SBG_NETWORK_H__ 36 #define __SBG_NETWORK_H__ 50 #define SBG_IPV4_UNSPECIFIED_ADDR sbgIpAddr(0, 0, 0, 0) 51 #define SBG_IPV4_BROADCAST_ADDR sbgIpAddr(255, 255, 255, 255) 53 //----------------------------------------------------------------------// 67 #if SBG_CONFIG_BIG_ENDIAN == 1 68 return (a << 24) | (b << 16) | (c << 8) | d;
70 return a | (b << 8) | (c << 16) | (d << 24);
81 #if SBG_CONFIG_BIG_ENDIAN == 1 82 return (
uint8)((ipAddr & 0xFF000000) >> 24);
84 return (
uint8)((ipAddr & 0x000000FF));
95 #if SBG_CONFIG_BIG_ENDIAN == 1 96 return (
uint8)((ipAddr & 0x00FF0000) >> 16);
98 return (
uint8)((ipAddr & 0x0000FF00) >> 8);
109 #if SBG_CONFIG_BIG_ENDIAN == 1 110 return (
uint8)((ipAddr & 0x0000FF00) >> 8);
112 return (
uint8)((ipAddr & 0x00FF0000) >> 16);
123 #if SBG_CONFIG_BIG_ENDIAN == 1 124 return (
uint8)((ipAddr & 0x000000FF));
126 return (
uint8)((ipAddr & 0xFF000000) >> 24);
161 return (ipAddress & netmask);
172 return (ipAddress & ~netmask);
252 if ((firstIpAddr & netmask) == (secondIpAddr & netmask))
SBG_INLINE uint8 sbgIpAddrGetA(sbgIpAddress ipAddr)
SBG_INLINE bool sbgIpAddrIsSameNetwork(sbgIpAddress firstIpAddr, sbgIpAddress secondIpAddr, sbgIpAddress netmask)
SBG_INLINE uint8 sbgIpAddrGetB(sbgIpAddress ipAddr)
SBG_INLINE sbgIpAddress sbgIpAddr(uint8 a, uint8 b, uint8 c, uint8 d)
SBG_INLINE sbgIpAddress sbgIpGetHostAddr(sbgIpAddress ipAddress, sbgIpAddress netmask)
SBG_INLINE bool sbgIpAddressValid(sbgIpAddress ipAddress)
SBG_INLINE sbgIpAddress sbgIpAddrWithinSubnet(sbgIpAddress ipAddress, sbgIpAddress netmask)
SBG_INLINE bool sbgIpAddressIsUnspecified(sbgIpAddress ipAddress)
bool sbgIpNetMaskValid(sbgIpAddress netmask)
Main header file for SBG Systems common C library.
void sbgNetworkIpToString(sbgIpAddress ipAddr, char *pBuffer, size_t maxSize)
SBG_INLINE uint8 sbgIpAddrGetC(sbgIpAddress ipAddr)
SBG_INLINE uint8 sbgIpAddrGetD(sbgIpAddress ipAddr)
SBG_INLINE sbgIpAddress sbgIpGetNetworkAddr(sbgIpAddress ipAddress, sbgIpAddress netmask)
sbgIpAddress sbgNetworkIpFromString(const char *pBuffer)