Version 0.5.0 of tinydtls
Dependents: tinydtls_test_cellular tinydtls_test_ethernet tiny-dtls
alert.h@0:ff9ebe0cf0e9, 2013-10-18 (annotated)
- Committer:
- ashleymills
- Date:
- Fri Oct 18 13:18:30 2013 +0000
- Revision:
- 0:ff9ebe0cf0e9
Upgraded to tinydtls 0.5.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ashleymills | 0:ff9ebe0cf0e9 | 1 | /* alert.h -- DTLS alert protocol |
ashleymills | 0:ff9ebe0cf0e9 | 2 | * |
ashleymills | 0:ff9ebe0cf0e9 | 3 | * Copyright (C) 2012 Olaf Bergmann <bergmann@tzi.org> |
ashleymills | 0:ff9ebe0cf0e9 | 4 | * |
ashleymills | 0:ff9ebe0cf0e9 | 5 | * Permission is hereby granted, free of charge, to any person |
ashleymills | 0:ff9ebe0cf0e9 | 6 | * obtaining a copy of this software and associated documentation |
ashleymills | 0:ff9ebe0cf0e9 | 7 | * files (the "Software"), to deal in the Software without |
ashleymills | 0:ff9ebe0cf0e9 | 8 | * restriction, including without limitation the rights to use, copy, |
ashleymills | 0:ff9ebe0cf0e9 | 9 | * modify, merge, publish, distribute, sublicense, and/or sell copies |
ashleymills | 0:ff9ebe0cf0e9 | 10 | * of the Software, and to permit persons to whom the Software is |
ashleymills | 0:ff9ebe0cf0e9 | 11 | * furnished to do so, subject to the following conditions: |
ashleymills | 0:ff9ebe0cf0e9 | 12 | * |
ashleymills | 0:ff9ebe0cf0e9 | 13 | * The above copyright notice and this permission notice shall be |
ashleymills | 0:ff9ebe0cf0e9 | 14 | * included in all copies or substantial portions of the Software. |
ashleymills | 0:ff9ebe0cf0e9 | 15 | * |
ashleymills | 0:ff9ebe0cf0e9 | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
ashleymills | 0:ff9ebe0cf0e9 | 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
ashleymills | 0:ff9ebe0cf0e9 | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ashleymills | 0:ff9ebe0cf0e9 | 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
ashleymills | 0:ff9ebe0cf0e9 | 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
ashleymills | 0:ff9ebe0cf0e9 | 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
ashleymills | 0:ff9ebe0cf0e9 | 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
ashleymills | 0:ff9ebe0cf0e9 | 23 | * SOFTWARE. |
ashleymills | 0:ff9ebe0cf0e9 | 24 | */ |
ashleymills | 0:ff9ebe0cf0e9 | 25 | |
ashleymills | 0:ff9ebe0cf0e9 | 26 | /** |
ashleymills | 0:ff9ebe0cf0e9 | 27 | * @file alert.h |
ashleymills | 0:ff9ebe0cf0e9 | 28 | * @brief DTLS alert protocol |
ashleymills | 0:ff9ebe0cf0e9 | 29 | */ |
ashleymills | 0:ff9ebe0cf0e9 | 30 | |
ashleymills | 0:ff9ebe0cf0e9 | 31 | #ifndef _ALERT_H_ |
ashleymills | 0:ff9ebe0cf0e9 | 32 | #define _ALERT_H_ |
ashleymills | 0:ff9ebe0cf0e9 | 33 | |
ashleymills | 0:ff9ebe0cf0e9 | 34 | #include "config.h" |
ashleymills | 0:ff9ebe0cf0e9 | 35 | |
ashleymills | 0:ff9ebe0cf0e9 | 36 | typedef enum { |
ashleymills | 0:ff9ebe0cf0e9 | 37 | DTLS_ALERT_LEVEL_WARNING=1, |
ashleymills | 0:ff9ebe0cf0e9 | 38 | DTLS_ALERT_LEVEL_FATAL=2 |
ashleymills | 0:ff9ebe0cf0e9 | 39 | } dtls_alert_level_t; |
ashleymills | 0:ff9ebe0cf0e9 | 40 | |
ashleymills | 0:ff9ebe0cf0e9 | 41 | typedef enum { |
ashleymills | 0:ff9ebe0cf0e9 | 42 | DTLS_ALERT_CLOSE_NOTIFY = 0, /* close_notify */ |
ashleymills | 0:ff9ebe0cf0e9 | 43 | DTLS_ALERT_UNEXPECTED_MESSAGE = 10, /* unexpected_message */ |
ashleymills | 0:ff9ebe0cf0e9 | 44 | DTLS_ALERT_BAD_RECORD_MAC = 20, /* bad_record_mac */ |
ashleymills | 0:ff9ebe0cf0e9 | 45 | DTLS_ALERT_RECORD_OVERFLOW = 22, /* record_overflow */ |
ashleymills | 0:ff9ebe0cf0e9 | 46 | DTLS_ALERT_DECOMPRESSION_FAILURE = 30, /* decompression_failure */ |
ashleymills | 0:ff9ebe0cf0e9 | 47 | DTLS_ALERT_HANDSHAKE_FAILURE = 40, /* handshake_failure */ |
ashleymills | 0:ff9ebe0cf0e9 | 48 | DTLS_ALERT_BAD_CERTIFICATE = 42, /* bad_certificate */ |
ashleymills | 0:ff9ebe0cf0e9 | 49 | DTLS_ALERT_UNSUPPORTED_CERTIFICATE = 43, /* unsupported_certificate */ |
ashleymills | 0:ff9ebe0cf0e9 | 50 | DTLS_ALERT_CERTIFICATE_REVOKED = 44, /* certificate_revoked */ |
ashleymills | 0:ff9ebe0cf0e9 | 51 | DTLS_ALERT_CERTIFICATE_EXPIRED = 45, /* certificate_expired */ |
ashleymills | 0:ff9ebe0cf0e9 | 52 | DTLS_ALERT_CERTIFICATE_UNKNOWN = 46, /* certificate_unknown */ |
ashleymills | 0:ff9ebe0cf0e9 | 53 | DTLS_ALERT_ILLEGAL_PARAMETER = 47, /* illegal_parameter */ |
ashleymills | 0:ff9ebe0cf0e9 | 54 | DTLS_ALERT_UNKNOWN_CA = 48, /* unknown_ca */ |
ashleymills | 0:ff9ebe0cf0e9 | 55 | DTLS_ALERT_ACCESS_DENIED = 49, /* access_denied */ |
ashleymills | 0:ff9ebe0cf0e9 | 56 | DTLS_ALERT_DECODE_ERROR = 50, /* decode_error */ |
ashleymills | 0:ff9ebe0cf0e9 | 57 | DTLS_ALERT_DECRYPT_ERROR = 51, /* decrypt_error */ |
ashleymills | 0:ff9ebe0cf0e9 | 58 | DTLS_ALERT_PROTOCOL_VERSION = 70, /* protocol_version */ |
ashleymills | 0:ff9ebe0cf0e9 | 59 | DTLS_ALERT_INSUFFICIENT_SECURITY = 71, /* insufficient_security */ |
ashleymills | 0:ff9ebe0cf0e9 | 60 | DTLS_ALERT_INTERNAL_ERROR = 80, /* internal_error */ |
ashleymills | 0:ff9ebe0cf0e9 | 61 | DTLS_ALERT_USER_CANCELED = 90, /* user_canceled */ |
ashleymills | 0:ff9ebe0cf0e9 | 62 | DTLS_ALERT_NO_RENEGOTIATION = 100, /* no_renegotiation */ |
ashleymills | 0:ff9ebe0cf0e9 | 63 | DTLS_ALERT_UNSUPPORTED_EXTENSION = 110 /* unsupported_extension */ |
ashleymills | 0:ff9ebe0cf0e9 | 64 | } dtls_alert_t; |
ashleymills | 0:ff9ebe0cf0e9 | 65 | |
ashleymills | 0:ff9ebe0cf0e9 | 66 | #define DTLS_EVENT_CONNECTED 0x01DE |
ashleymills | 0:ff9ebe0cf0e9 | 67 | |
ashleymills | 0:ff9ebe0cf0e9 | 68 | static inline int |
ashleymills | 0:ff9ebe0cf0e9 | 69 | dtls_alert_create(dtls_alert_level_t level, dtls_alert_t desc) |
ashleymills | 0:ff9ebe0cf0e9 | 70 | { |
ashleymills | 0:ff9ebe0cf0e9 | 71 | return -((level << 8) | desc); |
ashleymills | 0:ff9ebe0cf0e9 | 72 | } |
ashleymills | 0:ff9ebe0cf0e9 | 73 | |
ashleymills | 0:ff9ebe0cf0e9 | 74 | static inline int |
ashleymills | 0:ff9ebe0cf0e9 | 75 | dtls_alert_fatal_create(dtls_alert_t desc) |
ashleymills | 0:ff9ebe0cf0e9 | 76 | { |
ashleymills | 0:ff9ebe0cf0e9 | 77 | return dtls_alert_create(DTLS_ALERT_LEVEL_FATAL, desc); |
ashleymills | 0:ff9ebe0cf0e9 | 78 | } |
ashleymills | 0:ff9ebe0cf0e9 | 79 | |
ashleymills | 0:ff9ebe0cf0e9 | 80 | #endif /* _ALERT_H_ */ |