The docsis encoder, ported to Rust. Same bytes.
gen_docsis encodes a DOCSIS binary configuration file from a human-readable text configuration file, and decodes a binary file back into that text form. It is a Rust port of the docsis utility originally written by Cornel Ciocirlan and later maintained by Evvolve Media and Adrian Simionov: it reads the same configuration syntax, produces the same bytes, and keeps the same command-line interface.
cargo build --release also works
docsis is too general a name to be safe to type
Repository: github.com/mmqr-developer/docsis_config_generator · DOCSIS is a registered trademark of CableLabs.
Encode, decode, or many at once
gen_docsis [modifiers] -e <modem_cfg_file> <key_file> <output_file> gen_docsis [modifiers] -m <modem_cfg_file1> ... <key_file> <new_extension> gen_docsis [modifiers] -p <mta_cfg_file> <output_file> gen_docsis [modifiers] -m -p <mta_file1> ... <new_extension> gen_docsis [modifiers] -d <binary_file> gen_docsis --version
-e writes a cable modem file, complete with CM MIC, CMTS MIC, end-of-data marker and padding. -p writes a PacketCable MTA file, which gets none of those. -d decodes either kind. -m processes several inputs at once, replacing each file's extension. An input or output of - means standard input or standard output.
-oPrint object identifiers numerically when decoding-M "PATH1:PATH2"Directories to read SNMP MIBs from-na | -euAppend the CableLabs or Excentis SHA-1 configuration hash when encoding an MTA file-dialplanAppend a PacketCable 2.0 dial plan read from dialplan.txt in the current directory-nohashComment out the PacketCable hash when decodingBundled, and read in a fixed order
Settings that carry an SNMP object, such as SnmpMibObject and SnmpWriteControl, need the MIBs that define those objects. The search path comes from -M, else from MIBDIRS, else from the usual net-snmp locations: $HOME/.snmp/mibs, /usr/share/snmp/mibs, and that directory's iana and ietf subdirectories. The SNMP MIB reader and the ASN.1 encoder that net-snmp used to provide are part of this program.
The mibs directory in the repository holds the DOCSIS, PacketCable and IETF modules the tool needs. To run against them without installing anything:
gen_docsis -M "mibs:mibs/ietf:mibs/iana" -e config.txt key config.cm
When two modules define different objects at the same OID, as the bundled PacketCable MIBs do, the module read first wins, matching net-snmp. Modules are read in path order, and alphabetically within each directory, so the result does not depend on the filesystem.
Build and test
build.sh targets x86_64-unknown-linux-musl, so the binary is statically linked and carries no libc expectations to the host it lands on. That needs rustup target add x86_64-unknown-linux-musl and a musl C compiler, and the script checks for both.
git clone https://github.com/mmqr-developer/docsis_config_generator.git cd docsis_config_generator ./build.sh # checks, then a static build with the time compiled in cargo test # 142 fixtures, encoded, decoded and re-encoded
The file format
doc/config-format.html documents the syntax, and examples/ holds working configuration files.
What the settings come from
docs/spec-coverage.md records which CableLabs specifications each setting comes from, and what is known to be missing.
The ten that are excluded
Ten fixtures are left out of the byte-for-byte comparison because their golden files predate later changes to the symbol table. tests/regression.rs names them and says why.