Coverage Report

Created: 2021-11-03 07:11

/rust/registry/src/github.com-1ecc6299db9ec823/ipsec-parser-0.5.0/src/ikev2_notify.rs
Line
Count
Source (jump to first uncovered line)
1
use std::fmt;
2
3
/// Notify Message Type
4
///
5
/// Notification information can be error messages specifying why an SA
6
/// could not be established.  It can also be status data that a process
7
/// managing an SA database wishes to communicate with a peer process.
8
///
9
/// The table below lists the notification messages and their
10
/// corresponding values.  The number of different error statuses was
11
/// greatly reduced from IKEv1 both for simplification and to avoid
12
/// giving configuration information to probers.
13
///
14
/// Types in the range 0 - 16383 are intended for reporting errors.  An
15
/// implementation receiving a Notify payload with one of these types
16
/// that it does not recognize in a response MUST assume that the
17
/// corresponding request has failed entirely.  Unrecognized error types
18
/// in a request and status types in a request or response MUST be
19
/// ignored, and they should be logged.
20
///
21
/// Notify payloads with status types MAY be added to any message and
22
/// MUST be ignored if not recognized.  They are intended to indicate
23
/// capabilities, and as part of SA negotiation, are used to negotiate
24
/// non-cryptographic parameters.
25
///
26
/// Defined in [RFC7296](https://tools.ietf.org/html/rfc7296) section 3.10.1
27
///
28
/// Extensions:
29
///
30
/// - [RFC4555](https://tools.ietf.org/html/rfc4555) IKEv2 Mobility and Multihoming Protocol (MOBIKE)
31
/// - [RFC4739](https://tools.ietf.org/html/rfc4739) Multiple Authentication Exchanges in the Internet Key Exchange (IKEv2) Protocol
32
/// - [RFC5685](https://tools.ietf.org/html/rfc5685) Redirect Mechanism for the Internet Key Exchange Protocol Version 2 (IKEv2)
33
/// - [RFC5723](https://tools.ietf.org/html/rfc5723) Internet Key Exchange Protocol Version 2 (IKEv2) Session Resumption
34
/// - [RFC7427](https://tools.ietf.org/html/rfc7427) Signature Authentication in the Internet Key Exchange Version 2 (IKEv2)
35
///
36
/// See also [IKEV2IANA](https://www.iana.org/assignments/ikev2-parameters/ikev2-parameters.xhtml) for the latest values.
37
0
#[derive(Clone, Copy, PartialEq, Eq)]
Unexecuted instantiation: <ipsec_parser::ikev2_notify::NotifyType as core::cmp::PartialEq>::ne
Unexecuted instantiation: <ipsec_parser::ikev2_notify::NotifyType as core::cmp::PartialEq>::eq
38
pub struct NotifyType(pub u16);
39
40
#[rustfmt::skip]
41
impl NotifyType {
42
    // error types
43
    pub const UNSUPPORTED_CRITICAL_PAYLOAD  : NotifyType = NotifyType(1);
44
    pub const INVALID_IKE_SPI               : NotifyType = NotifyType(4);
45
    pub const INVALID_MAJOR_VERSION         : NotifyType = NotifyType(5);
46
    pub const INVALID_SYNTAX                : NotifyType = NotifyType(7);
47
    pub const INVALID_MESSAGE_ID            : NotifyType = NotifyType(9);
48
    pub const INVALID_SPI                   : NotifyType = NotifyType(11);
49
    pub const NO_PROPOSAL_CHOSEN            : NotifyType = NotifyType(14);
50
    pub const INVALID_KE_PAYLOAD            : NotifyType = NotifyType(17);
51
    pub const AUTHENTICATION_FAILED         : NotifyType = NotifyType(24);
52
    pub const SINGLE_PAIR_REQUIRED          : NotifyType = NotifyType(34);
53
    pub const NO_ADDITIONAL_SAS             : NotifyType = NotifyType(35);
54
    pub const INTERNAL_ADDRESS_FAILURE      : NotifyType = NotifyType(36);
55
    pub const FAILED_CP_REQUIRED            : NotifyType = NotifyType(37);
56
    pub const TS_UNACCEPTABLE               : NotifyType = NotifyType(38);
57
    pub const INVALID_SELECTORS             : NotifyType = NotifyType(39);
58
    pub const TEMPORARY_FAILURE             : NotifyType = NotifyType(43);
59
    pub const CHILD_SA_NOT_FOUND            : NotifyType = NotifyType(44);
60
    // status types
61
    pub const INITIAL_CONTACT               : NotifyType = NotifyType(16384);
62
    pub const SET_WINDOW_SIZE               : NotifyType = NotifyType(16385);
63
    pub const ADDITIONAL_TS_POSSIBLE        : NotifyType = NotifyType(16386);
64
    pub const IPCOMP_SUPPORTED              : NotifyType = NotifyType(16387);
65
    pub const NAT_DETECTION_SOURCE_IP       : NotifyType = NotifyType(16388);
66
    pub const NAT_DETECTION_DESTINATION_IP  : NotifyType = NotifyType(16389);
67
    pub const COOKIE                        : NotifyType = NotifyType(16390);
68
    pub const USE_TRANSPORT_MODE            : NotifyType = NotifyType(16391);
69
    pub const HTTP_CERT_LOOKUP_SUPPORTED    : NotifyType = NotifyType(16392);
70
    pub const REKEY_SA                      : NotifyType = NotifyType(16393);
71
    pub const ESP_TFC_PADDING_NOT_SUPPORTED : NotifyType = NotifyType(16394);
72
    pub const NON_FIRST_FRAGMENTS_ALSO      : NotifyType = NotifyType(16395);
73
    //
74
    pub const MULTIPLE_AUTH_SUPPORTED       : NotifyType = NotifyType(16404);
75
    pub const ANOTHER_AUTH_FOLLOWS          : NotifyType = NotifyType(16405);
76
    pub const REDIRECT_SUPPORTED            : NotifyType = NotifyType(16406);
77
    //
78
    pub const IKEV2_FRAGMENTATION_SUPPORTED : NotifyType = NotifyType(16430);
79
    pub const SIGNATURE_HASH_ALGORITHMS     : NotifyType = NotifyType(16431);
80
81
5.85k
    pub fn is_error(&self) -> bool { self.0 < 16384 }
82
0
    pub fn is_status(&self) -> bool { self.0 > 16384 }
83
}
84
85
impl fmt::Debug for NotifyType {
86
    #[rustfmt::skip]
87
0
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
88
0
        match self.0 {
89
0
            1     => f.write_str("UNSUPPORTED_CRITICAL_PAYLOAD"),
90
0
            4     => f.write_str("INVALID_IKE_SPI"),
91
0
            5     => f.write_str("INVALID_MAJOR_VERSION"),
92
0
            7     => f.write_str("INVALID_SYNTAX"),
93
0
            9     => f.write_str("INVALID_MESSAGE_ID"),
94
0
            11    => f.write_str("INVALID_SPI"),
95
0
            14    => f.write_str("NO_PROPOSAL_CHOSEN"),
96
0
            17    => f.write_str("INVALID_KE_PAYLOAD"),
97
0
            24    => f.write_str("AUTHENTICATION_FAILED"),
98
0
            34    => f.write_str("SINGLE_PAIR_REQUIRED"),
99
0
            35    => f.write_str("NO_ADDITIONAL_SAS"),
100
0
            36    => f.write_str("INTERNAL_ADDRESS_FAILURE"),
101
0
            37    => f.write_str("FAILED_CP_REQUIRED"),
102
0
            38    => f.write_str("TS_UNACCEPTABLE"),
103
0
            39    => f.write_str("INVALID_SELECTORS"),
104
0
            43    => f.write_str("TEMPORARY_FAILURE"),
105
0
            44    => f.write_str("CHILD_SA_NOT_FOUND"),
106
            //
107
0
            16384 => f.write_str("INITIAL_CONTACT"),
108
0
            16385 => f.write_str("SET_WINDOW_SIZE"),
109
0
            16386 => f.write_str("ADDITIONAL_TS_POSSIBLE"),
110
0
            16387 => f.write_str("IPCOMP_SUPPORTED"),
111
0
            16388 => f.write_str("NAT_DETECTION_SOURCE_IP"),
112
0
            16389 => f.write_str("NAT_DETECTION_DESTINATION_IP"),
113
0
            16390 => f.write_str("COOKIE"),
114
0
            16391 => f.write_str("USE_TRANSPORT_MODE"),
115
0
            16392 => f.write_str("HTTP_CERT_LOOKUP_SUPPORTED"),
116
0
            16393 => f.write_str("REKEY_SA"),
117
0
            16394 => f.write_str("ESP_TFC_PADDING_NOT_SUPPORTED"),
118
0
            16395 => f.write_str("NON_FIRST_FRAGMENTS_ALSO"),
119
            //
120
0
            16404 => f.write_str("MULTIPLE_AUTH_SUPPORTED"),
121
0
            16405 => f.write_str("ANOTHER_AUTH_FOLLOWS"),
122
0
            16406 => f.write_str("REDIRECT_SUPPORTED"),
123
            //
124
0
            16430 => f.write_str("IKEV2_FRAGMENTATION_SUPPORTED"),
125
0
            16431 => f.write_str("SIGNATURE_HASH_ALGORITHMS"),
126
            //
127
0
            n     => f.debug_tuple("Notify").field(&n).finish(),
128
        }
129
0
    }
130
}