3 * $Id: ident.h,v 1.2 1999/12/10 23:42:04 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,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.2 1999/12/10 23:42:04 mdw
34 * Change header file guard names.
36 * Revision 1.1 1999/10/04 21:41:58 mdw
37 * Added ident client from `fw'.
48 /*----- Header files ------------------------------------------------------*/
50 #include <sys/types.h>
51 #include <sys/socket.h>
52 #include <netinet/in.h>
53 #include <arpa/inet.h>
67 /*----- Data structures ---------------------------------------------------*/
69 /* --- Parsed response from ident server --- */
71 typedef struct ident_reply {
72 unsigned short sport, dport; /* Source and destination ports */
73 unsigned type; /* Type of reply from server */
76 char *os; /* Operating system name */
77 char *user; /* User name */
79 char *error; /* Error message from server */
83 /* --- Response type codes --- */
91 /* --- Request structure --- */
93 typedef struct ident_request {
94 struct sockaddr_in local, remote;
96 void (*func)(ident_reply */*i*/, void */*p*/);
109 /*----- Functions provided ------------------------------------------------*/
111 /* --- @ident_abort@ --- *
113 * Arguments: @ident_request *rq@ = pointer to request block
117 * Use: Cancels an ident request in progress.
120 extern void ident_abort(ident_request */*rq*/);
124 * Arguments: @ident_request *rq@ = pointer to request block
125 * @sel_state *s@ = I/O multiplexor
126 * @const struct sockaddr_in *local, *remote@ = addresses
127 * @void (*func)(ident_reply *i, void *p)@ = handler function
128 * @void *p@ = argument for handler
132 * Use: Initializes an ident request.
135 extern void ident(ident_request */*rq*/, sel_state */*s*/,
136 const struct sockaddr_in */*local*/,
137 const struct sockaddr_in */*remote*/,
138 void (*/*func*/)(ident_reply */*i*/, void */*p*/),
141 /* --- @ident_socket@ --- *
143 * Arguments: @ident_request *rq@ = pointer to request block
144 * @sel_state *s@ = I/O multiplexor
145 * @int sk@ = connected socket file descriptor
146 * @void (*func)(ident_reply *i, void *p)@ = handler function
147 * @void *p@ = argument for handler
151 * Use: An alternative interface to @ident@. Initializes an ident
152 * request from a connected socket, rather than from an explicit
153 * address. This will call @getsockname@ and @getpeername@ to
154 * find out what the socket is actually connected to, which adds
155 * convenience but wastes time.
158 extern void ident_socket(ident_request */*rq*/, sel_state */*s*/, int /*sk*/,
159 void (*/*func*/)(ident_reply */*i*/, void */*p*/),
162 /*----- That's all, folks -------------------------------------------------*/