3 * $Id: ident.h,v 1.3 2004/04/08 01:36:11 mdw Exp $
5 * Nonblocking RFC931 client
7 * (c) 1999 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the mLib utilities library.
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
37 /*----- Header files ------------------------------------------------------*/
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
56 /*----- Data structures ---------------------------------------------------*/
58 /* --- Parsed response from ident server --- */
60 typedef struct ident_reply {
61 unsigned short sport, dport; /* Source and destination ports */
62 unsigned type; /* Type of reply from server */
65 char *os; /* Operating system name */
66 char *user; /* User name */
68 char *error; /* Error message from server */
72 /* --- Response type codes --- */
80 /* --- Request structure --- */
82 typedef struct ident_request {
83 struct sockaddr_in local, remote;
85 void (*func)(ident_reply */*i*/, void */*p*/);
98 /*----- Functions provided ------------------------------------------------*/
100 /* --- @ident_abort@ --- *
102 * Arguments: @ident_request *rq@ = pointer to request block
106 * Use: Cancels an ident request in progress.
109 extern void ident_abort(ident_request */*rq*/);
113 * Arguments: @ident_request *rq@ = pointer to request block
114 * @sel_state *s@ = I/O multiplexor
115 * @const struct sockaddr_in *local, *remote@ = addresses
116 * @void (*func)(ident_reply *i, void *p)@ = handler function
117 * @void *p@ = argument for handler
121 * Use: Initializes an ident request.
124 extern void ident(ident_request */*rq*/, sel_state */*s*/,
125 const struct sockaddr_in */*local*/,
126 const struct sockaddr_in */*remote*/,
127 void (*/*func*/)(ident_reply */*i*/, void */*p*/),
130 /* --- @ident_socket@ --- *
132 * Arguments: @ident_request *rq@ = pointer to request block
133 * @sel_state *s@ = I/O multiplexor
134 * @int sk@ = connected socket file descriptor
135 * @void (*func)(ident_reply *i, void *p)@ = handler function
136 * @void *p@ = argument for handler
140 * Use: An alternative interface to @ident@. Initializes an ident
141 * request from a connected socket, rather than from an explicit
142 * address. This will call @getsockname@ and @getpeername@ to
143 * find out what the socket is actually connected to, which adds
144 * convenience but wastes time.
147 extern void ident_socket(ident_request */*rq*/, sel_state */*s*/, int /*sk*/,
148 void (*/*func*/)(ident_reply */*i*/, void */*p*/),
151 /*----- That's all, folks -------------------------------------------------*/