Postfix3.3.1
tls_proxy_print.c
[詳解]
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 /* ... SEND_ATTR_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 
55 int 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,
65  STRING_OR_EMPTY(tp->peer_CN)),
67  STRING_OR_EMPTY(tp->issuer_CN)),
69  STRING_OR_EMPTY(tp->peer_cert_fprint)),
71  STRING_OR_EMPTY(tp->peer_pkey_fprint)),
73  tp->peer_status),
75  STRING_OR_EMPTY(tp->protocol)),
77  STRING_OR_EMPTY(tp->cipher_name)),
79  tp->cipher_usebits),
81  tp->cipher_algbits),
83  return (ret);
84 }
85 
86 #endif
int(* ATTR_PRINT_MASTER_FN)(VSTREAM *, int,...)
Definition: attr.h:33
#define MAIL_ATTR_PEER_CN
Definition: mail_proto.h:287
#define MAIL_ATTR_CIPHER_ALGBITS
Definition: mail_proto.h:295
#define ATTR_TYPE_END
Definition: attr.h:39
#define MAIL_ATTR_PEER_PKEY_FPT
Definition: mail_proto.h:290
#define MAIL_ATTR_CIPHER_PROTOCOL
Definition: mail_proto.h:292
#define SEND_ATTR_INT(name, val)
Definition: attr.h:63
#define MAIL_ATTR_CIPHER_USEBITS
Definition: mail_proto.h:294
#define MAIL_ATTR_PEER_CERT_FPT
Definition: mail_proto.h:289
#define MAIL_ATTR_CIPHER_NAME
Definition: mail_proto.h:293
#define MAIL_ATTR_PEER_STATUS
Definition: mail_proto.h:291
#define ATTR_FLAG_MORE
Definition: attr.h:101
#define SEND_ATTR_STR(name, val)
Definition: attr.h:64
#define MAIL_ATTR_ISSUER_CN
Definition: mail_proto.h:288