📄 ident.3
字号:
.\" P鋜 Emanuelsson <pell@lysator.liu.se> 1993-03-28.ds : \h'\w'u'u/5'\z"\h'-\w'e'u/5'.TH IDENT 3N "4 April 1993" "Lysator ACS".SH NAMEident_lookup, ident_id, ident_free, id_open, id_close, id_query, id_parse,id_fileno \- query remote IDENT server.SH SYNOPSIS.nf.B #include <ident.h>.LP.I High-level calls.LP.B IDENT *ident_lookup(int fd, int timeout).LP.B char *ident_id(int fd, int timeout).LP.B void ident_free(IDENT *id).LP.I Low-level calls.LP.B id_t *id_open(laddr, faddr, timeout).B struct in_addr *laddr, *faddr;.B struct timeval *timeout;.LP.B int id_close(id).B id_t *id;.LP.B id_query(id, lport, fport, timeout).B id_t *id;.B int lport, fport;.B struct timeval *timeout;.LP.B int id_parse(id, timeout, lport, fport, identifier,.B opsys, charset).B id_t *id;.B struct timeval *timeout;.B int *lport, *fport;.B char **identifier, **opsys, **charset;.LP.B int id_fileno(id).B id_t *id;.fi.SH DESCRIPTION.LP.B ident_lookuptries to connect to a remote.B IDENTserver to establish the identity of the peer connected on.I fd,which should be a socket file descriptor..I timeoutis the longest permissible time to block waiting for an answer, and isgiven in seconds. A value of 0 (zero) means wait indefinitely (which in themost extreme case will normally be until the underlying network times out)..B ident_lookupreturns a pointer to an.I IDENTstruct, which has the following contents:.RS.LP.nf.ft Btypedef struct { int lport; /* Local port */ int fport; /* Far (remote) port */ char *identifier; /* Normally user name */ char *opsys; /* OS */ char *charset; /* Charset (what did you expect?) */} IDENT;.ft R.fi.RE.LPFor a full description of the different fields, refer to.I RFC-1413..LPAll data returned by.B ident_lookup(including the.SM IDENTstruct) points to malloc'd data, which can be freed with a call to.B ident_free..B ident_lookupreturns 0 on error or timeout. Presently, this should normally be taken tomean that the remote site is not running an.SM IDENTserver, but it might naturally be caused by other network related problemsas well..B Note thatall fields of the.SM IDENTstruct need not necessarily be set..LP.B ident_idtakes the same parameters as.B ident_lookupbut only returns a pointer to a malloc'd area containing the.I identifierstring, which is probably the most wanted data from the.SM IDENTquery..LP.B ident_freefrees all data areas associated with the.SM IDENTstruct pointed to by.I id,including the struct itself..LP.ce.I Low-level calls.LPThe low-level calls can be used when greater flexibility is needed. Forexample, if non-blocking I/O is needed, or multiple queries to thesame host are to be made..LP.B id_openopens a connection to the remote.SM IDENTserver referred to by.I faddr.The timeout is specified by.I timeout.A null-pointer means wait indefinitely, while a pointer to azero-valued.I timevalstruct sets non-blocking I/O, in the same way as for.B select(2)..B id_openreturns a pointer to an.B id_tdatum, which is an opaque structure to be used as future referenceto the opened connection. When using non-blocking I/O it might howeverbe useful to access the underlying socket file descriptior, whichcan be gotten at through the.B id_filenomacro described below..LP.B id_closecloses the connection opened with.B id_openand frees all data associated with.I id..LP.B id_querysends off a query to a remote.SM IDENTserver..I lportand.I fportare sent to the server to identify the connection for whichidentification is needed..I timeoutis given as for.B id_open.If successful,.B id_queryreturns the number of bytes sent to the remote server. If not, -1 isreturned and.B errnois set..LP.B id_parseparses the reply to a query sent off by.B id_queryand returns information to the locations pointed to by.I lport, fport, identifier, opsysand.I charset.For string data.I (identifier, opsysand.I charset)pointers to malloc'd space are returned..LP.B id_parsereturns:.RS.TP 1If completely successful..TP-3Illegal reply type from remote server..I identifieris set to the illegal reply..TP-2Cannot parse the reply from the server..I identifieris normally set to the illegal reply..TP-1On general errors or timeout..TP 0When non-blocking mode is set and.B id_parsehas not finished parsing the reply from the remote server..TP 2Indicates the query/reply were successful, but the remote serverexperienced some error..I identifieris set to the error message from the remote server..RE.LPFor all errors,.I errnois set as appropriate..LP.B id_filenois a macro that takes an.B id_thandle and returns the actual socket file descriptor used forthe connection to the remote server..SH ERRORS.TP 15ETIMEDOUTThe call timed out and non-blocking I/O was not set..SH EXAMPLES.LPHere's an example how to handle the reply from id_reply() inthe case that non-blocking I/O is set. Note that id_reply() willreturn 0 as long as it's not finished parsing a reply..LP.RS.nf.njint rcode; ...idp = id_open(...) ...while ((rcode = id_parse(idp, timeout, &lport, &fport, &id, &op, &cs)) == 0) ;if (rcode < 0){ if (rcode == ETIMEDOUT) foo(); /* Lookup timed out */ else bar(); /* Fatal error */}else if (rcode == 1){ /* Valid USERID protocol reply */}else if (rcode == 2){ /* Protocol ERROR reply */}.fi.RE.SH SEE ALSORFC-1413, socket(2), select(2).SH AUTHORSPeter Eriksson.I <pen@lysator.liu.se>.brP\*:ar Emanuelsson.I <pell@lysator.liu.se>.SH BUGSFor.B ident_lookupand.B ident_idthe blocking time in extreme cases might be as much as three timesthe value given in the.I timeoutparameter.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -