peername(3)

NAME
peername() - an advanced frontend to unix getpeername() function

SYNOPSIS
#include "fwfunc.h"

int peername(int fd,char *lname,char *sname,int z)

DESCRIPTION
The peername function performs peer address and dns lookups for given socket (fd), performs sanity and security checks to detect possibly dangerous connections and dns-driven attacks, and writes first z characters of text representation of the resulting ip address and lowercased host fqdn to strings pointed by lname (fqdn) and sname (address).

If the name lookup fails or seems to be unreliable, 'unknown' is returned to lname.

RETURN VALUES
The function return value is 0 unless getpeername() failed.

SECURITY CONDITIONS
ip options are set on socket,

action: 'Connection received using ip options (ignored)' securityalert is generated, options are being reset. If options reset fails,'unknown' is assumed as lname.

host name lookup failed,

action: lname is 'unknown', a log warning message is generated.

address entry returned by name server after performing reverse lookup and then forward lookup again exceeds sizeof appropriate structure, action: lname is 'unknown', 'invalid host address length' securityalert is generated.

hostname returned by reverse lookup does not resolve to ip address,

action: lname is 'unknown',i a log warning message is generated.

no ip addresses of hostname returned by reverse lookup match peer,

action: lname is 'unknown', a 'possible spoof' securityalert is generated.

SEE ALSO
getpeername(3),ip2name(3)

HISTORY
present in fwtk since v1