Skip to main content

ocpp_kit/standard/
security_events.rs

1// @generated by `cargo xtask appendix` from OCPP 2.1 Part 2 — Appendices v2.1 (2025-12-03).
2//
3// Only the interoperability surface is reproduced: names, data types and criticality. The
4// appendix's prose descriptions are not copied, and the appendix itself is not redistributed.
5// DO NOT EDIT — re-run the generator instead.
6
7//! The standardized security events of OCPP 2.x, and which of them are critical.
8//!
9//! Appendix chapter 1: an implemented event is written to the security log, and an
10//! implemented event marked **critical** is additionally pushed to the CSMS with
11//! `SecurityEventNotification`. Deciding *which* events to implement is the
12//! application's business; knowing which of them are critical is not.
13
14ocpp_enum! {
15    /// A security event from the standardized list.
16    ///
17    /// The list is explicitly non-exhaustive: a vendor-specific event is carried in
18    /// `UnknownValue`, and the specification asks that a standardized event be used
19    /// wherever one matches.
20    SecurityEvent {
21        /// `FirmwareUpdated`.
22        FirmwareUpdated = "FirmwareUpdated",
23        /// `FailedToAuthenticateAtCsms`.
24        FailedToAuthenticateAtCsms = "FailedToAuthenticateAtCsms",
25        /// `CsmsFailedToAuthenticate`.
26        CsmsFailedToAuthenticate = "CsmsFailedToAuthenticate",
27        /// `SettingSystemTime`.
28        SettingSystemTime = "SettingSystemTime",
29        /// `StartupOfTheDevice`.
30        StartupOfTheDevice = "StartupOfTheDevice",
31        /// `ResetOrReboot`.
32        ResetOrReboot = "ResetOrReboot",
33        /// `SecurityLogWasCleared`.
34        SecurityLogWasCleared = "SecurityLogWasCleared",
35        /// `ReconfigurationOfSecurityParameters`.
36        ReconfigurationOfSecurityParameters = "ReconfigurationOfSecurityParameters",
37        /// `MemoryExhaustion`.
38        MemoryExhaustion = "MemoryExhaustion",
39        /// `InvalidMessages`.
40        InvalidMessages = "InvalidMessages",
41        /// `AttemptedReplayAttacks`.
42        AttemptedReplayAttacks = "AttemptedReplayAttacks",
43        /// `TamperDetectionActivated`.
44        TamperDetectionActivated = "TamperDetectionActivated",
45        /// `InvalidFirmwareSignature`.
46        InvalidFirmwareSignature = "InvalidFirmwareSignature",
47        /// `InvalidFirmwareSigningCertificate`.
48        InvalidFirmwareSigningCertificate = "InvalidFirmwareSigningCertificate",
49        /// `InvalidCsmsCertificate`.
50        InvalidCsmsCertificate = "InvalidCsmsCertificate",
51        /// `InvalidChargingStationCertificate`.
52        InvalidChargingStationCertificate = "InvalidChargingStationCertificate",
53        /// `DiscardedRenewedClientCertificate`.
54        DiscardedRenewedClientCertificate = "DiscardedRenewedClientCertificate",
55        /// `InvalidTLSVersion`.
56        InvalidTLSVersion = "InvalidTLSVersion",
57        /// `InvalidTLSCipherSuite`.
58        InvalidTLSCipherSuite = "InvalidTLSCipherSuite",
59        /// `MaintenanceLoginAccepted`.
60        MaintenanceLoginAccepted = "MaintenanceLoginAccepted",
61        /// `MaintenanceLoginFailed`.
62        MaintenanceLoginFailed = "MaintenanceLoginFailed",
63    }
64}
65
66impl SecurityEvent {
67    /// Whether the event must be pushed to the CSMS as well as logged.
68    ///
69    /// A vendor-specific event is treated as critical: the safe default is to report it.
70    #[must_use]
71    #[allow(clippy::match_same_arms)]
72    pub fn is_critical(&self) -> bool {
73        match self {
74            Self::FirmwareUpdated => true,
75            Self::FailedToAuthenticateAtCsms => false,
76            Self::CsmsFailedToAuthenticate => false,
77            Self::SettingSystemTime => true,
78            Self::StartupOfTheDevice => true,
79            Self::ResetOrReboot => true,
80            Self::SecurityLogWasCleared => true,
81            Self::ReconfigurationOfSecurityParameters => false,
82            Self::MemoryExhaustion => true,
83            Self::InvalidMessages => false,
84            Self::AttemptedReplayAttacks => false,
85            Self::TamperDetectionActivated => true,
86            Self::InvalidFirmwareSignature => true,
87            Self::InvalidFirmwareSigningCertificate => true,
88            Self::InvalidCsmsCertificate => true,
89            Self::InvalidChargingStationCertificate => true,
90            Self::DiscardedRenewedClientCertificate => true,
91            Self::InvalidTLSVersion => true,
92            Self::InvalidTLSCipherSuite => true,
93            Self::MaintenanceLoginAccepted => true,
94            Self::MaintenanceLoginFailed => true,
95            Self::UnknownValue(_) => true,
96        }
97    }
98
99    /// Every event the specification defines as critical.
100    #[must_use]
101    pub fn critical() -> alloc::vec::Vec<Self> {
102        Self::VARIANTS
103            .iter()
104            .map(|name| Self::from_wire(name))
105            .filter(Self::is_critical)
106            .collect()
107    }
108}