10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * include/cm.h 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * Copyright 2002 by the Massachusetts Institute of Technology. 50Sstevel@tonic-gate * All Rights Reserved. 60Sstevel@tonic-gate * 70Sstevel@tonic-gate * Export of this software from the United States of America may 80Sstevel@tonic-gate * require a specific license from the United States Government. 90Sstevel@tonic-gate * It is the responsibility of any person or organization contemplating 100Sstevel@tonic-gate * export to obtain such a license before exporting. 110Sstevel@tonic-gate * 120Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 130Sstevel@tonic-gate * distribute this software and its documentation for any purpose and 140Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright 150Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and 160Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that 170Sstevel@tonic-gate * the name of M.I.T. not be used in advertising or publicity pertaining 180Sstevel@tonic-gate * to distribution of the software without specific, written prior 190Sstevel@tonic-gate * permission. Furthermore if you modify this software you must label 200Sstevel@tonic-gate * your software as modified software and not distribute it in such a 210Sstevel@tonic-gate * fashion that it might be confused with the original M.I.T. software. 220Sstevel@tonic-gate * M.I.T. makes no representations about the suitability of 230Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express 240Sstevel@tonic-gate * or implied warranty. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 27*7934SMark.Phalan@Sun.COM /* Since fd_set is large on some platforms (8K on AIX 5.2), this 28*7934SMark.Phalan@Sun.COM probably shouldn't be allocated in automatic storage. */ 290Sstevel@tonic-gate struct select_state { 300Sstevel@tonic-gate int max, nfds; 310Sstevel@tonic-gate fd_set rfds, wfds, xfds; 320Sstevel@tonic-gate struct timeval end_time; /* magic: tv_sec==0 => never time out */ 330Sstevel@tonic-gate }; 340Sstevel@tonic-gate 35*7934SMark.Phalan@Sun.COM 360Sstevel@tonic-gate /* Select state flags. */ 370Sstevel@tonic-gate #define SSF_READ 0x01 380Sstevel@tonic-gate #define SSF_WRITE 0x02 390Sstevel@tonic-gate #define SSF_EXCEPTION 0x04 400Sstevel@tonic-gate 41*7934SMark.Phalan@Sun.COM 42*7934SMark.Phalan@Sun.COM static const char *const state_strings[] = { 43*7934SMark.Phalan@Sun.COM "INITIALIZING", "CONNECTING", "WRITING", "READING", "FAILED" 44*7934SMark.Phalan@Sun.COM }; 45*7934SMark.Phalan@Sun.COM 46*7934SMark.Phalan@Sun.COM 47*7934SMark.Phalan@Sun.COM /* connection states */ 48*7934SMark.Phalan@Sun.COM enum conn_states { INITIALIZING, CONNECTING, WRITING, READING, FAILED }; 49*7934SMark.Phalan@Sun.COM struct incoming_krb5_message { 50*7934SMark.Phalan@Sun.COM size_t bufsizebytes_read; 51*7934SMark.Phalan@Sun.COM size_t bufsize; 52*7934SMark.Phalan@Sun.COM char *buf; 53*7934SMark.Phalan@Sun.COM char *pos; 54*7934SMark.Phalan@Sun.COM unsigned char bufsizebytes[4]; 55*7934SMark.Phalan@Sun.COM size_t n_left; 56*7934SMark.Phalan@Sun.COM }; 57*7934SMark.Phalan@Sun.COM struct conn_state { 58*7934SMark.Phalan@Sun.COM SOCKET fd; 59*7934SMark.Phalan@Sun.COM krb5_error_code err; 60*7934SMark.Phalan@Sun.COM enum conn_states state; 61*7934SMark.Phalan@Sun.COM unsigned int is_udp : 1; 62*7934SMark.Phalan@Sun.COM int (*service)(struct conn_state *, struct select_state *, int); 63*7934SMark.Phalan@Sun.COM struct addrinfo *addr; 64*7934SMark.Phalan@Sun.COM struct { 65*7934SMark.Phalan@Sun.COM struct { 66*7934SMark.Phalan@Sun.COM sg_buf sgbuf[2]; 67*7934SMark.Phalan@Sun.COM sg_buf *sgp; 68*7934SMark.Phalan@Sun.COM int sg_count; 69*7934SMark.Phalan@Sun.COM unsigned char msg_len_buf[4]; 70*7934SMark.Phalan@Sun.COM } out; 71*7934SMark.Phalan@Sun.COM struct incoming_krb5_message in; 72*7934SMark.Phalan@Sun.COM } x; 73*7934SMark.Phalan@Sun.COM }; 74*7934SMark.Phalan@Sun.COM 75*7934SMark.Phalan@Sun.COM struct sendto_callback_info { 76*7934SMark.Phalan@Sun.COM int (*pfn_callback) (struct conn_state *, void *, krb5_data *); 77*7934SMark.Phalan@Sun.COM void (*pfn_cleanup) (void *, krb5_data *); 78*7934SMark.Phalan@Sun.COM void *context; 79*7934SMark.Phalan@Sun.COM }; 80*7934SMark.Phalan@Sun.COM 81*7934SMark.Phalan@Sun.COM 820Sstevel@tonic-gate krb5_error_code krb5int_cm_call_select (const struct select_state *, 830Sstevel@tonic-gate struct select_state *, int *); 84