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