|
|
|
@ -22,8 +22,11 @@
|
|
|
|
|
int answ_system(e_session type, char *connstr, int inetd)
|
|
|
|
|
{
|
|
|
|
|
TIO oldtio;
|
|
|
|
|
struct sockaddr_in client;
|
|
|
|
|
struct sockaddr_storage client;
|
|
|
|
|
int clientlen = sizeof(client);
|
|
|
|
|
char clienthost[NI_MAXHOST];
|
|
|
|
|
char clientport[NI_MAXSERV];
|
|
|
|
|
int clientres = 0;
|
|
|
|
|
int rc = 0;
|
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
|
@ -74,18 +77,18 @@ int answ_system(e_session type, char *connstr, int inetd)
|
|
|
|
|
log("Answering TCPIP call...");
|
|
|
|
|
if( connstr && *connstr )
|
|
|
|
|
state.connstr = (char*)xstrcpy(connstr);
|
|
|
|
|
else if( getpeername(0, (struct sockaddr*)&client, &clientlen) == -1 )
|
|
|
|
|
logerr("can't get client address");
|
|
|
|
|
else
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef IPV6
|
|
|
|
|
>char addr_str[INET6_ADDRSTRLEN+1];
|
|
|
|
|
state.peername = (char*)xstrcpy(inet_ntop(AF_INET6, client.sin6_addr, addr_str, INET6_ADDRSTRLEN));
|
|
|
|
|
state.peerport = (long)ntohs(client.sin6_port);
|
|
|
|
|
#else
|
|
|
|
|
state.peername = (char*)xstrcpy(inet_ntoa(client.sin_addr));
|
|
|
|
|
state.peerport = (long)ntohs(client.sin_port);
|
|
|
|
|
#endif
|
|
|
|
|
clientres = getnameinfo( (struct sockaddr*)&client, clientlen,
|
|
|
|
|
clienthost, sizeof(clienthost), clientport,
|
|
|
|
|
sizeof(clientport), NI_NUMERICHOST | NI_NUMERICSERV);
|
|
|
|
|
if ( clientres == 0 )
|
|
|
|
|
{
|
|
|
|
|
state.peername = (char*)xstrcpy(clienthost);
|
|
|
|
|
state.peerport = (long)atol(clientport);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
log("sess_answ: can't get client address: ", gai_strerror(clientres));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|