Expand description
EN 50221 DVB Common Interface driver runtime: the device I/O, the TPDU poll
loop, SPDU session management and the per-resource state machines that
drive a physical Conditional Access Module (CAM), over the dvb-ci wire
codecs. It implements CENELEC EN 50221 (February 1997): the Annex A
transport and the host-provided Resource Manager, Application Information,
Conditional Access Support, Date-Time, MMI and Host Control resources, plus
the Linux DVB CA API for real hardware.
It builds on dvb-ci (codecs), dvb-si (PMT and CAT inputs), mpeg-ts
and broadcast-common. The core, CiStack, is sans-IO (events in,
actions out, the caller owns the clock); Driver runs it against a
CaDevice, and CaDescrambler adds the TS data plane. It serves no CI
Plus and no Low-Speed Communications, never descrambles itself (the CAM
does) and has no no_std claim. Every limit and timeout is the caller’s.
§Quickstart
Bring a slot up against an in-memory CAM and drain the host-facing events:
use std::time::Duration;
use dvb_ci::tpdu::tags;
use dvb_ci_runtime::{
Driver, DriverBounds, MockCaDevice, Notification, StackBounds, TransportBounds,
};
let dev = MockCaDevice::new([vec![tags::C_T_C_REPLY, 0x01, 0x01]]);
let bounds = DriverBounds {
stack: StackBounds {
transport: TransportBounds {
poll_interval: Duration::from_millis(100),
reply_timeout: Duration::from_secs(1),
max_setup_attempts: 5,
max_reassembly_len: 2 * 1024 * 1024,
max_outbound_queue: 64,
},
max_sessions: 32,
},
max_pending_notifications: 1024,
slot_ready_grace: Duration::from_secs(12),
slot_retry: Duration::from_millis(250),
};
let mut driver = Driver::new(dev, bounds);
driver.init()?;
for _ in 0..4 {
driver.pump(Duration::from_millis(100))?;
}
for note in driver.take_notifications() {
if let Notification::CamReady = note {
// now safe to send a ca_pmt
}
}§How do I…
- Drive a CAM from a loop:
Driver(init,pump,take_notifications),examples/mock_cam_session.rs. - Run the protocol with no device, thread or clock:
CiStack,Event,Action,examples/sans_io_core.rs. - React to CAM insertion and removal:
HotPlug,Driver::pump_hotplug,examples/hot_plug.rs. - Capture and read an annotated link trace:
device::RecordingCaDevice,trace::decode_log,examples/trace_session.rs. - Push scrambled TS through the CAM and read it back descrambled:
CaDescrambler,MockCiDataDevice,examples/descrambler_feed.rs. - Descramble a service from its PMT and track the active set:
Driver::add_service,Driver::set_cat, no example yet. - Answer a CAM menu or enquiry:
Driver::mmi_menu_answer,Driver::mmi_enquiry_answer, no example yet. - Test without hardware:
MockCaDevice,examples/mock_cam_session.rs. - Talk to a real slot on Linux: the
linuxmodule (LinuxCaDevice,LinuxCiDataDevice) and theci-probebinary, both behind featurelinux; no example yet.
§Modules
Host-facing driver: driver (the pump loop and the managed CAS calls),
managed (the active-service set, PID routing and re-query),
descrambler (turnkey control plus data plane), event (events,
actions, host requests, notifications, hot-plug).
Protocol core: stack (the composed sans-IO stack), transport (TPDU
poll loop), session (SPDU sessions), resource (the resource state
machines).
Devices and diagnostics: device (the control-plane trait, mock and
recorder), dataplane (the ciM TS data-plane trait and mock),
trace (annotated link traces); the linux module (feature linux,
Linux only: the /dev/dvb devices).
§Feature flags
linux(off by default):LinuxCaDevice,LinuxCiDataDeviceand theci-probebinary (pullsrustixandclap). Linux only; the portable core needs none of it.
§Spec citations
CENELEC EN 50221 Annex A section A.4 (TPDU transport), section 7.2 (SPDU
session layer), section 8 (resources), section 8.4.3.4 and Table 25
(ca_pmt); ISO/IEC 13818-1 section 2.6.16 (CA_descriptor); the Linux
linux/dvb/ca.h ABI for the device layer; transcriptions under
private/specs-verified/dvb/dvb-ci/.
Re-exports§
pub use dataplane::CiDataDevice;pub use dataplane::MockCiDataDevice;pub use dataplane::PartialWrite;pub use dataplane::partial_write_progress;pub use descrambler::CaDescrambler;pub use device::CaDevice;pub use device::DeviceOp;pub use device::DeviceOpError;pub use device::LinkEvent;pub use device::MAX_CA_FRAME;pub use device::MockCaDevice;pub use device::RecordingCaDevice;pub use device::SlotInfo;pub use driver::Driver;pub use driver::DriverBounds;pub use event::Action;pub use event::Event;pub use event::HostRequest;pub use event::HotPlug;pub use event::Notification;pub use linux::CiDataTimings;Linux and linuxpub use linux::LinuxCaDevice;Linux and linuxpub use linux::LinuxCiDataDevice;Linux and linuxpub use managed::CaError;pub use managed::ManagedCa;pub use managed::ManagedService;pub use managed::REQUERY_DEFAULT;pub use stack::CiStack;pub use stack::StackBounds;pub use transport::TransportBounds;
Modules§
- dataplane
- The CI TS data-plane device:
CiDataDevice. - descrambler
- Turnkey CAS descrambler — #763 Layer 2.
- device
- The hardware-abstraction boundary:
CaDevice. - driver
- The driver — the one place I/O happens. It pumps a
CaDeviceagainst the sans-IOCiStack: reads frames in, executes the stack’sActions (writes/ioctls) out, tracks the requested poll timer, and collectsNotifications for the host application. - event
- The sans-IO event/action model.
- linux
Linux and linux - Linux
/dev/dvb/adapterN/caMCaDeviceimplementation (thelinuxfeature). - managed
- Managed CAS-layer state (#763) — the
Driver’s owned view of the slot’s active descrambled-service set. - resource
- The resource layer — application-layer state machines (ETSI EN 50221 §8), one per resource, driven by the session layer’s APDUs.
- session
- SPDU session layer — a sans-IO mechanism over the transport layer (ETSI EN 50221 §7.2).
- stack
- The CI protocol stack — composes the transport + session layers and the resource state machines (Resource Manager, application_information, conditional_access, date_time, mmi, host_control) into one sans-IO core.
- trace
- Human-readable decoding of CI link frames, for diagnosing live-CAM exchanges (e.g. issue #337).
- transport
- TPDU transport layer — a sans-IO state machine for the single transport connection per CI slot (ETSI EN 50221 §A.4).