chiark / gitweb /
Undefine PATHSEP when finished with.
[mLib] / ident.h
CommitLineData
7bd2091e 1/* -*-c-*-
2 *
3 * $Id: ident.h,v 1.1 1999/10/04 21:41:58 mdw Exp $
4 *
5 * Nonblocking RFC931 client
6 *
7 * (c) 1999 Mark Wooding
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the mLib utilities library.
13 *
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.
18 *
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.
23 *
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,
27 * MA 02111-1307, USA.
28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: ident.h,v $
33 * Revision 1.1 1999/10/04 21:41:58 mdw
34 * Added ident client from `fw'.
35 *
36 */
37
38#ifndef IDENT_H
39#define IDENT_H
40
41#ifdef __cplusplus
42 extern "C" {
43#endif
44
45/*----- Header files ------------------------------------------------------*/
46
47#include <sys/types.h>
48#include <sys/socket.h>
49#include <netinet/in.h>
50#include <arpa/inet.h>
51
52#ifndef CONN_H
53# include "conn.h"
54#endif
55
56#ifndef SEL_H
57# include "sel.h"
58#endif
59
60#ifndef SELBUF_H
61# include "selbuf.h"
62#endif
63
64/*----- Data structures ---------------------------------------------------*/
65
66/* --- Parsed response from ident server --- */
67
68typedef struct ident_reply {
69 unsigned short sport, dport; /* Source and destination ports */
70 unsigned type; /* Type of reply from server */
71 union {
72 struct {
73 char *os; /* Operating system name */
74 char *user; /* User name */
75 } userid;
76 char *error; /* Error message from server */
77 } u;
78} ident_reply;
79
80/* --- Response type codes --- */
81
82enum {
83 IDENT_USERID,
84 IDENT_ERROR,
85 IDENT_BAD
86};
87
88/* --- Request structure --- */
89
90typedef struct ident_request {
91 struct sockaddr_in local, remote;
92 unsigned state;
93 void (*func)(ident_reply */*i*/, void */*p*/);
94 void *p;
95 sel_state *s;
96 conn c;
97 selbuf b;
98} ident_request;
99
100enum {
101 IDENT_CONN,
102 IDENT_READ,
103 IDENT_DONE
104};
105
106/*----- Functions provided ------------------------------------------------*/
107
108/* --- @ident_abort@ --- *
109 *
110 * Arguments: @ident_request *rq@ = pointer to request block
111 *
112 * Returns: ---
113 *
114 * Use: Cancels an ident request in progress.
115 */
116
117extern void ident_abort(ident_request */*rq*/);
118
119/* --- @ident@ --- *
120 *
121 * Arguments: @ident_request *rq@ = pointer to request block
122 * @sel_state *s@ = I/O multiplexor
123 * @const struct sockaddr_in *local, *remote@ = addresses
124 * @void (*func)(ident_reply *i, void *p)@ = handler function
125 * @void *p@ = argument for handler
126 *
127 * Returns: ---
128 *
129 * Use: Initializes an ident request.
130 */
131
132extern void ident(ident_request */*rq*/, sel_state */*s*/,
133 const struct sockaddr_in */*local*/,
134 const struct sockaddr_in */*remote*/,
135 void (*/*func*/)(ident_reply */*i*/, void */*p*/),
136 void */*p*/);
137
138/* --- @ident_socket@ --- *
139 *
140 * Arguments: @ident_request *rq@ = pointer to request block
141 * @sel_state *s@ = I/O multiplexor
142 * @int sk@ = connected socket file descriptor
143 * @void (*func)(ident_reply *i, void *p)@ = handler function
144 * @void *p@ = argument for handler
145 *
146 * Returns: ---
147 *
148 * Use: An alternative interface to @ident@. Initializes an ident
149 * request from a connected socket, rather than from an explicit
150 * address. This will call @getsockname@ and @getpeername@ to
151 * find out what the socket is actually connected to, which adds
152 * convenience but wastes time.
153 */
154
155extern void ident_socket(ident_request */*rq*/, sel_state */*s*/, int /*sk*/,
156 void (*/*func*/)(ident_reply */*i*/, void */*p*/),
157 void */*p*/);
158
159/*----- That's all, folks -------------------------------------------------*/
160
161#ifdef __cplusplus
162 }
163#endif
164
165#endif