OpengateM Source Repository
修訂 | 933b9198939b5c4c9b0c096c4f37cc3fa500d5b3 (tree) |
---|---|
時間 | 2013-06-13 15:15:14 |
作者 | watanaby <watanaby@user...> |
Commiter | watanaby |
fixed error on ip address conversion
@@ -212,6 +212,10 @@ OpengateM History</H3> | ||
212 | 212 | </DT><DD> |
213 | 213 | Fixed bug in script to create vendor table(opengatemsql) |
214 | 214 | </DD> |
215 | + <DT>Ver.0.8.2 at 2013.6.13 | |
216 | + </DT><DD> | |
217 | + Fixed bug in ip-address conversion(opengatemd) | |
218 | + </DD> | |
215 | 219 | </DL> |
216 | 220 | |
217 | 221 | </BODY> |
@@ -175,7 +175,7 @@ int main(int argc, char **argv) | ||
175 | 175 | /* if sig-hup flag is on, reload this program */ |
176 | 176 | if(sigHupArrived)execlp(argv[0], argv[0], NULL); |
177 | 177 | |
178 | - /* if mac addresses are received from management proc by udp, | |
178 | + /* if mac addresses are received from management program through udp port, | |
179 | 179 | remove the addresses from caches */ |
180 | 180 | if(sigIoArrived){ |
181 | 181 | sigIoArrived=FALSE; |
@@ -193,7 +193,8 @@ int main(int argc, char **argv) | ||
193 | 193 | /* if no packet */ |
194 | 194 | if(ret==0){ |
195 | 195 | |
196 | - /* check useless sessions at some interval */ | |
196 | + /* check&delete useless sessions */ | |
197 | + /* when long time passed from previous check */ | |
197 | 198 | if( time(NULL) - uselessCheckTime > checkInterval ){ |
198 | 199 | uselessCheckTime = time(NULL); |
199 | 200 | DelUselessSessions(); |
@@ -216,14 +217,14 @@ int main(int argc, char **argv) | ||
216 | 217 | |
217 | 218 | /* convert address from network-raw form to presentation form */ |
218 | 219 | ConvertMacFromRawToDisplay(macAddressRaw,macAddress); |
219 | - if(!ConvertIpFromRawToDisplay(ipAddressRaw,ipAddrLen,ipAddress)) continue; | |
220 | + ConvertIpFromRawToDisplay(ipAddressRaw,ipAddrLen,ipAddress); | |
220 | 221 | |
221 | 222 | /* check nat/router and save info to db */ |
222 | 223 | isNatOrRouter=IsSentViaNatOrRouter(ipAddress, macAddress, ttl); |
223 | 224 | if(isNatOrRouter) PutLogAtNatOrRouter(isNatOrRouter,ipAddress,macAddress,ttl); |
224 | 225 | PutMacInfoToWorkDb(macAddress, ttl, isNatOrRouter); |
225 | 226 | |
226 | - /*** get the states of the terminal in data structures ***/ | |
227 | + /*** get the status of the terminal from session table and DB ***/ | |
227 | 228 | /* search the address in session table */ |
228 | 229 | sessionFound = IsMatchedSessionFound(macAddress); |
229 | 230 |
@@ -157,7 +157,7 @@ int InitPcap(void); | ||
157 | 157 | int GetNextPacketFromPcap(unsigned char* macAddressRaw, unsigned char* ipAddressRaw, int* pIpAddrLen, int* pTtl); |
158 | 158 | void ClosePcap(void); |
159 | 159 | int GetMyMacAddress(char* macAddress); |
160 | -int ConvertIpFromRawToDisplay(unsigned char* ipAddressRaw, int ipAddrLen, char* ipAddress); | |
160 | +void ConvertIpFromRawToDisplay(unsigned char* ipAddressRaw, int ipAddrLen, char* ipAddress); | |
161 | 161 | void ConvertMacFromRawToDisplay(unsigned char* macAddressRaw, char* macAddress); |
162 | 162 | |
163 | 163 | /* packetcache.c */ |
@@ -199,30 +199,22 @@ int getMyMacAddress(char* macAddress){ | ||
199 | 199 | /***************************** |
200 | 200 | convert IP address from network raw form to display form |
201 | 201 | *****************************/ |
202 | -int convertIpFromRawToDisplay(unsigned char* ipAddressRaw, int ipAddrLen, char* ipAddress){ | |
203 | - int ret; | |
204 | - char zeroAddress[IPV6ADDRLN]={0}; | |
202 | +void convertIpFromRawToDisplay(unsigned char* ipAddressRaw, int ipAddrLen, char* ipAddress){ | |
205 | 203 | |
206 | 204 | /* convert ip address from network form to presentation form */ |
207 | 205 | switch (ipAddrLen) { |
208 | 206 | case IPV4ADDRLN: |
209 | 207 | inet_ntop(AF_INET, ipAddressRaw, ipAddress, ADDRMAXLN); |
210 | - if(memcmp(ipAddressRaw, zeroAddress, IPV4ADDRLN)==0) ret=FALSE; | |
211 | - else ret=TRUE; | |
212 | 208 | break; |
213 | 209 | |
214 | 210 | case IPV6ADDRLN: |
215 | 211 | inet_ntop(AF_INET6, ipAddressRaw, ipAddress, ADDRMAXLN); |
216 | - if(memcmp(ipAddressRaw, zeroAddress, IPV6ADDRLN)==0) ret=FALSE; | |
217 | - else ret=TRUE; | |
218 | 212 | break; |
219 | 213 | |
220 | 214 | default: |
221 | 215 | ipAddress[0]='\0'; |
222 | - ret=FALSE; | |
223 | 216 | break; |
224 | 217 | } |
225 | - return ret; | |
226 | 218 | } |
227 | 219 | |
228 | 220 | /***************************** |
@@ -265,12 +257,10 @@ int GetMyMacAddress(char* macAddress){ | ||
265 | 257 | return ret; |
266 | 258 | } |
267 | 259 | |
268 | -int ConvertIpFromRawToDisplay(unsigned char* ipAddressRaw, int ipAddrLen, char* ipAddress){ | |
269 | - int ret; | |
260 | +void ConvertIpFromRawToDisplay(unsigned char* ipAddressRaw, int ipAddrLen, char* ipAddress){ | |
270 | 261 | if(debug>1) err_msg("DEBUG:=>convertIpFromRawtoDisplay(%x,%d,)",ipAddressRaw[0],ipAddrLen); |
271 | - ret=convertIpFromRawToDisplay(ipAddressRaw, ipAddrLen, ipAddress); | |
262 | + convertIpFromRawToDisplay(ipAddressRaw, ipAddrLen, ipAddress); | |
272 | 263 | if(debug>1) err_msg("DEBUG:<=convertIpFromRawToDisplay(,,%s)",ipAddress); |
273 | - return ret; | |
274 | 264 | } |
275 | 265 | |
276 | 266 | void ConvertMacFromRawToDisplay(unsigned char* macAddressRaw, char* macAddress){ |