19#ifndef _NETSIM_IPADDRESSING_H_
20#define _NETSIM_IPADDRESSING_H_
29#define _NETSIM_IP_LEN 50
30#define _NETSIM_BIN_IP_LEN 130
32 typedef struct stru_ip* NETSIM_IPAddress;
51 unsigned int int_ip[4];
54 char str_ip[_NETSIM_IP_LEN];
60#define IP_COMPARE6(ip1,ip2) (ip1->int_ip[0]==ip2->int_ip[0] \
61 ?(ip1->int_ip[1]==ip2->int_ip[1] \
62 ?(ip1->int_ip[2]==ip2->int_ip[2] \
63 ?(ip1->int_ip[3]==ip2->int_ip[3]?0:1) :1) :1) :1)
65#define IP_COMPARE4(ip1,ip2) (ip1->int_ip[0]==ip2->int_ip[0]?0:1)
67#define IP_COMPARE(ip1,ip2) ((ip1)->type==(ip2)->type \
68 ? ((ip1)->type==4?IP_COMPARE4((ip1),(ip2)):IP_COMPARE6((ip1),(ip2))) \
71#define IP_TO_STR(ip,ipstr) ((ip)?(strcpy((ipstr),((ip)->str_ip))):strcpy(ipstr,"0.0.0.0"))
74_declspec(dllexport) NETSIM_IPAddress STR_TO_IP(
char* ipStr,
int type);
76_declspec(dllexport) NETSIM_IPAddress IP_COPY(NETSIM_IPAddress ip);
77_declspec(dllexport)
void IP_FREE(NETSIM_IPAddress ip);
78_declspec(dllexport) NETSIM_IPAddress IP_COPY_FORCE(NETSIM_IPAddress ip);
79_declspec(dllexport)
void IP_FREE_FORCE(NETSIM_IPAddress ip);
80_declspec(dllexport)
void IP_TO_BINARY(NETSIM_IPAddress ip,
char* binary);
81_declspec(dllexport)
unsigned int IP_ADD_TO_LIST(NETSIM_IPAddress** pipList,
unsigned int* count,
const NETSIM_IPAddress ip);
82_declspec(dllexport)
unsigned int IP_REMOVE_FROM_LIST(NETSIM_IPAddress* pipList,
unsigned int* count,
const NETSIM_IPAddress ip);
83_declspec(dllexport)
int IP_CHECK_IN_LIST(
const NETSIM_IPAddress* ipList,
unsigned int count,
const NETSIM_IPAddress ip);
84_declspec(dllexport)
int IP_IS_IN_SAME_NETWORK(NETSIM_IPAddress ip1,NETSIM_IPAddress ip2,NETSIM_IPAddress subnet,
unsigned int prefix_len);
85_declspec(dllexport) NETSIM_IPAddress IP_NETWORK_ADDRESS(NETSIM_IPAddress ip,NETSIM_IPAddress subnet,
unsigned int prefix_len);
86_declspec(dllexport) NETSIM_IPAddress GET_BROADCAST_IP(
int type);
88_declspec(dllexport)
int IP_FREE_ALL();
91_declspec(dllexport)
int IP_VALIDATE_ALL_IP();
93_declspec(dllexport)
int STR_GET_IP_TYPE(
char* ip);
94#define STR_TO_IP4(ipstr) STR_TO_IP(ipstr,4)
95#define STR_TO_IP6(ipstr) STR_TO_IP(ipstr,6)
97#define IP_IS_IN_SAME_NETWORK_IPV4(ip1,ip2,subnet) IP_IS_IN_SAME_NETWORK(ip1,ip2,subnet,0)
98#define IP_IS_IN_SAME_NETWORK_IPV6(ip1,ip2,prefix) IP_IS_IN_SAME_NETWORK(ip1,ip2,NULL,prefix)
100#define IP_NETWORK_ADDRESS_IPV4(ip,subnet) IP_NETWORK_ADDRESS(ip,subnet,0)
101#define IP_NETWORK_ADDRESS_IPV6(ip,prefix) IP_NETWORK_ADDRESS(ip,NULL,prefix)
103_declspec(dllexport)
bool isBroadcastIP(NETSIM_IPAddress ip);
104_declspec(dllexport)
bool isMulticastIP(NETSIM_IPAddress ip);
105_declspec(dllexport)
bool isValidIPAddress(
char* ip);
106_declspec(dllexport)
int IP_find_match_length(NETSIM_IPAddress ip1, NETSIM_IPAddress ip2);