1#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23 ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26pub const ID: ClusterId = 0x001F;
28
29pub const REVISION: u16 = 3;
32
33pub const PICS: &str = "ACL";
35
36pub mod feature {
41 pub const EXTENSION: u32 = 1 << 0;
45 pub const MANAGED_DEVICE: u32 = 1 << 1;
49 pub const AUXILIARY: u32 = 1 << 2;
53}
54
55pub const FEATURES: &[Feature] = &[
57 Feature {
58 bit: 0,
59 code: "EXTS",
60 name: "Extension",
61 conform: Conform::OPTIONAL,
62 },
63 Feature {
64 bit: 1,
65 code: "MNGD",
66 name: "ManagedDevice",
67 conform: Conform::DESCRIBED,
68 },
69 Feature {
70 bit: 2,
71 code: "AUX",
72 name: "Auxiliary",
73 conform: Conform {
74 clauses: &[
75 Clause {
76 verdict: Conformance::Provisional,
77 when: Condition::Always,
78 },
79 Clause {
80 verdict: Conformance::Described,
81 when: Condition::Always,
82 },
83 ],
84 },
85 },
86];
87
88pub mod attribute {
90 use crate::im::AttributeId;
91
92 pub const ACL: AttributeId = 0x00;
94 pub const EXTENSION: AttributeId = 0x01;
96 pub const SUBJECTS_PER_ACCESS_CONTROL_ENTRY: AttributeId = 0x02;
98 pub const TARGETS_PER_ACCESS_CONTROL_ENTRY: AttributeId = 0x03;
100 pub const ACCESS_CONTROL_ENTRIES_PER_FABRIC: AttributeId = 0x04;
102 pub const COMMISSIONING_ARL: AttributeId = 0x05;
104 pub const ARL: AttributeId = 0x06;
106 pub const AUXILIARY_ACL: AttributeId = 0x07;
108}
109
110pub mod command {
112 use crate::im::CommandId;
113
114 pub const REVIEW_FABRIC_RESTRICTIONS: CommandId = 0x00;
116 pub const REVIEW_FABRIC_RESTRICTIONS_RESPONSE: CommandId = 0x01;
118}
119
120pub mod event {
122 use crate::im::EventId;
123
124 pub const ACCESS_CONTROL_ENTRY_CHANGED: EventId = 0x00;
126 pub const ACCESS_CONTROL_EXTENSION_CHANGED: EventId = 0x01;
128 pub const FABRIC_RESTRICTION_REVIEW_UPDATE: EventId = 0x02;
130 pub const AUXILIARY_ACCESS_UPDATED: EventId = 0x03;
132}
133
134#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
136#[repr(u8)]
137pub enum AccessControlAuxiliaryTypeEnum {
138 System = 0,
140 Groupcast = 1,
142}
143
144impl AccessControlAuxiliaryTypeEnum {
145 #[must_use]
147 pub const fn from_value(value: u8) -> Option<Self> {
148 match value {
149 0 => Some(Self::System),
150 1 => Some(Self::Groupcast),
151 _ => None,
152 }
153 }
154
155 #[must_use]
157 pub const fn value(self) -> u8 {
158 self as u8
159 }
160}
161
162impl ToTlv for AccessControlAuxiliaryTypeEnum {
163 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
164 self.value().to_tlv(w, tag)
165 }
166}
167
168impl<'a> FromTlv<'a> for AccessControlAuxiliaryTypeEnum {
169 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
170 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
171 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
172 }
173}
174
175#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
177#[repr(u8)]
178pub enum AccessControlEntryAuthModeEnum {
179 PASE = 1,
181 CASE = 2,
183 Group = 3,
185}
186
187impl AccessControlEntryAuthModeEnum {
188 #[must_use]
190 pub const fn from_value(value: u8) -> Option<Self> {
191 match value {
192 1 => Some(Self::PASE),
193 2 => Some(Self::CASE),
194 3 => Some(Self::Group),
195 _ => None,
196 }
197 }
198
199 #[must_use]
201 pub const fn value(self) -> u8 {
202 self as u8
203 }
204}
205
206impl ToTlv for AccessControlEntryAuthModeEnum {
207 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
208 self.value().to_tlv(w, tag)
209 }
210}
211
212impl<'a> FromTlv<'a> for AccessControlEntryAuthModeEnum {
213 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
214 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
215 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
216 }
217}
218
219#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
221#[repr(u8)]
222pub enum AccessControlEntryPrivilegeEnum {
223 View = 1,
225 ProxyView = 2,
227 Operate = 3,
229 Manage = 4,
231 Administer = 5,
233}
234
235impl AccessControlEntryPrivilegeEnum {
236 #[must_use]
238 pub const fn from_value(value: u8) -> Option<Self> {
239 match value {
240 1 => Some(Self::View),
241 2 => Some(Self::ProxyView),
242 3 => Some(Self::Operate),
243 4 => Some(Self::Manage),
244 5 => Some(Self::Administer),
245 _ => None,
246 }
247 }
248
249 #[must_use]
251 pub const fn value(self) -> u8 {
252 self as u8
253 }
254}
255
256impl ToTlv for AccessControlEntryPrivilegeEnum {
257 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
258 self.value().to_tlv(w, tag)
259 }
260}
261
262impl<'a> FromTlv<'a> for AccessControlEntryPrivilegeEnum {
263 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
264 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
265 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
266 }
267}
268
269#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
271#[repr(u8)]
272pub enum AccessRestrictionTypeEnum {
273 AttributeAccessForbidden = 0,
275 AttributeWriteForbidden = 1,
277 CommandForbidden = 2,
279 EventForbidden = 3,
281}
282
283impl AccessRestrictionTypeEnum {
284 #[must_use]
286 pub const fn from_value(value: u8) -> Option<Self> {
287 match value {
288 0 => Some(Self::AttributeAccessForbidden),
289 1 => Some(Self::AttributeWriteForbidden),
290 2 => Some(Self::CommandForbidden),
291 3 => Some(Self::EventForbidden),
292 _ => None,
293 }
294 }
295
296 #[must_use]
298 pub const fn value(self) -> u8 {
299 self as u8
300 }
301}
302
303impl ToTlv for AccessRestrictionTypeEnum {
304 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
305 self.value().to_tlv(w, tag)
306 }
307}
308
309impl<'a> FromTlv<'a> for AccessRestrictionTypeEnum {
310 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
311 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
312 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
313 }
314}
315
316#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
318#[repr(u8)]
319pub enum ChangeTypeEnum {
320 Changed = 0,
322 Added = 1,
324 Removed = 2,
326}
327
328impl ChangeTypeEnum {
329 #[must_use]
331 pub const fn from_value(value: u8) -> Option<Self> {
332 match value {
333 0 => Some(Self::Changed),
334 1 => Some(Self::Added),
335 2 => Some(Self::Removed),
336 _ => None,
337 }
338 }
339
340 #[must_use]
342 pub const fn value(self) -> u8 {
343 self as u8
344 }
345}
346
347impl ToTlv for ChangeTypeEnum {
348 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
349 self.value().to_tlv(w, tag)
350 }
351}
352
353impl<'a> FromTlv<'a> for ChangeTypeEnum {
354 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
355 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
356 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
357 }
358}
359
360#[derive(Debug, Clone, Copy, PartialEq)]
362pub struct AccessControlEntryStruct<'a> {
363 pub privilege: AccessControlEntryPrivilegeEnum,
365 pub auth_mode: AccessControlEntryAuthModeEnum,
367 pub subjects: Nullable<TlvList<'a, u64>>,
369 pub targets: Nullable<TlvList<'a, AccessControlTargetStruct>>,
371 pub auxiliary_type: Option<AccessControlAuxiliaryTypeEnum>,
373 pub fabric_index: crate::msg::FabricIndex,
375}
376
377impl<'a> ToTlv for AccessControlEntryStruct<'a> {
378 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
379 w.start_structure(tag)?;
380 self.privilege.to_tlv(w, Tag::Context(1))?;
381 self.auth_mode.to_tlv(w, Tag::Context(2))?;
382 self.subjects.to_tlv(w, Tag::Context(3))?;
383 self.targets.to_tlv(w, Tag::Context(4))?;
384 if let Some(value) = &self.auxiliary_type {
385 value.to_tlv(w, Tag::Context(5))?;
386 }
387 self.fabric_index.to_tlv(w, Tag::Context(254))?;
388 w.end_container()
389 }
390}
391
392impl<'a> FromTlv<'a> for AccessControlEntryStruct<'a> {
393 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
394 if element.value.container() != Some(ContainerKind::Structure) {
395 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
396 }
397 let mut privilege = None;
398 let mut auth_mode = None;
399 let mut subjects = None;
400 let mut targets = None;
401 let mut auxiliary_type = None;
402 let mut fabric_index = None;
403 loop {
404 let Some(field) = reader.next_element()? else {
405 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
406 };
407 if field.value == Value::EndOfContainer {
408 break;
409 }
410 match field.tag.context() {
411 Some(1) => {
412 privilege = Some(<AccessControlEntryPrivilegeEnum>::from_tlv(reader, &field)?)
413 }
414 Some(2) => {
415 auth_mode = Some(<AccessControlEntryAuthModeEnum>::from_tlv(reader, &field)?)
416 }
417 Some(3) => subjects = Some(<Nullable<TlvList<'a, u64>>>::from_tlv(reader, &field)?),
418 Some(4) => {
419 targets = Some(
420 <Nullable<TlvList<'a, AccessControlTargetStruct>>>::from_tlv(
421 reader, &field,
422 )?,
423 )
424 }
425 Some(5) => {
426 auxiliary_type =
427 Some(<AccessControlAuxiliaryTypeEnum>::from_tlv(reader, &field)?)
428 }
429 Some(254) => {
430 fabric_index = Some(<crate::msg::FabricIndex>::from_tlv(reader, &field)?)
431 }
432 _ => reader.skip_value(&field)?,
436 }
437 }
438 Ok(Self {
439 privilege: privilege.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
440 auth_mode: auth_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
441 subjects: subjects.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
442 targets: targets.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
443 auxiliary_type,
444 fabric_index: fabric_index.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
445 })
446 }
447}
448
449#[derive(Debug, Clone, Copy, PartialEq)]
451pub struct AccessControlExtensionStruct<'a> {
452 pub data: &'a [u8],
454 pub fabric_index: crate::msg::FabricIndex,
456}
457
458impl<'a> ToTlv for AccessControlExtensionStruct<'a> {
459 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
460 w.start_structure(tag)?;
461 self.data.to_tlv(w, Tag::Context(1))?;
462 self.fabric_index.to_tlv(w, Tag::Context(254))?;
463 w.end_container()
464 }
465}
466
467impl<'a> FromTlv<'a> for AccessControlExtensionStruct<'a> {
468 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
469 if element.value.container() != Some(ContainerKind::Structure) {
470 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
471 }
472 let mut data = None;
473 let mut fabric_index = None;
474 loop {
475 let Some(field) = reader.next_element()? else {
476 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
477 };
478 if field.value == Value::EndOfContainer {
479 break;
480 }
481 match field.tag.context() {
482 Some(1) => data = Some(<&'a [u8]>::from_tlv(reader, &field)?),
483 Some(254) => {
484 fabric_index = Some(<crate::msg::FabricIndex>::from_tlv(reader, &field)?)
485 }
486 _ => reader.skip_value(&field)?,
490 }
491 }
492 Ok(Self {
493 data: data.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
494 fabric_index: fabric_index.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
495 })
496 }
497}
498
499#[derive(Debug, Clone, Copy, PartialEq)]
501pub struct AccessControlTargetStruct {
502 pub cluster: Nullable<u32>,
504 pub endpoint: Nullable<u16>,
506 pub device_type: Nullable<u32>,
508}
509
510impl ToTlv for AccessControlTargetStruct {
511 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
512 w.start_structure(tag)?;
513 self.cluster.to_tlv(w, Tag::Context(0))?;
514 self.endpoint.to_tlv(w, Tag::Context(1))?;
515 self.device_type.to_tlv(w, Tag::Context(2))?;
516 w.end_container()
517 }
518}
519
520impl<'a> FromTlv<'a> for AccessControlTargetStruct {
521 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
522 if element.value.container() != Some(ContainerKind::Structure) {
523 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
524 }
525 let mut cluster = None;
526 let mut endpoint = None;
527 let mut device_type = None;
528 loop {
529 let Some(field) = reader.next_element()? else {
530 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
531 };
532 if field.value == Value::EndOfContainer {
533 break;
534 }
535 match field.tag.context() {
536 Some(0) => cluster = Some(<Nullable<u32>>::from_tlv(reader, &field)?),
537 Some(1) => endpoint = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
538 Some(2) => device_type = Some(<Nullable<u32>>::from_tlv(reader, &field)?),
539 _ => reader.skip_value(&field)?,
543 }
544 }
545 Ok(Self {
546 cluster: cluster.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
547 endpoint: endpoint.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
548 device_type: device_type.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
549 })
550 }
551}
552
553#[derive(Debug, Clone, Copy, PartialEq)]
555pub struct AccessRestrictionEntryStruct<'a> {
556 pub endpoint: u16,
558 pub cluster: u32,
560 pub restrictions: TlvList<'a, AccessRestrictionStruct>,
562 pub fabric_index: crate::msg::FabricIndex,
564}
565
566impl<'a> ToTlv for AccessRestrictionEntryStruct<'a> {
567 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
568 w.start_structure(tag)?;
569 self.endpoint.to_tlv(w, Tag::Context(0))?;
570 self.cluster.to_tlv(w, Tag::Context(1))?;
571 self.restrictions.to_tlv(w, Tag::Context(2))?;
572 self.fabric_index.to_tlv(w, Tag::Context(254))?;
573 w.end_container()
574 }
575}
576
577impl<'a> FromTlv<'a> for AccessRestrictionEntryStruct<'a> {
578 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
579 if element.value.container() != Some(ContainerKind::Structure) {
580 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
581 }
582 let mut endpoint = None;
583 let mut cluster = None;
584 let mut restrictions = None;
585 let mut fabric_index = None;
586 loop {
587 let Some(field) = reader.next_element()? else {
588 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
589 };
590 if field.value == Value::EndOfContainer {
591 break;
592 }
593 match field.tag.context() {
594 Some(0) => endpoint = Some(<u16>::from_tlv(reader, &field)?),
595 Some(1) => cluster = Some(<u32>::from_tlv(reader, &field)?),
596 Some(2) => {
597 restrictions = Some(<TlvList<'a, AccessRestrictionStruct>>::from_tlv(
598 reader, &field,
599 )?)
600 }
601 Some(254) => {
602 fabric_index = Some(<crate::msg::FabricIndex>::from_tlv(reader, &field)?)
603 }
604 _ => reader.skip_value(&field)?,
608 }
609 }
610 Ok(Self {
611 endpoint: endpoint.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
612 cluster: cluster.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
613 restrictions: restrictions.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
614 fabric_index: fabric_index.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
615 })
616 }
617}
618
619#[derive(Debug, Clone, Copy, PartialEq)]
621pub struct AccessRestrictionStruct {
622 pub type_: AccessRestrictionTypeEnum,
624 pub id: Nullable<u32>,
626}
627
628impl ToTlv for AccessRestrictionStruct {
629 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
630 w.start_structure(tag)?;
631 self.type_.to_tlv(w, Tag::Context(0))?;
632 self.id.to_tlv(w, Tag::Context(1))?;
633 w.end_container()
634 }
635}
636
637impl<'a> FromTlv<'a> for AccessRestrictionStruct {
638 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
639 if element.value.container() != Some(ContainerKind::Structure) {
640 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
641 }
642 let mut type_ = None;
643 let mut id = None;
644 loop {
645 let Some(field) = reader.next_element()? else {
646 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
647 };
648 if field.value == Value::EndOfContainer {
649 break;
650 }
651 match field.tag.context() {
652 Some(0) => type_ = Some(<AccessRestrictionTypeEnum>::from_tlv(reader, &field)?),
653 Some(1) => id = Some(<Nullable<u32>>::from_tlv(reader, &field)?),
654 _ => reader.skip_value(&field)?,
658 }
659 }
660 Ok(Self {
661 type_: type_.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
662 id: id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
663 })
664 }
665}
666
667#[derive(Debug, Clone, Copy, PartialEq)]
669pub struct CommissioningAccessRestrictionEntryStruct<'a> {
670 pub endpoint: u16,
672 pub cluster: u32,
674 pub restrictions: TlvList<'a, AccessRestrictionStruct>,
676}
677
678impl<'a> ToTlv for CommissioningAccessRestrictionEntryStruct<'a> {
679 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
680 w.start_structure(tag)?;
681 self.endpoint.to_tlv(w, Tag::Context(0))?;
682 self.cluster.to_tlv(w, Tag::Context(1))?;
683 self.restrictions.to_tlv(w, Tag::Context(2))?;
684 w.end_container()
685 }
686}
687
688impl<'a> FromTlv<'a> for CommissioningAccessRestrictionEntryStruct<'a> {
689 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
690 if element.value.container() != Some(ContainerKind::Structure) {
691 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
692 }
693 let mut endpoint = None;
694 let mut cluster = None;
695 let mut restrictions = None;
696 loop {
697 let Some(field) = reader.next_element()? else {
698 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
699 };
700 if field.value == Value::EndOfContainer {
701 break;
702 }
703 match field.tag.context() {
704 Some(0) => endpoint = Some(<u16>::from_tlv(reader, &field)?),
705 Some(1) => cluster = Some(<u32>::from_tlv(reader, &field)?),
706 Some(2) => {
707 restrictions = Some(<TlvList<'a, AccessRestrictionStruct>>::from_tlv(
708 reader, &field,
709 )?)
710 }
711 _ => reader.skip_value(&field)?,
715 }
716 }
717 Ok(Self {
718 endpoint: endpoint.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
719 cluster: cluster.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
720 restrictions: restrictions.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
721 })
722 }
723}
724
725#[derive(Debug, Clone, Copy, PartialEq)]
727pub struct ReviewFabricRestrictionsFields<'a> {
728 pub arl: TlvList<'a, CommissioningAccessRestrictionEntryStruct<'a>>,
730}
731
732impl<'a> ToTlv for ReviewFabricRestrictionsFields<'a> {
733 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
734 w.start_structure(tag)?;
735 self.arl.to_tlv(w, Tag::Context(0))?;
736 w.end_container()
737 }
738}
739
740impl<'a> FromTlv<'a> for ReviewFabricRestrictionsFields<'a> {
741 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
742 if element.value.container() != Some(ContainerKind::Structure) {
743 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
744 }
745 let mut arl = None;
746 loop {
747 let Some(field) = reader.next_element()? else {
748 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
749 };
750 if field.value == Value::EndOfContainer {
751 break;
752 }
753 match field.tag.context() {
754 Some(0) => {
755 arl = Some(
756 <TlvList<'a, CommissioningAccessRestrictionEntryStruct<'a>>>::from_tlv(
757 reader, &field,
758 )?,
759 )
760 }
761 _ => reader.skip_value(&field)?,
765 }
766 }
767 Ok(Self {
768 arl: arl.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
769 })
770 }
771}
772
773#[derive(Debug, Clone, Copy, PartialEq)]
775pub struct ReviewFabricRestrictionsResponseFields {
776 pub token: u64,
778}
779
780impl ToTlv for ReviewFabricRestrictionsResponseFields {
781 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
782 w.start_structure(tag)?;
783 self.token.to_tlv(w, Tag::Context(0))?;
784 w.end_container()
785 }
786}
787
788impl<'a> FromTlv<'a> for ReviewFabricRestrictionsResponseFields {
789 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
790 if element.value.container() != Some(ContainerKind::Structure) {
791 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
792 }
793 let mut token = None;
794 loop {
795 let Some(field) = reader.next_element()? else {
796 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
797 };
798 if field.value == Value::EndOfContainer {
799 break;
800 }
801 match field.tag.context() {
802 Some(0) => token = Some(<u64>::from_tlv(reader, &field)?),
803 _ => reader.skip_value(&field)?,
807 }
808 }
809 Ok(Self {
810 token: token.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
811 })
812 }
813}
814
815pub const ATTRIBUTES: &[Attribute] = &[
817 Attribute {
818 id: 0x0000,
819 name: "ACL",
820 kind: "list[AccessControlEntryStruct]",
821 access: Access::read_write_with(Privilege::Administer, Privilege::Administer)
822 .with_qualities(AccessQualities::FABRIC_SCOPED),
823 qualities: AttributeQualities::empty(),
824 reporting: Reporting::OnChange,
825 conform: Conform::MANDATORY,
826 },
827 Attribute {
828 id: 0x0001,
829 name: "Extension",
830 kind: "list[AccessControlExtensionStruct]",
831 access: Access::read_write_with(Privilege::Administer, Privilege::Administer)
832 .with_qualities(AccessQualities::FABRIC_SCOPED),
833 qualities: AttributeQualities::empty(),
834 reporting: Reporting::OnChange,
835 conform: Conform {
836 clauses: &[Clause {
837 verdict: Conformance::Mandatory,
838 when: Condition::Feature(0),
839 }],
840 },
841 },
842 Attribute {
843 id: 0x0002,
844 name: "SubjectsPerAccessControlEntry",
845 kind: "uint16",
846 access: Access::read_only(Privilege::View),
847 qualities: AttributeQualities::FIXED,
848 reporting: Reporting::OnChange,
849 conform: Conform::MANDATORY,
850 },
851 Attribute {
852 id: 0x0003,
853 name: "TargetsPerAccessControlEntry",
854 kind: "uint16",
855 access: Access::read_only(Privilege::View),
856 qualities: AttributeQualities::FIXED,
857 reporting: Reporting::OnChange,
858 conform: Conform::MANDATORY,
859 },
860 Attribute {
861 id: 0x0004,
862 name: "AccessControlEntriesPerFabric",
863 kind: "uint16",
864 access: Access::read_only(Privilege::View),
865 qualities: AttributeQualities::FIXED,
866 reporting: Reporting::OnChange,
867 conform: Conform::MANDATORY,
868 },
869 Attribute {
870 id: 0x0005,
871 name: "CommissioningARL",
872 kind: "list[CommissioningAccessRestrictionEntryStruct]",
873 access: Access::read_only(Privilege::View),
874 qualities: AttributeQualities::FIXED,
875 reporting: Reporting::OnChange,
876 conform: Conform {
877 clauses: &[Clause {
878 verdict: Conformance::Mandatory,
879 when: Condition::Feature(1),
880 }],
881 },
882 },
883 Attribute {
884 id: 0x0006,
885 name: "ARL",
886 kind: "list[AccessRestrictionEntryStruct]",
887 access: Access::read_only(Privilege::View).with_qualities(AccessQualities::FABRIC_SCOPED),
888 qualities: AttributeQualities::empty(),
889 reporting: Reporting::OnChange,
890 conform: Conform {
891 clauses: &[Clause {
892 verdict: Conformance::Mandatory,
893 when: Condition::Feature(1),
894 }],
895 },
896 },
897 Attribute {
898 id: 0x0007,
899 name: "AuxiliaryACL",
900 kind: "list[AccessControlEntryStruct]",
901 access: Access::read_only(Privilege::Administer)
902 .with_qualities(AccessQualities::FABRIC_SCOPED),
903 qualities: AttributeQualities::empty(),
904 reporting: Reporting::ChangesOmitted,
905 conform: Conform {
906 clauses: &[
907 Clause {
908 verdict: Conformance::Provisional,
909 when: Condition::Always,
910 },
911 Clause {
912 verdict: Conformance::Mandatory,
913 when: Condition::Feature(2),
914 },
915 ],
916 },
917 },
918];
919
920pub const COMMANDS: &[Command] = &[
922 Command {
923 id: 0x00,
924 name: "ReviewFabricRestrictions",
925 to_server: true,
926 response: Some(0x01),
927 access: Access::invoke(Privilege::Administer)
928 .with_qualities(AccessQualities::FABRIC_SCOPED),
929 conform: Conform {
930 clauses: &[Clause {
931 verdict: Conformance::Mandatory,
932 when: Condition::Feature(1),
933 }],
934 },
935 },
936 Command {
937 id: 0x01,
938 name: "ReviewFabricRestrictionsResponse",
939 to_server: false,
940 response: None,
941 access: Access::invoke(Privilege::Operate),
942 conform: Conform {
943 clauses: &[Clause {
944 verdict: Conformance::Mandatory,
945 when: Condition::Feature(1),
946 }],
947 },
948 },
949];
950
951pub const EVENTS: &[Event] = &[
953 Event {
954 id: 0x00,
955 name: "AccessControlEntryChanged",
956 priority: EventPriority::Info,
957 access: Access::read_only(Privilege::Administer)
958 .with_qualities(AccessQualities::FABRIC_SENSITIVE),
959 conform: Conform::MANDATORY,
960 },
961 Event {
962 id: 0x01,
963 name: "AccessControlExtensionChanged",
964 priority: EventPriority::Info,
965 access: Access::read_only(Privilege::Administer)
966 .with_qualities(AccessQualities::FABRIC_SENSITIVE),
967 conform: Conform {
968 clauses: &[Clause {
969 verdict: Conformance::Mandatory,
970 when: Condition::Feature(0),
971 }],
972 },
973 },
974 Event {
975 id: 0x02,
976 name: "FabricRestrictionReviewUpdate",
977 priority: EventPriority::Info,
978 access: Access::read_only(Privilege::Administer)
979 .with_qualities(AccessQualities::FABRIC_SENSITIVE),
980 conform: Conform {
981 clauses: &[Clause {
982 verdict: Conformance::Mandatory,
983 when: Condition::Feature(1),
984 }],
985 },
986 },
987 Event {
988 id: 0x03,
989 name: "AuxiliaryAccessUpdated",
990 priority: EventPriority::Info,
991 access: Access::read_only(Privilege::Administer)
992 .with_qualities(AccessQualities::FABRIC_SENSITIVE),
993 conform: Conform {
994 clauses: &[
995 Clause {
996 verdict: Conformance::Provisional,
997 when: Condition::Always,
998 },
999 Clause {
1000 verdict: Conformance::Mandatory,
1001 when: Condition::Feature(2),
1002 },
1003 ],
1004 },
1005 },
1006];
1007
1008pub const CLUSTER: Cluster = Cluster {
1010 id: ID,
1011 name: "Access Control",
1012 revision: REVISION,
1013 pics: "ACL",
1014 derived_from: None,
1015 features: FEATURES,
1016 attributes: ATTRIBUTES,
1017 commands: COMMANDS,
1018 events: EVENTS,
1019};