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