~ubuntu-branches/ubuntu/saucy/postfix/saucy

« back to all changes in this revision

Viewing changes to src/tls/tls_proxy_print.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2011-02-22 11:20:43 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20110222112043-c34ht219w3ybrilr
Tags: 2.8.0-2
* a little more lintian cleanup
* Fix missing format strings in smtp-sink.c

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
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,
 
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_INT, MAIL_ATTR_PEER_STATUS,
 
71
                   tp->peer_status,
 
72
                   ATTR_TYPE_STR, MAIL_ATTR_CIPHER_PROTOCOL,
 
73
                   STRING_OR_EMPTY(tp->protocol),
 
74
                   ATTR_TYPE_STR, MAIL_ATTR_CIPHER_NAME,
 
75
                   STRING_OR_EMPTY(tp->cipher_name),
 
76
                   ATTR_TYPE_INT, MAIL_ATTR_CIPHER_USEBITS,
 
77
                   tp->cipher_usebits,
 
78
                   ATTR_TYPE_INT, MAIL_ATTR_CIPHER_ALGBITS,
 
79
                   tp->cipher_algbits,
 
80
                   ATTR_TYPE_END);
 
81
    return (ret);
 
82
}
 
83
 
 
84
#endif