1263970Sdes/* $OpenBSD: monitor.h,v 1.18 2014/01/29 06:18:35 djm Exp $ */
298675Sdes
398675Sdes/*
498675Sdes * Copyright 2002 Niels Provos <provos@citi.umich.edu>
598675Sdes * All rights reserved.
698675Sdes *
798675Sdes * Redistribution and use in source and binary forms, with or without
898675Sdes * modification, are permitted provided that the following conditions
998675Sdes * are met:
1098675Sdes * 1. Redistributions of source code must retain the above copyright
1198675Sdes *    notice, this list of conditions and the following disclaimer.
1298675Sdes * 2. Redistributions in binary form must reproduce the above copyright
1398675Sdes *    notice, this list of conditions and the following disclaimer in the
1498675Sdes *    documentation and/or other materials provided with the distribution.
1598675Sdes *
1698675Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1798675Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1898675Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1998675Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2098675Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2198675Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2298675Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2398675Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2498675Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2598675Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2698675Sdes */
2798675Sdes
2898675Sdes#ifndef _MONITOR_H_
2998675Sdes#define _MONITOR_H_
3098675Sdes
31251135Sdes/* Please keep *_REQ_* values on even numbers and *_ANS_* on odd numbers */
3298675Sdesenum monitor_reqtype {
33251135Sdes	MONITOR_REQ_MODULI = 0, MONITOR_ANS_MODULI = 1,
34251135Sdes	MONITOR_REQ_FREE = 2,
35251135Sdes	MONITOR_REQ_AUTHSERV = 4,
36251135Sdes	MONITOR_REQ_SIGN = 6, MONITOR_ANS_SIGN = 7,
37251135Sdes	MONITOR_REQ_PWNAM = 8, MONITOR_ANS_PWNAM = 9,
38251135Sdes	MONITOR_REQ_AUTH2_READ_BANNER = 10, MONITOR_ANS_AUTH2_READ_BANNER = 11,
39251135Sdes	MONITOR_REQ_AUTHPASSWORD = 12, MONITOR_ANS_AUTHPASSWORD = 13,
40251135Sdes	MONITOR_REQ_BSDAUTHQUERY = 14, MONITOR_ANS_BSDAUTHQUERY = 15,
41251135Sdes	MONITOR_REQ_BSDAUTHRESPOND = 16, MONITOR_ANS_BSDAUTHRESPOND = 17,
42251135Sdes	MONITOR_REQ_SKEYQUERY = 18, MONITOR_ANS_SKEYQUERY = 19,
43251135Sdes	MONITOR_REQ_SKEYRESPOND = 20, MONITOR_ANS_SKEYRESPOND = 21,
44251135Sdes	MONITOR_REQ_KEYALLOWED = 22, MONITOR_ANS_KEYALLOWED = 23,
45251135Sdes	MONITOR_REQ_KEYVERIFY = 24, MONITOR_ANS_KEYVERIFY = 25,
46251135Sdes	MONITOR_REQ_KEYEXPORT = 26,
47251135Sdes	MONITOR_REQ_PTY = 28, MONITOR_ANS_PTY = 29,
48251135Sdes	MONITOR_REQ_PTYCLEANUP = 30,
49251135Sdes	MONITOR_REQ_SESSKEY = 32, MONITOR_ANS_SESSKEY = 33,
50251135Sdes	MONITOR_REQ_SESSID = 34,
51251135Sdes	MONITOR_REQ_RSAKEYALLOWED = 36, MONITOR_ANS_RSAKEYALLOWED = 37,
52251135Sdes	MONITOR_REQ_RSACHALLENGE = 38, MONITOR_ANS_RSACHALLENGE = 39,
53251135Sdes	MONITOR_REQ_RSARESPONSE = 40, MONITOR_ANS_RSARESPONSE = 41,
54251135Sdes	MONITOR_REQ_GSSSETUP = 42, MONITOR_ANS_GSSSETUP = 43,
55251135Sdes	MONITOR_REQ_GSSSTEP = 44, MONITOR_ANS_GSSSTEP = 45,
56251135Sdes	MONITOR_REQ_GSSUSEROK = 46, MONITOR_ANS_GSSUSEROK = 47,
57251135Sdes	MONITOR_REQ_GSSCHECKMIC = 48, MONITOR_ANS_GSSCHECKMIC = 49,
58251135Sdes	MONITOR_REQ_TERM = 50,
59251135Sdes
60251135Sdes	MONITOR_REQ_PAM_START = 100,
61251135Sdes	MONITOR_REQ_PAM_ACCOUNT = 102, MONITOR_ANS_PAM_ACCOUNT = 103,
62251135Sdes	MONITOR_REQ_PAM_INIT_CTX = 104, MONITOR_ANS_PAM_INIT_CTX = 105,
63251135Sdes	MONITOR_REQ_PAM_QUERY = 106, MONITOR_ANS_PAM_QUERY = 107,
64251135Sdes	MONITOR_REQ_PAM_RESPOND = 108, MONITOR_ANS_PAM_RESPOND = 109,
65251135Sdes	MONITOR_REQ_PAM_FREE_CTX = 110, MONITOR_ANS_PAM_FREE_CTX = 111,
66251135Sdes	MONITOR_REQ_AUDIT_EVENT = 112, MONITOR_REQ_AUDIT_COMMAND = 113,
67251135Sdes
6898675Sdes};
6998675Sdes
7098675Sdesstruct mm_master;
7198675Sdesstruct monitor {
7298675Sdes	int			 m_recvfd;
7398675Sdes	int			 m_sendfd;
74247485Sdes	int			 m_log_recvfd;
75247485Sdes	int			 m_log_sendfd;
7698675Sdes	struct mm_master	*m_zback;
7798675Sdes	struct mm_master	*m_zlib;
7898675Sdes	struct Kex		**m_pkex;
7998675Sdes	pid_t			 m_pid;
8098675Sdes};
8198675Sdes
8298675Sdesstruct monitor *monitor_init(void);
8398675Sdesvoid monitor_reinit(struct monitor *);
8498675Sdesvoid monitor_sync(struct monitor *);
8598675Sdes
8698675Sdesstruct Authctxt;
87126277Sdesvoid monitor_child_preauth(struct Authctxt *, struct monitor *);
8898675Sdesvoid monitor_child_postauth(struct monitor *);
8998675Sdes
9098675Sdesstruct mon_table;
9198675Sdesint monitor_read(struct monitor*, struct mon_table *, struct mon_table **);
9298675Sdes
9398675Sdes/* Prototypes for request sending and receiving */
9498675Sdesvoid mm_request_send(int, enum monitor_reqtype, Buffer *);
9598675Sdesvoid mm_request_receive(int, Buffer *);
9698675Sdesvoid mm_request_receive_expect(int, enum monitor_reqtype, Buffer *);
9798675Sdes
9898675Sdes#endif /* _MONITOR_H_ */
99