Expand description
§IDM Frame Utilities
ITU-T Recommendation X.519 (2019) defines a protocol, Internet Directly-Mapped (IDM) Protocol, which is used to provide the OSI ROSE service and all lower layers of the OSI networking stack over TCP/IP, specifically for the purpose of making the X.500 directory easily available over the Internet.
There are two versions of the IDM protocol defined. This crate supports both. The second version supports negotiation of the transfer syntax, whereas the first uses the Basic Encoding Rules (BER).
This crate does not handle decoding of the contained IDM-PDU ASN.1 data
structure: it only handles the frames.
§This crate
This crate is no_std and does not require alloc, except for running the
tests. This crate was not written in any part by AI or LLMs. This crate was
fuzz-tested. It has no dependencies. Extremely simple and light-weight.
§Usage
To read an IDM frame, simply create an IdmFrameIter, and iterate over it one
or more times.
let buffer: Vec<u8> = Vec::from([
1, 1, 0, 0, 0, 5, 1, 2, 3, 4, 5,
].as_slice());
let mut frames = IdmFrameIter::new(buffer.as_slice());
let frame = frames.next()
.expect("uh oh, no frame")
.expect("uh oh, unrecognized / unsupported version");
assert_eq!(frame.version, 1);
assert_eq!(frame.final_, 1);
assert_eq!(frame.encoding, 0);
assert_eq!(frame.data, [1,2,3,4,5].as_slice());This crate also provides two fairly trivial functions for helping you write
valid IDM frames: write_idm_v1_frame_header and write_idm_v2_frame_header.
These can be used like so:
let mut buf: [u8; IDMV2_FRAME_SIZE] = [0, 0, 0, 0, 0, 0, 0, 0];
write_idm_v2_frame_header(&mut buf, true, IDM_ENCODING_XER, 1024);
assert_eq!(buf, [2, 1, 0x10, 0, 0, 0, 4, 0]);Cheers!
Structs§
- IdmFrame
- An IDM Frame
- IdmFrame
Iter - Iterator that reads IDM frames from a buffer, such as a buffer of bytes read in from a TCP socket.
Enums§
- IdmError
- An error pertaining to IDM frame decoding
Constants§
- IDMV1_
FRAME_ SIZE - Size of a Version 1 IDM Frame
- IDMV2_
FRAME_ SIZE - Size of a Version 2 IDM Frame
- IDM_
ENCODING_ DER - Distinguished Encoding Rules (DER) as described in ITU-T Recommendation X.690.
- IDM_
ENCODING_ PER_ ALIGNED - Basic Aligned variant of Packed Encoding Rules (PER) as described in ITU-T Recommendation X.691.
- IDM_
ENCODING_ PER_ UNALIGNED - Basic Unaligned variant of Packed Encoding Rules (PER) as described in ITU-T Recommendation X.691.
- IDM_
ENCODING_ XER - XML Encoding Rules (XER) as described in ITU-T Recommendation X.693.
- IDM_
FINAL - A final frame relaying the last bytes of a complete IDM-PDU
- IDM_
NOT_ FINAL - Not a final frame relaying the last bytes of a complete IDM-PDU
- IDM_
VERSION_ 1 - IDM Protocol Version 1
- IDM_
VERSION_ 2 - IDM Protocol Version 2
- MIN_
FRAME_ SIZE - Absolute smallest valid IDM frame
Functions§
- write_
idm_ v1_ frame_ header - Write an IDM version 1 frame header to
header - write_
idm_ v2_ frame_ header - Write an IDM version 2 frame header to
header
Type Aliases§
- Encoding
Mask - Mask for the
encodingfield of a version 2 IDM frame. - IDMFinality
- Values of the IDM
finalfield - IDMVersion
- Values of the IDM
versionfield