Definition in file identd.cpp.
#include <time.h>
#include "sock.h"
#include "log.h"
#include "stdlib.h"
#include "stats.h"
#include "identd.h"
#include "params.h"
Include dependency graph for identd.cpp:
Go to the source code of this file.
Functions | |
void | identd4_shutdown () |
Shuts down IDENT daemon (IPv4). | |
void | identd6_shutdown () |
Shuts down IDENT daemon (IPv6). | |
bool | identd_check (const char *ident_string) |
Checks and handles IDENT request. | |
void | identd_error_log (int io_error) |
Writes OS's socket I/O error to log file. | |
void | identd_renew () |
Resets IDENT daemon (both IPv4 and IPv6). | |
void | identd_shutdown () |
Shuts down IDENT daemon (both IPv4 and IPv6). | |
bool | identd_startup (in_addr bind, unsigned short port) |
Starts IDENT daemon. | |
char * | ltoa (long value, char *buffer, int radix) |
ltoa() emulation for compiler which doesn't have it | |
Variables | |
time_t | ident_last_response |
Timestamp of last response. | |
s_socket | identd_client |
Socket of IDENTD client. | |
s_socket | identd_sock |
Stores socket handle of IDENT daemon. |
|
Shuts down IDENT daemon (IPv4).
Definition at line 338 of file identd.cpp. References s_socket::clear(), s_socket::cmp(), ident_last_response, log_identd(), and sock_close(). Referenced by logic_exec(). 00339 { 00340 if(identd_sock.cmp()) { 00341 log_identd("Shuted down (IPv4)"); 00342 sock_close(identd_sock); 00343 identd_sock.clear(); 00344 sock_close(identd_client); 00345 identd_client.clear(); 00346 ident_last_response=0; 00347 } 00348 }
Here is the call graph for this function: ![]() |
|
Shuts down IDENT daemon (IPv6).
Definition at line 356 of file identd.cpp. References s_socket::clear(), s_socket::cmp(), ident_last_response, log_identd(), and sock_close(). Referenced by logic_exec(). 00357 { 00358 #ifdef IPv6 00359 if(identd_sock_ipv6.cmp()) { 00360 log_identd("Shuted down (IPv6)"); 00361 sock_close(identd_sock_ipv6); 00362 identd_sock_ipv6.clear(); 00363 sock_close(identd_client_ipv6); 00364 identd_client_ipv6.clear(); 00365 ident_last_response=0; 00366 } 00367 #endif 00368 }
Here is the call graph for this function: ![]() |
|
Checks and handles IDENT request.
Definition at line 159 of file identd.cpp. References s_socket::clear(), s_socket::cmp(), ident_last_response, identd_error_log(), log_identd(), sock_accept(), sock_accept6(), sock_async(), sock_close(), sock_read(), sock_send(), stats_identd_bytes_received(), stats_identd_bytes_sent(), and stats_identd_new_connection(). Referenced by logic_loop_identd(). 00160 { 00161 for(int i=0; i<2; i++) { 00162 s_socket* identd; 00163 s_socket* client; 00164 if(i==0) { 00165 identd=&identd_sock; 00166 client=&identd_client; 00167 } else { 00168 #ifdef IPv6 00169 identd=&identd_sock_ipv6; 00170 client=&identd_client_ipv6; 00171 #else 00172 return false; 00173 #endif 00174 } 00175 00176 if(identd->cmp()==false) 00177 continue; 00178 00179 if(!client->cmp()) { 00180 ident_last_response=0; 00181 s_socket s; 00182 if(i==0) 00183 s=sock_accept(*identd); 00184 else 00185 s=sock_accept6(*identd); 00186 if(s.cmp()) { 00187 00188 sock_async(s); 00189 00190 if(i==0) 00191 identd_client=s; 00192 #ifdef IPv6 00193 else 00194 identd_client_ipv6=s; 00195 #endif 00196 stats_identd_new_connection(); 00197 } 00198 } 00199 00200 if(client->cmp()) { 00201 if(ident_last_response) { 00202 if(ident_last_response+20<time(NULL)) { 00203 ident_last_response=0; 00204 sock_close(*client); 00205 client->clear(); 00206 ident_last_response=0; 00207 //identd_shutdown(); 00208 return true; 00209 } 00210 } 00211 char buff[1024]; 00212 int ec=0; 00213 bool closed; 00214 size_t size=sock_read(*client,buff,sizeof(buff)-1,ec,closed); 00215 stats_identd_bytes_received(size); 00216 if(ec) { 00217 sock_close(*client); 00218 client->clear(); 00219 ident_last_response=0; 00220 identd_error_log(ec); 00221 return false; 00222 } 00223 buff[size]=0; 00224 char tmp[2*1024]; 00225 if(size) { 00226 strcpy(tmp,"Ident request "); 00227 if(i==0) 00228 strcat(tmp,"(IPv4)"); 00229 else 00230 strcat(tmp,"(IPv6)"); 00231 strcat(tmp,": "); 00232 strcat(tmp,buff); 00233 tmp[strlen(tmp)-1]=0; 00234 tmp[strlen(tmp)-1]=0; 00235 log_identd(tmp); 00236 00237 //int i2=0; 00238 int cnt=0; 00239 unsigned int i1; 00240 char num1[64], num2[64]; 00241 int num_c=0; 00242 for(i1=0; i1<strlen(buff); i1++) { 00243 if(cnt==0 && buff[i1]==',') { 00244 cnt++; 00245 num_c=0; 00246 continue; 00247 } 00248 if(cnt==0 && (buff[i1]<'0' || buff[i1]>'9')) 00249 continue; 00250 if(cnt==0 && buff[i1]!=0x20 && buff[i1]!=',') { 00251 num1[num_c++]=buff[i1]; 00252 num1[num_c]=0; 00253 if(num_c>60) 00254 break; 00255 continue; 00256 } 00257 if(cnt==1 && (buff[i1]<'0' || buff[i1]>'9')) 00258 continue; 00259 if(cnt==1 && buff[i1]!=0x20 && buff[i1]!=',') { 00260 num2[num_c++]=buff[i1]; 00261 num2[num_c]=0; 00262 if(num_c>60) 00263 break; 00264 continue; 00265 } 00266 } 00267 00268 strcpy(tmp,num1); 00269 strcat(tmp," , "); 00270 strcat(tmp,num2); 00271 strcat(tmp," "); 00272 00273 strcat(tmp,ident_string); 00274 char tmp2[2*1024]; 00275 tmp2[0]='\r'; 00276 tmp2[1]='\n'; 00277 tmp2[2]=0; 00278 strcat(tmp,tmp2); 00279 00280 size_t sent=sock_send(*client,tmp,strlen(tmp),ec); 00281 stats_identd_bytes_sent(sent); 00282 if(ec) { 00283 sock_close(*client); 00284 client->clear(); 00285 ident_last_response=0; 00286 identd_error_log(ec); 00287 return false; 00288 } 00289 strcpy(tmp2,"Ident reply: "); 00290 strcat(tmp2,tmp); 00291 tmp2[strlen(tmp2)-1]=0; 00292 tmp2[strlen(tmp2)-1]=0; 00293 log_identd(tmp2); 00294 time(&ident_last_response); 00295 return true; 00296 } else 00297 return false; 00298 } 00299 } 00300 return false; 00301 }
Here is the call graph for this function: ![]() |
|
Writes OS's socket I/O error to log file.
Definition at line 76 of file identd.cpp. References log_identd(), ltoa(), and sock_error(). Referenced by identd_check(), and identd_startup(). 00077 { 00078 char log[2*1024]; 00079 strcpy(log,"I/O error, OS error code #"); 00080 char tmp[64]; 00081 strcat(log,ltoa(io_error,tmp,10)); 00082 strcat(log,": "); 00083 strcat(log,sock_error(io_error)); 00084 log_identd(log); 00085 }
Here is the call graph for this function: ![]() |
|
Resets IDENT daemon (both IPv4 and IPv6).
Definition at line 376 of file identd.cpp. References s_socket::clear(), s_socket::cmp(), ident_last_response, and sock_close(). Referenced by logic_exec(). 00377 { 00378 if(identd_client.cmp()) { 00379 sock_close(identd_client); 00380 identd_client.clear(); 00381 ident_last_response=0; 00382 } 00383 00384 #ifdef IPv6 00385 if(identd_client_ipv6.cmp()) { 00386 sock_close(identd_client_ipv6); 00387 identd_client_ipv6.clear(); 00388 ident_last_response=0; 00389 } 00390 #endif 00391 }
Here is the call graph for this function: ![]() |
|
Shuts down IDENT daemon (both IPv4 and IPv6).
Definition at line 309 of file identd.cpp. References s_socket::clear(), s_socket::cmp(), ident_last_response, log_identd(), and sock_close(). Referenced by logic_exec(). 00310 { 00311 if(identd_sock.cmp()) { 00312 log_identd("Shuted down (IPv4)"); 00313 sock_close(identd_sock); 00314 identd_sock.clear(); 00315 sock_close(identd_client); 00316 identd_client.clear(); 00317 ident_last_response=0; 00318 } 00319 00320 #ifdef IPv6 00321 if(identd_sock_ipv6.cmp()) { 00322 log_identd("Shuted down (IPv6)"); 00323 sock_close(identd_sock_ipv6); 00324 identd_sock_ipv6.clear(); 00325 sock_close(identd_client_ipv6); 00326 identd_client_ipv6.clear(); 00327 ident_last_response=0; 00328 } 00329 #endif 00330 }
Here is the call graph for this function: ![]() |
|
Starts IDENT daemon.
Definition at line 96 of file identd.cpp. Referenced by logic_exec(). 00097 { 00098 if(identd_sock.cmp()) { 00099 sock_close(identd_sock); 00100 identd_sock.clear(); 00101 sock_close(identd_client); 00102 identd_client.clear(); 00103 ident_last_response=0; 00104 } 00105 00106 int error_code=0; 00107 identd_sock=sock_bind(bind,port,error_code); 00108 if(!identd_sock.cmp()) { 00109 identd_error_log(error_code); 00110 return false; 00111 } 00112 log_identd("Started up (IPv4)"); 00113 00114 return true; 00115 }
|
|
ltoa() emulation for compiler which doesn't have it
Definition at line 171 of file dcc.cpp.
|
|
Timestamp of last response.
Definition at line 67 of file identd.cpp. Referenced by identd4_shutdown(), identd6_shutdown(), identd_check(), identd_renew(), identd_shutdown(), and identd_startup(). |
|
Socket of IDENTD client.
Definition at line 62 of file identd.cpp. |
|
Stores socket handle of IDENT daemon.
Definition at line 61 of file identd.cpp. |