1/* pptp_ctrl.h ... handle PPTP control connection.
2 *                 C. Scott Ananian <cananian@alumni.princeton.edu>
3 *
4 * $Id: pptp_ctrl.h,v 1.5 2004/11/09 01:42:32 quozl Exp $
5 */
6
7#ifndef INC_PPTP_CTRL_H
8#define INC_PPTP_CTRL_H
9#include <sys/types.h>
10
11typedef struct PPTP_CONN PPTP_CONN;
12typedef struct PPTP_CALL PPTP_CALL;
13
14enum call_state { CALL_OPEN_RQST,  CALL_OPEN_DONE, CALL_OPEN_FAIL,
15		  CALL_CLOSE_RQST, CALL_CLOSE_DONE };
16enum conn_state { CONN_OPEN_RQST,  CONN_OPEN_DONE, CONN_OPEN_FAIL,
17		  CONN_CLOSE_RQST, CONN_CLOSE_DONE };
18
19typedef void (*pptp_call_cb)(PPTP_CONN*, PPTP_CALL*, enum call_state);
20typedef void (*pptp_conn_cb)(PPTP_CONN*, enum conn_state);
21
22/* if 'isclient' is true, then will send 'conn open' packet to other host.
23 * not necessary if this is being opened by a server process after
24 * receiving a conn_open packet from client.
25 */
26PPTP_CONN * pptp_conn_open(int inet_sock, int isclient,
27			   pptp_conn_cb callback);
28PPTP_CALL * pptp_call_open(PPTP_CONN * conn,
29			   pptp_call_cb callback, char *phonenr);
30int pptp_conn_established(PPTP_CONN * conn);
31/* soft close.  Will callback on completion. */
32void pptp_call_close(PPTP_CONN * conn, PPTP_CALL * call);
33/* hard close. */
34void pptp_call_destroy(PPTP_CONN *conn, PPTP_CALL *call);
35/* soft close.  Will callback on completion. */
36void pptp_conn_close(PPTP_CONN * conn, u_int8_t close_reason);
37/* hard close */
38void pptp_conn_destroy(PPTP_CONN * conn);
39
40/* Add file descriptors used by pptp to fd_set. */
41void pptp_fd_set(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set, int *max_fd);
42/* handle any pptp file descriptors set in fd_set, and clear them */
43int pptp_dispatch(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set);
44
45/* Get info about connection, call */
46void pptp_call_get_ids(PPTP_CONN * conn, PPTP_CALL * call,
47		       u_int16_t * call_id, u_int16_t * peer_call_id);
48/* Arbitrary user data about this call/connection.
49 * It is the caller's responsibility to free this data before calling
50 * pptp_call|conn_close()
51 */
52void * pptp_conn_closure_get(PPTP_CONN * conn);
53void   pptp_conn_closure_put(PPTP_CONN * conn, void *cl);
54void * pptp_call_closure_get(PPTP_CONN * conn, PPTP_CALL * call);
55void   pptp_call_closure_put(PPTP_CONN * conn, PPTP_CALL * call, void *cl);
56
57#endif /* INC_PPTP_CTRL_H */
58