~ubuntu-branches/ubuntu/raring/gnutls26/raring

« back to all changes in this revision

Viewing changes to lib/gnutls_alert.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-05-20 13:07:18 UTC
  • mfrom: (12.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110520130718-db41dybbanzfvlji
Tags: 2.10.5-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Fix build failure with --no-add-needed.
  - Build for multiarch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2008 Free Software Foundation
 
2
 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2010 Free
 
3
 * Software Foundation, Inc.
3
4
 *
4
5
 * Author: Nikos Mavrogiannopoulos
5
6
 *
6
 
 * This file is part of GNUTLS.
 
7
 * This file is part of GnuTLS.
7
8
 *
8
 
 * The GNUTLS library is free software; you can redistribute it and/or
 
9
 * The GnuTLS is free software; you can redistribute it and/or
9
10
 * modify it under the terms of the GNU Lesser General Public License
10
11
 * as published by the Free Software Foundation; either version 2.1 of
11
12
 * the License, or (at your option) any later version.
77
78
};
78
79
 
79
80
/**
80
 
 * gnutls_alert_get_name - Returns a string describing the alert number given
 
81
 * gnutls_alert_get_name:
81
82
 * @alert: is an alert number #gnutls_session_t structure.
82
83
 *
83
84
 * This function will return a string that describes the given alert
98
99
}
99
100
 
100
101
/**
101
 
 * gnutls_alert_send - send an alert message to the peer
 
102
 * gnutls_alert_send:
102
103
 * @session: is a #gnutls_session_t structure.
103
104
 * @level: is the level of the alert
104
105
 * @desc: is the alert description
139
140
}
140
141
 
141
142
/**
142
 
 * gnutls_error_to_alert - return an alert code based on the given error code
 
143
 * gnutls_error_to_alert:
143
144
 * @err: is a negative integer
144
145
 * @level: the alert level will be stored there
145
146
 *
180
181
      ret = GNUTLS_A_ILLEGAL_PARAMETER;
181
182
      _level = GNUTLS_AL_FATAL;
182
183
      break;
 
184
    case GNUTLS_E_UNKNOWN_SRP_USERNAME:
 
185
      ret = GNUTLS_A_UNKNOWN_PSK_IDENTITY;
 
186
      _level = GNUTLS_AL_FATAL;
 
187
      break;
183
188
    case GNUTLS_E_ASN1_ELEMENT_NOT_FOUND:
184
189
    case GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND:
185
190
    case GNUTLS_E_ASN1_DER_ERROR:
191
196
    case GNUTLS_E_ASN1_TYPE_ANY_ERROR:
192
197
    case GNUTLS_E_ASN1_SYNTAX_ERROR:
193
198
    case GNUTLS_E_ASN1_DER_OVERFLOW:
 
199
    case GNUTLS_E_CERTIFICATE_ERROR:
194
200
      ret = GNUTLS_A_BAD_CERTIFICATE;
195
201
      _level = GNUTLS_AL_FATAL;
196
202
      break;
199
205
    case GNUTLS_E_INSUFFICIENT_CREDENTIALS:
200
206
    case GNUTLS_E_NO_CIPHER_SUITES:
201
207
    case GNUTLS_E_NO_COMPRESSION_ALGORITHMS:
 
208
    case GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM:
 
209
    case GNUTLS_E_SAFE_RENEGOTIATION_FAILED:
202
210
      ret = GNUTLS_A_HANDSHAKE_FAILURE;
203
211
      _level = GNUTLS_AL_FATAL;
204
212
      break;
212
220
      _level = GNUTLS_AL_FATAL;
213
221
      break;
214
222
    case GNUTLS_E_REHANDSHAKE:
 
223
    case GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED:
215
224
      ret = GNUTLS_A_NO_RENEGOTIATION;
216
225
      _level = GNUTLS_AL_WARNING;
217
226
      break;
255
264
}
256
265
 
257
266
/**
258
 
 * gnutls_alert_send_appropriate - send alert to peer depending on error code
 
267
 * gnutls_alert_send_appropriate:
259
268
 * @session: is a #gnutls_session_t structure.
260
269
 * @err: is an integer
261
270
 *
288
297
}
289
298
 
290
299
/**
291
 
 * gnutls_alert_get - Returns the last alert number received.
 
300
 * gnutls_alert_get:
292
301
 * @session: is a #gnutls_session_t structure.
293
302
 *
294
303
 * This function will return the last alert number received.  This