1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2003 by Sun Microsystems, Inc.	All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  *
5*7c478bd9Sstevel@tonic-gate  */
6*7c478bd9Sstevel@tonic-gate 
7*7c478bd9Sstevel@tonic-gate /*
8*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1999 by Internet Software Consortium.
9*7c478bd9Sstevel@tonic-gate  *
10*7c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software for any
11*7c478bd9Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
12*7c478bd9Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
15*7c478bd9Sstevel@tonic-gate  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
16*7c478bd9Sstevel@tonic-gate  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
17*7c478bd9Sstevel@tonic-gate  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
18*7c478bd9Sstevel@tonic-gate  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
19*7c478bd9Sstevel@tonic-gate  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
20*7c478bd9Sstevel@tonic-gate  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21*7c478bd9Sstevel@tonic-gate  * SOFTWARE.
22*7c478bd9Sstevel@tonic-gate  */
23*7c478bd9Sstevel@tonic-gate 
24*7c478bd9Sstevel@tonic-gate /*
25*7c478bd9Sstevel@tonic-gate  * $Id: irp.h,v 8.4 2003/05/02 05:56:21 marka Exp $
26*7c478bd9Sstevel@tonic-gate  */
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate #ifndef _IRP_H_INCLUDED
29*7c478bd9Sstevel@tonic-gate #define _IRP_H_INCLUDED
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #define IRPD_TIMEOUT 30			/* seconds */
34*7c478bd9Sstevel@tonic-gate #define IRPD_MAXSESS 50			/* number of simultaneous sessions. */
35*7c478bd9Sstevel@tonic-gate #define IRPD_PORT 6660			/* 10 times the number of the beast. */
36*7c478bd9Sstevel@tonic-gate #define IRPD_PATH "/var/run/irpd"	/* af_unix socket path */
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /* If sets the environment variable IRPDSERVER to an IP address
39*7c478bd9Sstevel@tonic-gate    (e.g. "192.5.5.1"), then that's the host the client expects irpd to be
40*7c478bd9Sstevel@tonic-gate    running on. */
41*7c478bd9Sstevel@tonic-gate #define IRPD_HOST_ENV "IRPDSERVER"
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /* Protocol response codes.  */
44*7c478bd9Sstevel@tonic-gate #define IRPD_WELCOME_CODE 200
45*7c478bd9Sstevel@tonic-gate #define IRPD_NOT_WELCOME_CODE 500
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #define IRPD_GETHOST_ERROR 510
48*7c478bd9Sstevel@tonic-gate #define IRPD_GETHOST_NONE 210
49*7c478bd9Sstevel@tonic-gate #define IRPD_GETHOST_OK 211
50*7c478bd9Sstevel@tonic-gate #define IRPD_GETHOST_SETOK 212
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate #define IRPD_GETNET_ERROR 520
53*7c478bd9Sstevel@tonic-gate #define IRPD_GETNET_NONE 220
54*7c478bd9Sstevel@tonic-gate #define IRPD_GETNET_OK 221
55*7c478bd9Sstevel@tonic-gate #define IRPD_GETNET_SETOK 222
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #define IRPD_GETUSER_ERROR 530
58*7c478bd9Sstevel@tonic-gate #define IRPD_GETUSER_NONE 230
59*7c478bd9Sstevel@tonic-gate #define IRPD_GETUSER_OK 231
60*7c478bd9Sstevel@tonic-gate #define IRPD_GETUSER_SETOK 232
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate #define IRPD_GETGROUP_ERROR 540
63*7c478bd9Sstevel@tonic-gate #define IRPD_GETGROUP_NONE 240
64*7c478bd9Sstevel@tonic-gate #define IRPD_GETGROUP_OK 241
65*7c478bd9Sstevel@tonic-gate #define IRPD_GETGROUP_SETOK 242
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate #define IRPD_GETSERVICE_ERROR 550
68*7c478bd9Sstevel@tonic-gate #define IRPD_GETSERVICE_NONE 250
69*7c478bd9Sstevel@tonic-gate #define IRPD_GETSERVICE_OK 251
70*7c478bd9Sstevel@tonic-gate #define IRPD_GETSERVICE_SETOK 252
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate #define IRPD_GETPROTO_ERROR 560
73*7c478bd9Sstevel@tonic-gate #define IRPD_GETPROTO_NONE 260
74*7c478bd9Sstevel@tonic-gate #define IRPD_GETPROTO_OK 261
75*7c478bd9Sstevel@tonic-gate #define IRPD_GETPROTO_SETOK 262
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate #define IRPD_GETNETGR_ERROR 570
78*7c478bd9Sstevel@tonic-gate #define IRPD_GETNETGR_NONE 270
79*7c478bd9Sstevel@tonic-gate #define IRPD_GETNETGR_OK 271
80*7c478bd9Sstevel@tonic-gate #define IRPD_GETNETGR_NOMORE 272
81*7c478bd9Sstevel@tonic-gate #define IRPD_GETNETGR_MATCHES 273
82*7c478bd9Sstevel@tonic-gate #define IRPD_GETNETGR_NOMATCH 274
83*7c478bd9Sstevel@tonic-gate #define IRPD_GETNETGR_SETOK 275
84*7c478bd9Sstevel@tonic-gate #define IRPD_GETNETGR_SETERR 276
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate #define	irs_irp_read_body __irs_irp_read_body
87*7c478bd9Sstevel@tonic-gate #define irs_irp_read_response __irs_irp_read_response
88*7c478bd9Sstevel@tonic-gate #define irs_irp_disconnect __irs_irp_disconnect
89*7c478bd9Sstevel@tonic-gate #define irs_irp_connect __irs_irp_connect
90*7c478bd9Sstevel@tonic-gate #define irs_irp_connection_setup __irs_irp_connection_setup
91*7c478bd9Sstevel@tonic-gate #define irs_irp_send_command __irs_irp_send_command
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate struct irp_p;
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate char   *irs_irp_read_body(struct irp_p *pvt, size_t *size);
96*7c478bd9Sstevel@tonic-gate int	irs_irp_read_response(struct irp_p *pvt, char *text, size_t len);
97*7c478bd9Sstevel@tonic-gate void	irs_irp_disconnect(struct irp_p *pvt);
98*7c478bd9Sstevel@tonic-gate int	irs_irp_connect(struct irp_p *pvt);
99*7c478bd9Sstevel@tonic-gate int	irs_irp_is_connected(struct irp_p *pvt);
100*7c478bd9Sstevel@tonic-gate int	irs_irp_connection_setup(struct irp_p *cxndata, int *warned);
101*7c478bd9Sstevel@tonic-gate #ifdef	__GNUC__
102*7c478bd9Sstevel@tonic-gate int	irs_irp_send_command(struct irp_p *, const char *, ...)
103*7c478bd9Sstevel@tonic-gate 			__attribute__((__format__(__printf__, 2, 3)));
104*7c478bd9Sstevel@tonic-gate #else
105*7c478bd9Sstevel@tonic-gate int	irs_irp_send_command(struct irp_p *pvt, const char *fmt, ...);
106*7c478bd9Sstevel@tonic-gate #endif
107*7c478bd9Sstevel@tonic-gate int	irs_irp_get_full_response(struct irp_p *pvt, int *code, char *text,
108*7c478bd9Sstevel@tonic-gate 				  size_t textlen, char **body,
109*7c478bd9Sstevel@tonic-gate 				  size_t *bodylen);
110*7c478bd9Sstevel@tonic-gate int	irs_irp_read_line(struct irp_p *pvt, char *buffer, int len);
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate #endif
113