.\" openfwtk project: peername.3 1-Nov-2000 .TH peername 3 .SH NAME peername() \- an advanced frontend to unix getpeername() function .SH SYNOPSIS .nf #include "fwfunc.h" .fi .sp int \fBpeername\fP(int fd,char *lname,char *sname,int z) .SH DESCRIPTION The \fIpeername\fP function performs peer address and dns lookups for given socket (\fIfd\fP), performs sanity and security checks to detect possibly dangerous connections and dns-driven attacks, and writes first \fIz\fP characters of text representation of the resulting ip address and lowercased host fqdn to strings pointed by \fIlname\fP (fqdn) and \fIsname\fP (address). .PP If the name lookup fails or seems to be unreliable, '\fBunknown\fP' is returned to \fIlname\fP. .SH RETURN VALUES The function return value is 0 unless getpeername() failed. .SH SECURITY CONDITIONS ip options are set on socket, .PP \fBaction:\fP 'Connection received using ip options (ignored)' securityalert is generated, options are being reset. If options reset fails,'\fBunknown\fP' is assumed as \fIlname\fP. .PP host name lookup failed, .PP \fBaction:\fP \fIlname\fP is '\fBunknown\fP', a log warning message is generated. .PP address entry returned by name server after performing reverse lookup and then forward lookup again exceeds sizeof appropriate structure, \fBaction:\fP \fIlname\fP is '\fBunknown\fP', 'invalid host address length' securityalert is generated. .PP hostname returned by reverse lookup does not resolve to ip address, .PP \fBaction:\fP \fIlname\fP is '\fBunknown\fP',i a log warning message is generated. .PP no ip addresses of hostname returned by reverse lookup match peer, .PP \fBaction:\fP \fIlname\fP is '\fBunknown\fP', a 'possible spoof' securityalert is generated. .SH SEE ALSO getpeername(3),ip2name(3) .SH HISTORY present in fwtk since v1