1/*++ 2/* NAME 3/* tls_proxy_print 4/* SUMMARY 5/* write DSN structure to stream 6/* SYNOPSIS 7/* #include <tls_proxy.h> 8/* 9/* int tls_proxy_context_print(print_fn, stream, flags, ptr) 10/* ATTR_PRINT_MASTER_FN print_fn; 11/* VSTREAM *stream; 12/* int flags; 13/* void *ptr; 14/* DESCRIPTION 15/* tls_proxy_context_print() writes a TLS_SESS_STATE structure 16/* to the named stream using the specified attribute print 17/* routine. TLS_SESS_STATE() is meant to be passed as a call-back 18/* to attr_print(), thusly: 19/* 20/* ... ATTR_TYPE_FUNC, tls_proxy_context_print, (void *) tls_context, ... 21/* DIAGNOSTICS 22/* Fatal: out of memory. 23/* LICENSE 24/* .ad 25/* .fi 26/* The Secure Mailer license must be distributed with this software. 27/* AUTHOR(S) 28/* Wietse Venema 29/* IBM T.J. Watson Research 30/* P.O. Box 704 31/* Yorktown Heights, NY 10598, USA 32/*--*/ 33 34#ifdef USE_TLS 35 36/* System library. */ 37 38#include <sys_defs.h> 39 40/* Utility library */ 41 42#include <attr.h> 43 44/* Global library. */ 45 46#include <mail_proto.h> 47 48/* TLS library. */ 49 50#include <tls.h> 51#include <tls_proxy.h> 52 53/* tls_proxy_context_print - send TLS session state over stream */ 54 55int tls_proxy_context_print(ATTR_PRINT_MASTER_FN print_fn, VSTREAM *fp, 56 int flags, void *ptr) 57{ 58 TLS_SESS_STATE *tp = (TLS_SESS_STATE *) ptr; 59 int ret; 60 61#define STRING_OR_EMPTY(s) ((s) ? (s) : "") 62 63 ret = print_fn(fp, flags | ATTR_FLAG_MORE, 64 ATTR_TYPE_STR, MAIL_ATTR_PEER_CN, 65 STRING_OR_EMPTY(tp->peer_CN), 66 ATTR_TYPE_STR, MAIL_ATTR_ISSUER_CN, 67 STRING_OR_EMPTY(tp->issuer_CN), 68 ATTR_TYPE_STR, MAIL_ATTR_PEER_FPT, 69 STRING_OR_EMPTY(tp->peer_fingerprint), 70 ATTR_TYPE_STR, MAIL_ATTR_PEER_PKEY_FPT, 71 STRING_OR_EMPTY(tp->peer_pkey_fprint), 72 ATTR_TYPE_INT, MAIL_ATTR_PEER_STATUS, 73 tp->peer_status, 74 ATTR_TYPE_STR, MAIL_ATTR_CIPHER_PROTOCOL, 75 STRING_OR_EMPTY(tp->protocol), 76 ATTR_TYPE_STR, MAIL_ATTR_CIPHER_NAME, 77 STRING_OR_EMPTY(tp->cipher_name), 78 ATTR_TYPE_INT, MAIL_ATTR_CIPHER_USEBITS, 79 tp->cipher_usebits, 80 ATTR_TYPE_INT, MAIL_ATTR_CIPHER_ALGBITS, 81 tp->cipher_algbits, 82 ATTR_TYPE_END); 83 return (ret); 84} 85 86#endif 87