Changeset 1409
- Timestamp:
- Jul 28, 2007 1:58:36 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ip_helper_win32.c
r1119 r1409 35 35 #include <pj/string.h> 36 36 37 typedef DWORD (WINAPI *PFN_GetIpAddrTable)(PMIB_IPADDRTABLE pIpAddrTable, 38 PULONG pdwSize, 39 BOOL bOrder); 40 typedef DWORD (WINAPI *PFN_GetIpForwardTable)(PMIB_IPFORWARDTABLE pIpForwardTable, 41 PULONG pdwSize, 42 BOOL bOrder); 43 44 static HANDLE s_hDLL; 45 static PFN_GetIpAddrTable s_pfnGetIpAddrTable; 46 static PFN_GetIpForwardTable s_pfnGetIpForwardTable; 47 48 static unload_iphlp_module(void) 49 { 50 FreeLibrary(s_hDLL); 51 s_hDLL = NULL; 52 s_pfnGetIpAddrTable = NULL; 53 s_pfnGetIpForwardTable = NULL; 54 } 55 56 static FARPROC GetIpHlpApiProc(pj_char_t *lpProcName) 57 { 58 if(NULL == s_hDLL) { 59 s_hDLL = LoadLibrary(PJ_T("IpHlpApi")); 60 if(NULL != s_hDLL) { 61 pj_atexit(&unload_iphlp_module); 62 } 63 } 64 65 if(NULL != s_hDLL) 66 return GetProcAddress(s_hDLL, lpProcName); 67 68 return NULL; 69 } 70 71 static DWORD MyGetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, 72 PULONG pdwSize, 73 BOOL bOrder) 74 { 75 if(NULL == s_pfnGetIpAddrTable) { 76 s_pfnGetIpAddrTable = (PFN_GetIpAddrTable) 77 GetIpHlpApiProc(PJ_T("GetIpAddrTable")); 78 } 79 80 if(NULL != s_pfnGetIpAddrTable) { 81 return s_pfnGetIpAddrTable(pIpAddrTable, pdwSize, bOrder); 82 } 83 84 return ERROR_NOT_SUPPORTED; 85 } 86 87 88 static DWORD MyGetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, 89 PULONG pdwSize, 90 BOOL bOrder) 91 { 92 if(NULL == s_pfnGetIpForwardTable) { 93 s_pfnGetIpForwardTable = (PFN_GetIpForwardTable) 94 GetIpHlpApiProc(PJ_T("GetIpForwardTable")); 95 } 96 97 if(NULL != s_pfnGetIpForwardTable) { 98 return s_pfnGetIpForwardTable(pIpForwardTable, pdwSize, bOrder); 99 } 100 101 return ERROR_NOT_SUPPORTED; 102 } 37 103 38 104 /* … … 49 115 ULONG tabSize; 50 116 unsigned i, count; 51 DWORD rc ;117 DWORD rc = NO_ERROR; 52 118 53 119 PJ_ASSERT_RETURN(p_cnt && ifs, PJ_EINVAL); … … 57 123 /* Get IP address table */ 58 124 tabSize = sizeof(ipTabBuff); 59 rc = GetIpAddrTable(pTab, &tabSize, FALSE); 125 126 rc = MyGetIpAddrTable(pTab, &tabSize, FALSE); 60 127 if (rc != NO_ERROR) 61 128 return PJ_RETURN_OS_ERROR(rc); … … 92 159 ULONG tabSize; 93 160 unsigned i, count; 94 DWORD rc ;161 DWORD rc = NO_ERROR; 95 162 96 163 PJ_ASSERT_RETURN(p_cnt && routes, PJ_EINVAL); … … 101 168 /* First get IP address table */ 102 169 tabSize = sizeof(ipTabBuff); 103 rc = GetIpAddrTable(pIpTab, &tabSize, FALSE);170 rc = MyGetIpAddrTable(pIpTab, &tabSize, FALSE); 104 171 if (rc != NO_ERROR) 105 172 return PJ_RETURN_OS_ERROR(rc); … … 107 174 /* Next get IP route table */ 108 175 tabSize = sizeof(rtabBuff); 109 rc = GetIpForwardTable(prTab, &tabSize, 1); 176 177 rc = MyGetIpForwardTable(prTab, &tabSize, 1); 110 178 if (rc != NO_ERROR) 111 179 return PJ_RETURN_OS_ERROR(rc); … … 139 207 } 140 208 141 142
Note: See TracChangeset
for help on using the changeset viewer.